Example usage for javax.xml.registry.infomodel User getType

List of usage examples for javax.xml.registry.infomodel User getType

Introduction

In this page you can find the example usage for javax.xml.registry.infomodel User getType.

Prototype

public String getType() throws JAXRException;

Source Link

Document

Gets the type for this User.

Usage

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

/**
 *
 * Convert JAXR User Object to UDDI  Contact
 *//*from   w  w w.  j av a 2  s.co  m*/
public static Contact getContactFromJAXRUser(User user) throws JAXRException {
    Contact ct = objectFactory.createContact();
    if (user == null) {
        return null;
    }

    Address[] addarr = new Address[0];
    Phone[] phonearr = new Phone[0];
    Email[] emailarr = new Email[0];
    try {

        if (user.getPersonName() != null && user.getPersonName().getFullName() != null) {
            ct.setPersonName(user.getPersonName().getFullName());
        }

        if (user.getType() != null) {
            ct.setUseType(user.getType());
        }
        // Postal Address
        Collection<PostalAddress> postc = user.getPostalAddresses();

        addarr = new Address[postc.size()];

        Iterator<PostalAddress> iterator = postc.iterator();
        int addarrPos = 0;
        while (iterator.hasNext()) {
            PostalAddress post = (PostalAddress) iterator.next();
            addarr[addarrPos] = ScoutJaxrUddiHelper.getAddress(post);
            addarrPos++;
        }
        // Phone Numbers
        Collection ph = user.getTelephoneNumbers(null);

        phonearr = new Phone[ph.size()];

        Iterator it = ph.iterator();
        int phonearrPos = 0;
        while (it.hasNext()) {
            TelephoneNumber t = (TelephoneNumber) it.next();
            Phone phone = objectFactory.createPhone();
            String str = t.getNumber();
            log.debug("Telephone=" + str);

            // FIXME: If phone number is null, should the phone 
            // not be set at all, or set to empty string?
            if (str != null) {
                phone.setValue(str);
            } else {
                phone.setValue("");
            }

            phonearr[phonearrPos] = phone;
            phonearrPos++;
        }

        // Email Addresses
        Collection ec = user.getEmailAddresses();

        emailarr = new Email[ec.size()];

        Iterator iter = ec.iterator();
        int emailarrPos = 0;
        while (iter.hasNext()) {
            EmailAddress ea = (EmailAddress) iter.next();
            Email email = objectFactory.createEmail();

            if (ea.getAddress() != null) {
                email.setValue(ea.getAddress());
            }
            // email.setText( ea.getAddress() );

            if (ea.getType() != null) {
                email.setUseType(ea.getType());
            }

            emailarr[emailarrPos] = email;
            emailarrPos++;
        }
        ct.getAddress().addAll(Arrays.asList(addarr));
        ct.getPhone().addAll(Arrays.asList(phonearr));
        ct.getEmail().addAll(Arrays.asList(emailarr));
    } catch (Exception ud) {
        throw new JAXRException("Apache JAXR Impl:", ud);
    }
    return ct;
}

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

/**
 *
 * Convert JAXR User Object to UDDI  Contact
 *//*from w ww  .  j a  va2 s .  co m*/
public static Contact getContactFromJAXRUser(User user) throws JAXRException {
    Contact ct = objectFactory.createContact();
    if (user == null) {
        return null;
    }

    Address[] addarr = new Address[0];
    Phone[] phonearr = new Phone[0];
    Email[] emailarr = new Email[0];
    try {

        if (user.getPersonName() != null && user.getPersonName().getFullName() != null) {
            org.uddi.api_v3.PersonName pn = new org.uddi.api_v3.PersonName();
            pn.setValue(user.getPersonName().getFullName());
            ct.getPersonName().add(pn);
        }

        if (user.getType() != null) {
            ct.setUseType(user.getType());
        }
        // Postal Address
        Collection<PostalAddress> postc = user.getPostalAddresses();

        addarr = new Address[postc.size()];

        Iterator<PostalAddress> iterator = postc.iterator();
        int addarrPos = 0;
        while (iterator.hasNext()) {
            PostalAddress post = (PostalAddress) iterator.next();
            addarr[addarrPos] = ScoutJaxrUddiV3Helper.getAddress(post);
            addarrPos++;
        }
        // Phone Numbers
        Collection ph = user.getTelephoneNumbers(null);

        phonearr = new Phone[ph.size()];

        Iterator it = ph.iterator();
        int phonearrPos = 0;
        while (it.hasNext()) {
            TelephoneNumber t = (TelephoneNumber) it.next();
            Phone phone = objectFactory.createPhone();
            String str = t.getNumber();
            log.debug("Telephone=" + str);

            // FIXME: If phone number is null, should the phone 
            // not be set at all, or set to empty string?
            if (str != null) {
                phone.setValue(str);
            } else {
                phone.setValue("");
            }

            phonearr[phonearrPos] = phone;
            phonearrPos++;
        }

        // Email Addresses
        Collection ec = user.getEmailAddresses();

        emailarr = new Email[ec.size()];

        Iterator iter = ec.iterator();
        int emailarrPos = 0;
        while (iter.hasNext()) {
            EmailAddress ea = (EmailAddress) iter.next();
            Email email = objectFactory.createEmail();

            if (ea.getAddress() != null) {
                email.setValue(ea.getAddress());
            }
            // email.setText( ea.getAddress() );

            if (ea.getType() != null) {
                email.setUseType(ea.getType());
            }

            emailarr[emailarrPos] = email;
            emailarrPos++;
        }
        ct.getAddress().addAll(Arrays.asList(addarr));
        ct.getPhone().addAll(Arrays.asList(phonearr));
        ct.getEmail().addAll(Arrays.asList(emailarr));
    } catch (Exception ud) {
        throw new JAXRException("Apache JAXR Impl:", ud);
    }
    return ct;
}