ws-scout-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r153229 - webservices/scout/trunk/modules/scout/src/java/org/apache/ws/scout/util/ScoutJaxrUddiHelper.java webservices/scout/trunk/modules/scout/src/java/org/apache/ws/scout/util/ScoutUddiJaxrHelper.java
Date Thu, 10 Feb 2005 15:10:46 GMT
Author: geirm
Date: Thu Feb 10 07:10:44 2005
New Revision: 153229

URL: http://svn.apache.org/viewcvs?view=rev&rev=153229
Log:
- changed author tags to be proper HTML mailto's   Hope no
   one minds - makes for better javadoc

- first cut at fixing the JAXR<->-UDDI user<->contact
  mapping problem.  JAXR has the concept of primary 
  contact, and UDDI doesn't.  so we make the first UDDI
  contact the primary contact JAXR user.  D6.1 in the
  JAXR spec seems to indicate this is the Right Way


Modified:
    webservices/scout/trunk/modules/scout/src/java/org/apache/ws/scout/util/ScoutJaxrUddiHelper.java
    webservices/scout/trunk/modules/scout/src/java/org/apache/ws/scout/util/ScoutUddiJaxrHelper.java

Modified: webservices/scout/trunk/modules/scout/src/java/org/apache/ws/scout/util/ScoutJaxrUddiHelper.java
URL: http://svn.apache.org/viewcvs/webservices/scout/trunk/modules/scout/src/java/org/apache/ws/scout/util/ScoutJaxrUddiHelper.java?view=diff&r1=153228&r2=153229
==============================================================================
--- webservices/scout/trunk/modules/scout/src/java/org/apache/ws/scout/util/ScoutJaxrUddiHelper.java
(original)
+++ webservices/scout/trunk/modules/scout/src/java/org/apache/ws/scout/util/ScoutJaxrUddiHelper.java
Thu Feb 10 07:10:44 2005
@@ -57,7 +57,8 @@
 /**
  * Helper class that does Jaxr->UDDI Mapping
  *
- * @author Anil Saldhana  <anil@apache.org>
+ * @author <a href="mailto:anil@apache.org">Anil Saldhana</a>
+ * @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
  */
 public class ScoutJaxrUddiHelper
 {
@@ -121,8 +122,6 @@
         BindingTemplate bt = new BindingTemplate();
         try
         {
-            InternationalStringImpl iname = (InternationalStringImpl) ((RegistryObject) serve).getName();
-            String name = iname.getValue();
             //Set Access URI
             String accessuri = serve.getAccessURI();
             if (accessuri != null)
@@ -230,9 +229,7 @@
     {
         BusinessEntity biz = new BusinessEntity();
         BusinessServices bss = new BusinessServices();
-        Contacts cts = new Contacts();
         Vector bvect = new Vector();
-        Vector cvect = new Vector();
 
         try
         {
@@ -257,14 +254,36 @@
                 bvect.add(bs);
             }
 
+            /*
+             * 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 = new Contacts();
+            Vector cvect = new Vector();
+
+            User primaryContact = org.getPrimaryContact();
             Collection users = org.getUsers();
+
+            // TODO - remove this
             System.out.println("?Org has users=" + users.isEmpty());
+
+            /*
+             * first do primary, and then filter that out in the loop
+             */
+            Contact ct = getContactFromJAXRUser(primaryContact);
+            cvect.add(ct);
+
             Iterator it = users.iterator();
             while (it.hasNext())
             {
-                Contact ct =
-                        getContactFromJAXRUser((User) it.next());
-                cvect.add(ct);
+                User u = (User) it.next();
+
+                if (u != primaryContact) {
+                    ct = getContactFromJAXRUser(u);
+                    cvect.add(ct);
+                }
             }
 
             bss.setBusinessServiceVector(bvect);

Modified: webservices/scout/trunk/modules/scout/src/java/org/apache/ws/scout/util/ScoutUddiJaxrHelper.java
URL: http://svn.apache.org/viewcvs/webservices/scout/trunk/modules/scout/src/java/org/apache/ws/scout/util/ScoutUddiJaxrHelper.java?view=diff&r1=153228&r2=153229
==============================================================================
--- webservices/scout/trunk/modules/scout/src/java/org/apache/ws/scout/util/ScoutUddiJaxrHelper.java
(original)
+++ webservices/scout/trunk/modules/scout/src/java/org/apache/ws/scout/util/ScoutUddiJaxrHelper.java
Thu Feb 10 07:10:44 2005
@@ -16,17 +16,8 @@
  */
 package org.apache.ws.scout.util;
 
-import org.apache.juddi.datatype.Address;
-import org.apache.juddi.datatype.AddressLine;
 import org.apache.juddi.datatype.Description;
-import org.apache.juddi.datatype.DiscoveryURL;
-import org.apache.juddi.datatype.Email;
 import org.apache.juddi.datatype.Name;
-import org.apache.juddi.datatype.PersonName;
-import org.apache.juddi.datatype.Phone;
-import org.apache.juddi.datatype.binding.AccessPoint;
-import org.apache.juddi.datatype.binding.BindingTemplate;
-import org.apache.juddi.datatype.binding.HostingRedirector;
 import org.apache.juddi.datatype.business.BusinessEntity;
 import org.apache.juddi.datatype.business.Contact;
 import org.apache.juddi.datatype.business.Contacts;
@@ -36,7 +27,6 @@
 import org.apache.juddi.datatype.service.BusinessService;
 import org.apache.juddi.datatype.service.BusinessServices;
 import org.apache.juddi.datatype.tmodel.TModel;
-import org.apache.ws.scout.registry.infomodel.InternationalStringImpl;
 import org.apache.ws.scout.registry.infomodel.OrganizationImpl;
 import org.apache.ws.scout.registry.infomodel.UserImpl;
 import org.apache.ws.scout.registry.infomodel.PersonNameImpl;
@@ -45,68 +35,74 @@
 
 import javax.xml.registry.JAXRException;
 import javax.xml.registry.LifeCycleManager;
-import javax.xml.registry.infomodel.ClassificationScheme;
 import javax.xml.registry.infomodel.Concept;
-import javax.xml.registry.infomodel.EmailAddress;
-import javax.xml.registry.infomodel.ExternalLink;
-import javax.xml.registry.infomodel.Key;
 import javax.xml.registry.infomodel.Organization;
-import javax.xml.registry.infomodel.PostalAddress;
-import javax.xml.registry.infomodel.RegistryObject;
 import javax.xml.registry.infomodel.Service;
-import javax.xml.registry.infomodel.ServiceBinding;
-import javax.xml.registry.infomodel.Slot;
-import javax.xml.registry.infomodel.TelephoneNumber;
 import javax.xml.registry.infomodel.User;
 import javax.xml.registry.infomodel.InternationalString;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Locale;
 import java.util.Vector;
 
 /**
  * Helper class that does UDDI->Jaxr Mapping
  *
- * @author Anil Saldhana  <anil@apache.org>
+ * @author <a href="mailto:anil@apache.org">Anil Saldhana</a>
+ * @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
  */
 public class ScoutUddiJaxrHelper
 {
     public static Organization getOrganization(BusinessEntity entity,
                                                    LifeCycleManager lcm)
-                throws JAXRException
+        throws JAXRException
+    {
+        Vector namevect = entity.getNameVector();
+        Name n = (Name)namevect.elementAt(0);
+        String name = n.getValue() ;
+        Vector descvect = entity.getDescriptionVector();
+        Description desc = (Description)descvect.elementAt(0);
+
+        Organization org = new OrganizationImpl(lcm);
+        org.setName(getIString(name,lcm));
+        org.setDescription(getIString((String)desc.getValue(),lcm));
+        org.setKey(lcm.createKey(entity.getBusinessKey()));
+
+        //Set Services also
+        BusinessServices services = entity.getBusinessServices();
+        Vector svect = services.getBusinessServiceVector();
+        for(int i=0; svect != null && i< svect.size();i++)
+        {
+            BusinessService s = (BusinessService)svect.elementAt(i);
+            org.addService(getService(s,lcm));
+        }
+
+        /*
+         *  Users
+         *
+         *  we need to take the first contact and designate as the
+         *  'primary contact'.  Currently, the OrganizationImpl
+         *  class does that automatically as a safety in case
+         *  user forgets to set - lets be explicit here as to not
+         *  depend on that behavior
+         */
+
+        Contacts contacts = entity.getContacts();
+        Vector cvect = contacts.getContactVector();
+
+        for(int i=0; cvect != null && i< cvect.size();i++)
         {
-            Vector namevect = entity.getNameVector();
-            Name n = (Name)namevect.elementAt(0);
-            String name = n.getValue() ;
-            Vector descvect = entity.getDescriptionVector();
-            Description desc = (Description)descvect.elementAt(0);
-
-            Organization org = new OrganizationImpl(lcm);
-            org.setName(getIString(name,lcm));
-            org.setDescription(getIString((String)desc.getValue(),lcm));
-            org.setKey(lcm.createKey(entity.getBusinessKey()));
-
-            //Set Services also
-            BusinessServices services = entity.getBusinessServices();
-            Vector svect = services.getBusinessServiceVector();
-            for(int i=0; svect != null && i< svect.size();i++)
-            {
-                BusinessService s = (BusinessService)svect.elementAt(i);
-                org.addService(getService(s,lcm));
+            Contact contact = (Contact)cvect.elementAt(i);
+            User user = new UserImpl(null);
+            String pname = contact.getPersonName().getValue();
+            user.setPersonName(new PersonNameImpl(pname));
+
+            if (i == 0) {
+                org.setPrimaryContact(user);
             }
-            //Get Contacts or Users
-            Contacts contacts = entity.getContacts();
-            Vector cvect = contacts.getContactVector();
-            for(int i=0; cvect != null && i< cvect.size();i++)
-            {
-                Contact contact = (Contact)cvect.elementAt(i);
-                User user = new UserImpl(null);
-                String pname = contact.getPersonName().getValue();
-                user.setPersonName(new PersonNameImpl(pname));
+            else {
                 org.addUser(user);
             }
-            return org;
         }
+        return org;
+    }
 
 
     public static Organization getOrganization(BusinessDetail bizdetail,
@@ -134,7 +130,16 @@
             BusinessService s = (BusinessService)svect.elementAt(i);
             org.addService(getService(s,lcm));
         }
-        //Get Contacts or Users
+
+        /*
+         *  Users
+         *
+         *  we need to take the first contact and designate as the
+         *  'primary contact'.  Currently, the OrganizationImpl
+         *  class does that automatically as a safety in case
+         *  user forgets to set - lets be explicit here as to not
+         *  depend on that behavior
+         */
         Contacts contacts = entity.getContacts();
         Vector cvect = contacts.getContactVector();
         for(int i=0; cvect != null && i< cvect.size();i++)
@@ -144,7 +149,13 @@
             String pname = contact.getPersonName().getValue();
             user.setType( contact.getUseType());
             user.setPersonName(new PersonNameImpl(pname));
-            org.addUser(user);
+
+            if (i == 0) {
+                org.setPrimaryContact(user);
+            }
+            else {
+                org.addUser(user);
+            }
         }
         return org;
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: scout-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: scout-dev-help@ws.apache.org


Mime
View raw message