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

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

Introduction

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

Prototype

public String getType() throws JAXRException;

Source Link

Document

Gets the type for this object.

Usage

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

private List<RegistryObjectBean> getEmailAddressesSearchResultsBeans(RegistryObjectBean roBean)
        throws ClassNotFoundException, NoSuchMethodException, ExceptionInInitializerError, Exception {
    Collection<?> emailAddresses = roBean.getEmailAddresses();
    if (emailAddresses == null) {
        return null;
    }//from  w  w w  . j  a v a 2s .c o  m
    int numEmailAddressObjects = emailAddresses.size();
    @SuppressWarnings("unused")
    ArrayList<Object> list = new ArrayList<Object>(numEmailAddressObjects);

    Iterator<?> roItr = emailAddresses.iterator();
    if (log.isDebugEnabled()) {
        log.debug("Query results: ");
    }

    String objectType = "EmailAddress";
    int numCols = 2;
    // Replace ObjectType with Id. TODO - formalize this convention
    List<RegistryObjectBean> roBeans = new ArrayList<RegistryObjectBean>(numEmailAddressObjects);
    for (@SuppressWarnings("unused")
    int i = 0; roItr.hasNext(); i++) {
        EmailAddress emailAddress = (EmailAddress) roItr.next();
        String header = null;
        Object columnValue = null;
        @SuppressWarnings("unused")
        List<?> srvbHeader = new ArrayList<Object>(numCols);
        List<SearchResultValueBean> searchResultValueBeans = new ArrayList<SearchResultValueBean>(numCols);

        header = WebUIResourceBundle.getInstance().getString("Details");
        columnValue = roBean.getId() + "." + emailAddress.hashCode();
        searchResultValueBeans.add(new SearchResultValueBean(header, columnValue));

        header = WebUIResourceBundle.getInstance().getString("Email Address");
        columnValue = emailAddress.getAddress();
        searchResultValueBeans.add(new SearchResultValueBean(header, columnValue));

        header = WebUIResourceBundle.getInstance().getString("Type");
        columnValue = emailAddress.getType();
        searchResultValueBeans.add(new SearchResultValueBean(header, columnValue));

        header = "";
        columnValue = "";
        searchResultValueBeans.add(new SearchResultValueBean(header, columnValue));

        RegistryObjectBean srb = new RegistryObjectBean(searchResultValueBeans, roBean.getRegistryObject(),
                objectType, emailAddress, false);
        roBeans.add(srb);
    }
    return roBeans;
}

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

/**
 *
 * Convert JAXR User Object to UDDI  Contact
 *//*www  .  j  a v a  2s.c o  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
 *//*w  w  w .j a  va 2  s  .  c  o  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;
}