You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scout-dev@ws.apache.org by ks...@apache.org on 2007/11/02 02:31:09 UTC

svn commit: r591187 - in /webservices/scout/trunk/scout/src/main/java/org/apache/ws/scout/util: ScoutJaxrUddiHelper.java ScoutUddiJaxrHelper.java

Author: kstam
Date: Thu Nov  1 18:31:09 2007
New Revision: 591187

URL: http://svn.apache.org/viewvc?rev=591187&view=rev
Log:
SCOUT-47, Adding the handling of SpecificationLinks. Completing the 0.7 branch to trunk.

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

Modified: webservices/scout/trunk/scout/src/main/java/org/apache/ws/scout/util/ScoutJaxrUddiHelper.java
URL: http://svn.apache.org/viewvc/webservices/scout/trunk/scout/src/main/java/org/apache/ws/scout/util/ScoutJaxrUddiHelper.java?rev=591187&r1=591186&r2=591187&view=diff
==============================================================================
--- webservices/scout/trunk/scout/src/main/java/org/apache/ws/scout/util/ScoutJaxrUddiHelper.java (original)
+++ webservices/scout/trunk/scout/src/main/java/org/apache/ws/scout/util/ScoutJaxrUddiHelper.java Thu Nov  1 18:31:09 2007
@@ -61,8 +61,10 @@
 import org.apache.ws.scout.uddi.Email;
 import org.apache.ws.scout.uddi.HostingRedirector;
 import org.apache.ws.scout.uddi.IdentifierBag;
+import org.apache.ws.scout.uddi.InstanceDetails;
 import org.apache.ws.scout.uddi.KeyedReference;
 import org.apache.ws.scout.uddi.Name;
+import org.apache.ws.scout.uddi.OverviewDoc;
 import org.apache.ws.scout.uddi.Phone;
 import org.apache.ws.scout.uddi.PublisherAssertion;
 import org.apache.ws.scout.uddi.TModel;
@@ -76,9 +78,11 @@
  *
  * @author <a href="mailto:anil@apache.org">Anil Saldhana</a>
  * @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
+ * @author <a href="mailto:kstam@apache.org">Kurt T Stam</a>
  */
-public class ScoutJaxrUddiHelper {
-	
+public class ScoutJaxrUddiHelper 
+{
+    private static final String UDDI_ORG_TYPES = "uuid:C1ACF26D-9672-4404-9D70-39B756E62AB4";
 	private static Log log = LogFactory.getLog(ScoutJaxrUddiHelper.class);
     /**
      * Get UDDI Address given JAXR Postal Address
@@ -200,10 +204,30 @@
 					TModelInstanceInfo emptyTInfo = tid
 							.addNewTModelInstanceInfo();
 
-					if (slink.getSpecificationObject().getKey() != null && 
-						slink.getSpecificationObject().getKey().getId() != null) {
-						emptyTInfo.setTModelKey(slink.getSpecificationObject()
-								.getKey().getId());
+                    RegistryObject specificationObject = slink.getSpecificationObject();
+					if (specificationObject.getKey() != null && specificationObject.getKey().getId() != null) {
+						emptyTInfo.setTModelKey(specificationObject.getKey().getId());
+                        if (specificationObject.getDescription()!=null) {
+                            for (LocalizedString locDesc : specificationObject.getDescription().getLocalizedStrings()) {
+                                Description description = emptyTInfo.addNewDescription();
+                                description.setStringValue(locDesc.getValue());
+                                description.setLang(locDesc.getLocale().getLanguage());
+                            }
+                        }
+                        Collection<ExternalLink> externalLinks = slink.getExternalLinks();
+                        if (externalLinks!=null && externalLinks.size()>0) {
+                            for (ExternalLink link : externalLinks) {
+                                InstanceDetails ids = emptyTInfo.addNewInstanceDetails();
+                                if (link.getDescription()!=null) {
+                                    Description description = ids.addNewDescription();
+                                    description.setStringValue(link.getDescription().getValue());
+                                }
+                                if (link.getExternalURI()!=null) {
+                                    OverviewDoc overviewDoc = ids.addNewOverviewDoc();
+                                    overviewDoc.setOverviewURL(link.getExternalURI());
+                                }
+                            } 
+                        }
 					}
               }
               bt.setTModelInstanceDetails(tid);
@@ -452,6 +476,12 @@
                     desc.setLang(locName.getLocale().getLanguage());
                 }
             }
+//          External Links 
+            Collection externalLinks = scheme.getExternalLinks(); 
+            if(externalLinks != null && externalLinks.size() > 0)
+            {
+                tm.setOverviewDoc(getOverviewDocFromExternalLink((ExternalLink)externalLinks.iterator().next()));
+            }  
 
             IdentifierBag idBag = getIdentifierBagFromExternalIdentifiers(scheme.getExternalIdentifiers());
             if (idBag!=null) {
@@ -462,8 +492,6 @@
                 tm.setCategoryBag(catBag);
             }
 
-			// ToDO: overviewDoc
-
 		} catch (Exception ud) {
             throw new JAXRException("Apache JAXR Impl:", ud);
         }
@@ -561,9 +589,6 @@
 
             carr = new Contact[carrSize];
 
-            // TODO - remove this
-            log.debug("?Org has users=" + users.isEmpty());
-
             /*
              * first do primary, and then filter that out in the loop
              */
@@ -739,7 +764,7 @@
 
        return uri;
    }
-
+    
 	/**
      * According to JAXR Javadoc, there are two types of classification, internal and external and they use the Classification, Concept,     
      * and ClassificationScheme objects.  It seems the only difference between internal and external (as related to UDDI) is that the
@@ -770,33 +795,43 @@
 					InternationalStringImpl iname = null;
 					String value = null;
 					ClassificationScheme scheme = classification.getClassificationScheme();
-					if (classification.isExternal()) {
-						iname = (InternationalStringImpl) ((RegistryObject) classification).getName();
-						value = classification.getValue();
-						scheme = classification.getClassificationScheme();
-					}
-					else {
-						Concept concept = classification.getConcept();
-						if (concept != null) {
-							iname = (InternationalStringImpl) ((RegistryObject) concept).getName();
-							value = concept.getValue();
-							scheme = concept.getClassificationScheme();
-						}
-					}
-	
-					String name = iname.getValue();
-					if (name != null)
-						keyr.setKeyName(name);
-	
-					if (value != null)
-						keyr.setKeyValue(value);
-					
-					if (scheme != null) {
-						Key key = scheme.getKey();
-						if (key != null && key.getId() != null)
-							keyr.setTModelKey(key.getId());
-					}
-				}
+                    if (scheme==null || (classification.isExternal() && classification.getConcept()==null)) {
+                        /*
+                        * JAXR 1.0 Specification: Section D6.4.4
+                        * Specification related tModels mapped from Concept may be automatically
+                        * categorized by the well-known uddi-org:types taxonomy in UDDI (with
+                        * tModelKey uuid:C1ACF26D-9672-4404-9D70-39B756E62AB4) as follows:
+                        * The keyed reference is assigned a taxonomy value of specification.
+                        */
+                        keyr.setTModelKey(UDDI_ORG_TYPES);
+                        keyr.setKeyValue("specification"); 
+                    } else {
+    					if (classification.isExternal()) {
+                            iname = (InternationalStringImpl) ((RegistryObject) classification).getName();
+                            value = classification.getValue();
+    					} else {
+    						Concept concept = classification.getConcept();
+    						if (concept != null) {
+    							iname = (InternationalStringImpl) ((RegistryObject) concept).getName();
+    							value = concept.getValue();
+    							scheme = concept.getClassificationScheme();
+    						}
+    					}
+    	
+    					String name = iname.getValue();
+    					if (name != null)
+    						keyr.setKeyName(name);
+    	
+    					if (value != null)
+    						keyr.setKeyValue(value);
+    					
+    					if (scheme != null) {
+    						Key key = scheme.getKey();
+    						if (key != null && key.getId() != null)
+    							keyr.setTModelKey(key.getId());
+    					}
+    				}
+                }
 			}
 			return cbag;
     	} catch (Exception ud) {
@@ -847,6 +882,21 @@
 			throw new JAXRException("Apache JAXR Impl:", ud);
 		}
     }
+    
+    private static OverviewDoc getOverviewDocFromExternalLink(ExternalLink link)
+       throws JAXRException
+       {
+           OverviewDoc od = (OverviewDoc)(XmlObject.Factory.newInstance()).changeType(OverviewDoc.type);
+           String url = link.getExternalURI();
+           if(url != null)
+               od.setOverviewURL(url);
+           InternationalString extDesc = link.getDescription();
+           if(extDesc != null) {
+               Description description = od.addNewDescription();
+               description.setStringValue(extDesc.getValue());
+           }
+           return od;
+       }
 
     private static BindingTemplates getBindingTemplates(Collection serviceBindings)
         throws JAXRException {

Modified: webservices/scout/trunk/scout/src/main/java/org/apache/ws/scout/util/ScoutUddiJaxrHelper.java
URL: http://svn.apache.org/viewvc/webservices/scout/trunk/scout/src/main/java/org/apache/ws/scout/util/ScoutUddiJaxrHelper.java?rev=591187&r1=591186&r2=591187&view=diff
==============================================================================
--- webservices/scout/trunk/scout/src/main/java/org/apache/ws/scout/util/ScoutUddiJaxrHelper.java (original)
+++ webservices/scout/trunk/scout/src/main/java/org/apache/ws/scout/util/ScoutUddiJaxrHelper.java Thu Nov  1 18:31:09 2007
@@ -47,6 +47,7 @@
 import org.apache.ws.scout.registry.infomodel.PersonNameImpl;
 import org.apache.ws.scout.registry.infomodel.ServiceBindingImpl;
 import org.apache.ws.scout.registry.infomodel.ServiceImpl;
+import org.apache.ws.scout.registry.infomodel.SpecificationLinkImpl;
 import org.apache.ws.scout.registry.infomodel.UserImpl;
 import org.apache.ws.scout.uddi.AccessPoint;
 import org.apache.ws.scout.uddi.BindingTemplate;
@@ -61,13 +62,18 @@
 import org.apache.ws.scout.uddi.Description;
 import org.apache.ws.scout.uddi.DiscoveryURL;
 import org.apache.ws.scout.uddi.DiscoveryURLs;
+import org.apache.ws.scout.uddi.HostingRedirector;
 import org.apache.ws.scout.uddi.IdentifierBag;
+import org.apache.ws.scout.uddi.InstanceDetails;
 import org.apache.ws.scout.uddi.KeyedReference;
 import org.apache.ws.scout.uddi.Name;
+import org.apache.ws.scout.uddi.OverviewDoc;
 import org.apache.ws.scout.uddi.ServiceInfo;
 import org.apache.ws.scout.uddi.TModel;
 import org.apache.ws.scout.uddi.TModelDetail;
 import org.apache.ws.scout.uddi.TModelInfo;
+import org.apache.ws.scout.uddi.TModelInstanceDetails;
+import org.apache.ws.scout.uddi.TModelInstanceInfo;
 
 /**
  * Helper class that does UDDI->Jaxr Mapping
@@ -327,32 +333,60 @@
    public static ServiceBinding getServiceBinding(BindingTemplate bs, LifeCycleManager lcm)
            throws JAXRException
    {
-      ServiceBinding serve = new ServiceBindingImpl(lcm);
+      ServiceBinding serviceBinding = new ServiceBindingImpl(lcm);
 
       String keystr = bs.getServiceKey();
       if (keystr != null)
       {
          Service svc = new ServiceImpl(lcm);
          svc.setKey(lcm.createKey(keystr));
-         ((ServiceBindingImpl)serve).setService(svc);
+         ((ServiceBindingImpl)serviceBinding).setService(svc);
       }
       String bindingKey = bs.getBindingKey();
-      if(bindingKey != null) serve.setKey(new KeyImpl(bindingKey));
-      //TODO:Add more stuff
+      if(bindingKey != null) serviceBinding.setKey(new KeyImpl(bindingKey));
+     
       //Access URI
       AccessPoint access = bs.getAccessPoint();
-      //FIXME: accesspoint should have a getURL? 
-      if (access != null) serve.setAccessURI(access.getStringValue());
+      if (access != null) serviceBinding.setAccessURI(access.getStringValue());
 
       //Description
       Description[] da = bs.getDescriptionArray();
       if (da != null && da.length > 0)
       {
          Description des = da[0];
-         serve.setDescription(new InternationalStringImpl(des.getStringValue()));
+         serviceBinding.setDescription(new InternationalStringImpl(des.getStringValue()));
+      }
+      /**Section D.10 of JAXR 1.0 Specification */
+      
+      TModelInstanceDetails details = bs.getTModelInstanceDetails();
+      TModelInstanceInfo[] tmodelInstanceInfoArray = details.getTModelInstanceInfoArray();
+      for (int i = 0; tmodelInstanceInfoArray != null && i < tmodelInstanceInfoArray.length; i++)
+      {
+         TModelInstanceInfo info = (TModelInstanceInfo)tmodelInstanceInfoArray[i];
+         InstanceDetails idetails = info.getInstanceDetails(); 
+         Collection<ExternalLink> elinks = getExternalLinks(idetails.getOverviewDoc(),lcm);
+         SpecificationLinkImpl slink = new SpecificationLinkImpl(lcm);
+         slink.addExternalIdentifiers(elinks);
+         serviceBinding.addSpecificationLink(slink); 
+         
+         ConceptImpl c = new ConceptImpl(lcm);
+         c.setExternalLinks(elinks);
+         c.setKey(lcm.createKey(info.getTModelKey())); 
+         c.setName(lcm.createInternationalString(idetails.getInstanceParms()));
+         c.setValue(idetails.getInstanceParms());
+         
+         slink.setSpecificationObject(c);
+      }
+      
+      HostingRedirector hr = bs.getHostingRedirector();
+      if(hr != null)
+      {
+         ServiceBinding sb = lcm.createServiceBinding();
+         sb.setKey(new KeyImpl(hr.getBindingKey()));
+         serviceBinding.setTargetBinding(sb);
       }
 
-      return serve;
+      return serviceBinding;
    }
 
    public static Concept getConcept(TModelDetail tm, LifeCycleManager lcm)
@@ -443,6 +477,23 @@
 		}
 	    return classifications;
 	}
+   
+   public static Collection<ExternalLink> getExternalLinks(OverviewDoc odoc , LifeCycleManager lcm)
+   throws JAXRException
+   {
+       ArrayList<ExternalLink> alist = new ArrayList<ExternalLink>(1);
+       if(odoc != null)
+       {
+           Description[] descVect = odoc.getDescriptionArray();
+           String desc = "";
+           if(descVect != null && descVect.length > 0) {
+             desc = ((Description)descVect[0]).getStringValue(); 
+           }
+           alist.add(lcm.createExternalLink(odoc.getOverviewURL(),desc));
+       }
+       
+       return alist;
+   }
    
    /**
     * External Identifiers



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