Example usage for javax.xml.registry.infomodel ExternalLink getExternalURI

List of usage examples for javax.xml.registry.infomodel ExternalLink getExternalURI

Introduction

In this page you can find the example usage for javax.xml.registry.infomodel ExternalLink getExternalURI.

Prototype

String getExternalURI() throws JAXRException;

Source Link

Document

Gets URI to the an external resource.

Usage

From source file:JAXRQueryByWSDLClassification.java

/**
     * Searches for organizations using a WSDL
     * classification and displays data about them.
     */*from   w  ww.  j  av  a 2  s .c  o m*/
     * @param qString        the string argument
     */
    public void executeQuery(String qString) {
        RegistryService rs = null;
        BusinessQueryManager bqm = null;
        BusinessLifeCycleManager blcm = null;

        try {
            // Get registry service and managers
            rs = connection.getRegistryService();
            bqm = rs.getBusinessQueryManager();
            blcm = rs.getBusinessLifeCycleManager();
            System.out.println("Got registry service, query " + "manager, and lifecycle manager");

            ResourceBundle bundle = ResourceBundle.getBundle("JAXRExamples");

            /*
             * Find the uddi-org:types classification scheme defined
             * by the UDDI specification, using well-known key id.
             */
            String uuid_types = "uuid:C1ACF26D-9672-4404-9D70-39B756E62AB4";
            ClassificationScheme uddiOrgTypes = (ClassificationScheme) bqm.getRegistryObject(uuid_types,
                    LifeCycleManager.CLASSIFICATION_SCHEME);

            // Define name pattern
            Collection<String> namePatterns = new ArrayList<String>();
            namePatterns.add("%" + qString + "%");

            /*
             * Create a classification, specifying the scheme
             *  and the taxonomy name and value defined for WSDL
             *  documents by the UDDI specification.
             */
            Classification wsdlSpecClassification = blcm.createClassification(uddiOrgTypes,
                    blcm.createInternationalString("wsdlSpec"), "wsdlSpec");

            Collection<Classification> classifications = new ArrayList<Classification>();
            classifications.add(wsdlSpecClassification);

            // Find concepts
            BulkResponse br = bqm.findConcepts(null, namePatterns, classifications, null, null);
            Collection specConcepts = br.getCollection();

            // Display information about the concepts found
            int numConcepts = 0;

            if (specConcepts.isEmpty()) {
                System.out.println("No WSDL specification concepts found");
            } else {
                for (Object sc : specConcepts) {
                    numConcepts++;

                    Concept concept = (Concept) sc;

                    String name = getName(concept);

                    Collection links = concept.getExternalLinks();

                    System.out.println("\nSpecification Concept:\n\tName: " + name + "\n\tKey: " + getKey(concept)
                            + "\n\tDescription: " + getDescription(concept));

                    if (links.size() > 0) {
                        ExternalLink link = (ExternalLink) links.iterator().next();
                        System.out.println("\tURL of WSDL document: '" + link.getExternalURI() + "'");
                    }

                    // Find organizations that use this concept
                    Collection<Concept> specConcepts1 = new ArrayList<Concept>();
                    specConcepts1.add(concept);

                    br = bqm.findOrganizations(null, null, null, specConcepts1, null, null);

                    Collection orgs = br.getCollection();

                    // Display information about organizations
                    if (!(orgs.isEmpty())) {
                        System.out.println("Organizations using the '" + name + "' WSDL Specification:");
                    } else {
                        System.out.println("No Organizations using the '" + name + "' WSDL Specification");
                    }

                    for (Object o : orgs) {
                        Organization org = (Organization) o;
                        System.out.println("\tName: " + getName(org) + "\n\tKey: " + getKey(org)
                                + "\n\tDescription: " + getDescription(org));
                    }
                }
            }

            System.out.println("Found " + numConcepts + " concepts");
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            // At end, close connection to registry
            if (connection != null) {
                try {
                    connection.close();
                } catch (JAXRException je) {
                }
            }
        }
    }

From source file:JAXRPublishHelloOrg.java

/**
     * Creates an organization, its classification, and its
     * services, and saves it to the registry.
     *//from  w  ww.  j av a  2s.  co  m
     * @param username  the username for the registry
     * @param password  the password for the registry
     */
    public void executePublish(String uuidString, String username, String password) {
        RegistryService rs = null;
        BusinessLifeCycleManager blcm = null;
        BusinessQueryManager bqm = null;

        try {
            // Get registry service and managers
            rs = connection.getRegistryService();
            bqm = rs.getBusinessQueryManager();
            blcm = rs.getBusinessLifeCycleManager();
            System.out.println("Got registry service, query " + "manager, and life cycle manager");

            // Get authorization from the registry
            PasswordAuthentication passwdAuth = new PasswordAuthentication(username, password.toCharArray());

            HashSet<PasswordAuthentication> creds = new HashSet<PasswordAuthentication>();
            creds.add(passwdAuth);
            connection.setCredentials(creds);
            System.out.println("Established security credentials");

            ResourceBundle bundle = ResourceBundle.getBundle("JAXRExamples");

            // Create organization name and description
            InternationalString s = blcm.createInternationalString(bundle.getString("wsdlorg.name"));
            Organization org = blcm.createOrganization(s);
            s = blcm.createInternationalString(bundle.getString("wsdlorg.description"));
            org.setDescription(s);

            // Create primary contact, set name
            User primaryContact = blcm.createUser();
            PersonName pName = blcm.createPersonName(bundle.getString("wsdlorg.person.name"));
            primaryContact.setPersonName(pName);
            s = blcm.createInternationalString(bundle.getString("wsdlorg.person.description"));
            primaryContact.setDescription(s);

            // Set primary contact phone number
            TelephoneNumber tNum = blcm.createTelephoneNumber();
            tNum.setNumber(bundle.getString("wsdlorg.phone"));

            Collection<TelephoneNumber> phoneNums = new ArrayList<TelephoneNumber>();
            phoneNums.add(tNum);
            primaryContact.setTelephoneNumbers(phoneNums);

            // Set primary contact email address
            EmailAddress emailAddress = blcm.createEmailAddress(bundle.getString("wsdlorg.email.address"));
            Collection<EmailAddress> emailAddresses = new ArrayList<EmailAddress>();
            emailAddresses.add(emailAddress);
            primaryContact.setEmailAddresses(emailAddresses);

            // Set primary contact for organization
            org.setPrimaryContact(primaryContact);

            // Create services and service
            Collection<Service> services = new ArrayList<Service>();
            s = blcm.createInternationalString(bundle.getString("wsdlorg.svc.name"));

            Service service = blcm.createService(s);
            s = blcm.createInternationalString(bundle.getString("wsdlorg.svc.description"));
            service.setDescription(s);

            // Create service bindings
            Collection<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>();
            ServiceBinding binding = blcm.createServiceBinding();
            s = blcm.createInternationalString(bundle.getString("wsdlorg.svcbnd.description"));
            binding.setDescription(s);
            binding.setAccessURI(bundle.getString("wsdlorg.svcbnd.uri"));

            /*
             * Find the uddi-org:types classification scheme defined
             * by the UDDI specification, using well-known key id.
             */
            String uuid_types = "uuid:C1ACF26D-9672-4404-9D70-39B756E62AB4";
            ClassificationScheme uddiOrgTypes = (ClassificationScheme) bqm.getRegistryObject(uuid_types,
                    LifeCycleManager.CLASSIFICATION_SCHEME);

            /*
             * Create a classification, specifying the scheme
             *  and the taxonomy name and value defined for WSDL
             *  documents by the UDDI specification.
             */
            Classification wsdlSpecClassification = blcm.createClassification(uddiOrgTypes,
                    blcm.createInternationalString("wsdlSpec"), "wsdlSpec");

            // Define classifications
            Collection<Classification> classifications = new ArrayList<Classification>();
            classifications.add(wsdlSpecClassification);

            // Find the concept by its UUID
            Concept specConcept = (Concept) bqm.getRegistryObject(uuidString, LifeCycleManager.CONCEPT);

            // If we found the concept, we can save the organization
            if (specConcept != null) {
                String name = getName(specConcept);

                Collection links = specConcept.getExternalLinks();

                System.out.println("\nSpecification Concept:\n\tName: " + name + "\n\tKey: " + getKey(specConcept));

                if (links.size() > 0) {
                    ExternalLink link = (ExternalLink) links.iterator().next();
                    System.out.println("\tURL of WSDL document: '" + link.getExternalURI() + "'");
                }

                // Now set the specification link for the service binding
                SpecificationLink specLink = blcm.createSpecificationLink();
                specLink.setSpecificationObject(specConcept);

                binding.addSpecificationLink(specLink);
                serviceBindings.add(binding);

                // Add service bindings to service
                service.addServiceBindings(serviceBindings);

                // Add service to services, then add services to organization
                services.add(service);
                org.addServices(services);

                // Add organization and submit to registry
                // Retrieve key if successful
                Collection<Organization> orgs = new ArrayList<Organization>();
                orgs.add(org);

                BulkResponse response = blcm.saveOrganizations(orgs);
                Collection exceptions = response.getExceptions();

                if (exceptions == null) {
                    System.out.println("Organization saved");

                    Collection keys = response.getCollection();

                    for (Object k : keys) {
                        Key orgKey = (Key) k;
                        String id = orgKey.getId();
                        System.out.println("Organization key is " + id);
                    }
                } else {
                    for (Object e : exceptions) {
                        Exception exception = (Exception) e;
                        System.err.println("Exception on save: " + exception.toString());
                    }
                }
            } else {
                System.out.println("Specified concept not found, " + "organization not saved");
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            // At end, close connection to registry
            if (connection != null) {
                try {
                    connection.close();
                } catch (JAXRException je) {
                }
            }
        }
    }

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

public List<SelectItem> getExternalLinks() throws JAXRException {
    ArrayList<SelectItem> list = new ArrayList<SelectItem>();
    Collection<?> externalLinks = (Collection<?>) getCurrentRegistryObjectBean().getFields()
            .get("externalLinks");
    Iterator<?> iter = externalLinks.iterator();
    while (iter.hasNext()) {
        ExternalLink anItem = (ExternalLink) iter.next();
        list.add(new SelectItem(anItem.getExternalURI() + "(" + anItem.getName() + ")"));
    }//from  w  w  w  .  jav  a 2 s.com
    return list;
}

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 {/*w w w.j ava  2  s . com*/
        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

public static BusinessEntity getBusinessEntityFromJAXROrg(Organization organization) throws JAXRException {
    BusinessEntity biz = objectFactory.createBusinessEntity();
    BusinessServices bss = objectFactory.createBusinessServices();
    BusinessService[] barr = new BusinessService[0];

    try {/*from w  w w.j av a  2s.  c o  m*/
        // It may just be an update
        Key key = organization.getKey();
        if (key != null && key.getId() != null) {
            biz.setBusinessKey(key.getId());
        } else {
            biz.setBusinessKey("");
        }
        // Lets get the Organization attributes at the top level

        InternationalString iname = organization.getName();

        if (iname != null) {
            addNames(biz.getName(), iname);
        }

        InternationalString idesc = organization.getDescription();

        addDescriptions(biz.getDescription(), idesc);

        if (organization.getPrimaryContact() != null && organization.getPrimaryContact().getPersonName() != null
                && organization.getPrimaryContact().getPersonName().getFullName() != null) {

            biz.setAuthorizedName(organization.getPrimaryContact().getPersonName().getFullName());
        }

        Collection<Service> s = organization.getServices();
        log.debug("?Org has services=" + s.isEmpty());

        barr = new BusinessService[s.size()];

        Iterator<Service> iter = s.iterator();
        int barrPos = 0;
        while (iter.hasNext()) {
            BusinessService bs = ScoutJaxrUddiHelper.getBusinessServiceFromJAXRService((Service) iter.next());
            barr[barrPos] = bs;
            barrPos++;
        }

        /*
         * map users : JAXR has concept of 'primary contact', which is a
         * special designation for one of the users, and D6.1 seems to say
         * that the first UDDI user is the primary contact
         */

        Contacts cts = objectFactory.createContacts();
        Contact[] carr = new Contact[0];

        User primaryContact = organization.getPrimaryContact();
        Collection<User> users = organization.getUsers();

        // Expand array to necessary size only (xmlbeans does not like
        // null items in cases like this)

        int carrSize = 0;

        if (primaryContact != null) {
            carrSize += 1;
        }

        // TODO: Clean this up and make it more efficient
        Iterator<User> it = users.iterator();
        while (it.hasNext()) {
            User u = (User) it.next();
            if (u != primaryContact) {
                carrSize++;
            }
        }

        carr = new Contact[carrSize];

        /*
         * first do primary, and then filter that out in the loop
         */
        if (primaryContact != null) {
            Contact ct = getContactFromJAXRUser(primaryContact);
            carr[0] = ct;
        }

        it = users.iterator();
        int carrPos = 1;
        while (it.hasNext()) {
            User u = (User) it.next();

            if (u != primaryContact) {
                Contact ct = getContactFromJAXRUser(u);
                carr[carrPos] = ct;
                carrPos++;
            }
        }

        bss.getBusinessService().addAll(Arrays.asList(barr));
        if (carr.length > 0) {
            cts.getContact().addAll(Arrays.asList(carr));
            biz.setContacts(cts);
        }
        biz.setBusinessServices(bss);

        // External Links
        Iterator<ExternalLink> exiter = organization.getExternalLinks().iterator();
        DiscoveryURLs emptyDUs = null;
        boolean first = true;
        while (exiter.hasNext()) {
            ExternalLink link = (ExternalLink) exiter.next();
            /** Note: jUDDI adds its own discoverURL as the businessEntity* */
            if (first) {
                emptyDUs = objectFactory.createDiscoveryURLs();
                biz.setDiscoveryURLs(emptyDUs);
                first = false;
            }
            DiscoveryURL emptyDU = objectFactory.createDiscoveryURL();
            emptyDUs.getDiscoveryURL().add(emptyDU);
            emptyDU.setUseType("businessEntityExt");

            if (link.getExternalURI() != null) {
                emptyDU.setValue(link.getExternalURI());
            }
        }

        IdentifierBag idBag = getIdentifierBagFromExternalIdentifiers(organization.getExternalIdentifiers());
        if (idBag != null) {
            biz.setIdentifierBag(idBag);
        }
        CategoryBag catBag = getCategoryBagFromClassifications(organization.getClassifications());
        if (catBag != null) {
            biz.setCategoryBag(catBag);
        }

    } catch (Exception ud) {
        throw new JAXRException("Apache JAXR Impl:", ud);
    }
    return biz;
}

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

private static OverviewDoc getOverviewDocFromExternalLink(ExternalLink link) throws JAXRException {
    OverviewDoc od = objectFactory.createOverviewDoc();
    String url = link.getExternalURI();
    if (url != null)
        od.setOverviewURL(url);/*from  ww  w .  ja  v  a  2  s . c  om*/
    InternationalString extDesc = link.getDescription();
    if (extDesc != null) {
        Description description = objectFactory.createDescription();
        od.getDescription().add(description);
        description.setValue(extDesc.getValue());
    }
    return od;
}

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  ww  w .  ja  v a 2s. co  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;
}

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

public static BusinessEntity getBusinessEntityFromJAXROrg(Organization organization) throws JAXRException {
    BusinessEntity biz = objectFactory.createBusinessEntity();
    BusinessServices bss = objectFactory.createBusinessServices();
    BusinessService[] barr = new BusinessService[0];

    try {/*from ww w  .  ja v  a  2s .  c  o m*/
        // It may just be an update
        Key key = organization.getKey();
        if (key != null && key.getId() != null) {
            biz.setBusinessKey(key.getId());
        } else {
            biz.setBusinessKey("");
        }
        // Lets get the Organization attributes at the top level

        InternationalString iname = organization.getName();

        if (iname != null) {
            addNames(biz.getName(), iname);
        }

        InternationalString idesc = organization.getDescription();

        addDescriptions(biz.getDescription(), idesc);

        if (organization.getPrimaryContact() != null && organization.getPrimaryContact().getPersonName() != null
                && organization.getPrimaryContact().getPersonName().getFullName() != null) {

            //biz.setAuthorizedName(organization.getPrimaryContact().getPersonName()
            //      .getFullName());
        }

        Collection<Service> s = organization.getServices();
        log.debug("?Org has services=" + s.isEmpty());

        barr = new BusinessService[s.size()];

        Iterator<Service> iter = s.iterator();
        int barrPos = 0;
        while (iter.hasNext()) {
            BusinessService bs = ScoutJaxrUddiV3Helper.getBusinessServiceFromJAXRService((Service) iter.next());
            barr[barrPos] = bs;
            barrPos++;
        }

        /*
         * map users : JAXR has concept of 'primary contact', which is a
         * special designation for one of the users, and D6.1 seems to say
         * that the first UDDI user is the primary contact
         */

        Contacts cts = objectFactory.createContacts();
        Contact[] carr = new Contact[0];

        User primaryContact = organization.getPrimaryContact();
        Collection<User> users = organization.getUsers();

        // Expand array to necessary size only (xmlbeans does not like
        // null items in cases like this)

        int carrSize = 0;

        if (primaryContact != null) {
            carrSize += 1;
        }

        // TODO: Clean this up and make it more efficient
        Iterator<User> it = users.iterator();
        while (it.hasNext()) {
            User u = (User) it.next();
            if (u != primaryContact) {
                carrSize++;
            }
        }

        carr = new Contact[carrSize];

        /*
         * first do primary, and then filter that out in the loop
         */
        if (primaryContact != null) {
            Contact ct = getContactFromJAXRUser(primaryContact);
            carr[0] = ct;
        }

        it = users.iterator();
        int carrPos = 1;
        while (it.hasNext()) {
            User u = (User) it.next();

            if (u != primaryContact) {
                Contact ct = getContactFromJAXRUser(u);
                carr[carrPos] = ct;
                carrPos++;
            }
        }

        bss.getBusinessService().addAll(Arrays.asList(barr));
        if (carr.length > 0) {
            cts.getContact().addAll(Arrays.asList(carr));
            biz.setContacts(cts);
        }
        biz.setBusinessServices(bss);

        // External Links
        Iterator<ExternalLink> exiter = organization.getExternalLinks().iterator();
        DiscoveryURLs emptyDUs = null;
        boolean first = true;
        while (exiter.hasNext()) {
            ExternalLink link = (ExternalLink) exiter.next();
            /** Note: jUDDI adds its own discoverURL as the businessEntity* */
            if (first) {
                emptyDUs = objectFactory.createDiscoveryURLs();
                biz.setDiscoveryURLs(emptyDUs);
                first = false;
            }
            DiscoveryURL emptyDU = objectFactory.createDiscoveryURL();
            emptyDUs.getDiscoveryURL().add(emptyDU);
            emptyDU.setUseType("businessEntityExt");

            if (link.getExternalURI() != null) {
                emptyDU.setValue(link.getExternalURI());
            }
        }

        IdentifierBag idBag = getIdentifierBagFromExternalIdentifiers(organization.getExternalIdentifiers());
        if (idBag != null) {
            biz.setIdentifierBag(idBag);
        }
        CategoryBag catBag = getCategoryBagFromClassifications(organization.getClassifications());
        if (catBag != null) {
            biz.setCategoryBag(catBag);
        }

    } catch (Exception ud) {
        throw new JAXRException("Apache JAXR Impl:", ud);
    }
    return biz;
}

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

private static OverviewDoc getOverviewDocFromExternalLink(ExternalLink link) throws JAXRException {
    OverviewDoc od = objectFactory.createOverviewDoc();
    String url = link.getExternalURI();
    if (url != null) {
        org.uddi.api_v3.OverviewURL ourl = new org.uddi.api_v3.OverviewURL();
        ourl.setValue(url.toString());//from ww w.  ja v  a 2s.  c  o  m
        od.setOverviewURL(ourl);
    }
    InternationalString extDesc = link.getDescription();
    if (extDesc != null) {
        Description description = objectFactory.createDescription();
        od.getDescription().add(description);
        description.setValue(extDesc.getValue());
    }
    return od;
}