Example usage for javax.xml.registry.infomodel LocalizedString getLocale

List of usage examples for javax.xml.registry.infomodel LocalizedString getLocale

Introduction

In this page you can find the example usage for javax.xml.registry.infomodel LocalizedString getLocale.

Prototype

Locale getLocale() throws JAXRException;

Source Link

Document

Get the Locale for this object.

Usage

From source file:it.cnr.icar.eric.client.xml.registry.infomodel.InternationalStringImpl.java

protected boolean removeLocalizedString_internal(LocalizedString ls) throws JAXRException {
    String key = getKey(ls.getLocale(), ls.getCharsetName());
    LocalizedString old = localizedStringMap.get(key);

    if (ls == old) {
        localizedStringMap.remove(key);//  w w  w.j  a  va  2s.co m
        return true;
    } else {
        return false;
    }
}

From source file:it.cnr.icar.eric.client.xml.registry.infomodel.InternationalStringImpl.java

protected void addLocalizedString_internal(LocalizedString ls) throws JAXRException {
    if (!localizedStringMap.containsValue(ls)) {
        localizedStringMap.put(getKey(ls.getLocale(), ls.getCharsetName()), ls);
    } else {/*  w w w .  ja v a  2s.co  m*/
        LocalizedString lsOrig = localizedStringMap.get(getKey(ls.getLocale(), ls.getCharsetName()));
        if (lsOrig == null) {
            Iterator<String> keys = localizedStringMap.keySet().iterator();
            LocalizedString tempLS = null;
            String tempKey = null;

            while (keys.hasNext() && tempKey == null) {
                tempKey = keys.next();
                tempLS = localizedStringMap.get(tempKey);
                if (tempLS != ls) {
                    tempKey = null;
                }
            }
            if (tempKey != null) {
                localizedStringMap.remove(tempKey);
                localizedStringMap.put(getKey(ls.getLocale(), ls.getCharsetName()), ls);
            }
        }
    }
}

From source file:it.cnr.icar.eric.client.ui.thin.RegistryObjectBean.java

public String getNameContentLocale() {
    String contentLocaleStr = null;
    try {//  w  ww  .  ja  va2s.c om
        Locale contentLocale = RegistryBrowser.getInstance().getUserPreferencesBean().getContentLocale();
        InternationalStringImpl iString = ((InternationalStringImpl) registryObject.getName());
        LocalizedString lString = null;
        if (iString != null) {
            lString = iString.getClosestLocalizedString(contentLocale, null);
        }
        if (lString == null) {
            contentLocaleStr = contentLocale.toString();
        } else {
            Locale locale = lString.getLocale();
            if (locale == null) {
                locale = Locale.getDefault();
            }
            contentLocaleStr = locale.toString();
        }
    } catch (Exception e) {
        log.error(WebUIResourceBundle.getInstance().getString("message.ErrorInGettingNameContent"), e);
    } finally {
        if (contentLocaleStr == null) {
            contentLocaleStr = Locale.getDefault().toString();
        }
    }
    return contentLocaleStr;
}

From source file:it.cnr.icar.eric.client.ui.thin.RegistryObjectBean.java

public String getDescriptionContentLocale() {
    String contentLocaleStr = null;
    try {/*from w w w .  j av a  2  s. c  om*/
        Locale contentLocale = RegistryBrowser.getInstance().getUserPreferencesBean().getContentLocale();
        InternationalStringImpl iString = ((InternationalStringImpl) registryObject.getName());
        LocalizedString lString = null;
        if (iString != null) {
            lString = iString.getClosestLocalizedString(contentLocale, null);
        }
        if (lString == null) {
            contentLocaleStr = contentLocale.toString();
        } else {
            Locale locale = lString.getLocale();
            if (locale == null) {
                locale = Locale.getDefault();
            }
            contentLocaleStr = locale.toString();
        }
    } catch (Exception e) {
        log.error(WebUIResourceBundle.getInstance().getString("message.ErrorInGettingDescriptionContent"), e);
    } finally {
        if (contentLocaleStr == null) {
            contentLocaleStr = Locale.getDefault().toString();
        }
    }
    return contentLocaleStr;
}

From source file:org.apache.ws.scout.registry.BusinessQueryManagerImpl.java

static Name[] mapNamePatterns(Collection namePatterns) throws JAXRException {
    if (namePatterns == null)
        return null;
    Name[] result = new Name[namePatterns.size()];
    int currLoc = 0;
    for (Iterator i = namePatterns.iterator(); i.hasNext();) {
        Object obj = i.next();//from   w ww .  j a v  a 2 s. c o  m
        Name name = objectFactory.createName();
        if (obj instanceof String) {
            name.setValue((String) obj);
        } else if (obj instanceof LocalizedString) {
            LocalizedString ls = (LocalizedString) obj;
            name.setValue(ls.getValue());
            name.setLang(ls.getLocale().getLanguage());
        }
        result[currLoc] = name;
        currLoc++;
    }
    return result;
}

From source file:org.apache.ws.scout.util.ScoutJaxrUddiHelper.java

public static BindingTemplate getBindingTemplateFromJAXRSB(ServiceBinding serviceBinding) throws JAXRException {
    BindingTemplate bt = objectFactory.createBindingTemplate();
    if (serviceBinding.getKey() != null && serviceBinding.getKey().getId() != null) {
        bt.setBindingKey(serviceBinding.getKey().getId());
    } else {//from  www .j  ava 2 s.c  o  m
        bt.setBindingKey("");
    }

    try {
        // Set Access URI
        String accessuri = serviceBinding.getAccessURI();
        if (accessuri != null) {
            AccessPoint accessPoint = objectFactory.createAccessPoint();
            accessPoint.setURLType(getURLType(accessuri));
            accessPoint.setValue(accessuri);
            bt.setAccessPoint(accessPoint);
        }
        ServiceBinding sb = serviceBinding.getTargetBinding();
        if (sb != null) {
            HostingRedirector red = objectFactory.createHostingRedirector();
            Key key = sb.getKey();
            if (key != null && key.getId() != null) {
                red.setBindingKey(key.getId());
            } else {
                red.setBindingKey("");
            }
            bt.setHostingRedirector(red);
        } else {
            if (bt.getAccessPoint() == null) {
                bt.setAccessPoint(objectFactory.createAccessPoint());
            }
        }
        // TODO:Need to look further at the mapping b/w BindingTemplate and
        // Jaxr ServiceBinding

        // Get Service information
        Service svc = serviceBinding.getService();
        if (svc != null && svc.getKey() != null && svc.getKey().getId() != null) {
            bt.setServiceKey(svc.getKey().getId());
        }

        InternationalString idesc = serviceBinding.getDescription();

        addDescriptions(bt.getDescription(), idesc);

        // SpecificationLink
        Collection<SpecificationLink> slcol = serviceBinding.getSpecificationLinks();
        TModelInstanceDetails tid = objectFactory.createTModelInstanceDetails();
        if (slcol != null && !slcol.isEmpty()) {
            Iterator<SpecificationLink> iter = slcol.iterator();
            while (iter.hasNext()) {
                SpecificationLink slink = (SpecificationLink) iter.next();

                TModelInstanceInfo emptyTInfo = objectFactory.createTModelInstanceInfo();
                tid.getTModelInstanceInfo().add(emptyTInfo);

                RegistryObject specificationObject = slink.getSpecificationObject();
                if (specificationObject.getKey() != null && specificationObject.getKey().getId() != null) {
                    emptyTInfo.setTModelKey(specificationObject.getKey().getId());
                    if (specificationObject.getDescription() != null) {
                        for (Object o : specificationObject.getDescription().getLocalizedStrings()) {
                            LocalizedString locDesc = (LocalizedString) o;
                            Description description = objectFactory.createDescription();
                            emptyTInfo.getDescription().add(description);
                            description.setValue(locDesc.getValue());
                            description.setLang(locDesc.getLocale().getLanguage());
                        }
                    }
                    Collection<ExternalLink> externalLinks = slink.getExternalLinks();
                    if (externalLinks != null && externalLinks.size() > 0) {
                        for (ExternalLink link : externalLinks) {
                            InstanceDetails ids = objectFactory.createInstanceDetails();
                            emptyTInfo.setInstanceDetails(ids);
                            if (link.getDescription() != null) {
                                Description description = objectFactory.createDescription();
                                ids.getDescription().add(description);
                                description.setValue(link.getDescription().getValue());
                            }
                            if (link.getExternalURI() != null) {
                                OverviewDoc overviewDoc = objectFactory.createOverviewDoc();
                                ids.setOverviewDoc(overviewDoc);
                                overviewDoc.setOverviewURL(link.getExternalURI());
                            }
                        }
                    }
                }
            }
        }
        bt.setTModelInstanceDetails(tid);
        log.debug("BindingTemplate=" + bt.toString());
    } catch (Exception ud) {
        throw new JAXRException("Apache JAXR Impl:", ud);
    }
    return bt;
}

From source file:org.apache.ws.scout.util.ScoutJaxrUddiHelper.java

private static void addDescriptions(List<Description> descripions, InternationalString idesc)
        throws JAXRException {
    if (idesc != null) {
        for (Object o : idesc.getLocalizedStrings()) {
            LocalizedString locName = (LocalizedString) o;
            Description desc = objectFactory.createDescription();
            descripions.add(desc);//from   ww  w.  j av  a2s  .c o m
            desc.setValue(locName.getValue());
            desc.setLang(locName.getLocale().getLanguage());
        }
    }
}

From source file:org.apache.ws.scout.util.ScoutJaxrUddiHelper.java

private static Name getFirstName(InternationalString iname) throws JAXRException {
    for (Object o : iname.getLocalizedStrings()) {
        LocalizedString locName = (LocalizedString) o;
        Name name = objectFactory.createName();
        name.setValue(locName.getValue());
        name.setLang(locName.getLocale().getLanguage());
        return name;
    }/*  w w w  .  j a  v a 2s.c  o m*/
    return null;
}

From source file:org.apache.ws.scout.util.ScoutJaxrUddiHelper.java

private static void addNames(List<Name> names, InternationalString iname) throws JAXRException {
    for (Object o : iname.getLocalizedStrings()) {
        LocalizedString locName = (LocalizedString) o;
        Name name = objectFactory.createName();
        name.setValue(locName.getValue());
        name.setLang(locName.getLocale().getLanguage());
        names.add(name);/* www.  jav  a 2  s.  c o  m*/
    }
}

From source file:org.apache.ws.scout.util.ScoutJaxrUddiV3Helper.java

public static BindingTemplate getBindingTemplateFromJAXRSB(ServiceBinding serviceBinding) throws JAXRException {
    BindingTemplate bt = objectFactory.createBindingTemplate();
    if (serviceBinding.getKey() != null && serviceBinding.getKey().getId() != null) {
        bt.setBindingKey(serviceBinding.getKey().getId());
    } else {/*from  w w w. ja va  2  s .  c  o  m*/
        bt.setBindingKey("");
    }

    try {
        // Set Access URI
        String accessuri = serviceBinding.getAccessURI();
        if (accessuri != null) {
            AccessPoint accessPoint = objectFactory.createAccessPoint();
            accessPoint.setUseType(getUseType(accessuri));
            accessPoint.setValue(accessuri);
            bt.setAccessPoint(accessPoint);
        }
        ServiceBinding sb = serviceBinding.getTargetBinding();
        if (sb != null) {
            HostingRedirector red = objectFactory.createHostingRedirector();
            Key key = sb.getKey();
            if (key != null && key.getId() != null) {
                red.setBindingKey(key.getId());
            } else {
                red.setBindingKey("");
            }
            bt.setHostingRedirector(red);
        } else {
            if (bt.getAccessPoint() == null) {
                bt.setAccessPoint(objectFactory.createAccessPoint());
            }
        }
        // TODO:Need to look further at the mapping b/w BindingTemplate and
        // Jaxr ServiceBinding

        CategoryBag catBag = getCategoryBagFromClassifications(serviceBinding.getClassifications());
        if (catBag != null) {
            bt.setCategoryBag(catBag);
        }

        // Get Service information
        Service svc = serviceBinding.getService();
        if (svc != null && svc.getKey() != null && svc.getKey().getId() != null) {
            bt.setServiceKey(svc.getKey().getId());
        }

        InternationalString idesc = serviceBinding.getDescription();

        addDescriptions(bt.getDescription(), idesc);

        // SpecificationLink
        Collection<SpecificationLink> slcol = serviceBinding.getSpecificationLinks();
        TModelInstanceDetails tid = objectFactory.createTModelInstanceDetails();
        if (slcol != null && !slcol.isEmpty()) {
            Iterator<SpecificationLink> iter = slcol.iterator();
            while (iter.hasNext()) {
                SpecificationLink slink = (SpecificationLink) iter.next();

                TModelInstanceInfo emptyTInfo = objectFactory.createTModelInstanceInfo();
                tid.getTModelInstanceInfo().add(emptyTInfo);

                RegistryObject specificationObject = slink.getSpecificationObject();
                if (specificationObject.getKey() != null && specificationObject.getKey().getId() != null) {
                    emptyTInfo.setTModelKey(specificationObject.getKey().getId());
                    if (specificationObject.getDescription() != null) {
                        for (Object o : specificationObject.getDescription().getLocalizedStrings()) {
                            LocalizedString locDesc = (LocalizedString) o;
                            Description description = objectFactory.createDescription();
                            emptyTInfo.getDescription().add(description);
                            description.setValue(locDesc.getValue());
                            description.setLang(locDesc.getLocale().getLanguage());
                        }
                    }
                    Collection<ExternalLink> externalLinks = slink.getExternalLinks();
                    if (externalLinks != null && externalLinks.size() > 0) {
                        for (ExternalLink link : externalLinks) {
                            InstanceDetails ids = objectFactory.createInstanceDetails();
                            emptyTInfo.setInstanceDetails(ids);
                            if (link.getDescription() != null) {
                                Description description = objectFactory.createDescription();
                                ids.getDescription().add(description);
                                description.setValue(link.getDescription().getValue());
                            }
                            if (link.getExternalURI() != null) {
                                OverviewDoc overviewDoc = objectFactory.createOverviewDoc();
                                ids.getOverviewDoc().add(overviewDoc);
                                org.uddi.api_v3.OverviewURL ourl = new org.uddi.api_v3.OverviewURL();
                                ourl.setValue(link.getExternalURI());
                                overviewDoc.setOverviewURL(ourl);
                            }
                            if (slink.getUsageParameters() != null) {
                                StringBuffer buffer = new StringBuffer();
                                for (Object o : slink.getUsageParameters()) {
                                    String s = (String) o;
                                    buffer.append(s + " ");
                                }
                                ids.setInstanceParms(buffer.toString().trim());
                            }
                        }
                    }
                }
            }
        }
        if (tid.getTModelInstanceInfo().size() != 0) {
            bt.setTModelInstanceDetails(tid);
        }
        log.debug("BindingTemplate=" + bt.toString());
    } catch (Exception ud) {
        throw new JAXRException("Apache JAXR Impl:", ud);
    }
    return bt;
}