SCOUT-66
Add support for UDDI v 3.0.
git-svn-id: https://svn.apache.org/repos/asf/webservices/scout/trunk@811951 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/pom.xml b/pom.xml
index b86da92..d40856e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -250,6 +250,12 @@
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.juddi</groupId>
+ <artifactId>uddi-ws</artifactId>
+ <version>3.0.0.SNAPSHOT</version>
+ </dependency>
+
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
diff --git a/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerImpl.java b/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerImpl.java
index b658128..54a0cda 100644
--- a/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerImpl.java
+++ b/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerImpl.java
@@ -55,21 +55,28 @@
import org.apache.ws.scout.model.uddi.v2.BindingTemplate;
import org.apache.ws.scout.model.uddi.v2.BusinessDetail;
import org.apache.ws.scout.model.uddi.v2.BusinessEntity;
+import org.apache.ws.scout.model.uddi.v2.BusinessInfo;
import org.apache.ws.scout.model.uddi.v2.BusinessService;
+import org.apache.ws.scout.model.uddi.v2.Description;
import org.apache.ws.scout.model.uddi.v2.DispositionReport;
import org.apache.ws.scout.model.uddi.v2.ErrInfo;
import org.apache.ws.scout.model.uddi.v2.KeyedReference;
+import org.apache.ws.scout.model.uddi.v2.Name;
import org.apache.ws.scout.model.uddi.v2.ObjectFactory;
import org.apache.ws.scout.model.uddi.v2.PublisherAssertion;
import org.apache.ws.scout.model.uddi.v2.PublisherAssertions;
import org.apache.ws.scout.model.uddi.v2.Result;
import org.apache.ws.scout.model.uddi.v2.ServiceDetail;
+import org.apache.ws.scout.model.uddi.v2.ServiceInfo;
import org.apache.ws.scout.model.uddi.v2.TModel;
import org.apache.ws.scout.model.uddi.v2.TModelDetail;
import org.apache.ws.scout.registry.infomodel.ConceptImpl;
import org.apache.ws.scout.registry.infomodel.InternationalStringImpl;
import org.apache.ws.scout.registry.infomodel.KeyImpl;
+import org.apache.ws.scout.registry.infomodel.OrganizationImpl;
+import org.apache.ws.scout.registry.infomodel.ServiceImpl;
import org.apache.ws.scout.util.ScoutJaxrUddiHelper;
+import org.apache.ws.scout.util.ScoutUddiJaxrHelper;
/**
* Implements JAXR BusinessLifeCycleManager Interface.
@@ -77,6 +84,7 @@
*
* @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:tcunning@apache.org">Tom Cunningham</a>
*/
public class BusinessLifeCycleManagerImpl extends LifeCycleManagerImpl
implements BusinessLifeCycleManager, Serializable {
@@ -551,7 +559,7 @@
throw new IllegalStateException("No registry");
}
- IRegistry ireg = registry.getRegistry();
+ IRegistry ireg = (IRegistry) registry.getRegistry();
ConnectionImpl connection = registry.getConnection();
AuthToken token = getAuthToken(connection, ireg);
@@ -817,4 +825,46 @@
}return pa;
}
+ Organization createOrganization(BusinessDetail bizDetail) throws JAXRException {
+ return ScoutUddiJaxrHelper.getOrganization(bizDetail, this);
+ }
+
+ Organization createOrganization(BusinessInfo bizInfo) throws JAXRException {
+ String key = bizInfo.getBusinessKey();
+ List<Name> names = bizInfo.getName();
+
+ List<Description> descriptions = bizInfo.getDescription();
+ List<ServiceInfo> serviceInfos = bizInfo.getServiceInfos().getServiceInfo();
+
+ OrganizationImpl org = new OrganizationImpl(this);
+ org.setKey(createKey(key));
+ if (names != null && names.size() > 0) {
+ org.setName(createInternationalString(names.get(0).getValue()));
+ }
+ if (descriptions != null && descriptions.size() > 0) {
+ org.setDescription(createInternationalString(descriptions.get(0).getValue()));
+ }
+ if (serviceInfos != null && serviceInfos.size() > 0) {
+ List<Service> services = new ArrayList<Service>(serviceInfos.size());
+ for (int i = 0; i < serviceInfos.size(); i++) {
+ ServiceInfo serviceInfo = serviceInfos.get(i);
+ services.add(createService(serviceInfo));
+ }
+ org.addServices(services);
+ }
+
+ return org;
+ }
+
+ Service createService(ServiceInfo serviceInfo) throws JAXRException {
+ String key = serviceInfo.getServiceKey();
+ List<Name> names = serviceInfo.getName();
+ ServiceImpl service = new ServiceImpl(this);
+ service.setKey(createKey(key));
+ if (names != null && names.size() > 0) {
+ service.setName(createInternationalString(names.get(0).getValue()));
+ }
+ return service;
+ }
+
}
diff --git a/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerV3Impl.java b/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerV3Impl.java
new file mode 100644
index 0000000..f0a633a
--- /dev/null
+++ b/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerV3Impl.java
@@ -0,0 +1,851 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ws.scout.registry;
+
+import java.io.Serializable;
+import java.net.PasswordAuthentication;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.Vector;
+
+import javax.xml.registry.BulkResponse;
+import javax.xml.registry.BusinessLifeCycleManager;
+import javax.xml.registry.DeleteException;
+import javax.xml.registry.InvalidRequestException;
+import javax.xml.registry.JAXRException;
+import javax.xml.registry.JAXRResponse;
+import javax.xml.registry.LifeCycleManager;
+import javax.xml.registry.RegistryService;
+import javax.xml.registry.SaveException;
+import javax.xml.registry.UnexpectedObjectException;
+import javax.xml.registry.infomodel.Association;
+import javax.xml.registry.infomodel.ClassificationScheme;
+import javax.xml.registry.infomodel.Concept;
+import javax.xml.registry.infomodel.Key;
+import javax.xml.registry.infomodel.Organization;
+import javax.xml.registry.infomodel.RegistryObject;
+import javax.xml.registry.infomodel.Service;
+import javax.xml.registry.infomodel.ServiceBinding;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.uddi.api_v3.*;
+import org.apache.ws.scout.registry.infomodel.ConceptImpl;
+import org.apache.ws.scout.registry.infomodel.InternationalStringImpl;
+import org.apache.ws.scout.registry.infomodel.KeyImpl;
+import org.apache.ws.scout.registry.infomodel.OrganizationImpl;
+import org.apache.ws.scout.registry.infomodel.ServiceImpl;
+import org.apache.ws.scout.util.ScoutJaxrUddiHelper;
+import org.apache.ws.scout.util.ScoutJaxrUddiV3Helper;
+import org.apache.ws.scout.util.ScoutUddiJaxrHelper;
+import org.apache.ws.scout.util.ScoutUddiV3JaxrHelper;
+
+/**
+ * Implements JAXR BusinessLifeCycleManager Interface.
+ * For futher details, look into the JAXR API Javadoc.
+ *
+ * @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:tcunning@apache.org">Tom Cunningham</a>
+ */
+public class BusinessLifeCycleManagerV3Impl extends LifeCycleManagerImpl
+ implements BusinessLifeCycleManager, Serializable {
+
+
+ private static final long serialVersionUID = 1L;
+ private Log log = LogFactory.getLog(this.getClass());
+
+ private transient ObjectFactory objectFactory = new ObjectFactory();
+
+ public BusinessLifeCycleManagerV3Impl(RegistryService registry) {
+ super(registry);
+ if(objectFactory == null)
+ objectFactory = new ObjectFactory();
+ }
+
+ /**
+ * Deletes one or more previously submitted objects from the registry
+ * using the object keys and a specified objectType attribute.
+ *
+ * @param keys
+ * @param objectType
+ * @return BulkResponse object
+ * @throws JAXRException
+ */
+ public BulkResponse deleteObjects(Collection keys, String objectType) throws JAXRException {
+ BulkResponse bulk = null;
+
+ if (objectType == LifeCycleManager.ASSOCIATION) {
+ bulk = this.deleteAssociations(keys);
+ }
+ else if (objectType == LifeCycleManager.CLASSIFICATION_SCHEME) {
+ bulk = this.deleteClassificationSchemes(keys);
+ }
+ else if (objectType == LifeCycleManager.CONCEPT) {
+ bulk = this.deleteConcepts(keys);
+ }
+ else if (objectType == LifeCycleManager.ORGANIZATION) {
+ bulk = this.deleteOrganizations(keys);
+ }
+ else if (objectType == LifeCycleManager.SERVICE) {
+ bulk = this.deleteServices(keys);
+ }
+ else if (objectType == LifeCycleManager.SERVICE_BINDING) {
+ bulk = this.deleteServiceBindings(keys);
+ }
+ else {
+ throw new JAXRException("Delete Operation for " + objectType + " not implemented by Scout");
+ }
+
+ return bulk;
+ }
+
+ public BulkResponse deleteAssociations(Collection associationKeys) throws JAXRException {
+ return this.deleteOperation(associationKeys, "DELETE_ASSOCIATION");
+ }
+
+ public BulkResponse deleteClassificationSchemes(Collection schemeKeys) throws JAXRException {
+ return this.deleteOperation(schemeKeys, "DELETE_CLASSIFICATIONSCHEME");
+ }
+
+ public BulkResponse deleteConcepts(Collection conceptKeys) throws JAXRException {
+ return this.deleteOperation(conceptKeys, "DELETE_CONCEPT");
+ }
+
+ public BulkResponse deleteOrganizations(Collection orgkeys) throws JAXRException {
+ return this.deleteOperation(orgkeys, "DELETE_ORG");
+ }
+
+ public BulkResponse deleteServiceBindings(Collection bindingKeys) throws JAXRException {
+ return this.deleteOperation(bindingKeys, "DELETE_SERVICEBINDING");
+ }
+
+ public BulkResponse deleteServices(Collection serviceKeys) throws JAXRException {
+ return this.deleteOperation(serviceKeys, "DELETE_SERVICE");
+ }
+
+ /**
+ * Saves one or more Objects to the registry. An object may be a
+ * RegistryObject subclass instance. If an object is not in the registry,
+ * it is created in the registry. If it already exists in the registry
+ * and has been modified, then its state is updated (replaced) in the
+ * registry
+ * <p/>
+ * TODO:Check if juddi can provide a facility to store a collection of heterogenous
+ * objects
+ * <p/>
+ * TODO - does this belong here? it's really an overload of
+ * LifecycleManager.saveObjects, but all the help we need
+ * like saveOrganization() is up here...
+ *
+ * @param col
+ * @return a BulkResponse containing the Collection of keys for those objects
+ * that were saved successfully and any SaveException that was encountered
+ * in case of partial commit
+ * @throws JAXRException
+ */
+ public BulkResponse saveObjects(Collection col) throws JAXRException {
+
+ Iterator iter = col.iterator();
+
+ LinkedHashSet<Object> suc = new LinkedHashSet<Object>();
+ Collection<Exception> exc = new ArrayList<Exception>();
+
+ while (iter.hasNext()) {
+ RegistryObject reg = (RegistryObject) iter.next();
+
+ BulkResponse br = null;
+
+ Collection<RegistryObject> c = new ArrayList<RegistryObject>();
+ c.add(reg);
+
+ if (reg instanceof javax.xml.registry.infomodel.Association) {
+ br = saveAssociations(c, true);
+ }
+ else if (reg instanceof javax.xml.registry.infomodel.ClassificationScheme) {
+ br = saveClassificationSchemes(c);
+ }
+ else if (reg instanceof javax.xml.registry.infomodel.Concept) {
+ br = saveConcepts(c);
+ }
+ else if (reg instanceof javax.xml.registry.infomodel.Organization) {
+ br = saveOrganizations(c);
+ }
+ else if (reg instanceof javax.xml.registry.infomodel.Service) {
+ br = saveServices(c);
+ }
+ else if (reg instanceof javax.xml.registry.infomodel.ServiceBinding) {
+ br = saveServiceBindings(c);
+ }
+ else {
+ throw new JAXRException("Delete Operation for " + reg.getClass()
+ + " not implemented by Scout");
+ }
+
+ if (br.getCollection() != null) {
+ suc.addAll(br.getCollection());
+ }
+
+ if (br.getExceptions() != null) {
+ exc.addAll(br.getExceptions());
+ }
+ }
+
+ BulkResponseImpl bulk = new BulkResponseImpl();
+
+ /*
+ * TODO - what is the right status?
+ */
+ bulk.setStatus(JAXRResponse.STATUS_SUCCESS);
+
+ bulk.setCollection(suc);
+ bulk.setExceptions(exc);
+
+ return bulk;
+ }
+
+
+ public BulkResponse saveAssociations(Collection associations, boolean replace) throws JAXRException {
+ BulkResponseImpl bulk = new BulkResponseImpl();
+ PublisherAssertion[] sarr = new PublisherAssertion[associations.size()];
+
+ Collection<Key> coll = new ArrayList<Key>();
+ Collection<Exception> exceptions = new ArrayList<Exception>();
+
+ Iterator iter = associations.iterator();
+ int currLoc = 0;
+ while (iter.hasNext()) {
+
+ Association association = (Association) iter.next();
+ association.getSourceObject();
+ PublisherAssertion pa = ScoutJaxrUddiV3Helper.getPubAssertionFromJAXRAssociation(association);
+ sarr[currLoc] = pa;
+ currLoc++;
+
+ // Save PublisherAssertion
+ PublisherAssertions bd = null;
+ try {
+ bd = (PublisherAssertions) executeOperation(sarr, "SAVE_ASSOCIATION");
+ }
+ catch (RegistryV3Exception e) {
+ exceptions.add(new SaveException(e));
+ bulk.setExceptions(exceptions);
+ bulk.setStatus(JAXRResponse.STATUS_FAILURE);
+ return bulk;
+ }
+ if(bd != null)
+ {
+ List<PublisherAssertion> publisherAssertionList = bd.getPublisherAssertion();
+ PublisherAssertion[] keyarr = new PublisherAssertion[publisherAssertionList.size()];
+ publisherAssertionList.toArray(keyarr);
+
+ for (int i = 0; keyarr != null && i < keyarr.length; i++) {
+ PublisherAssertion result = (PublisherAssertion) keyarr[i];
+ KeyedReference keyr = result.getKeyedReference();
+ Concept c = new ConceptImpl(getRegistryService().getBusinessLifeCycleManager());
+ c.setName(new InternationalStringImpl(keyr.getKeyName()));
+ c.setKey( new KeyImpl(keyr.getTModelKey()) );
+ c.setValue(keyr.getKeyValue());
+ association.setAssociationType(c);
+ coll.add(association.getKey());
+ }
+ }
+ }
+ bulk.setCollection(coll);
+ bulk.setExceptions(exceptions);
+
+ return bulk;
+ }
+
+ public BulkResponse saveClassificationSchemes(Collection schemes) throws JAXRException {
+ //Now we need to convert the collection into a vector for juddi
+ BulkResponseImpl bulk = new BulkResponseImpl();
+ TModel[] entityarr = new TModel[schemes.size()];
+
+ LinkedHashSet<Key> coll = new LinkedHashSet<Key>();
+ Collection<Exception> exceptions = new ArrayList<Exception>();
+
+ Iterator iter = schemes.iterator();
+ int currLoc = 0;
+ while (iter.hasNext()) {
+ try {
+ TModel en =
+ ScoutJaxrUddiV3Helper.getTModelFromJAXRClassificationScheme((ClassificationScheme) iter.next());
+ entityarr[currLoc] = en;
+ currLoc++;
+ }
+ catch (ClassCastException ce) {
+ throw new UnexpectedObjectException();
+ }
+ }
+ log.debug("Method:save_classificationscheme: ENlength=" + entityarr.length);
+ // Save business
+ TModelDetail td = null;
+ try {
+ td = (TModelDetail) executeOperation(entityarr, "SAVE_TMODEL");
+ }
+ catch (RegistryV3Exception e) {
+ exceptions.add(new SaveException(e.getLocalizedMessage()));
+ bulk.setStatus(JAXRResponse.STATUS_FAILURE);
+ return bulk;
+ }
+
+ List<TModel> tmodelList = td.getTModel();
+ entityarr = new TModel[tmodelList.size()];
+ tmodelList.toArray(entityarr);
+ log.debug("After Saving TModel. Obtained vector size:" + entityarr != null ? entityarr.length : 0);
+ for (int i = 0; entityarr != null && i < entityarr.length; i++) {
+ TModel tm = (TModel) entityarr[i];
+ coll.add(new KeyImpl(tm.getTModelKey()));
+ }
+
+ bulk.setCollection(coll);
+ bulk.setExceptions(exceptions);
+
+ return bulk;
+ }
+
+ public BulkResponse saveConcepts(Collection concepts) throws JAXRException {
+ //Now we need to convert the collection into a vector for juddi
+ BulkResponseImpl bulk = new BulkResponseImpl();
+ TModel[] entityarr = new TModel[concepts.size()];
+
+ LinkedHashSet<Key> coll = new LinkedHashSet<Key>();
+ Collection<Exception> exceptions = new ArrayList<Exception>();
+
+ Iterator iter = concepts.iterator();
+ int currLoc = 0;
+ while (iter.hasNext()) {
+ try {
+ TModel en =
+ ScoutJaxrUddiV3Helper.getTModelFromJAXRConcept((Concept) iter.next());
+ entityarr[currLoc] = en;
+ currLoc++;
+ }
+ catch (ClassCastException ce) {
+ throw new UnexpectedObjectException();
+ }
+ }
+ log.debug("Method:save_concept: ENlength=" + entityarr.length);
+ // Save business
+ TModelDetail td = null;
+ try {
+ td = (TModelDetail) executeOperation(entityarr, "SAVE_TMODEL");
+ }
+ catch (RegistryV3Exception e) {
+ exceptions.add(new SaveException(e.getLocalizedMessage()));
+ bulk.setStatus(JAXRResponse.STATUS_FAILURE);
+ return bulk;
+ }
+
+ List<TModel> tmodelList = td.getTModel();
+ entityarr = new TModel[tmodelList.size()];
+ tmodelList.toArray(entityarr);
+
+ log.debug("After Saving TModel. Obtained vector size:" + entityarr != null ? entityarr.length : 0);
+ for (int i = 0; entityarr != null && i < entityarr.length; i++) {
+ TModel tm = (TModel) entityarr[i];
+ coll.add(new KeyImpl(tm.getTModelKey()));
+ }
+
+ bulk.setCollection(coll);
+ bulk.setExceptions(exceptions);
+
+ return bulk;
+ }
+
+ public BulkResponse saveOrganizations(Collection organizations) throws JAXRException {
+ //Now we need to convert the collection into a vector for juddi
+ BulkResponseImpl bulk = new BulkResponseImpl();
+ BusinessEntity[] entityarr = new BusinessEntity[organizations.size()];
+
+ LinkedHashSet<Key> coll = new LinkedHashSet<Key>();
+ Collection<Exception> exceptions = new ArrayList<Exception>();
+
+ Iterator iter = organizations.iterator();
+ int currLoc = 0;
+ while (iter.hasNext()) {
+ try {
+ BusinessEntity en =
+ ScoutJaxrUddiV3Helper.getBusinessEntityFromJAXROrg((Organization) iter.next());
+ entityarr[currLoc] = en;
+ currLoc++;
+ }
+ catch (ClassCastException ce) {
+ throw new UnexpectedObjectException();
+ }
+ }
+ log.debug("Method:save_business: ENlength=" + entityarr.length);
+ // Save business
+ BusinessDetail bd = null;
+ try {
+ bd = (BusinessDetail) executeOperation(entityarr, "SAVE_ORG");
+ }
+ catch (RegistryV3Exception e) {
+ exceptions.add(new SaveException(e.getLocalizedMessage()));
+ bulk.setStatus(JAXRResponse.STATUS_FAILURE);
+ return bulk;
+ }
+
+ List<BusinessEntity> bizEntityList = bd.getBusinessEntity();
+
+ entityarr = new BusinessEntity[bizEntityList.size()];
+ bizEntityList.toArray(entityarr);
+
+ log.debug("After Saving Business. Obtained vector size:" + entityarr != null ? entityarr.length : 0);
+ for (int i = 0; entityarr != null && i < entityarr.length; i++) {
+ BusinessEntity entity = (BusinessEntity) entityarr[i];
+ coll.add(new KeyImpl(entity.getBusinessKey()));
+ }
+
+ bulk.setCollection(coll);
+ bulk.setExceptions(exceptions);
+
+ return bulk;
+ }
+
+ public BulkResponse saveServiceBindings(Collection bindings) throws JAXRException {
+ BulkResponseImpl bulk = new BulkResponseImpl();
+ BindingTemplate[] sbarr = new BindingTemplate[bindings.size()];
+
+ LinkedHashSet<Key> coll = new LinkedHashSet<Key>();
+ Collection<Exception> exceptions = new ArrayList<Exception>();
+
+ Iterator iter = bindings.iterator();
+ int currLoc = 0;
+ while (iter.hasNext()) {
+ try {
+ BindingTemplate bs = ScoutJaxrUddiV3Helper.getBindingTemplateFromJAXRSB((ServiceBinding) iter.next());
+ sbarr[currLoc] = bs;
+ currLoc++;
+ }
+ catch (ClassCastException ce) {
+ throw new UnexpectedObjectException();
+ }
+ }
+ // Save ServiceBinding
+ BindingDetail bd = null;
+ try {
+ bd = (BindingDetail) executeOperation(sbarr, "SAVE_SERVICE_BINDING");
+ }
+ catch (RegistryV3Exception e) {
+ exceptions.add(new SaveException(e.getLocalizedMessage()));
+ bulk.setStatus(JAXRResponse.STATUS_FAILURE);
+ return bulk;
+ }
+
+ List<BindingTemplate> bindingTemplateList = bd.getBindingTemplate();
+ sbarr = new BindingTemplate[bindingTemplateList.size()];
+ bindingTemplateList.toArray(sbarr);
+
+ for (int i = 0; sbarr != null && i < sbarr.length; i++) {
+ BindingTemplate bt = (BindingTemplate) sbarr[i];
+ coll.add(new KeyImpl(bt.getBindingKey()));
+ }
+ if (coll.size()>0) {
+ bulk.setCollection(coll);
+ }
+ bulk.setExceptions(exceptions);
+
+ return bulk;
+ }
+
+ public BulkResponse saveServices(Collection services) throws JAXRException {
+ BulkResponseImpl bulk = new BulkResponseImpl();
+ BusinessService[] sarr = new BusinessService[services.size()];
+
+ LinkedHashSet<Key> coll = new LinkedHashSet<Key>();
+ Collection<Exception> exceptions = new ArrayList<Exception>();
+
+
+ Iterator iter = services.iterator();
+ int currLoc = 0;
+ while (iter.hasNext()) {
+ try {
+ BusinessService bs = ScoutJaxrUddiV3Helper.getBusinessServiceFromJAXRService((Service) iter.next());
+ sarr[currLoc] = bs;
+ currLoc++;
+ }
+ catch (ClassCastException ce) {
+ throw new UnexpectedObjectException();
+ }
+ }
+ // Save Service
+ ServiceDetail sd = null;
+ try {
+ sd = (ServiceDetail) executeOperation(sarr, "SAVE_SERVICE");
+ }
+ catch (RegistryV3Exception e) {
+ exceptions.add(new SaveException(e.getLocalizedMessage()));
+ bulk.setStatus(JAXRResponse.STATUS_FAILURE);
+ return bulk;
+ }
+
+ List<BusinessService> bizServiceList = sd.getBusinessService();
+ sarr = new BusinessService[bizServiceList.size()];
+ bizServiceList.toArray(sarr);
+
+ for (int i = 0; sarr != null && i < sarr.length; i++) {
+ BusinessService entity = (BusinessService) sarr[i];
+ coll.add(new KeyImpl(entity.getServiceKey()));
+ }
+ bulk.setCollection(coll);
+ bulk.setExceptions(exceptions);
+
+ return bulk;
+ }
+
+ public void confirmAssociation(Association assoc) throws JAXRException, InvalidRequestException {
+ //Store it in the UDDI registry
+ HashSet<Association> col = new HashSet<Association>();
+ col.add(assoc);
+ BulkResponse br = this.saveAssociations(col, true);
+ if(br.getExceptions()!= null)
+ throw new JAXRException("Confiming the Association Failed");
+ }
+
+ public void unConfirmAssociation(Association assoc) throws JAXRException, InvalidRequestException {
+ //TODO
+ //Delete it from the UDDI registry
+ Collection<Key> col = new ArrayList<Key>();
+ col.add(assoc.getKey());
+ BulkResponse br = this.deleteAssociations(col);
+ if(br.getExceptions()!= null)
+ throw new JAXRException("UnConfiming the Association Failed");
+ }
+
+ //Protected Methods
+ protected Object executeOperation(Object dataarray, String op)
+ throws RegistryV3Exception, JAXRException {
+ if (registry == null) {
+ throw new IllegalStateException("No registry");
+ }
+
+ IRegistryV3 ireg = (IRegistryV3) registry.getRegistry();
+
+ ConnectionImpl connection = registry.getConnection();
+ AuthToken token = getAuthToken(connection, ireg);
+ if (token == null) {
+ throw new IllegalStateException("No auth token returned");
+ }
+
+ Object regobj;
+ if(op.equalsIgnoreCase("SAVE_ASSOCIATION"))
+ {
+ regobj = ireg.setPublisherAssertions(token.getAuthInfo(), (PublisherAssertion[]) dataarray);
+ } else
+ if (op.equalsIgnoreCase("SAVE_SERVICE")) {
+ regobj = ireg.saveService(token.getAuthInfo(), (BusinessService[])dataarray);
+ }
+ else if (op.equalsIgnoreCase("SAVE_SERVICE_BINDING")) {
+ regobj = ireg.saveBinding(token.getAuthInfo(), (BindingTemplate[]) dataarray);
+ }
+ else if (op.equalsIgnoreCase("SAVE_ORG")) {
+ regobj = ireg.saveBusiness(token.getAuthInfo(), (BusinessEntity[]) dataarray);
+ }
+ else if (op.equalsIgnoreCase("SAVE_TMODEL")) {
+ regobj = ireg.saveTModel(token.getAuthInfo(), (TModel[]) dataarray);
+ }
+ else if (op.equalsIgnoreCase("DELETE_ORG")) {
+ clearPublisherAssertions(token.getAuthInfo(), ireg);
+ regobj = ireg.deleteBusiness(token.getAuthInfo(), (String[]) dataarray);
+ }
+ else if (op.equalsIgnoreCase("DELETE_SERVICE")) {
+ regobj = ireg.deleteService(token.getAuthInfo(), (String[]) dataarray);
+ }
+ else if (op.equalsIgnoreCase("DELETE_SERVICEBINDING")) {
+ regobj = ireg.deleteBinding(token.getAuthInfo(), (String[]) dataarray);
+ }
+ else if (op.equalsIgnoreCase("DELETE_CONCEPT")) {
+ regobj = ireg.deleteTModel(token.getAuthInfo(), (String[]) dataarray);
+ }
+ else if (op.equalsIgnoreCase("DELETE_ASSOCIATION")) {
+ int len = ((String[]) dataarray).length;
+ PublisherAssertion[] paarr = new PublisherAssertion[len];
+ for(int i=0;i<len;i++)
+ {
+ String keystr = ((String[])dataarray)[i];
+ paarr[i] = ScoutJaxrUddiV3Helper.getPubAssertionFromJAXRAssociationKey(keystr);
+ }
+ regobj = ireg.deletePublisherAssertions(token.getAuthInfo(), paarr);
+ }
+ else if (op.equalsIgnoreCase("DELETE_CLASSIFICATIONSCHEME")) {
+ regobj = ireg.deleteTModel(token.getAuthInfo(), (String[]) dataarray);
+ }
+ else {
+ throw new JAXRException("Unsupported operation:" + op);
+ }
+
+ return regobj;
+ }
+
+ private void clearPublisherAssertions( String authinfo,IRegistryV3 ireg)
+ {
+ Vector<PublisherAssertion> pasvect = null;
+ PublisherAssertion[] pasarr = null;
+ try
+ {
+ AssertionStatusReport report = ireg.getAssertionStatusReport(authinfo,"status:complete");
+ List<AssertionStatusItem> assertionStatusItemList = report.getAssertionStatusItem();
+ AssertionStatusItem[] assertionStatusItemArr =
+ new AssertionStatusItem[assertionStatusItemList.size()];
+
+ int len = assertionStatusItemArr != null? assertionStatusItemArr.length : 0;
+ for (int i = 0; i < len; i++)
+ {
+ AssertionStatusItem asi = assertionStatusItemArr[i];
+ /* String sourceKey = asi.getFromKey();
+ String targetKey = asi.getToKey();
+ PublisherAssertion pa = new PublisherAssertion();
+ pa.setFromKey(sourceKey);
+ pa.setToKey(targetKey);
+ KeyedReference keyr = asi.getKeyedReference();
+ pa.setKeyedReference(keyr);
+ pa.setTModelKey(keyr.getTModelKey());
+ pa.setKeyName(keyr.getKeyName());
+ pa.setKeyValue(keyr.getKeyValue());
+ if(pasvect == null) pasvect = new Vector(len);
+ pasvect.add(pa);*/
+ if(pasvect == null) pasvect = new Vector<PublisherAssertion>(len);
+ pasvect.add(this.getPublisherAssertion(asi));
+ }
+ report = ireg.getAssertionStatusReport(authinfo,"status:toKey_incomplete");
+ assertionStatusItemArr = report.getAssertionStatusItem().toArray(assertionStatusItemArr);
+
+ len = assertionStatusItemArr != null? assertionStatusItemArr.length : 0;
+ for (int i = 0; i < len; i++)
+ {
+ AssertionStatusItem asi = (AssertionStatusItem) assertionStatusItemArr[i];
+ if(pasvect == null) pasvect = new Vector<PublisherAssertion>(len);
+ pasvect.add(this.getPublisherAssertion(asi));
+ }
+
+ report = ireg.getAssertionStatusReport(authinfo,"status:fromKey_incomplete");
+ assertionStatusItemArr = report.getAssertionStatusItem().toArray(assertionStatusItemArr);
+
+ len = assertionStatusItemArr != null? assertionStatusItemArr.length : 0;
+ for (int i = 0; i < len; i++)
+ {
+ AssertionStatusItem asi = (AssertionStatusItem) assertionStatusItemArr[i];
+ if(pasvect == null) pasvect = new Vector<PublisherAssertion>(len);
+ pasvect.add(this.getPublisherAssertion(asi));
+ }
+
+ if (pasvect != null) {
+ pasarr = new PublisherAssertion[pasvect.size()];
+ Iterator iter = pasvect.iterator();
+ int pasarrPos = 0;
+ while (iter.hasNext()) {
+ pasarr[pasarrPos] = ((PublisherAssertion) iter.next());
+ pasarrPos++;
+ }
+ }
+ }
+ catch (RegistryV3Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+
+ if(pasarr != null && pasarr.length > 0)
+ try
+ {
+ ireg.deletePublisherAssertions(authinfo, pasarr);
+ }
+ catch (RegistryV3Exception e)
+ {
+ log.debug("Ignoring exception " + e.getMessage(),e);
+ }
+ }
+
+
+
+ protected BulkResponse deleteOperation(Collection<Key> keys, String op)
+ throws JAXRException {
+ if(keys == null)
+ throw new JAXRException("Keys provided to "+op+" are null");
+
+ //Now we need to convert the collection into a vector for juddi
+ BulkResponseImpl bulk = new BulkResponseImpl();
+ String[] keyarr = new String[keys.size()];
+ Result[] keyResultArr;
+
+ LinkedHashSet<Key> coll = new LinkedHashSet<Key>();
+ Collection<Exception> exceptions = new ArrayList<Exception>();
+
+ try {
+ Iterator iter = keys.iterator();
+ int currLoc = 0;
+ while (iter.hasNext()) {
+ Key key = (Key) iter.next();
+ keyarr[currLoc] = key.getId();
+ currLoc++;
+ }
+ // Save business
+ DispositionReport bd = (DispositionReport) executeOperation(keyarr, op);
+ List<Result> resultList = bd.getResult();
+ keyResultArr = new Result[resultList.size()];
+ resultList.toArray(keyResultArr);
+
+ log.debug("After deleting Business. Obtained vector size:" + keyResultArr != null ? keyResultArr.length : 0);
+ for (int i = 0; keyResultArr != null && i < keyResultArr.length; i++) {
+ Result result = (Result) keyResultArr[i];
+ int errno = result.getErrno();
+ if (errno == 0) {
+ coll.addAll(keys);
+ }
+ else {
+ ErrInfo errinfo = result.getErrInfo();
+ DeleteException de = new DeleteException(errinfo.getErrCode() + ":" + errinfo.getValue());
+ bulk.setStatus(JAXRResponse.STATUS_FAILURE);
+ exceptions.add(de);
+ }
+ }
+ }
+ catch (RegistryV3Exception regExcept) {
+
+ /*
+ * jUDDI (and prollie others) throw an exception on any fault in
+ * the transaction w/ the registry, so we don't get any partial
+ * success
+ */
+ DeleteException de = new DeleteException(regExcept.getFaultCode()
+ + ":" + regExcept.getFaultString(), regExcept);
+
+ bulk.setStatus(JAXRResponse.STATUS_FAILURE);
+ exceptions.add(de);
+ }
+ catch (JAXRException tran) {
+ exceptions.add(new JAXRException("Apache JAXR Impl:", tran));
+ bulk.setStatus(JAXRResponse.STATUS_FAILURE);
+ }
+
+ bulk.setCollection(coll);
+ bulk.setExceptions(exceptions);
+
+ return bulk;
+ }
+
+
+ /**
+ * Get the Auth Token from the registry
+ *
+ * @param connection
+ * @param ireg
+ * @return auth token
+ * @throws JAXRException
+ */
+ private AuthToken getAuthToken(ConnectionImpl connection, IRegistryV3 ireg)
+ throws JAXRException {
+ Set creds = connection.getCredentials();
+ String username = "", pwd = "";
+ if (creds != null) {
+ Iterator it = creds.iterator();
+ while (it.hasNext()) {
+ PasswordAuthentication pass = (PasswordAuthentication) it.next();
+ username = pass.getUserName();
+ pwd = new String(pass.getPassword());
+ }
+ }
+
+ AuthToken token = null;
+ try {
+ token = ireg.getAuthToken(username, pwd);
+ }
+ catch (Exception e)
+ {
+ throw new JAXRException(e);
+ }
+ return token;
+ }
+
+ private PublisherAssertion getPublisherAssertion(AssertionStatusItem asi)
+ {
+ PublisherAssertion pa = this.objectFactory.createPublisherAssertion();
+
+ if(asi != null)
+ {
+ String sourceKey = asi.getFromKey();
+ String targetKey = asi.getToKey();
+
+ if (sourceKey != null) {
+ pa.setFromKey(sourceKey);
+ }
+
+ if (targetKey != null) {
+ pa.setToKey(targetKey);
+ }
+
+ KeyedReference keyr = asi.getKeyedReference();
+
+ if (keyr != null) {
+ pa.setKeyedReference(keyr);
+ }
+ //pa.setTModelKey(keyr.getTModelKey());
+ //pa.setKeyName(keyr.getKeyName());
+ //pa.setKeyValue(keyr.getKeyValue()); // -CBC- These are redundant?
+
+ }return pa;
+ }
+
+ Organization createOrganization(BusinessDetail bizDetail) throws JAXRException {
+ return ScoutUddiV3JaxrHelper.getOrganization(bizDetail, this);
+ }
+
+ Organization createOrganization(BusinessInfo bizInfo) throws JAXRException {
+ String key = bizInfo.getBusinessKey();
+ List<Name> names = bizInfo.getName();
+
+ List<Description> descriptions = bizInfo.getDescription();
+ List<ServiceInfo> serviceInfos = bizInfo.getServiceInfos().getServiceInfo();
+
+ OrganizationImpl org = new OrganizationImpl(this);
+ org.setKey(createKey(key));
+ if (names != null && names.size() > 0) {
+ org.setName(createInternationalString(names.get(0).getValue()));
+ }
+ if (descriptions != null && descriptions.size() > 0) {
+ org.setDescription(createInternationalString(descriptions.get(0).getValue()));
+ }
+ if (serviceInfos != null && serviceInfos.size() > 0) {
+ List<Service> services = new ArrayList<Service>(serviceInfos.size());
+ for (int i = 0; i < serviceInfos.size(); i++) {
+ ServiceInfo serviceInfo = serviceInfos.get(i);
+ services.add(createService(serviceInfo));
+ }
+ org.addServices(services);
+ }
+
+ return org;
+ }
+
+ Service createService(ServiceInfo serviceInfo) throws JAXRException {
+ String key = serviceInfo.getServiceKey();
+ List<Name> names = serviceInfo.getName();
+ ServiceImpl service = new ServiceImpl(this);
+ service.setKey(createKey(key));
+ if (names != null && names.size() > 0) {
+ service.setName(createInternationalString(names.get(0).getValue()));
+ }
+ return service;
+ }
+
+}
diff --git a/src/main/java/org/apache/ws/scout/registry/BusinessQueryManagerImpl.java b/src/main/java/org/apache/ws/scout/registry/BusinessQueryManagerImpl.java
index c58f5f4..2711fba 100644
--- a/src/main/java/org/apache/ws/scout/registry/BusinessQueryManagerImpl.java
+++ b/src/main/java/org/apache/ws/scout/registry/BusinessQueryManagerImpl.java
@@ -126,7 +126,7 @@
Collection externalIdentifiers,
Collection externalLinks) throws JAXRException
{
- IRegistry registry = registryService.getRegistry();
+ IRegistry registry = (IRegistry) registryService.getRegistry();
try
{
FindQualifiers juddiFindQualifiers = mapFindQualifiers(findQualifiers);
@@ -148,8 +148,8 @@
for (BusinessInfo businessInfo : bizInfoList) {
//Now get the details on the individual biz
BusinessDetail detail = registry.getBusinessDetail(businessInfo.getBusinessKey());
- orgs.add(registryService.getLifeCycleManagerImpl().createOrganization(detail));
- }
+ orgs.add(((BusinessLifeCycleManagerImpl)registryService.getLifeCycleManagerImpl()).createOrganization(detail));
+ }
bizInfoArr = new BusinessInfo[bizInfoList.size()];
bizInfoList.toArray(bizInfoArr);
}
@@ -166,7 +166,7 @@
Collection associationTypes) throws JAXRException
{
//TODO: Currently we just return all the Association objects owned by the caller
- IRegistry registry = registryService.getRegistry();
+ IRegistry registry = (IRegistry) registryService.getRegistry();
try
{
ConnectionImpl con = ((RegistryServiceImpl)getRegistryService()).getConnection();
@@ -205,7 +205,7 @@
Collection associationTypes) throws JAXRException
{
//TODO: Currently we just return all the Association objects owned by the caller
- IRegistry registry = registryService.getRegistry();
+ IRegistry registry = (IRegistry) registryService.getRegistry();
try
{
ConnectionImpl con = ((RegistryServiceImpl)getRegistryService()).getConnection();
@@ -423,7 +423,7 @@
else {
//Lets ask the uddi registry if it has the TModels
- IRegistry registry = registryService.getRegistry();
+ IRegistry registry = (IRegistry) registryService.getRegistry();
FindQualifiers juddiFindQualifiers = mapFindQualifiers(findQualifiers);
try
{
@@ -513,7 +513,7 @@
LinkedHashSet<Concept> col = new LinkedHashSet<Concept>();
//Lets ask the uddi registry if it has the TModels
- IRegistry registry = registryService.getRegistry();
+ IRegistry registry = (IRegistry) registryService.getRegistry();
FindQualifiers juddiFindQualifiers = mapFindQualifiers(findQualifiers);
Iterator iter = null;
if (namePatterns != null) iter = namePatterns.iterator();
@@ -558,7 +558,7 @@
{
BulkResponseImpl blkRes = new BulkResponseImpl();
- IRegistry iRegistry = registryService.getRegistry();
+ IRegistry iRegistry = (IRegistry) registryService.getRegistry();
FindQualifiers juddiFindQualifiers = mapFindQualifiers(findQualifiers);
try
@@ -623,7 +623,7 @@
{
BulkResponseImpl blkRes = new BulkResponseImpl();
- IRegistry iRegistry = registryService.getRegistry();
+ IRegistry iRegistry = (IRegistry) registryService.getRegistry();
FindQualifiers juddiFindQualifiers = mapFindQualifiers(findQualifiers);
Name[] juddiNames = mapNamePatterns(namePatterns);
@@ -677,7 +677,7 @@
public RegistryObject getRegistryObject(String id, String objectType) throws JAXRException
{
- IRegistry registry = registryService.getRegistry();
+ IRegistry registry = (IRegistry) registryService.getRegistry();
BusinessLifeCycleManager lcm = registryService.getBusinessLifeCycleManager();
if (LifeCycleManager.CLASSIFICATION_SCHEME.equalsIgnoreCase(objectType)) {
@@ -803,7 +803,7 @@
public BulkResponse getRegistryObjects(Collection objectKeys, String objectType) throws JAXRException
{
- IRegistry registry = registryService.getRegistry();
+ IRegistry registry = (IRegistry) registryService.getRegistry();
//Convert into a vector of strings
String[] keys = new String[objectKeys.size()];
int currLoc = 0;
@@ -845,7 +845,7 @@
List<BusinessInfo> bizInfoList = infos.getBusinessInfo();
for (BusinessInfo businessInfo: bizInfoList) {
BusinessDetail detail = registry.getBusinessDetail(businessInfo.getBusinessKey());
- col.add(registryService.getLifeCycleManagerImpl().createOrganization(detail));
+ col.add(((BusinessLifeCycleManagerImpl)registryService.getLifeCycleManagerImpl()).createOrganization(detail));
}
}
}
@@ -902,7 +902,7 @@
public BulkResponse getRegistryObjects(String id) throws JAXRException
{
if (LifeCycleManager.ORGANIZATION.equalsIgnoreCase(id)) {
- IRegistry registry = registryService.getRegistry();
+ IRegistry registry = (IRegistry) registryService.getRegistry();
ConnectionImpl con = ((RegistryServiceImpl)getRegistryService()).getConnection();
AuthToken auth = this.getAuthToken(con,registry);
LinkedHashSet<Organization> orgs = null;
@@ -914,7 +914,7 @@
orgs = new LinkedHashSet<Organization>();
for (BusinessInfo businessInfo : bizInfoList) {
BusinessDetail detail = registry.getBusinessDetail(businessInfo.getBusinessKey());
- orgs.add(registryService.getLifeCycleManagerImpl().createOrganization(detail));
+ orgs.add(((BusinessLifeCycleManagerImpl)registryService.getLifeCycleManagerImpl()).createOrganization(detail));
}
}
diff --git a/src/main/java/org/apache/ws/scout/registry/BusinessQueryManagerV3Impl.java b/src/main/java/org/apache/ws/scout/registry/BusinessQueryManagerV3Impl.java
new file mode 100644
index 0000000..5344928
--- /dev/null
+++ b/src/main/java/org/apache/ws/scout/registry/BusinessQueryManagerV3Impl.java
@@ -0,0 +1,989 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ws.scout.registry;
+
+import java.net.PasswordAuthentication;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.registry.BulkResponse;
+import javax.xml.registry.BusinessLifeCycleManager;
+import javax.xml.registry.BusinessQueryManager;
+import javax.xml.registry.InvalidRequestException;
+import javax.xml.registry.JAXRException;
+import javax.xml.registry.LifeCycleManager;
+import javax.xml.registry.RegistryService;
+import javax.xml.registry.UnsupportedCapabilityException;
+import javax.xml.registry.infomodel.Association;
+import javax.xml.registry.infomodel.ClassificationScheme;
+import javax.xml.registry.infomodel.Concept;
+import javax.xml.registry.infomodel.Key;
+import javax.xml.registry.infomodel.LocalizedString;
+import javax.xml.registry.infomodel.Organization;
+import javax.xml.registry.infomodel.RegistryObject;
+import javax.xml.registry.infomodel.Service;
+import javax.xml.registry.infomodel.ServiceBinding;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.uddi.api_v3.*;
+import org.apache.ws.scout.registry.infomodel.AssociationImpl;
+import org.apache.ws.scout.registry.infomodel.ClassificationSchemeImpl;
+import org.apache.ws.scout.registry.infomodel.ConceptImpl;
+import org.apache.ws.scout.registry.infomodel.InternationalStringImpl;
+import org.apache.ws.scout.registry.infomodel.KeyImpl;
+import org.apache.ws.scout.registry.infomodel.ServiceBindingImpl;
+import org.apache.ws.scout.registry.infomodel.ServiceImpl;
+import org.apache.ws.scout.util.EnumerationHelper;
+import org.apache.ws.scout.util.ScoutJaxrUddiV3Helper;
+import org.apache.ws.scout.util.ScoutUddiV3JaxrHelper;
+
+/**
+ * Implements the JAXR BusinessQueryManager Interface
+ * For futher details, look into the JAXR API Javadoc.
+ *
+ * @author <a href="mailto:tcunning@apache.org">Tom Cunningham</a>
+ * @author <a href="mailto:anil@apache.org">Anil Saldhana</a>
+ * @author <a href="mailto:jboynes@apache.org">Jeremy Boynes</a>
+ * @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
+ */
+public class BusinessQueryManagerV3Impl implements BusinessQueryManager
+{
+ private final RegistryServiceImpl registryService;
+ private Log log = LogFactory.getLog(this.getClass());
+
+ private static ObjectFactory objectFactory = new ObjectFactory();
+
+ public BusinessQueryManagerV3Impl(RegistryServiceImpl registry)
+ {
+ this.registryService = registry;
+ }
+
+ public RegistryService getRegistryService()
+ {
+ return registryService;
+ }
+
+ /**
+ * Finds organizations in the registry that match the specified parameters
+ *
+ * @param findQualifiers
+ * @param namePatterns
+ * @param classifications
+ * @param specifications
+ * @param externalIdentifiers
+ * @param externalLinks
+ * @return BulkResponse
+ * @throws JAXRException
+ */
+ public BulkResponse findOrganizations(Collection findQualifiers,
+ Collection namePatterns,
+ Collection classifications,
+ Collection specifications,
+ Collection externalIdentifiers,
+ Collection externalLinks) throws JAXRException
+ {
+ IRegistryV3 registry = (IRegistryV3) registryService.getRegistry();
+ try
+ {
+ FindQualifiers juddiFindQualifiers = mapFindQualifiers(findQualifiers);
+ Name[] nameArray = mapNamePatterns(namePatterns);
+ BusinessList result = registry.findBusiness(nameArray,
+ null,
+ ScoutJaxrUddiV3Helper.getIdentifierBagFromExternalIdentifiers(externalIdentifiers),
+ ScoutJaxrUddiV3Helper.getCategoryBagFromClassifications(classifications),
+ ScoutJaxrUddiV3Helper.getTModelBagFromSpecifications(specifications),
+ juddiFindQualifiers,
+ registryService.getMaxRows());
+
+ BusinessInfo[] bizInfoArr =null;
+ BusinessInfos bizInfos = result.getBusinessInfos();
+ LinkedHashSet<Organization> orgs = new LinkedHashSet<Organization>();
+ if(bizInfos != null)
+ {
+ List<BusinessInfo> bizInfoList = bizInfos.getBusinessInfo();
+ for (BusinessInfo businessInfo : bizInfoList) {
+ //Now get the details on the individual biz
+ BusinessDetail detail = registry.getBusinessDetail(businessInfo.getBusinessKey());
+ BusinessLifeCycleManagerV3Impl blcm = (BusinessLifeCycleManagerV3Impl)registryService.getLifeCycleManagerImpl();
+ orgs.add(blcm.createOrganization(detail));
+ }
+ bizInfoArr = new BusinessInfo[bizInfoList.size()];
+ bizInfoList.toArray(bizInfoArr);
+ }
+ return new BulkResponseImpl(orgs);
+ } catch (RegistryV3Exception e)
+ {
+ throw new JAXRException(e);
+ }
+ }
+
+ public BulkResponse findAssociations(Collection findQualifiers,
+ String sourceObjectId,
+ String targetObjectId,
+ Collection associationTypes) throws JAXRException
+ {
+ //TODO: Currently we just return all the Association objects owned by the caller
+ IRegistryV3 registry = (IRegistryV3) registryService.getRegistry();
+ try
+ {
+ ConnectionImpl con = ((RegistryServiceImpl)getRegistryService()).getConnection();
+ AuthToken auth = this.getAuthToken(con,registry);
+ PublisherAssertions result =
+ registry.getPublisherAssertions(auth.getAuthInfo());
+ List<PublisherAssertion> publisherAssertionList = result.getPublisherAssertion();
+ LinkedHashSet<Association> col = new LinkedHashSet<Association>();
+ for (PublisherAssertion pas : publisherAssertionList) {
+ String sourceKey = pas.getFromKey();
+ String targetKey = pas.getToKey();
+ Collection<Key> orgcol = new ArrayList<Key>();
+ orgcol.add(new KeyImpl(sourceKey));
+ orgcol.add(new KeyImpl(targetKey));
+ BulkResponse bl = getRegistryObjects(orgcol, LifeCycleManager.ORGANIZATION);
+ Association asso = ScoutUddiV3JaxrHelper.getAssociation(bl.getCollection(),
+ registryService.getBusinessLifeCycleManager());
+ KeyedReference keyr = pas.getKeyedReference();
+ Concept c = new ConceptImpl(getRegistryService().getBusinessLifeCycleManager());
+ c.setName(new InternationalStringImpl(keyr.getKeyName()));
+ c.setKey( new KeyImpl(keyr.getTModelKey()) );
+ c.setValue(keyr.getKeyValue());
+ asso.setAssociationType(c);
+ col.add(asso);
+ }
+ return new BulkResponseImpl(col);
+ } catch (RegistryV3Exception e)
+ {
+ throw new JAXRException(e);
+ }
+ }
+
+ public BulkResponse findCallerAssociations(Collection findQualifiers,
+ Boolean confirmedByCaller,
+ Boolean confirmedByOtherParty,
+ Collection associationTypes) throws JAXRException
+ {
+ //TODO: Currently we just return all the Association objects owned by the caller
+ IRegistryV3 registry = (IRegistryV3) registryService.getRegistry();
+ try
+ {
+ ConnectionImpl con = ((RegistryServiceImpl)getRegistryService()).getConnection();
+ AuthToken auth = this.getAuthToken(con,registry);
+
+ AssertionStatusReport report = null;
+ String confirm = "";
+ boolean caller = confirmedByCaller.booleanValue();
+ boolean other = confirmedByOtherParty.booleanValue();
+
+ if(caller && other )
+ confirm = Constants.COMPLETION_STATUS_COMPLETE;
+ else
+ if(!caller && other )
+ confirm = Constants.COMPLETION_STATUS_FROMKEY_INCOMPLETE;
+ else
+ if(caller && !other )
+ confirm = Constants.COMPLETION_STATUS_TOKEY_INCOMPLETE;
+
+ report = registry.getAssertionStatusReport(auth.getAuthInfo(),confirm);
+
+
+ List<AssertionStatusItem> assertionStatusItemList = report.getAssertionStatusItem();
+ LinkedHashSet<Association> col = new LinkedHashSet<Association>();
+ for (AssertionStatusItem asi : assertionStatusItemList) {
+ String sourceKey = asi.getFromKey();
+ String targetKey = asi.getToKey();
+ Collection<Key> orgcol = new ArrayList<Key>();
+ orgcol.add(new KeyImpl(sourceKey));
+ orgcol.add(new KeyImpl(targetKey));
+ BulkResponse bl = getRegistryObjects(orgcol, LifeCycleManager.ORGANIZATION);
+ Association asso = ScoutUddiV3JaxrHelper.getAssociation(bl.getCollection(),
+ registryService.getBusinessLifeCycleManager());
+ //Set Confirmation
+ ((AssociationImpl)asso).setConfirmedBySourceOwner(caller);
+ ((AssociationImpl)asso).setConfirmedByTargetOwner(other);
+
+ if(confirm != Constants.COMPLETION_STATUS_COMPLETE)
+ ((AssociationImpl)asso).setConfirmed(false);
+
+ Concept c = new ConceptImpl(getRegistryService().getBusinessLifeCycleManager());
+ KeyedReference keyr = asi.getKeyedReference();
+ c.setKey(new KeyImpl(keyr.getTModelKey()));
+ c.setName(new InternationalStringImpl(keyr.getKeyName()));
+ c.setValue(keyr.getKeyValue());
+ asso.setKey(new KeyImpl(keyr.getTModelKey())); //TODO:Validate this
+ asso.setAssociationType(c);
+ col.add(asso);
+ }
+
+
+ return new BulkResponseImpl(col);
+ } catch (RegistryV3Exception e)
+ {
+ throw new JAXRException(e);
+ }
+ }
+
+ /**
+ * TODO - need to support the qualifiers
+ *
+ * @param findQualifiers
+ * @param namePatterns
+ * @return ClassificationScheme
+ * @throws JAXRException
+ */
+ public ClassificationScheme findClassificationSchemeByName(Collection findQualifiers,
+ String namePatterns) throws JAXRException
+ {
+ ClassificationScheme scheme = null;
+
+ if (namePatterns.indexOf("uddi-org:types") != -1) {
+
+ scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
+ scheme.setName(new InternationalStringImpl(namePatterns));
+ scheme.setKey(new KeyImpl(Constants.TMODEL_TYPES_TMODEL_KEY));
+ }
+ else if (namePatterns.indexOf("dnb-com:D-U-N-S") != -1) {
+
+ scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
+ scheme.setName(new InternationalStringImpl(namePatterns));
+ scheme.setKey(new KeyImpl(Constants.TMODEL_D_U_N_S_TMODEL_KEY));
+ }
+ else if (namePatterns.indexOf("uddi-org:iso-ch:3166:1999") != -1)
+ {
+ scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
+ scheme.setName(new InternationalStringImpl(namePatterns));
+ scheme.setKey(new KeyImpl(Constants.TMODEL_ISO_CH_TMODEL_KEY));
+ }
+ else if (namePatterns.indexOf("uddi-org:iso-ch:3166-1999") != -1)
+ {
+ scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
+ scheme.setName(new InternationalStringImpl(namePatterns));
+ scheme.setKey(new KeyImpl(Constants.TMODEL_ISO_CH_TMODEL_KEY));
+ }
+ else if (namePatterns.indexOf("iso-ch:3166:1999") != -1)
+ {
+ scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
+ scheme.setName(new InternationalStringImpl(namePatterns));
+ scheme.setKey(new KeyImpl(Constants.TMODEL_ISO_CH_TMODEL_KEY));
+ }
+ else if (namePatterns.indexOf("iso-ch:3166-1999") != -1)
+ {
+ scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
+ scheme.setName(new InternationalStringImpl(namePatterns));
+ scheme.setKey(new KeyImpl(Constants.TMODEL_ISO_CH_TMODEL_KEY));
+ }
+ else if (namePatterns.indexOf("unspsc-org:unspsc") != -1) {
+
+ scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
+ scheme.setName(new InternationalStringImpl(namePatterns));
+ scheme.setKey(new KeyImpl(Constants.TMODEL_UNSPSC_TMODEL_KEY));
+ }
+ else if (namePatterns.indexOf("ntis-gov:naics") != -1) {
+
+ scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
+ scheme.setName(new InternationalStringImpl(namePatterns));
+ scheme.setKey(new KeyImpl(Constants.TMODEL_NAICS_TMODEL_KEY));
+ }
+ else
+ { //TODO:Before going to the registry, check if it a predefined Enumeration
+
+ /*
+ * predefined Enumerations
+ */
+
+ if ("AssociationType".equals(namePatterns)) {
+ scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
+
+ scheme.setName(new InternationalStringImpl(namePatterns));
+
+ scheme.setKey(new KeyImpl(Constants.TMODEL_UNSPSC_TMODEL_KEY));
+
+ addChildConcept((ClassificationSchemeImpl)scheme, "RelatedTo");
+ addChildConcept((ClassificationSchemeImpl)scheme, "HasChild");
+ addChildConcept((ClassificationSchemeImpl)scheme, "HasMember");
+ addChildConcept((ClassificationSchemeImpl)scheme, "HasParent");
+ addChildConcept((ClassificationSchemeImpl)scheme, "ExternallyLinks");
+ addChildConcept((ClassificationSchemeImpl)scheme, "Contains");
+ addChildConcept((ClassificationSchemeImpl)scheme, "EquivalentTo");
+ addChildConcept((ClassificationSchemeImpl)scheme, "Extends");
+ addChildConcept((ClassificationSchemeImpl)scheme, "Implements");
+ addChildConcept((ClassificationSchemeImpl)scheme, "InstanceOf");
+ addChildConcept((ClassificationSchemeImpl)scheme, "Supersedes");
+ addChildConcept((ClassificationSchemeImpl)scheme, "Uses");
+ addChildConcept((ClassificationSchemeImpl)scheme, "Replaces");
+ addChildConcept((ClassificationSchemeImpl)scheme, "ResponsibleFor");
+ addChildConcept((ClassificationSchemeImpl)scheme, "SubmitterOf");
+ }
+ else if ("ObjectType".equals(namePatterns)) {
+ scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
+
+ scheme.setName(new InternationalStringImpl(namePatterns));
+
+ scheme.setKey(new KeyImpl(Constants.TMODEL_UNSPSC_TMODEL_KEY));
+
+ addChildConcept((ClassificationSchemeImpl)scheme, "CPP");
+ addChildConcept((ClassificationSchemeImpl)scheme, "CPA");
+ addChildConcept((ClassificationSchemeImpl)scheme, "Process");
+ addChildConcept((ClassificationSchemeImpl)scheme, "WSDL");
+ addChildConcept((ClassificationSchemeImpl)scheme, "Association");
+ addChildConcept((ClassificationSchemeImpl)scheme, "AuditableEvent");
+ addChildConcept((ClassificationSchemeImpl)scheme, "Classification");
+ addChildConcept((ClassificationSchemeImpl)scheme, "Concept");
+ addChildConcept((ClassificationSchemeImpl)scheme, "ExternalIdentifier");
+ addChildConcept((ClassificationSchemeImpl)scheme, "ExternalLink");
+ addChildConcept((ClassificationSchemeImpl)scheme, "ExtrinsicObject");
+ addChildConcept((ClassificationSchemeImpl)scheme, "Organization");
+ addChildConcept((ClassificationSchemeImpl)scheme, "Package");
+ addChildConcept((ClassificationSchemeImpl)scheme, "Service");
+ addChildConcept((ClassificationSchemeImpl)scheme, "ServiceBinding");
+ addChildConcept((ClassificationSchemeImpl)scheme, "User");
+ }
+ else if ("PhoneType".equals(namePatterns)) {
+ scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
+
+ scheme.setName(new InternationalStringImpl(namePatterns));
+
+ scheme.setKey(new KeyImpl(Constants.TMODEL_UNSPSC_TMODEL_KEY));
+
+ addChildConcept((ClassificationSchemeImpl)scheme, "OfficePhone");
+ addChildConcept((ClassificationSchemeImpl)scheme, "HomePhone");
+ addChildConcept((ClassificationSchemeImpl)scheme, "MobilePhone");
+ addChildConcept((ClassificationSchemeImpl)scheme, "Beeper");
+ addChildConcept((ClassificationSchemeImpl)scheme, "FAX");
+ }
+ else if ("URLType".equals(namePatterns)) {
+ scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
+
+ scheme.setName(new InternationalStringImpl(namePatterns));
+
+ scheme.setKey(new KeyImpl(Constants.TMODEL_UNSPSC_TMODEL_KEY));
+
+ addChildConcept((ClassificationSchemeImpl)scheme, "HTTP");
+ addChildConcept((ClassificationSchemeImpl)scheme, "HTTPS");
+ addChildConcept((ClassificationSchemeImpl)scheme, "SMTP");
+ addChildConcept((ClassificationSchemeImpl)scheme, "PHONE");
+ addChildConcept((ClassificationSchemeImpl)scheme, "FAX");
+ addChildConcept((ClassificationSchemeImpl)scheme, "OTHER");
+ }
+ else if ("PostalAddressAttributes".equals(namePatterns)) {
+ scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
+
+ scheme.setName(new InternationalStringImpl(namePatterns));
+
+ scheme.setKey(new KeyImpl(Constants.TMODEL_UNSPSC_TMODEL_KEY));
+
+ addChildConcept((ClassificationSchemeImpl)scheme, "StreetNumber");
+ addChildConcept((ClassificationSchemeImpl)scheme, "Street");
+ addChildConcept((ClassificationSchemeImpl)scheme, "City");
+ addChildConcept((ClassificationSchemeImpl)scheme, "State");
+ addChildConcept((ClassificationSchemeImpl)scheme, "PostalCode");
+ addChildConcept((ClassificationSchemeImpl)scheme, "Country");
+ }
+ else {
+
+ //Lets ask the uddi registry if it has the TModels
+ IRegistryV3 registry = (IRegistryV3) registryService.getRegistry();
+ FindQualifiers juddiFindQualifiers = mapFindQualifiers(findQualifiers);
+ try
+ {
+ //We are looking for one exact match, so getting upto 3 records is fine
+ TModelList list = registry.findTModel(namePatterns, null, null, juddiFindQualifiers, 3);
+ if (list != null) {
+ TModelInfos infos = list.getTModelInfos();
+ if (infos != null) {
+ List<TModelInfo> tmodelInfoList = infos.getTModelInfo();
+ if (tmodelInfoList.size() > 1) {
+ throw new InvalidRequestException("Multiple matches found:" + tmodelInfoList.size());
+ }
+ if (tmodelInfoList.size() ==1) {
+ TModelInfo info = tmodelInfoList.get(0);
+ scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
+ scheme.setName(new InternationalStringImpl(info.getName().getValue()));
+ scheme.setKey(new KeyImpl(info.getTModelKey()));
+ }
+ }
+ }
+
+ } catch (RegistryV3Exception e)
+ {
+ throw new JAXRException(e.getLocalizedMessage());
+ }
+ }
+ }
+ return scheme;
+ }
+
+ /**
+ * Creates a new Concept, associates w/ parent scheme, and then
+ * adds as decendent.
+ * @param scheme
+ * @param name
+ * @throws JAXRException
+ */
+ private void addChildConcept(ClassificationSchemeImpl scheme, String name)
+ throws JAXRException {
+ Concept c = new ConceptImpl(registryService.getLifeCycleManagerImpl());
+
+ c.setName(new InternationalStringImpl(name));
+ c.setValue(name);
+ ((ConceptImpl)c).setScheme((ClassificationSchemeImpl)scheme);
+
+ scheme.addChildConcept(c);
+ }
+
+ public BulkResponse findClassificationSchemes(Collection findQualifiers,
+ Collection namePatterns,
+ Collection classifications,
+ Collection externalLinks) throws JAXRException
+ {
+ //TODO: Handle this better
+ LinkedHashSet<ClassificationScheme> col = new LinkedHashSet<ClassificationScheme>();
+ Iterator iter = namePatterns.iterator();
+ String name = "";
+ while(iter.hasNext())
+ {
+ name = (String)iter.next();
+ break;
+ }
+
+ ClassificationScheme classificationScheme = findClassificationSchemeByName(findQualifiers,name);
+ if (classificationScheme!=null) {
+ col.add(classificationScheme);
+ }
+ return new BulkResponseImpl(col);
+ }
+
+ public Concept findConceptByPath(String path) throws JAXRException
+ {
+ //We will store the enumerations datastructure in the util package
+ /**
+ * I am not clear about how this association type enumerations
+ * are to be implemented.
+ */
+ return EnumerationHelper.getConceptByPath(path);
+ }
+
+ public BulkResponse findConcepts(Collection findQualifiers,
+ Collection namePatterns,
+ Collection classifications,
+ Collection externalIdentifiers,
+ Collection externalLinks) throws JAXRException
+ {
+ LinkedHashSet<Concept> col = new LinkedHashSet<Concept>();
+
+ //Lets ask the uddi registry if it has the TModels
+ IRegistryV3 registry = (IRegistryV3) registryService.getRegistry();
+ FindQualifiers juddiFindQualifiers = mapFindQualifiers(findQualifiers);
+ Iterator iter = null;
+ if (namePatterns != null) iter = namePatterns.iterator();
+ while (iter.hasNext())
+ {
+ String namestr = (String) iter.next();
+ try
+ {
+ TModelList list = registry.findTModel(namestr,
+ ScoutJaxrUddiV3Helper.getCategoryBagFromClassifications(classifications),
+ ScoutJaxrUddiV3Helper.getIdentifierBagFromExternalIdentifiers(externalIdentifiers),
+ juddiFindQualifiers, 10);
+
+ if (list != null && list.getTModelInfos()!=null) {
+ List<TModelInfo> tmodelInfoList = list.getTModelInfos().getTModelInfo();
+ if (tmodelInfoList!=null) {
+ for (TModelInfo info: tmodelInfoList) {
+ col.add(ScoutUddiV3JaxrHelper.getConcept(info, this.registryService.getBusinessLifeCycleManager()));
+ }
+ }
+ }
+ } catch (RegistryV3Exception e) {
+ throw new JAXRException(e.getLocalizedMessage());
+ }
+ }
+
+ return new BulkResponseImpl(col);
+ }
+
+ public BulkResponse findRegistryPackages(Collection findQualifiers,
+ Collection namePatterns,
+ Collection classifications,
+ Collection externalLinks) throws JAXRException
+ {
+ throw new UnsupportedCapabilityException();
+ }
+
+ public BulkResponse findServiceBindings(Key serviceKey,
+ Collection findQualifiers,
+ Collection classifications,
+ Collection specifications) throws JAXRException
+ {
+ BulkResponseImpl blkRes = new BulkResponseImpl();
+
+ IRegistryV3 iRegistry = (IRegistryV3) registryService.getRegistry();
+ FindQualifiers juddiFindQualifiers = mapFindQualifiers(findQualifiers);
+
+ try
+ {
+
+ BindingDetail bindingDetail = iRegistry.findBinding(serviceKey.getId(),
+ ScoutJaxrUddiV3Helper.getCategoryBagFromClassifications(classifications),
+ ScoutJaxrUddiV3Helper.getTModelBagFromSpecifications(specifications),
+ juddiFindQualifiers,registryService.getMaxRows());
+
+ /*
+ * now convert from jUDDI ServiceInfo objects to JAXR Services
+ */
+ if (bindingDetail != null) {
+
+ List<BindingTemplate> bindingTemplateList = bindingDetail.getBindingTemplate();
+ BindingTemplate[] bindarr = new BindingTemplate[bindingTemplateList.size()];
+ bindingTemplateList.toArray(bindarr);
+
+ LinkedHashSet<ServiceBinding> col = new LinkedHashSet<ServiceBinding>();
+
+ for (int i=0; bindarr != null && i < bindarr.length; i++) {
+ BindingTemplate si = bindarr[i];
+ ServiceBinding sb = ScoutUddiV3JaxrHelper.getServiceBinding(si,
+ registryService.getBusinessLifeCycleManager());
+ col.add(sb);
+ //Fill the Service object by making a call to registry
+ Service s = (Service)getRegistryObject(serviceKey.getId(), LifeCycleManager.SERVICE);
+ ((ServiceBindingImpl)sb).setService(s);
+ }
+
+ blkRes.setCollection(col);
+ }
+ }
+ catch (RegistryV3Exception e) {
+ throw new JAXRException(e.getLocalizedMessage());
+ }
+
+ return blkRes;
+ }
+
+
+ /**
+ * Finds all Service objects that match all of the criteria specified by
+ * the parameters of this call. This is a logical AND operation between
+ * all non-null parameters
+ *
+ * TODO - support findQualifiers, classifications and specifications
+ *
+ * @param orgKey
+ * @param findQualifiers
+ * @param namePatterns
+ * @param classifications
+ * @param specificationa
+ * @return BulkResponse
+ * @throws JAXRException
+ */
+ public BulkResponse findServices(Key orgKey, Collection findQualifiers,
+ Collection namePatterns,
+ Collection classifications,
+ Collection specificationa) throws JAXRException
+ {
+ BulkResponseImpl blkRes = new BulkResponseImpl();
+
+ IRegistryV3 iRegistry = (IRegistryV3) registryService.getRegistry();
+ FindQualifiers juddiFindQualifiers = mapFindQualifiers(findQualifiers);
+ Name[] juddiNames = mapNamePatterns(namePatterns);
+
+ try
+ {
+ /*
+ * hit the registry. The key is not required for UDDI2
+ */
+
+ String id = null;
+
+ if (orgKey != null) {
+ id = orgKey.getId();
+ }
+
+ ServiceList serviceList = iRegistry.findService(id,
+ juddiNames,
+ ScoutJaxrUddiV3Helper.getCategoryBagFromClassifications(classifications),
+ null,
+ juddiFindQualifiers, registryService.getMaxRows());
+
+ /*
+ * now convert from jUDDI ServiceInfo objects to JAXR Services
+ */
+ if (serviceList != null) {
+
+ ServiceInfos serviceInfos = serviceList.getServiceInfos();
+ LinkedHashSet<Service> col = new LinkedHashSet<Service>();
+
+ if(serviceInfos != null && serviceInfos.getServiceInfo()!=null) {
+ for (ServiceInfo si : serviceInfos.getServiceInfo()) {
+ Service srv = (Service) getRegistryObject(si.getServiceKey(), LifeCycleManager.SERVICE);
+ col.add(srv);
+ }
+
+ }
+ blkRes.setCollection(col);
+ }
+ }
+ catch (RegistryV3Exception e) {
+ throw new JAXRException(e.getLocalizedMessage());
+ }
+
+ return blkRes;
+ }
+
+ public RegistryObject getRegistryObject(String id) throws JAXRException
+ {
+ throw new UnsupportedCapabilityException();
+ }
+
+ public RegistryObject getRegistryObject(String id, String objectType) throws JAXRException
+ {
+ IRegistryV3 registry = (IRegistryV3) registryService.getRegistry();
+ BusinessLifeCycleManager lcm = registryService.getBusinessLifeCycleManager();
+
+ if (LifeCycleManager.CLASSIFICATION_SCHEME.equalsIgnoreCase(objectType)) {
+
+ try {
+
+ TModelDetail tmodeldetail = registry.getTModelDetail(id);
+ Concept c = ScoutUddiV3JaxrHelper.getConcept(tmodeldetail, lcm);
+
+ /*
+ * now turn into a concrete ClassificationScheme
+ */
+
+ ClassificationScheme scheme = new ClassificationSchemeImpl(lcm);
+
+ scheme.setName(c.getName());
+ scheme.setDescription(c.getDescription());
+ scheme.setKey(c.getKey());
+
+ return scheme;
+ }
+ catch (RegistryV3Exception e) {
+ throw new JAXRException(e.getLocalizedMessage());
+ }
+ }
+ else if (LifeCycleManager.ORGANIZATION.equalsIgnoreCase(objectType)) {
+ try
+ {
+ BusinessDetail orgdetail = registry.getBusinessDetail(id);
+ return ScoutUddiV3JaxrHelper.getOrganization(orgdetail, lcm);
+ }
+ catch (RegistryV3Exception e) {
+ throw new JAXRException(e.getLocalizedMessage());
+ }
+
+ }
+ else if (LifeCycleManager.CONCEPT.equalsIgnoreCase(objectType)) {
+
+ try
+ {
+ TModelDetail tmodeldetail = registry.getTModelDetail(id);
+ return ScoutUddiV3JaxrHelper.getConcept(tmodeldetail, lcm);
+ }
+ catch (RegistryV3Exception e) {
+ throw new JAXRException(e.getLocalizedMessage());
+ }
+ }
+ else if (LifeCycleManager.SERVICE.equalsIgnoreCase(objectType)) {
+
+ try {
+ ServiceDetail sd = registry.getServiceDetail(id);
+ if (sd != null && sd.getBusinessService()!=null) {
+ for (BusinessService businessService : sd.getBusinessService()) {
+ Service service = getServiceFromBusinessService(businessService, lcm);
+ return service;
+ }
+ }
+ }
+ catch (RegistryV3Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Helper routine to take a jUDDI business service and turn into a useful
+ * Service. Needs to go back to the registry to get the organization to
+ * properly hydrate the Service
+ *
+ * @param bs BusinessService object to turn in to a Service
+ * @param lcm manager to use
+ * @return new Service object
+ * @throws JAXRException
+ */
+ protected Service getServiceFromBusinessService(BusinessService bs, LifeCycleManager lcm)
+ throws JAXRException {
+
+ ServiceImpl service = (ServiceImpl) ScoutUddiV3JaxrHelper.getService(bs, lcm);
+ service.setSubmittingOrganizationKey(bs.getBusinessKey());
+
+ return service;
+ }
+
+ /**
+ * Gets the RegistryObjects owned by the caller. The objects
+ * are returned as their concrete type (e.g. Organization, User etc.)
+ *
+ * TODO - need to figure out what the set are. This is just to get some
+ * basic functionality
+ *
+ * @return BulkResponse
+ * @throws JAXRException
+ */
+ public BulkResponse getRegistryObjects() throws JAXRException
+ {
+ String types[] = {
+ LifeCycleManager.ORGANIZATION,
+ LifeCycleManager.SERVICE};
+
+ LinkedHashSet<Object> c = new LinkedHashSet<Object>();
+
+ for (int i = 0; i < types.length; i++) {
+ try {
+ BulkResponse bk = getRegistryObjects(types[i]);
+
+ if (bk.getCollection() != null) {
+ c.addAll(bk.getCollection());
+ }
+ } catch(JAXRException e) {
+ log.debug("ignore - just a problem with that type? " + e.getMessage(), e);
+ }
+ }
+
+ return new BulkResponseImpl(c);
+ }
+
+ public BulkResponse getRegistryObjects(Collection objectKeys) throws JAXRException
+ {
+ throw new UnsupportedCapabilityException();
+ }
+
+ public BulkResponse getRegistryObjects(Collection objectKeys, String objectType) throws JAXRException
+ {
+ IRegistryV3 registry = (IRegistryV3) registryService.getRegistry();
+ //Convert into a vector of strings
+ String[] keys = new String[objectKeys.size()];
+ int currLoc = 0;
+ for (Key key : (Collection<Key>) objectKeys) {
+ keys[currLoc] = key.getId();
+ currLoc++;
+ }
+ LinkedHashSet<RegistryObject> col = new LinkedHashSet<RegistryObject>();
+ LifeCycleManager lcm = registryService.getLifeCycleManagerImpl();
+
+ if (LifeCycleManager.CLASSIFICATION_SCHEME.equalsIgnoreCase(objectType))
+ {
+ try
+ {
+ TModelDetail tmodeldetail = registry.getTModelDetail(keys);
+ List<TModel> tmodelList = tmodeldetail.getTModel();
+
+ for (TModel tModel: tmodelList)
+ {
+ col.add(ScoutUddiV3JaxrHelper.getConcept(tModel, lcm));
+ }
+
+ } catch (RegistryV3Exception e)
+ {
+ throw new JAXRException(e.getLocalizedMessage());
+ }
+ }
+ else if (LifeCycleManager.ORGANIZATION.equalsIgnoreCase(objectType))
+ {
+ ConnectionImpl con = ((RegistryServiceImpl)getRegistryService()).getConnection();
+ AuthToken auth = this.getAuthToken(con,registry);
+
+ try
+ {
+ RegisteredInfo ri = registry.getRegisteredInfo(auth.getAuthInfo());
+ if (ri != null) {
+ BusinessInfos infos = ri.getBusinessInfos();
+ if (infos != null) {
+ List<BusinessInfo> bizInfoList = infos.getBusinessInfo();
+ for (BusinessInfo businessInfo: bizInfoList) {
+ BusinessDetail detail = registry.getBusinessDetail(businessInfo.getBusinessKey());
+ col.add(((BusinessLifeCycleManagerV3Impl)registryService.getLifeCycleManagerImpl()).createOrganization(detail));
+ }
+ }
+ }
+ } catch (RegistryV3Exception e) {
+ throw new JAXRException(e.getLocalizedMessage());
+ }
+ }
+ else if (LifeCycleManager.CONCEPT.equalsIgnoreCase(objectType))
+ {
+ try {
+ TModelDetail tmodeldetail = registry.getTModelDetail(keys);
+ List<TModel> tmodelList = tmodeldetail.getTModel();
+
+ for (TModel tmodel: tmodelList)
+ {
+ col.add(ScoutUddiV3JaxrHelper.getConcept(tmodel, lcm));
+ }
+
+ }
+ catch (RegistryV3Exception e)
+ {
+ throw new JAXRException(e.getLocalizedMessage());
+ }
+ }
+ else if (LifeCycleManager.SERVICE.equalsIgnoreCase(objectType)) {
+
+ try {
+ ServiceDetail serviceDetail = registry.getServiceDetail(keys);
+
+ if (serviceDetail != null) {
+ List<BusinessService> bizServiceList = serviceDetail.getBusinessService();
+
+ for (BusinessService businessService: bizServiceList) {
+
+ Service service = getServiceFromBusinessService(businessService, lcm);
+
+ col.add(service);
+ }
+ }
+ }
+ catch (RegistryV3Exception e) {
+ throw new JAXRException(e);
+ }
+ }
+ else {
+ throw new JAXRException("Unsupported type " + objectType +
+ " for getRegistryObjects() in Apache Scout");
+ }
+
+ return new BulkResponseImpl(col);
+
+ }
+
+ public BulkResponse getRegistryObjects(String id) throws JAXRException
+ {
+ if (LifeCycleManager.ORGANIZATION.equalsIgnoreCase(id)) {
+ IRegistryV3 registry = (IRegistryV3) registryService.getRegistry();
+ ConnectionImpl con = ((RegistryServiceImpl)getRegistryService()).getConnection();
+ AuthToken auth = this.getAuthToken(con,registry);
+ LinkedHashSet<Organization> orgs = null;
+ try
+ {
+ RegisteredInfo ri = registry.getRegisteredInfo(auth.getAuthInfo());
+ if (ri != null && ri.getBusinessInfos()!=null) {
+ List<BusinessInfo> bizInfoList = ri.getBusinessInfos().getBusinessInfo();
+ orgs = new LinkedHashSet<Organization>();
+ for (BusinessInfo businessInfo : bizInfoList) {
+ BusinessDetail detail = registry.getBusinessDetail(businessInfo.getBusinessKey());
+ orgs.add(((BusinessLifeCycleManagerV3Impl)registryService.getLifeCycleManagerImpl()).createOrganization(detail));
+ }
+ }
+
+ } catch (RegistryV3Exception re) {
+ throw new JAXRException(re);
+ }
+ return new BulkResponseImpl(orgs);
+ }
+ else if (LifeCycleManager.SERVICE.equalsIgnoreCase(id)) {
+ List<String> a = new ArrayList<String>();
+ a.add("%");
+
+ BulkResponse br = this.findServices(null,null, a, null, null);
+
+ return br;
+ }
+ else
+ {
+ throw new JAXRException("Unsupported type for getRegistryObjects() :" + id);
+ }
+
+ }
+
+ static FindQualifiers mapFindQualifiers(Collection jaxrQualifiers) throws UnsupportedCapabilityException
+ {
+ if (jaxrQualifiers == null)
+ {
+ return null;
+ }
+ FindQualifiers result = objectFactory.createFindQualifiers();
+ for (Iterator i = jaxrQualifiers.iterator(); i.hasNext();)
+ {
+ String jaxrQualifier = (String) i.next();
+ String juddiQualifier = jaxrQualifier;
+ if (juddiQualifier == null)
+ {
+ throw new UnsupportedCapabilityException("jUDDI does not support FindQualifer: " + jaxrQualifier);
+ }
+ result.getFindQualifier().add(juddiQualifier);
+ }
+ return result;
+ }
+
+ static Name[] mapNamePatterns(Collection namePatterns)
+ throws JAXRException
+ {
+ if (namePatterns == null)
+ return null;
+ Name[] result = new Name[namePatterns.size()];
+ int currLoc = 0;
+ for (Iterator i = namePatterns.iterator(); i.hasNext();)
+ {
+ Object obj = i.next();
+ Name name = objectFactory.createName();
+ if (obj instanceof String) {
+ name.setValue((String)obj);
+ } else if (obj instanceof LocalizedString) {
+ LocalizedString ls = (LocalizedString)obj;
+ name.setValue(ls.getValue());
+ name.setLang(ls.getLocale().getLanguage());
+ }
+ result[currLoc] = name;
+ currLoc++;
+ }
+ return result;
+ }
+
+ /**
+ * Get the Auth Token from the registry
+ *
+ * @param connection
+ * @param ireg
+ * @return auth token
+ * @throws JAXRException
+ */
+ private AuthToken getAuthToken(ConnectionImpl connection, IRegistryV3 ireg)
+ throws JAXRException {
+ Set creds = connection.getCredentials();
+ Iterator it = creds.iterator();
+ String username = "", pwd = "";
+ while (it.hasNext()) {
+ PasswordAuthentication pass = (PasswordAuthentication) it.next();
+ username = pass.getUserName();
+ pwd = new String(pass.getPassword());
+ }
+ AuthToken token = null;
+ try {
+ token = ireg.getAuthToken(username, pwd);
+ }
+ catch (Exception e) {
+ throw new JAXRException(e);
+ }
+ return token;
+ }
+}
diff --git a/src/main/java/org/apache/ws/scout/registry/ConnectionFactoryImpl.java b/src/main/java/org/apache/ws/scout/registry/ConnectionFactoryImpl.java
index d1353cb..36394e3 100644
--- a/src/main/java/org/apache/ws/scout/registry/ConnectionFactoryImpl.java
+++ b/src/main/java/org/apache/ws/scout/registry/ConnectionFactoryImpl.java
@@ -36,12 +36,14 @@
*
* @author Anil Saldhana <anil@apache.org>
* @author Jeremy Boynes <jboynes@apache.org>
+ * @author Tom Cunningham <tcunning@apache.org>
*/
public class ConnectionFactoryImpl extends ConnectionFactory implements Serializable
{
private static final long serialVersionUID = 1L;
private static final String QUERYMANAGER_PROPERTY = "javax.xml.registry.queryManagerURL";
private static final String LIFECYCLEMANAGER_PROPERTY = "javax.xml.registry.lifeCycleManagerURL";
+ private static final String SECURITYMANAGER_PROPERTY = "javax.xml.registry.securityManagerURL";
private static final String SEMANTICEQUIVALENCES_PROPERTY = "javax.xml.registry.semanticEquivalences";
private static final String POSTALADDRESSSCHEME_PROPERTY = "javax.xml.registry.postalAddressScheme";
private static final String AUTHENTICATIONMETHOD_PROPERTY = "javax.xml.registry.security.authenticationMethod";
@@ -49,11 +51,14 @@
private String queryManagerURL;
private String lifeCycleManagerURL;
+ private String securityManagerURL;
private String transportClass;
private String semanticEquivalences;
private String authenticationMethod;
private Integer maxRows;
private String postalAddressScheme;
+ private String uddiNamespace;
+ private String uddiVersion;
/**
* Public no-arg constructor so that this ConnectionFactory can be
@@ -71,6 +76,7 @@
}
URI queryManager;
URI lifeCycleManager;
+ URI securityManager = null;
try
{
queryManager = new URI(queryManagerURL);
@@ -85,7 +91,16 @@
{
throw new InvalidRequestException("Invalid lifeCycleManagerURL: " + lifeCycleManagerURL, e);
}
- return new ConnectionImpl(queryManager, lifeCycleManager, transportClass, null, maxRows == null ? -1 : maxRows.intValue());
+ try
+ {
+ if (securityManagerURL != null) {
+ securityManager = new URI(securityManagerURL);
+ }
+ } catch (URISyntaxException e) {
+ securityManager = null;
+ }
+ return new ConnectionImpl(queryManager, lifeCycleManager, securityManager, transportClass, null, maxRows == null ? -1 : maxRows.intValue(),
+ uddiNamespace, uddiVersion);
}
public FederatedConnection createFederatedConnection(Collection collection) throws JAXRException
@@ -111,6 +126,10 @@
{
props.put(LIFECYCLEMANAGER_PROPERTY, lifeCycleManagerURL);
}
+ if (securityManagerURL != null)
+ {
+ props.put(SECURITYMANAGER_PROPERTY, securityManagerURL);
+ }
if (semanticEquivalences != null)
{
props.put(SEMANTICEQUIVALENCES_PROPERTY, semanticEquivalences);
@@ -127,6 +146,13 @@
{
props.put(MAXROWS_PROPERTY, maxRows.toString());
}
+ if (uddiNamespace != null) {
+ props.put(RegistryImpl.UDDI_NAMESPACE_PROPERTY_NAME, uddiNamespace);
+ }
+ if (uddiVersion != null) {
+ props.put(RegistryImpl.UDDI_VERSION_PROPERTY_NAME, uddiVersion);
+ }
+
return props;
}
@@ -139,10 +165,15 @@
{
queryManagerURL = properties.getProperty(QUERYMANAGER_PROPERTY);
lifeCycleManagerURL = properties.getProperty(LIFECYCLEMANAGER_PROPERTY);
+ securityManagerURL = properties.getProperty(SECURITYMANAGER_PROPERTY);
+
transportClass = properties.getProperty(RegistryImpl.TRANSPORT_CLASS_PROPERTY_NAME);
semanticEquivalences = properties.getProperty(SEMANTICEQUIVALENCES_PROPERTY);
authenticationMethod = properties.getProperty(AUTHENTICATIONMETHOD_PROPERTY);
postalAddressScheme = properties.getProperty(POSTALADDRESSSCHEME_PROPERTY);
+ uddiVersion = properties.getProperty(RegistryImpl.UDDI_VERSION_PROPERTY_NAME);
+ uddiNamespace = properties.getProperty(RegistryImpl.UDDI_NAMESPACE_PROPERTY_NAME);
+
String val = properties.getProperty(MAXROWS_PROPERTY);
maxRows = (val == null) ? null : Integer.valueOf(val);
}
diff --git a/src/main/java/org/apache/ws/scout/registry/ConnectionImpl.java b/src/main/java/org/apache/ws/scout/registry/ConnectionImpl.java
index af10229..bd7846a 100644
--- a/src/main/java/org/apache/ws/scout/registry/ConnectionImpl.java
+++ b/src/main/java/org/apache/ws/scout/registry/ConnectionImpl.java
@@ -30,6 +30,7 @@
* For futher details, look into the JAXR API Javadoc.
*
* @author Anil Saldhana <anil@apache.org>
+ * @author Tom Cunningham <tcunning@apache.org>
*/
public class ConnectionImpl implements Connection, Serializable
{
@@ -37,11 +38,13 @@
private boolean closed = false;
private boolean synchronous = true;
private Set credentials;
- private final RegistryImpl registry;
+ private final IRegistryBase registry;
private final String postalScheme;
private final int maxRows;
+ private String uddiVersion;
- public ConnectionImpl(URI queryManagerURI, URI lifeCycleManagerURI, String transportClass, String postalScheme, int maxRows)
+ public ConnectionImpl(URI queryManagerURI, URI lifeCycleManagerURI, URI securityManagerURI, String transportClass, String postalScheme, int maxRows,
+ String uddiNamespace, String uddiVersion)
{
Properties prop = new Properties();
/**
@@ -49,8 +52,12 @@
* juddi RegistryProxy uses, set the System property
* accordingly.
*/
+ this.uddiVersion = uddiVersion;
+
if (transportClass!=null) {
prop.setProperty(RegistryImpl.TRANSPORT_CLASS_PROPERTY_NAME, transportClass);
+ prop.setProperty(RegistryImpl.UDDI_NAMESPACE_PROPERTY_NAME, uddiNamespace);
+ prop.setProperty(RegistryImpl.UDDI_VERSION_PROPERTY_NAME, uddiVersion);
} else {
String transport = SecurityActions.getProperty(RegistryImpl.TRANSPORT_CLASS_PROPERTY_NAME);
if (transport != null) {
@@ -61,9 +68,14 @@
* Even if the properties passed contains no values,
* juddi takes default values
*/
- registry = new RegistryImpl(prop);
+ if ("3.0".equals(uddiVersion)) {
+ registry = new RegistryV3Impl(prop);
+ } else {
+ registry = new RegistryImpl(prop);
+ }
registry.setInquiryURI(queryManagerURI);
registry.setPublishURI(lifeCycleManagerURI);
+ registry.setSecurityURI(securityManagerURI);
this.postalScheme = postalScheme;
this.maxRows = maxRows;
@@ -71,7 +83,7 @@
public RegistryService getRegistryService() throws JAXRException
{
- RegistryServiceImpl reg = new RegistryServiceImpl(registry, postalScheme, maxRows);
+ RegistryServiceImpl reg = new RegistryServiceImpl(registry, postalScheme, maxRows, uddiVersion);
reg.setConnection(this);
return reg;
}
diff --git a/src/main/java/org/apache/ws/scout/registry/IRegistry.java b/src/main/java/org/apache/ws/scout/registry/IRegistry.java
index 84a3077..352fb34 100644
--- a/src/main/java/org/apache/ws/scout/registry/IRegistry.java
+++ b/src/main/java/org/apache/ws/scout/registry/IRegistry.java
@@ -50,12 +50,11 @@
*
* <i>Borrowed from jUDDI.</i>
*
+ *
+ * @author <a href="mailto:tcunning@apache.org">Tom Cunningham</a>
*/
-public interface IRegistry {
-
- String execute(String uddiRequest, String urltype) throws RegistryException;
-
+public interface IRegistry extends IRegistryBase {
/**
* @return Returns the inquiryURL.
*/
diff --git a/src/main/java/org/apache/ws/scout/registry/IRegistryBase.java b/src/main/java/org/apache/ws/scout/registry/IRegistryBase.java
new file mode 100644
index 0000000..3acfa80
--- /dev/null
+++ b/src/main/java/org/apache/ws/scout/registry/IRegistryBase.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ws.scout.registry;
+
+import java.net.URI;
+
+import org.apache.ws.scout.transport.Transport;
+import org.apache.ws.scout.transport.TransportException;
+
+/**
+ *
+ * IRegistryBase interface.
+ *
+ * <p>Provides a common interface to IRegistry and IRegistryV3 and any
+ * subsequent directory implementation.</p>
+ *
+ * <i>Borrowed from jUDDI.</i>
+ *
+ *
+ * @author <a href="mailto:tcunning@apache.org">Tom Cunningham</a>
+ */
+
+public interface IRegistryBase {
+
+ String execute(String uddiRequest, String urltype) throws TransportException;
+
+ /**
+ * @return Returns the inquiryURL.
+ */
+ URI getInquiryURI();
+
+ /**
+ * @param uri The inquiry uri to set.
+ */
+ void setInquiryURI(URI uri);
+
+ /**
+ * @return Returns the publishURL.
+ */
+ URI getPublishURI();
+
+ /**
+ * @param uri The publish uri to set.
+ */
+ void setPublishURI(URI uri);
+
+ /**
+ * @return Returns the publishURL.
+ */
+ URI getSecurityURI();
+
+ /**
+ * @param uri The publish uri to set.
+ */
+ void setSecurityURI(URI uri);
+
+
+ /**
+ * @return Returns the transport.
+ */
+ Transport getTransport();
+
+ /**
+ * @param transport The transport to set.
+ */
+ void setTransport(Transport transport);
+
+}
diff --git a/src/main/java/org/apache/ws/scout/registry/IRegistryV3.java b/src/main/java/org/apache/ws/scout/registry/IRegistryV3.java
new file mode 100644
index 0000000..9c21765
--- /dev/null
+++ b/src/main/java/org/apache/ws/scout/registry/IRegistryV3.java
@@ -0,0 +1,273 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ws.scout.registry;
+
+import java.net.URI;
+import org.uddi.api_v3.*;
+import org.apache.ws.scout.transport.Transport;
+
+/**
+ *
+ * IRegistry interface.
+ *
+ * <p>Only the functions that scout relies on, are in this interface.</p>
+ *
+ * <i>Borrowed from jUDDI.</i>
+ *
+ */
+
+public interface IRegistryV3 extends IRegistryBase {
+
+ /**
+ * @return Returns the inquiryURL.
+ */
+ URI getInquiryURI();
+
+ /**
+ * @param uri The inquiry uri to set.
+ */
+ void setInquiryURI(URI uri);
+
+ /**
+ * @return Returns the publishURL.
+ */
+ URI getPublishURI();
+
+ /**
+ * @param uri The publish uri to set.
+ */
+ void setPublishURI(URI uri);
+
+ /**
+ * @return Returns the transport.
+ */
+ Transport getTransport();
+
+ /**
+ * @param transport The transport to set.
+ */
+ void setTransport(Transport transport);
+
+ /**
+ * @exception RegistryV3Exception;
+ */
+ PublisherAssertions setPublisherAssertions(String authInfo, PublisherAssertion[] assertionArray)
+ throws RegistryV3Exception;
+
+ /**
+ * "Used to register or update complete information about a businessService
+ * exposed by a specified businessEntity."
+ *
+ * @exception RegistryV3Exception;
+ */
+ ServiceDetail saveService(String authInfo, BusinessService[] serviceArray)
+ throws RegistryV3Exception;
+
+ /**
+ * "Used to register new bindingTemplate information or update existing
+ * bindingTemplate information. Use this to control information about
+ * technical capabilities exposed by a registered business."
+ *
+ * @exception RegistryV3Exception;
+ */
+ BindingDetail saveBinding(String authInfo, BindingTemplate[] bindingArray)
+ throws RegistryV3Exception;
+
+ /**
+ * "Used to register new businessEntity information or update existing
+ * businessEntity information. Use this to control the overall
+ * information about the entire business. Of the save_x APIs this one
+ * has the broadest effect."
+ *
+ * @exception RegistryV3Exception;
+ */
+ BusinessDetail saveBusiness(String authInfo, BusinessEntity[] businessArray)
+ throws RegistryV3Exception;
+
+
+ /**
+ * "Used to register or update complete information about a tModel."
+ *
+ * @exception RegistryV3Exception;
+ */
+ TModelDetail saveTModel(String authInfo, TModel[] tModelArray)
+ throws RegistryV3Exception;
+
+ /**
+ * "Used to remove an existing bindingTemplate from the bindingTemplates
+ * collection that is part of a specified businessService structure."
+ *
+ * @exception RegistryV3Exception;
+ */
+ DispositionReport deleteBinding(String authInfo, String[] bindingKeyArray)
+ throws RegistryV3Exception;
+
+ /**
+ * "Used to delete registered businessEntity information from the registry."
+ *
+ * @exception RegistryV3Exception;
+ */
+ DispositionReport deleteBusiness(String authInfo, String[] businessKeyArray)
+ throws RegistryV3Exception;
+
+ /**
+ * "Used to delete an existing businessService from the businessServices
+ * collection that is part of a specified businessEntity."
+ *
+ * @exception RegistryV3Exception;
+ */
+ DispositionReport deleteService(String authInfo, String[] serviceKeyArray)
+ throws RegistryV3Exception;
+
+ /**
+ * "Used to delete registered information about a tModel. If there
+ * are any references to a tModel when this call is made, the tModel
+ * will be marked deleted instead of being physically removed."
+ *
+ * @exception RegistryV3Exception;
+ */
+ DispositionReport deleteTModel(String authInfo, String[] tModelKeyArray)
+ throws RegistryV3Exception;
+
+ /**
+ * @exception RegistryV3Exception;
+ */
+ AssertionStatusReport getAssertionStatusReport(String authInfo, String completionStatus)
+ throws RegistryV3Exception;
+
+ /**
+ * @exception RegistryV3Exception;
+ */
+ DispositionReport deletePublisherAssertions(String authInfo, PublisherAssertion[] assertionArray)
+ throws RegistryV3Exception;
+
+ /**
+ * "Used to request an authentication token from an Operator Site.
+ * Authentication tokens are required to use all other APIs defined
+ * in the publishers API. This server serves as the program's
+ * equivalent of a login request."
+ *
+ * @exception RegistryV3Exception;
+ */
+ AuthToken getAuthToken(String userID,String cred)
+ throws RegistryV3Exception;
+
+ /**
+ * Used to locate information about one or more businesses. Returns a
+ * businessList message that matches the conditions specified.
+ *
+ * @exception RegistryV3Exception;
+ */
+ BusinessList findBusiness(Name[] nameArray,DiscoveryURLs discoveryURLs,IdentifierBag identifierBag,CategoryBag categoryBag,TModelBag tModelBag,FindQualifiers findQualifiers,int maxRows)
+ throws RegistryV3Exception;
+
+ /**
+ * "Used to get the full businessEntity information for one or more
+ * businesses. Returns a businessDetail message."
+ *
+ * @exception RegistryV3Exception;
+ */
+ BusinessDetail getBusinessDetail(String businessKey)
+ throws RegistryV3Exception;
+
+ /**
+ * "Used to get the full businessEntity information for one or more
+ * businesses. Returns a businessDetail message."
+ *
+ * @exception RegistryV3Exception;
+ */
+ BusinessDetail getBusinessDetail(String[] businessKeyVector)
+ throws RegistryV3Exception;
+
+ /**
+ * @exception RegistryV3Exception;
+ */
+ PublisherAssertions getPublisherAssertions(String authInfo)
+ throws RegistryV3Exception;
+
+ /**
+ * @exception RegistryV3Exception;
+ */
+ RegisteredInfo getRegisteredInfo(String authInfo)
+ throws RegistryV3Exception;
+
+ /**
+ * "Used to locate one or more tModel information structures. Returns a
+ * tModelList structure."
+ *
+ * @exception RegistryV3Exception;
+ */
+ TModelList findTModel(String name,CategoryBag categoryBag,IdentifierBag identifierBag,FindQualifiers findQualifiers,int maxRows)
+ throws RegistryV3Exception;
+
+ /**
+ * "Used to locate specific bindings within a registered
+ * businessService. Returns a bindingDetail message."
+ *
+ * @exception RegistryV3Exception
+ */
+ BindingDetail findBinding(String serviceKey,CategoryBag categoryBag,TModelBag tModelBag,FindQualifiers findQualifiers,int maxRows)
+ throws RegistryV3Exception;
+
+ /**
+ * "Used to locate specific services within a registered
+ * businessEntity. Return a serviceList message." From the
+ * XML spec (API, p18) it appears that the name, categoryBag,
+ * and tModelBag arguments are mutually exclusive.
+ *
+ * @exception RegistryV3Exception;
+ */
+ ServiceList findService(String businessKey,Name[] nameArray,CategoryBag categoryBag,TModelBag tModelBag,FindQualifiers findQualifiers,int maxRows)
+ throws RegistryV3Exception;
+
+ /**
+ * "Used to get full details for a given set of registered tModel
+ * data. Returns a tModelDetail message."
+ *
+ * @exception RegistryV3Exception;
+ */
+ TModelDetail getTModelDetail(String tModelKey)
+ throws RegistryV3Exception;
+
+ /**
+ * "Used to get full details for a given set of registered tModel
+ * data. Returns a tModelDetail message."
+ *
+ * @exception RegistryV3Exception;
+ */
+ TModelDetail getTModelDetail(String[] tModelKeyArray)
+ throws RegistryV3Exception;
+
+ /**
+ * "Used to get full details for a given set of registered
+ * businessService data. Returns a serviceDetail message."
+ *
+ * @exception RegistryV3Exception;
+ */
+ ServiceDetail getServiceDetail(String serviceKey)
+ throws RegistryV3Exception;
+
+ /**
+ * "Used to get full details for a given set of registered
+ * businessService data. Returns a serviceDetail message."
+ *
+ * @exception RegistryV3Exception;
+ */
+ ServiceDetail getServiceDetail(String[] serviceKeyArray)
+ throws RegistryV3Exception;
+
+
+}
diff --git a/src/main/java/org/apache/ws/scout/registry/LifeCycleManagerImpl.java b/src/main/java/org/apache/ws/scout/registry/LifeCycleManagerImpl.java
index 2022ed2..9e0ab07 100644
--- a/src/main/java/org/apache/ws/scout/registry/LifeCycleManagerImpl.java
+++ b/src/main/java/org/apache/ws/scout/registry/LifeCycleManagerImpl.java
@@ -18,7 +18,6 @@
import java.util.ArrayList;
import java.util.Collection;
-import java.util.List;
import java.util.Locale;
import javax.activation.DataHandler;
@@ -51,11 +50,6 @@
import javax.xml.registry.infomodel.TelephoneNumber;
import javax.xml.registry.infomodel.User;
-import org.apache.ws.scout.model.uddi.v2.BusinessDetail;
-import org.apache.ws.scout.model.uddi.v2.BusinessInfo;
-import org.apache.ws.scout.model.uddi.v2.Description;
-import org.apache.ws.scout.model.uddi.v2.Name;
-import org.apache.ws.scout.model.uddi.v2.ServiceInfo;
import org.apache.ws.scout.registry.infomodel.AssociationImpl;
import org.apache.ws.scout.registry.infomodel.ClassificationImpl;
import org.apache.ws.scout.registry.infomodel.ClassificationSchemeImpl;
@@ -75,7 +69,6 @@
import org.apache.ws.scout.registry.infomodel.SpecificationLinkImpl;
import org.apache.ws.scout.registry.infomodel.TelephoneNumberImpl;
import org.apache.ws.scout.registry.infomodel.UserImpl;
-import org.apache.ws.scout.util.ScoutUddiJaxrHelper;
/**
* Implements JAXR LifeCycleManager Interface
@@ -449,45 +442,4 @@
throw new UnsupportedCapabilityException();
}
- Organization createOrganization(BusinessInfo bizInfo) throws JAXRException {
- String key = bizInfo.getBusinessKey();
- List<Name> names = bizInfo.getName();
-
- List<Description> descriptions = bizInfo.getDescription();
- List<ServiceInfo> serviceInfos = bizInfo.getServiceInfos().getServiceInfo();
-
- OrganizationImpl org = new OrganizationImpl(this);
- org.setKey(createKey(key));
- if (names != null && names.size() > 0) {
- org.setName(createInternationalString(names.get(0).getValue()));
- }
- if (descriptions != null && descriptions.size() > 0) {
- org.setDescription(createInternationalString(descriptions.get(0).getValue()));
- }
- if (serviceInfos != null && serviceInfos.size() > 0) {
- List<Service> services = new ArrayList<Service>(serviceInfos.size());
- for (int i = 0; i < serviceInfos.size(); i++) {
- ServiceInfo serviceInfo = serviceInfos.get(i);
- services.add(createService(serviceInfo));
- }
- org.addServices(services);
- }
-
- return org;
- }
-
- Organization createOrganization(BusinessDetail bizDetail) throws JAXRException {
- return ScoutUddiJaxrHelper.getOrganization(bizDetail, this);
- }
-
- Service createService(ServiceInfo serviceInfo) throws JAXRException {
- String key = serviceInfo.getServiceKey();
- List<Name> names = serviceInfo.getName();
- ServiceImpl service = new ServiceImpl(this);
- service.setKey(createKey(key));
- if (names != null && names.size() > 0) {
- service.setName(createInternationalString(names.get(0).getValue()));
- }
- return service;
- }
}
diff --git a/src/main/java/org/apache/ws/scout/registry/RegistryImpl.java b/src/main/java/org/apache/ws/scout/registry/RegistryImpl.java
index d11b223..a47daca 100644
--- a/src/main/java/org/apache/ws/scout/registry/RegistryImpl.java
+++ b/src/main/java/org/apache/ws/scout/registry/RegistryImpl.java
@@ -22,6 +22,7 @@
import java.net.URISyntaxException;
import java.security.AccessController;
import java.security.PrivilegedAction;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Properties;
@@ -82,8 +83,11 @@
import org.apache.ws.scout.model.uddi.v2.TModelDetail;
import org.apache.ws.scout.model.uddi.v2.TModelList;
import org.apache.ws.scout.transport.Transport;
+import org.apache.ws.scout.transport.TransportException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
@@ -103,6 +107,7 @@
public static final String INQUIRY_ENDPOINT_PROPERTY_NAME = "scout.proxy.inquiryURL";
public static final String PUBLISH_ENDPOINT_PROPERTY_NAME = "scout.proxy.publishURL";
+ public static final String SECURITY_ENDPOINT_PROPERTY_NAME = "scout.proxy.securityURL";
public static final String ADMIN_ENDPOINT_PROPERTY_NAME = "scout.proxy.adminURL";
public static final String TRANSPORT_CLASS_PROPERTY_NAME = "scout.proxy.transportClass";
public static final String SECURITY_PROVIDER_PROPERTY_NAME = "scout.proxy.securityProvider";
@@ -112,6 +117,7 @@
public static final String DEFAULT_INQUIRY_ENDPOINT = "http://localhost/juddi/inquiry";
public static final String DEFAULT_PUBLISH_ENDPOINT = "http://localhost/juddi/publish";
+ public static final String DEFAULT_SECURITY_ENDPOINT = "http://localhost/juddi/security";
public static final String DEFAULT_ADMIN_ENDPOINT = "http://localhost/juddi/admin";
public static final String DEFAULT_TRANSPORT_CLASS = "org.apache.ws.scout.transport.AxisTransport";
public static final String DEFAULT_SECURITY_PROVIDER = "com.sun.net.ssl.internal.ssl.Provider";
@@ -122,6 +128,7 @@
private URI adminURI;
private URI inquiryURI;
private URI publishURI;
+ private URI securityURI;
private Transport transport;
@@ -169,6 +176,12 @@
else
this.setPublishURI(new URI(DEFAULT_PUBLISH_ENDPOINT));
+ String sURL = props.getProperty(SECURITY_ENDPOINT_PROPERTY_NAME);
+ if (sURL != null)
+ this.setSecurityURI(new URI(sURL));
+ else
+ this.setSecurityURI(new URI(DEFAULT_SECURITY_ENDPOINT));
+
String aURL = props.getProperty(ADMIN_ENDPOINT_PROPERTY_NAME);
if (aURL != null)
this.setAdminURI(new URI(aURL));
@@ -211,8 +224,13 @@
try
{
JAXBContext context = JAXBContext.newInstance(new Class[] {ObjectFactory.class});
+ JAXBContext v3context = JAXBContext.newInstance(new Class[] {org.uddi.api_v3.ObjectFactory.class});
+ if ("3.0".equals(uddiVer)) {
+ this.unmarshaller = v3context.createUnmarshaller();
+ } else {
+ this.unmarshaller = context.createUnmarshaller();
+ }
this.marshaller = context.createMarshaller();
- this.unmarshaller = context.createUnmarshaller();
}
catch(JAXBException e)
{
@@ -227,7 +245,7 @@
* @throws RegistryException
*/
public String execute(String uddiRequest, String urltype)
- throws RegistryException {
+ throws TransportException {
URI endPointURL = null;
if (urltype.equalsIgnoreCase("INQUIRY"))
endPointURL = this.getInquiryURI();
@@ -266,16 +284,42 @@
}
Element request = doc.getDocumentElement();
- request.setAttribute("generic", this.getUddiVersion());
+ request.setAttribute("xmlns", this.getUddiNamespace());
+ if (!"3.0".equals(this.getUddiVersion())) {
+ request.setAttribute("generic", this.getUddiVersion());
+ }
//request.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns", this.getUddiNamespace());
// A SOAP request is made and a SOAP response
// is returned.
- Element response = transport.send(request, endPointURI);
-
- if (response.getNamespaceURI()==null) {
+
+ Element response;
+ try {
+ response = transport.send(request, endPointURI);
+ } catch (TransportException te) {
+ throw new RegistryException(te);
+ }
+ /* if (response.hasAttributes()) {
+ NamedNodeMap am = response.getAttributes();
+ ArrayList<String> al = new ArrayList<String>();
+ for (int i = 0; i < am.getLength(); i++) {
+ Node n = am.item(i);
+ String attribute = n.getNodeName();
+ if (attribute!= null && attribute.startsWith("xmlns")) {
+ al.add(attribute);
+ }
+ }
+ for (String attr : al) {
+ response.removeAttribute(attr);
+ }
+ }*/
+
+ if (response.getNamespaceURI()==null) {
response.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns", this.getUddiNamespace());
}
+
+ // If we are getting responses from a UDDI v3, remove the xmlns
+
// First, let's make sure that a response
// (any response) is found in the SOAP Body.
@@ -283,8 +327,8 @@
if (responseName == null) {
throw new RegistryException("Unsupported response "
+ "from registry. A value was not present.");
- }
-
+ }
+
// Let's now try to determine which UDDI response
// we received and unmarshal it appropriately or
// throw a RegistryException if it's unknown.
@@ -399,6 +443,13 @@
public URI getPublishURI() {
return this.publishURI;
}
+
+ /**
+ * @return Returns the publishURL.
+ */
+ public URI getSecurityURI() {
+ return this.securityURI;
+ }
/**
* @param publishURI
@@ -407,6 +458,14 @@
public void setPublishURI(URI publishURI) {
this.publishURI = publishURI;
}
+
+ /**
+ * @param publishURI
+ * The publishURI to set.
+ */
+ public void setSecurityURI(URI securityURI) {
+ this.securityURI = securityURI;
+ }
/**
* @return Returns the securityProvider.
@@ -812,9 +871,16 @@
request.setCred(cred);
}
+ URI getAuthTokenURI = null;
+ if ("3.0".equals(uddiVersion)) {
+ getAuthTokenURI = this.getSecurityURI();
+ } else {
+ getAuthTokenURI = this.getPublishURI();
+ }
+
AuthToken at;
JAXBElement<?> o = execute(this.objectFactory.createGetAuthToken(request),
- this.getPublishURI());
+ getAuthTokenURI);
at = (AuthToken) o.getValue();
return at;
diff --git a/src/main/java/org/apache/ws/scout/registry/RegistryServiceImpl.java b/src/main/java/org/apache/ws/scout/registry/RegistryServiceImpl.java
index 6be2146..77cfc14 100644
--- a/src/main/java/org/apache/ws/scout/registry/RegistryServiceImpl.java
+++ b/src/main/java/org/apache/ws/scout/registry/RegistryServiceImpl.java
@@ -29,6 +29,7 @@
import org.apache.ws.scout.registry.infomodel.ClassificationSchemeImpl;
import org.apache.ws.scout.registry.infomodel.KeyImpl;
+import org.apache.ws.scout.transport.TransportException;
/**
* Scout implementation of javax.xml.registry.RegistryService
@@ -36,25 +37,32 @@
*
* @author Anil Saldhana <anil@apache.org>
* @author Jeremy Boynes <jboynes@apache.org>
+ * @author Tom Cunningham <tcunning@apache.org>
*/
public class RegistryServiceImpl implements RegistryService
{
- private final RegistryImpl registry;
- private final BusinessQueryManagerImpl queryManager;
- private final BusinessLifeCycleManagerImpl lifeCycleManager;
-
+ private final IRegistryBase registry;
+ private final BusinessQueryManager queryManager;
+ private final BusinessLifeCycleManager lifeCycleManager;
+
private final ClassificationSchemeImpl postalScheme;
private final int maxRows;
-
+ private final String uddiVersion;
private ConnectionImpl connection;
- public RegistryServiceImpl(RegistryImpl registry, String postalScheme, int maxRows)
+ public RegistryServiceImpl(IRegistryBase registry, String postalScheme, int maxRows, String uddiVersion)
{
this.registry = registry;
this.maxRows = maxRows;
- queryManager = new BusinessQueryManagerImpl(this);
- lifeCycleManager = new BusinessLifeCycleManagerImpl(this);
+ this.uddiVersion = uddiVersion;
+ if ("3.0".equals(uddiVersion)) {
+ queryManager = new BusinessQueryManagerV3Impl(this);
+ lifeCycleManager = new BusinessLifeCycleManagerV3Impl(this);
+ } else {
+ queryManager = new BusinessQueryManagerImpl(this);
+ lifeCycleManager = new BusinessLifeCycleManagerImpl(this);
+ }
if (postalScheme == null)
{
this.postalScheme = null;
@@ -64,13 +72,13 @@
this.postalScheme.setKey(new KeyImpl(postalScheme));
}
}
-
- IRegistry getRegistry()
+
+ IRegistryBase getRegistry()
{
return registry;
}
- BusinessLifeCycleManagerImpl getLifeCycleManagerImpl()
+ BusinessLifeCycleManager getLifeCycleManagerImpl()
{
return lifeCycleManager;
}
@@ -85,6 +93,10 @@
return new CapabilityProfileImpl();
}
+ public String getUddiVersion() {
+ return uddiVersion;
+ }
+
public BusinessQueryManager getBusinessQueryManager() throws JAXRException
{
return queryManager;
@@ -124,15 +136,12 @@
else
type = inquiry;
- try
- {
- return registry.execute(s,type);
- }
- catch (RegistryException e)
- {
- throw new JAXRException(e.getLocalizedMessage());
- }
- }
+ try {
+ return registry.execute(s,type);
+ } catch (TransportException e) {
+ throw new JAXRException(e.getLocalizedMessage());
+ }
+ }
public ConnectionImpl getConnection()
{
diff --git a/src/main/java/org/apache/ws/scout/registry/RegistryV3Exception.java b/src/main/java/org/apache/ws/scout/registry/RegistryV3Exception.java
new file mode 100644
index 0000000..3285420
--- /dev/null
+++ b/src/main/java/org/apache/ws/scout/registry/RegistryV3Exception.java
@@ -0,0 +1,351 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ws.scout.registry;
+
+import org.uddi.api_v3.*;
+
+/**
+ * Thrown to indicate that a UDDI Exception was encountered.
+ *
+ * <i>Borrowed from jUDDI project.</i>
+ *
+ * @author Steve Viens (sviens@apache.org)
+ */
+public class RegistryV3Exception extends Exception
+{
+ private static final long serialVersionUID = 1L;
+ public static final int E_ASSERTION_NOT_FOUND = 30000;
+ public static final int E_AUTH_TOKEN_EXPIRED = 10110;
+ public static final int E_AUTH_TOKEN_REQUIRED = 10120;
+ public static final int E_ACCOUNT_LIMIT_EXCEEDED = 10160;
+ public static final int E_BUSY = 10400;
+ public static final int E_CATEGORIZATION_NOT_ALLOWED = 20100;
+ public static final int E_FATAL_ERROR = 10500;
+ public static final int E_INVALID_KEY_PASSED = 10210;
+ public static final int E_INVALID_PROJECTION = 20230;
+ public static final int E_INVALID_CATEGORY = 20000;
+ public static final int E_INVALID_COMPLETION_STATUS = 30100;
+ public static final int E_INVALID_URL_PASSED = 10220;
+ public static final int E_INVALID_VALUE = 20200;
+ public static final int E_KEY_RETIRED = 10310;
+ public static final int E_LANGUAGE_ERROR = 10060;
+ public static final int E_MESSAGE_TOO_LARGE = 30110;
+ public static final int E_NAME_TOO_LONG = 10020;
+ public static final int E_OPERATOR_MISMATCH = 10130;
+ public static final int E_PUBLISHER_CANCELLED = 30220;
+ public static final int E_REQUEST_DENIED = 30210;
+ public static final int E_SECRET_UNKNOWN = 30230;
+ public static final int E_SUCCESS = 0;
+ public static final int E_TOO_MANY_OPTIONS = 10030;
+ public static final int E_TRANSFER_ABORTED = 30200;
+ public static final int E_UNRECOGNIZED_VERSION = 10040;
+ public static final int E_UNKNOWN_USER = 10150;
+ public static final int E_UNSUPPORTED = 10050;
+ public static final int E_USER_MISMATCH = 10140;
+ public static final int E_VALUE_NOT_ALLOWED = 20210;
+ public static final int E_UNVALIDATABLE = 20220;
+ public static final int E_REQUEST_TIMEOUT = 20240;
+ public static final int E_INVALID_TIME = 40030;
+ public static final int E_RESULT_SET_TOO_LARGE = 40300;
+
+ // SOAP SOAPFault Actor
+ private String faultActor;
+
+ // SOAP SOAPFault Code
+ private String faultCode;
+
+ // SOAP SOAPFault SOAPMessage
+ private String faultString;
+
+ // UDDI DispositionReport
+ private DispositionReport dispReport;
+
+ private ObjectFactory objectFactory = new ObjectFactory();
+
+ /**
+ * Constructs a RegistryException instance.
+ * @param msg additional error information
+ */
+ public RegistryV3Exception(String msg)
+ {
+ super(msg);
+
+ setFaultCode(null);
+ setFaultString(msg);
+ setFaultActor(null);
+ }
+
+ /**
+ * Constructs a RegistryException instance.
+ * @param ex the original exception
+ */
+ public RegistryV3Exception(Exception ex)
+ {
+ super(ex);
+
+ if (ex != null)
+ {
+ // Not sure why this would ever happen but
+ // just in case we are asked to create a new
+ // RegistryException using values from another
+ // let's be sure to grab all relevant values.
+ //
+ if (ex instanceof RegistryV3Exception)
+ {
+ RegistryV3Exception regex = (RegistryV3Exception)ex;
+ setFaultCode(regex.getFaultCode());
+ setFaultString(regex.getFaultString());
+ setFaultActor(regex.getFaultActor());
+ setDispositionReport(regex.getDispositionReport());
+ }
+ else // Not a RegistryException (or subclass)
+ {
+ setFaultString(ex.getMessage());
+ }
+ }
+ }
+
+ /**
+ * Constructs a RegistryException instance.
+ *
+ * @param fCode
+ * @param fString
+ * @param fActor
+ * @param dispRpt
+ */
+ public RegistryV3Exception(String fCode,String fString,String fActor,DispositionReport dispRpt)
+ {
+ super(fString);
+
+ setFaultCode(fCode);
+ setFaultString(fString);
+ setFaultActor(fActor);
+ setDispositionReport(dispRpt);
+ }
+
+ /**
+ * Constructs a RegistryException instance.
+ * @param ex the original exception
+ */
+ RegistryV3Exception(String fCode,int errno,String msg)
+ {
+ super(buildMessage(errno,msg));
+
+ String errCode = lookupErrCode(errno);
+
+ if (fCode != null) {
+ setFaultCode(fCode);
+ }
+
+ setFaultString(getMessage());
+
+ Result r = this.objectFactory.createResult();
+ ErrInfo ei = this.objectFactory.createErrInfo();
+
+ if (errCode != null) {
+ ei.setErrCode(errCode);
+ }
+
+ ei.setValue(getMessage());
+
+ r.setErrno(errno);
+
+ if (ei != null) {
+ r.setErrInfo(ei);
+ }
+
+ addResult(r);
+ }
+
+ /**
+ * Sets the fault actor of this SOAP SOAPFault to the given value.
+ * @param actor The new actor value for this SOAP SOAPFault.
+ */
+ public void setFaultActor(String actor)
+ {
+ this.faultActor = actor;
+ }
+
+ /**
+ * Returns the fault actor of this SOAP SOAPFault.
+ * @return The fault actor of this SOAP SOAPFault.
+ */
+ public String getFaultActor()
+ {
+ return this.faultActor;
+ }
+
+ /**
+ * Sets the fault code of this SOAP SOAPFault to the given value.
+ * @param code The new code number for this SOAP SOAPFault.
+ */
+ public void setFaultCode(String code)
+ {
+ this.faultCode = code;
+ }
+
+ /**
+ * Returns the fault code of this SOAP SOAPFault.
+ * @return The fault code of this SOAP SOAPFault.
+ */
+ public String getFaultCode()
+ {
+ return this.faultCode;
+ }
+
+ /**
+ * Sets the fault string of this SOAP SOAPFault to the given value.
+ * @param value The new fault string for this SOAP SOAPFault.
+ */
+ public void setFaultString(String value)
+ {
+ this.faultString = value;
+ }
+
+ /**
+ * Returns the fault string of this SOAP SOAPFault.
+ * @return The fault string of this SOAP SOAPFault.
+ */
+ public String getFaultString()
+ {
+ return this.faultString;
+ }
+
+ /**
+ * Sets the UDDI DispositionReport value to the instance
+ * specified
+ * @param dispRpt The new UDDI DispositionReport instance for
+ * this SOAP Fault.
+ */
+ public void setDispositionReport(DispositionReport dispRpt)
+ {
+ this.dispReport = dispRpt;
+ }
+
+ /**
+ * Returns the disposition report associated with this jUDDI exception. It
+ * uses the results Vector to determine if a disposition report is present
+ * and should be returned.
+ * @return The disposition report associated with this jUDDI exception.
+ */
+ public DispositionReport getDispositionReport()
+ {
+ return this.dispReport;
+ }
+
+ /**
+ * Adds a result instance to this Exception. Multiple result objects
+ * may exist within a DispositionReport
+ */
+ public void addResult(Result result)
+ {
+ if (this.dispReport==null) {
+ this.dispReport = this.objectFactory.createDispositionReport();
+ }
+
+ Result jaxbResult = this.objectFactory.createResult();
+ this.dispReport.getResult().add(jaxbResult);
+
+ if (result.getErrInfo() != null) jaxbResult.setErrInfo(result.getErrInfo());
+ if (result.getKeyType() != null) jaxbResult.setKeyType(result.getKeyType());
+ jaxbResult.setErrno(result.getErrno());
+ }
+
+ /**
+ *
+ */
+ public String toString()
+ {
+ String msg = getMessage();
+ if (msg == null)
+ return "";
+ else
+ return getMessage();
+ }
+
+ private static final String buildMessage(int errno,String msg)
+ {
+ StringBuffer buffer = new StringBuffer();
+
+ String errCode = lookupErrCode(errno);
+ if (errCode != null)
+ {
+ buffer.append(errCode);
+ buffer.append(" ");
+ }
+
+ buffer.append("(");
+ buffer.append(errno);
+ buffer.append(") ");
+
+ //String errText = lookupErrText(errno);
+ // FIXME: What should error text be?
+ String errText = "";
+ if (errText != null)
+ {
+ buffer.append(errText);
+ buffer.append(" ");
+ }
+
+ if ((msg != null) && (msg.trim().length() > 0))
+ {
+ buffer.append(msg);
+ }
+
+ return buffer.toString();
+ }
+
+ public static final String lookupErrCode(int errno)
+ {
+ switch (errno)
+ {
+ case E_ACCOUNT_LIMIT_EXCEEDED : return "E_accountLimitExceeded";
+ case E_ASSERTION_NOT_FOUND : return "E_assertionNotFound";
+ case E_AUTH_TOKEN_EXPIRED : return "E_authTokenExpired";
+ case E_AUTH_TOKEN_REQUIRED : return "E_authTokenRequired";
+ case E_BUSY : return "E_busy";
+ case E_CATEGORIZATION_NOT_ALLOWED : return "E_categorizationNotAllowed";
+ case E_FATAL_ERROR : return "E_fatalError";
+ case E_INVALID_CATEGORY : return "E_invalidCategory";
+ case E_INVALID_COMPLETION_STATUS : return "E_invalidCompletionStatus";
+ case E_INVALID_KEY_PASSED : return "E_invalidKeyPassed";
+ case E_INVALID_PROJECTION : return "E_invalidProjection";
+ case E_INVALID_TIME : return "E_invalidTime";
+ case E_INVALID_URL_PASSED : return "E_invalidURLPassed";
+ case E_INVALID_VALUE : return "E_invalidValue";
+ case E_KEY_RETIRED : return "E_keyRetired";
+ case E_LANGUAGE_ERROR : return "E_languageError";
+ case E_MESSAGE_TOO_LARGE : return "E_messageTooLarge";
+ case E_NAME_TOO_LONG : return "E_nameTooLong";
+ case E_OPERATOR_MISMATCH : return "E_operatorMismatch";
+ case E_PUBLISHER_CANCELLED : return "E_publisherCancelled";
+ case E_REQUEST_DENIED : return "E_requestDenied";
+ case E_REQUEST_TIMEOUT : return "E_requestTimeout";
+ case E_RESULT_SET_TOO_LARGE : return "E_resultSetTooLarge";
+ case E_SECRET_UNKNOWN : return "E_secretUnknown";
+ case E_SUCCESS : return "E_success";
+ case E_TOO_MANY_OPTIONS : return "E_tooManyOptions";
+ case E_TRANSFER_ABORTED : return "E_transferAborted";
+ case E_UNKNOWN_USER : return "E_unknownUser";
+ case E_UNRECOGNIZED_VERSION : return "E_unrecognizedVersion";
+ case E_UNSUPPORTED : return "E_unsupported";
+ case E_UNVALIDATABLE : return "E_unvalidatable";
+ case E_USER_MISMATCH : return "E_userMismatch";
+ case E_VALUE_NOT_ALLOWED : return "E_valueNotAllowed";
+ default : return null;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/apache/ws/scout/registry/RegistryV3Impl.java b/src/main/java/org/apache/ws/scout/registry/RegistryV3Impl.java
new file mode 100644
index 0000000..45f6651
--- /dev/null
+++ b/src/main/java/org/apache/ws/scout/registry/RegistryV3Impl.java
@@ -0,0 +1,1206 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ws.scout.registry;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Properties;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.uddi.api_v3.*;
+import org.apache.ws.scout.transport.Transport;
+import org.apache.ws.scout.transport.TransportException;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ * RegistryImpl is the implementation of IRegistry.
+ *
+ * <p>The execute() function signature has been changed slightly from the jUDDI
+ * version, since the URL can no longer be decided dynamically (in an easy
+ * enough manner) as we don't use jUDDI data types anymore.</p>
+ *
+ * <i>The function code is borrowed from jUDDI, with appropriate modifications so
+ * that xmlbeans data types are used intead of jUDDI data types.</i>
+ *
+ */
+
+public class RegistryV3Impl implements IRegistryV3 {
+
+ public static final String INQUIRY_ENDPOINT_PROPERTY_NAME = "scout.proxy.inquiryURL";
+ public static final String PUBLISH_ENDPOINT_PROPERTY_NAME = "scout.proxy.publishURL";
+ public static final String SECURITY_ENDPOINT_PROPERTY_NAME = "scout.proxy.securityURL";
+ public static final String ADMIN_ENDPOINT_PROPERTY_NAME = "scout.proxy.adminURL";
+ public static final String TRANSPORT_CLASS_PROPERTY_NAME = "scout.proxy.transportClass";
+ public static final String SECURITY_PROVIDER_PROPERTY_NAME = "scout.proxy.securityProvider";
+ public static final String PROTOCOL_HANDLER_PROPERTY_NAME = "scout.proxy.protocolHandler";
+ public static final String UDDI_VERSION_PROPERTY_NAME = "scout.proxy.uddiVersion";
+ public static final String UDDI_NAMESPACE_PROPERTY_NAME = "scout.proxy.uddiNamespace";
+
+ public static final String DEFAULT_INQUIRY_ENDPOINT = "http://localhost/juddi/inquiry";
+ public static final String DEFAULT_PUBLISH_ENDPOINT = "http://localhost/juddi/publish";
+ public static final String DEFAULT_SECURITY_ENDPOINT = "http://localhost/juddi/security";
+ public static final String DEFAULT_ADMIN_ENDPOINT = "http://localhost/juddi/admin";
+ public static final String DEFAULT_TRANSPORT_CLASS = "org.apache.ws.scout.transport.AxisTransport";
+ public static final String DEFAULT_SECURITY_PROVIDER = "com.sun.net.ssl.internal.ssl.Provider";
+ public static final String DEFAULT_PROTOCOL_HANDLER = "com.sun.net.ssl.internal.www.protocol";
+ public static final String DEFAULT_UDDI_VERSION = "2.0";
+ public static final String DEFAULT_UDDI_NAMESPACE = "urn:uddi-org:api_v2";
+
+ private URI adminURI;
+ private URI inquiryURI;
+ private URI publishURI;
+ private URI securityURI;
+
+ private Transport transport;
+
+ private String securityProvider;
+ private String protocolHandler;
+ private String uddiVersion;
+ private String uddiNamespace;
+
+ private ObjectFactory objectFactory = new ObjectFactory();
+
+ private Marshaller marshaller = null;
+ private Unmarshaller unmarshaller = null;
+
+ private static Log log = LogFactory.getLog(RegistryV3Impl.class);
+
+ /**
+ * Creates a new instance of RegistryImpl.
+ */
+ public RegistryV3Impl(Properties props) {
+ super();
+
+ this.init(props);
+ }
+
+ /**
+ *
+ */
+ private void init(Properties props) {
+ // We need to have a non-null Properties
+ // instance so initialization takes place.
+ if (props == null)
+ props = new Properties();
+
+ // Override defaults with specific specific values
+ try {
+ String iURL = props.getProperty(INQUIRY_ENDPOINT_PROPERTY_NAME);
+ if (iURL != null)
+ this.setInquiryURI(new URI(iURL));
+ else
+ this.setInquiryURI(new URI(DEFAULT_INQUIRY_ENDPOINT));
+
+ String pURL = props.getProperty(PUBLISH_ENDPOINT_PROPERTY_NAME);
+ if (pURL != null)
+ this.setPublishURI(new URI(pURL));
+ else
+ this.setPublishURI(new URI(DEFAULT_PUBLISH_ENDPOINT));
+
+ String sURL = props.getProperty(SECURITY_ENDPOINT_PROPERTY_NAME);
+ if (sURL != null)
+ this.setSecurityURI(new URI(sURL));
+ else
+ this.setSecurityURI(new URI(DEFAULT_SECURITY_ENDPOINT));
+
+ String aURL = props.getProperty(ADMIN_ENDPOINT_PROPERTY_NAME);
+ if (aURL != null)
+ this.setAdminURI(new URI(aURL));
+ else
+ this.setAdminURI(new URI(DEFAULT_ADMIN_ENDPOINT));
+ } catch (URISyntaxException muex) {
+ throw new RuntimeException(muex);
+ }
+
+ String secProvider = props.getProperty(SECURITY_PROVIDER_PROPERTY_NAME);
+ if (secProvider != null)
+ this.setSecurityProvider(secProvider);
+ else
+ this.setSecurityProvider(DEFAULT_SECURITY_PROVIDER);
+
+ String protoHandler = props.getProperty(PROTOCOL_HANDLER_PROPERTY_NAME);
+ if (protoHandler != null)
+ this.setProtocolHandler(protoHandler);
+ else
+ this.setProtocolHandler(DEFAULT_PROTOCOL_HANDLER);
+
+ String uddiVer = props.getProperty(UDDI_VERSION_PROPERTY_NAME);
+ if (uddiVer != null)
+ this.setUddiVersion(uddiVer);
+ else
+ this.setUddiVersion(DEFAULT_UDDI_VERSION);
+
+ String uddiNS = props.getProperty(UDDI_NAMESPACE_PROPERTY_NAME);
+ if (uddiNS != null)
+ this.setUddiNamespace(uddiNS);
+ else
+ this.setUddiNamespace(DEFAULT_UDDI_NAMESPACE);
+
+ String transClass = props.getProperty(TRANSPORT_CLASS_PROPERTY_NAME);
+ if (transClass != null)
+ this.setTransport(this.getTransport(transClass));
+ else
+ this.setTransport(this.getTransport(DEFAULT_TRANSPORT_CLASS));
+
+ try
+ {
+ JAXBContext context = JAXBContext.newInstance(new Class[] {ObjectFactory.class});
+ JAXBContext v3context = JAXBContext.newInstance(new Class[] {org.uddi.api_v3.ObjectFactory.class});
+ if ("3.0".equals(uddiVer)) {
+ this.unmarshaller = v3context.createUnmarshaller();
+ } else {
+ this.unmarshaller = context.createUnmarshaller();
+ }
+ this.marshaller = context.createMarshaller();
+ }
+ catch(JAXBException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ *
+ * @param uddiRequest
+ * @return String
+ * @throws RegistryV3Exception
+ */
+ public String execute(String uddiRequest, String urltype)
+ throws TransportException {
+ URI endPointURL = null;
+ if (urltype.equalsIgnoreCase("INQUIRY"))
+ endPointURL = this.getInquiryURI();
+ else
+ endPointURL = this.getPublishURI();
+
+ // A SOAP request is made and a SOAP response
+ // is returned.
+
+ return transport.send(uddiRequest, endPointURL);
+ }
+
+ /**
+ *
+ */
+ public JAXBElement<?> execute(JAXBElement<?> uddiRequest, URI endPointURI)
+ throws RegistryV3Exception {
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ Document doc;
+ try {
+ DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+ docBuilderFactory.setNamespaceAware(true);
+ DocumentBuilder docBuilder= docBuilderFactory.newDocumentBuilder();
+ this.marshaller.marshal(uddiRequest, baos);
+ doc = docBuilder.parse(new ByteArrayInputStream(baos.toByteArray()));
+ } catch (SAXException saxe) {
+ throw (new RegistryV3Exception(saxe));
+ } catch (ParserConfigurationException pce) {
+ throw (new RegistryV3Exception(pce));
+ } catch (IOException ioe) {
+ throw (new RegistryV3Exception(ioe));
+ } catch (JAXBException ioe) {
+ throw (new RegistryV3Exception(ioe));
+ }
+ Element request = doc.getDocumentElement();
+
+ request.setAttribute("xmlns", this.getUddiNamespace());
+ if (!"3.0".equals(this.getUddiVersion())) {
+ request.setAttribute("generic", this.getUddiVersion());
+ }
+ //request.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns", this.getUddiNamespace());
+ // A SOAP request is made and a SOAP response
+ // is returned.
+
+ Element response;
+ try {
+ response = transport.send(request, endPointURI);
+ } catch (TransportException te) {
+ throw new RegistryV3Exception(te);
+ }
+ /* if (response.hasAttributes()) {
+ NamedNodeMap am = response.getAttributes();
+ ArrayList<String> al = new ArrayList<String>();
+ for (int i = 0; i < am.getLength(); i++) {
+ Node n = am.item(i);
+ String attribute = n.getNodeName();
+ if (attribute!= null && attribute.startsWith("xmlns")) {
+ al.add(attribute);
+ }
+ }
+ for (String attr : al) {
+ response.removeAttribute(attr);
+ }
+ }*/
+
+ if (response.getNamespaceURI()==null) {
+ response.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns", this.getUddiNamespace());
+ }
+
+ // If we are getting responses from a UDDI v3, remove the xmlns
+
+ // First, let's make sure that a response
+ // (any response) is found in the SOAP Body.
+
+ String responseName = response.getLocalName();
+ if (responseName == null) {
+ throw new RegistryV3Exception("Unsupported response "
+ + "from registry. A value was not present.");
+ }
+
+ // Let's now try to determine which UDDI response
+ // we received and unmarshal it appropriately or
+ // throw a RegistryV3Exception if it's unknown.
+ // Well, we have now determined that something was
+ // returned and it is "a something" that we know
+ // about so let's unmarshal it into a RegistryObject
+ // Next, let's make sure we didn't recieve a SOAP
+ // Fault. If it is a SOAP Fault then throw it
+ // immediately.
+
+ JAXBElement<?> uddiResponse = null;
+ try {
+ uddiResponse = (JAXBElement<?>) unmarshaller.unmarshal(response);
+ } catch (JAXBException xmle) {
+ throw (new RegistryV3Exception(xmle));
+ }
+
+ if (responseName.toLowerCase().equals("fault")) {
+ NodeList nodeList = null;
+
+ // Child Elements
+ String fCode = null;
+ nodeList = response.getElementsByTagName("faultcode");
+ if (nodeList.getLength() > 0)
+ fCode = nodeList.item(0).getNodeValue();
+
+ String fString = null;
+ nodeList = response.getElementsByTagName("faultstring");
+ if (nodeList.getLength() > 0)
+ fString = nodeList.item(0).getNodeValue();
+
+ String fActor = null;
+ nodeList = response.getElementsByTagName("faultactor");
+ if (nodeList.getLength() > 0)
+ fActor = nodeList.item(0).getNodeValue();
+
+ DispositionReport dispRpt = null;
+
+ nodeList = response.getElementsByTagName("detail");
+ if (nodeList.getLength() > 0) {
+ nodeList = ((Element) nodeList.item(0))
+ .getElementsByTagName("dispositionReport");
+ if (nodeList.getLength() > 0) {
+ JAXBElement<DispositionReport> dispRptObj = null;
+ try {
+ dispRptObj = (JAXBElement<DispositionReport>) unmarshaller.unmarshal((Element) nodeList
+ .item(0));
+ } catch (JAXBException xmle) {
+ throw (new RegistryV3Exception(xmle));
+ }
+ dispRpt = dispRptObj.getValue();
+ }
+ }
+
+ RegistryV3Exception e = new RegistryV3Exception(fCode, fString, fActor, dispRpt);
+
+ // Create RegistryV3Exception instance and return
+ throw e;
+ }
+
+ return uddiResponse;
+ }
+
+ /**
+ * @return Returns the adminURL.
+ */
+ public URI getAdminURI() {
+ return this.adminURI;
+ }
+
+ /**
+ * @param url
+ * The adminURL to set.
+ */
+ public void setAdminURI(URI url) {
+ this.adminURI = url;
+ }
+
+ /**
+ * @return Returns the inquiryURL.
+ */
+ public URI getInquiryURI() {
+ return this.inquiryURI;
+ }
+
+ /**
+ * @param inquiryURI
+ * The inquiryURI to set.
+ */
+ public void setInquiryURI(URI inquiryURI) {
+ this.inquiryURI = inquiryURI;
+ }
+
+ /**
+ * @return Returns the protocolHandler.
+ */
+ public String getProtocolHandler() {
+ return this.protocolHandler;
+ }
+
+ /**
+ * @param protocolHandler
+ * The protocolHandler to set.
+ */
+ public void setProtocolHandler(String protocolHandler) {
+ this.protocolHandler = protocolHandler;
+ }
+
+ /**
+ * @return Returns the publishURL.
+ */
+ public URI getPublishURI() {
+ return this.publishURI;
+ }
+
+ /**
+ * @return Returns the publishURL.
+ */
+ public URI getSecurityURI() {
+ return this.securityURI;
+ }
+
+ /**
+ * @param publishURI
+ * The publishURI to set.
+ */
+ public void setPublishURI(URI publishURI) {
+ this.publishURI = publishURI;
+ }
+
+ /**
+ * @param publishURI
+ * The publishURI to set.
+ */
+ public void setSecurityURI(URI securityURI) {
+ this.securityURI = securityURI;
+ }
+
+ /**
+ * @return Returns the securityProvider.
+ */
+ public String getSecurityProvider() {
+ return this.securityProvider;
+ }
+
+ /**
+ * @param securityProvider
+ * The securityProvider to set.
+ */
+ public void setSecurityProvider(String securityProvider) {
+ this.securityProvider = securityProvider;
+ }
+
+ /**
+ * @return Returns the transport.
+ */
+ public Transport getTransport() {
+ return transport;
+ }
+
+ /**
+ * @param transport
+ * The transport to set.
+ */
+ public void setTransport(Transport transport) {
+ this.transport = transport;
+ }
+
+ /**
+ * @return Returns the uddiNS.
+ */
+ public String getUddiNamespace() {
+ return this.uddiNamespace;
+ }
+
+ /**
+ * @param uddiNS
+ * The uddiNS to set.
+ */
+ public void setUddiNamespace(String uddiNS) {
+ this.uddiNamespace = uddiNS;
+ }
+
+ /**
+ * @return Returns the uddiVersion.
+ */
+ public String getUddiVersion() {
+ return this.uddiVersion;
+ }
+
+ /**
+ * @param uddiVersion
+ * The uddiVersion to set.
+ */
+ public void setUddiVersion(String uddiVersion) {
+ this.uddiVersion = uddiVersion;
+ }
+
+ /**
+ * "Used to remove an existing bindingTemplate from the bindingTemplates
+ * collection that is part of a specified businessService structure."
+ *
+ * @exception RegistryV3Exception;
+ */
+ public DispositionReport deleteBinding(String authInfo,
+ String[] bindingKeyArray) throws RegistryV3Exception {
+ DeleteBinding request = this.objectFactory.createDeleteBinding();
+
+ if (authInfo != null) {
+ request.setAuthInfo(authInfo);
+ }
+
+ if (bindingKeyArray != null) {
+ request.getBindingKey().addAll(Arrays.asList(bindingKeyArray));
+ }
+
+ DispositionReport dr;
+ JAXBElement<?> o = execute(this.objectFactory.createDeleteBinding(request), this.getPublishURI());
+ dr = (DispositionReport) o.getValue();
+
+ return dr;
+ }
+
+ /**
+ * "Used to delete registered businessEntity information from the registry."
+ *
+ * @exception RegistryV3Exception;
+ */
+ public DispositionReport deleteBusiness(String authInfo,
+ String[] businessKeyArray) throws RegistryV3Exception {
+ DeleteBusiness request = this.objectFactory.createDeleteBusiness();
+
+ if (authInfo != null) {
+ request.setAuthInfo(authInfo);
+ }
+
+ if (businessKeyArray != null) {
+ request.getBusinessKey().addAll(Arrays.asList(businessKeyArray));
+ }
+
+ DispositionReport dr;
+ JAXBElement<?> o = execute(this.objectFactory.createDeleteBusiness(request), this.getPublishURI());
+ dr = (DispositionReport) o.getValue();
+
+ return dr;
+ }
+
+ /**
+ * @exception RegistryV3Exception;
+ */
+ public DispositionReport deletePublisherAssertions(String authInfo,
+ PublisherAssertion[] assertionArray) throws RegistryV3Exception {
+ DeletePublisherAssertions request = this.objectFactory.createDeletePublisherAssertions();
+
+ if (authInfo != null) {
+ request.setAuthInfo(authInfo);
+ }
+
+ if (assertionArray != null) {
+ request.getPublisherAssertion().addAll(Arrays.asList(assertionArray));
+ }
+
+ DispositionReport dr;
+ JAXBElement<?> o = execute(this.objectFactory.createDeletePublisherAssertions(request),
+ this.getPublishURI());
+ dr = (DispositionReport) o.getValue();
+
+ return dr;
+ }
+
+ /**
+ * "Used to delete an existing businessService from the businessServices
+ * collection that is part of a specified businessEntity."
+ *
+ * @exception RegistryV3Exception;
+ */
+ public DispositionReport deleteService(String authInfo,
+ String[] serviceKeyArray) throws RegistryV3Exception {
+ DeleteService request = this.objectFactory.createDeleteService();
+
+ if (authInfo != null) {
+ request.setAuthInfo(authInfo);
+ }
+
+ if (serviceKeyArray != null) {
+ request.getServiceKey().addAll(Arrays.asList(serviceKeyArray));
+ }
+
+ DispositionReport dr;
+ JAXBElement<?> o = execute(this.objectFactory.createDeleteService(request),
+ this.getPublishURI());
+ dr = (DispositionReport) o.getValue();
+
+ return dr;
+ }
+
+ /**
+ * "Used to delete registered information about a tModel. If there are any
+ * references to a tModel when this call is made, the tModel will be marked
+ * deleted instead of being physically removed."
+ *
+ * @exception RegistryV3Exception;
+ */
+ public DispositionReport deleteTModel(String authInfo,
+ String[] tModelKeyArray) throws RegistryV3Exception {
+ DeleteTModel request = this.objectFactory.createDeleteTModel();
+
+ if (authInfo != null) {
+ request.setAuthInfo(authInfo);
+ }
+
+ if (tModelKeyArray != null) {
+ request.getTModelKey().addAll(Arrays.asList(tModelKeyArray));
+ }
+
+ DispositionReport dr;
+ JAXBElement<?> o = execute(this.objectFactory.createDeleteTModel(request),
+ this.getPublishURI());
+ dr = (DispositionReport) o.getValue();
+
+ return dr;
+ }
+
+ /**
+ * Used to locate information about one or more businesses. Returns a
+ * businessList message that matches the conditions specified.
+ *
+ * @exception RegistryV3Exception;
+ */
+ public BusinessList findBusiness(Name[] nameArray,
+ DiscoveryURLs discoveryURLs, IdentifierBag identifierBag,
+ CategoryBag categoryBag, TModelBag tModelBag,
+ FindQualifiers findQualifiers, int maxRows)
+ throws RegistryV3Exception {
+ FindBusiness request = this.objectFactory.createFindBusiness();
+
+ if (nameArray != null) {
+ request.getName().addAll(Arrays.asList(nameArray));
+ }
+
+ if (discoveryURLs != null) {
+ request.setDiscoveryURLs(discoveryURLs);
+ }
+
+ if (identifierBag != null) {
+ request.setIdentifierBag(identifierBag);
+ }
+
+ if (categoryBag != null) {
+ request.setCategoryBag(categoryBag);
+ }
+
+ if (tModelBag != null) {
+ request.setTModelBag(tModelBag);
+ }
+
+ if (findQualifiers != null) {
+ request.setFindQualifiers(findQualifiers);
+ }
+
+ request.setMaxRows(maxRows);
+
+ BusinessList bl;
+ JAXBElement<?> o = execute(this.objectFactory.createFindBusiness(request),
+ this.getInquiryURI());
+ bl = (BusinessList) o.getValue();
+
+ return bl;
+ }
+
+ /**
+ * "Used to locate specific bindings within a registered businessService.
+ * Returns a bindingDetail message."
+ *
+ * @exception RegistryV3Exception
+ */
+ public BindingDetail findBinding(String serviceKey,
+ CategoryBag categoryBag, TModelBag tModelBag,
+ FindQualifiers findQualifiers, int maxRows)
+ throws RegistryV3Exception {
+ // FIXME: Juddi's methods also set category bag (per uddi spec v3).
+ // However, we are sticking to v2 for now, so categorybag doesn't
+ // exist under FindBinding. It is fine for now, since the incoming
+ // parameter value is always null anyways -- but this may change
+ // in the future.
+
+ FindBinding request = this.objectFactory.createFindBinding();
+
+ if (serviceKey != null) {
+ request.setServiceKey(serviceKey);
+ }
+
+ if (categoryBag != null) {
+ request.setCategoryBag(categoryBag);
+ }
+
+ if (tModelBag != null) {
+ request.setTModelBag(tModelBag);
+ }
+
+ if (findQualifiers != null) {
+ request.setFindQualifiers(findQualifiers);
+ }
+ request.setMaxRows(maxRows);
+
+ BindingDetail bd;
+ JAXBElement<?> o = execute(this.objectFactory.createFindBinding(request),
+ this.getInquiryURI());
+ bd = (BindingDetail) o.getValue();
+
+ return bd;
+ }
+
+ /**
+ * "Used to locate specific services within a registered businessEntity.
+ * Return a serviceList message." From the XML spec (API, p18) it appears
+ * that the name, categoryBag, and tModelBag arguments are mutually
+ * exclusive.
+ *
+ * @exception RegistryV3Exception;
+ */
+ public ServiceList findService(String businessKey, Name[] nameArray,
+ CategoryBag categoryBag, TModelBag tModelBag,
+ FindQualifiers findQualifiers, int maxRows)
+ throws RegistryV3Exception {
+ FindService request = this.objectFactory.createFindService();
+
+ if (businessKey != null) {
+ request.setBusinessKey(businessKey);
+ }
+
+ if (nameArray != null) {
+ request.getName().addAll(Arrays.asList(nameArray));
+ }
+
+ if (categoryBag != null) {
+ request.setCategoryBag(categoryBag);
+ }
+
+ if (tModelBag != null) {
+ request.setTModelBag(tModelBag);
+ }
+
+ if (findQualifiers != null) {
+ request.setFindQualifiers(findQualifiers);
+ }
+
+ request.setMaxRows(maxRows);
+
+ ServiceList sl;
+ JAXBElement<?> o = execute(this.objectFactory.createFindService(request),
+ this.getInquiryURI());
+ sl = (ServiceList) o.getValue();
+
+ return sl;
+ }
+
+ /**
+ * "Used to locate one or more tModel information structures. Returns a
+ * tModelList structure."
+ *
+ * @exception RegistryV3Exception;
+ */
+ public TModelList findTModel(String name, CategoryBag categoryBag,
+ IdentifierBag identifierBag, FindQualifiers findQualifiers,
+ int maxRows) throws RegistryV3Exception {
+ FindTModel request = this.objectFactory.createFindTModel();
+
+ Name jaxbName = this.objectFactory.createName();
+
+ if (name != null) {
+ jaxbName.setValue(name);
+ }
+
+ request.setName(jaxbName);
+
+ if (categoryBag != null) {
+ request.setCategoryBag(categoryBag);
+ }
+
+ if (identifierBag != null) {
+ request.setIdentifierBag(identifierBag);
+ }
+
+ if (findQualifiers != null) {
+ request.setFindQualifiers(findQualifiers);
+ }
+
+ request.setMaxRows(maxRows);
+
+ TModelList tml;
+ JAXBElement<?> o = execute(this.objectFactory.createFindTModel(request),
+ this.getInquiryURI());
+ tml = (TModelList) o.getValue();
+
+ return tml;
+ }
+
+ /**
+ * @exception RegistryV3Exception;
+ */
+ public AssertionStatusReport getAssertionStatusReport(String authInfo,
+ String completionStatus) throws RegistryV3Exception {
+ GetAssertionStatusReport request = this.objectFactory.createGetAssertionStatusReport();
+
+ if (authInfo != null) {
+ request.setAuthInfo(authInfo);
+ }
+
+ if (completionStatus != null) {
+ CompletionStatus cs = CompletionStatus.fromValue(completionStatus);
+ request.setCompletionStatus(cs);
+ }
+
+ AssertionStatusReport asr;
+ JAXBElement<?> o = execute(this.objectFactory.createGetAssertionStatusReport(request),
+ this.getPublishURI());
+ asr = (AssertionStatusReport) o.getValue();
+
+ return asr;
+ }
+
+ /**
+ * "Used to request an authentication token from an Operator Site.
+ * Authentication tokens are required to use all other APIs defined in the
+ * publishers API. This server serves as the program's equivalent of a login
+ * request."
+ *
+ * @exception RegistryV3Exception;
+ */
+ public AuthToken getAuthToken(String userID, String cred)
+ throws RegistryV3Exception {
+ GetAuthToken request = this.objectFactory.createGetAuthToken();
+
+ if (userID != null) {
+ request.setUserID(userID);
+ }
+
+ if (cred != null) {
+ request.setCred(cred);
+ }
+
+ URI getAuthTokenURI = null;
+ if ("3.0".equals(uddiVersion)) {
+ getAuthTokenURI = this.getSecurityURI();
+ } else {
+ getAuthTokenURI = this.getPublishURI();
+ }
+
+ AuthToken at;
+ JAXBElement<?> o = execute(this.objectFactory.createGetAuthToken(request),
+ getAuthTokenURI);
+ at = (AuthToken) o.getValue();
+
+ return at;
+ }
+
+ /**
+ * Used to get the full businessEntity information for a particular business
+ * entity. Returns a businessDetail message.
+ *
+ * @exception RegistryV3Exception;
+ */
+ public BusinessDetail getBusinessDetail(String businessKey)
+ throws RegistryV3Exception {
+ String[] keys = new String[1];
+ keys[0] = businessKey;
+
+ return getBusinessDetail(keys);
+ }
+
+ /**
+ * "Used to get the full businessEntity information for one or more
+ * businesses. Returns a businessDetail message."
+ *
+ * @exception RegistryV3Exception;
+ */
+ public BusinessDetail getBusinessDetail(String[] businessKeyArray)
+ throws RegistryV3Exception {
+ GetBusinessDetail request = this.objectFactory.createGetBusinessDetail();
+
+ if (businessKeyArray != null) {
+ request.getBusinessKey().addAll(Arrays.asList(businessKeyArray));
+ }
+
+ BusinessDetail bd;
+ JAXBElement<?> o = execute(this.objectFactory.createGetBusinessDetail(request),
+ this.getInquiryURI());
+ bd = (BusinessDetail) o.getValue();
+ return bd;
+ }
+
+ /**
+ * @exception RegistryV3Exception;
+ */
+ public PublisherAssertions getPublisherAssertions(String authInfo)
+ throws RegistryV3Exception {
+ GetPublisherAssertions request = this.objectFactory.createGetPublisherAssertions();
+
+ if (authInfo != null) {
+ request.setAuthInfo(authInfo);
+ }
+
+ PublisherAssertions pa = new PublisherAssertions();
+ JAXBElement<?> o = execute(this.objectFactory.createGetPublisherAssertions(request),
+ this.getPublishURI());
+ PublisherAssertionsResponse par = (PublisherAssertionsResponse) o.getValue();
+ List<PublisherAssertion> assertions = par.getPublisherAssertion();
+ for (int i = 0; i < assertions.size(); i++ ) {
+ pa.getPublisherAssertion().add((PublisherAssertion)assertions.get(i));
+ }
+
+ return pa;
+ }
+
+ /**
+ * @exception RegistryV3Exception;
+ */
+ public RegisteredInfo getRegisteredInfo(String authInfo)
+ throws RegistryV3Exception {
+ GetRegisteredInfo request = this.objectFactory.createGetRegisteredInfo();
+
+ if (authInfo != null) {
+ request.setAuthInfo(authInfo);
+ }
+
+ RegisteredInfo ri;
+ JAXBElement<?> o = execute(this.objectFactory.createGetRegisteredInfo(request),
+ this.getPublishURI());
+ ri = (RegisteredInfo) o.getValue();
+
+ return ri;
+ }
+
+ /**
+ * "Used to get full details for a particular registered businessService.
+ * Returns a serviceDetail message."
+ *
+ * @exception RegistryV3Exception;
+ */
+ public ServiceDetail getServiceDetail(String serviceKey)
+ throws RegistryV3Exception {
+ String[] keys = new String[1];
+ keys[0] = serviceKey;
+
+ return getServiceDetail(keys);
+ }
+
+ /**
+ * "Used to get full details for a given set of registered businessService
+ * data. Returns a serviceDetail message."
+ *
+ * @exception RegistryV3Exception;
+ */
+ public ServiceDetail getServiceDetail(String[] serviceKeyArray)
+ throws RegistryV3Exception {
+ GetServiceDetail request = this.objectFactory.createGetServiceDetail();
+
+ if (serviceKeyArray != null) {
+ request.getServiceKey().addAll(Arrays.asList(serviceKeyArray));
+ }
+
+ ServiceDetail sd;
+ JAXBElement<?> o = execute(this.objectFactory.createGetServiceDetail(request),
+ this.getInquiryURI());
+ sd = (ServiceDetail) o.getValue();
+
+ return sd;
+ }
+
+ /**
+ * "Used to get full details for a particular registered TModel. Returns a
+ * tModelDetail message."
+ *
+ * @exception RegistryV3Exception;
+ */
+ public TModelDetail getTModelDetail(String tModelKey)
+ throws RegistryV3Exception {
+ String[] keys = new String[1];
+ keys[0] = tModelKey;
+
+ return getTModelDetail(keys);
+ }
+
+ /**
+ * "Used to get full details for a given set of registered tModel data.
+ * Returns a tModelDetail message."
+ *
+ * @exception RegistryV3Exception;
+ */
+ public TModelDetail getTModelDetail(String[] tModelKeyArray)
+ throws RegistryV3Exception {
+ GetTModelDetail request = this.objectFactory.createGetTModelDetail();
+
+ if (tModelKeyArray != null) {
+ request.getTModelKey().addAll(Arrays.asList(tModelKeyArray));
+ }
+
+ TModelDetail tmd;
+ JAXBElement<?> o = execute(this.objectFactory.createGetTModelDetail(request),
+ this.getInquiryURI());
+ tmd = (TModelDetail) o.getValue();
+
+ return tmd;
+ }
+
+ /**
+ * @exception RegistryV3Exception;
+ */
+ public PublisherAssertions setPublisherAssertions(String authInfo,
+ PublisherAssertion[] assertionArray) throws RegistryV3Exception {
+ SetPublisherAssertions request = this.objectFactory.createSetPublisherAssertions();
+
+ if (authInfo != null) {
+ request.setAuthInfo(authInfo);
+ }
+
+ if (assertionArray != null) {
+ request.getPublisherAssertion().addAll(Arrays.asList(assertionArray));
+ }
+
+ PublisherAssertions pa;
+ JAXBElement<?> o = execute(this.objectFactory.createSetPublisherAssertions(request),
+ this.getPublishURI());
+ pa = (PublisherAssertions) o.getValue();
+
+ return pa;
+ }
+
+ /**
+ * "Used to register new bindingTemplate information or update existing
+ * bindingTemplate information. Use this to control information about
+ * technical capabilities exposed by a registered business."
+ *
+ * @exception RegistryV3Exception;
+ */
+ public BindingDetail saveBinding(String authInfo,
+ BindingTemplate[] bindingArray) throws RegistryV3Exception {
+ SaveBinding request = this.objectFactory.createSaveBinding();
+
+ if (authInfo != null) {
+ request.setAuthInfo(authInfo);
+ }
+
+ if (bindingArray != null) {
+ request.getBindingTemplate().addAll(Arrays.asList(bindingArray));
+ }
+
+ BindingDetail bd;
+ JAXBElement<?> o = execute(this.objectFactory.createSaveBinding(request),
+ this.getPublishURI());
+ bd = (BindingDetail) o.getValue();
+
+ return bd;
+ }
+
+ /**
+ * "Used to register new businessEntity information or update existing
+ * businessEntity information. Use this to control the overall information
+ * about the entire business. Of the save_x APIs this one has the broadest
+ * effect."
+ *
+ * @exception RegistryV3Exception;
+ */
+ public BusinessDetail saveBusiness(String authInfo,
+ BusinessEntity[] businessArray) throws RegistryV3Exception {
+ SaveBusiness request = this.objectFactory.createSaveBusiness();
+
+ if (authInfo != null) {
+ request.setAuthInfo(authInfo);
+ }
+
+ if (businessArray != null) {
+ for (int i = 0; i < businessArray.length; i++) {
+ BusinessEntity be = businessArray[i];
+ if (be.getBusinessServices().getBusinessService().size() == 0) {
+ be.setBusinessServices(null);
+ }
+ }
+
+ request.getBusinessEntity().addAll(Arrays.asList(businessArray));
+ }
+
+ BusinessDetail bd;
+ JAXBElement<?> o = execute(this.objectFactory.createSaveBusiness(request),
+ this.getPublishURI());
+ bd = (BusinessDetail) o.getValue();
+
+ return bd;
+ }
+
+ /**
+ * "Used to register or update complete information about a businessService
+ * exposed by a specified businessEntity."
+ *
+ * @exception RegistryV3Exception;
+ */
+ public ServiceDetail saveService(String authInfo,
+ BusinessService[] serviceArray) throws RegistryV3Exception {
+ SaveService request = this.objectFactory.createSaveService();
+
+ if (authInfo != null) {
+ request.setAuthInfo(authInfo);
+ }
+
+ if (serviceArray != null) {
+ request.getBusinessService().addAll(Arrays.asList(serviceArray));
+ }
+
+ ServiceDetail sd;
+ JAXBElement<?> o = execute(this.objectFactory.createSaveService(request),
+ this.getPublishURI());
+ sd = (ServiceDetail) o.getValue();
+
+ return sd;
+ }
+
+ /**
+ * "Used to register or update complete information about a tModel."
+ *
+ * @exception RegistryV3Exception;
+ */
+ public TModelDetail saveTModel(String authInfo, TModel[] tModelArray)
+ throws RegistryV3Exception {
+ SaveTModel request = this.objectFactory.createSaveTModel();
+
+ if (authInfo != null) {
+ request.setAuthInfo(authInfo);
+ }
+
+ if (tModelArray != null) {
+ request.getTModel().addAll(Arrays.asList(tModelArray));
+ }
+
+ TModelDetail tmd;
+ JAXBElement<?> o = execute(this.objectFactory.createSaveTModel(request),
+ this.getPublishURI());
+ tmd = (TModelDetail) o.getValue();
+ return tmd;
+ }
+
+ /**
+ * Returns an implementation of Transport based on the className passed in.
+ * If a null value is passed then the default Transport implementation
+ * "org.apache.ws.scout.transport.AxisTransport" is created and returned.
+ *
+ * @return Transport
+ */
+ public Transport getTransport(String className) {
+ Transport transport = null;
+ Class transportClass = null;
+
+ // If a Transport class name isn't supplied use
+ // the default Transport implementation.
+ if (className == null)
+ className = DEFAULT_TRANSPORT_CLASS;
+
+ try {
+ // instruct class loader to load the TransportFactory
+ transportClass = getClassForName(className);
+ } catch (ClassNotFoundException cnfex) {
+ throw new RuntimeException(cnfex);
+ }
+
+ try {
+ // try to instantiate the TransportFactory
+ transport = (Transport) transportClass.newInstance();
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+
+ return transport;
+ }
+
+ /**
+ *
+ * @param name
+ * @return The class object for the name given
+ * @throws ClassNotFoundException
+ * @throws NoClassDefFoundError
+ */
+ public static Class getClassForName(String name)
+ throws ClassNotFoundException, NoClassDefFoundError {
+ Class clazz = null;
+
+ try {
+ // log.info("Using the Context ClassLoader");
+ ClassLoader ccl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+ {
+ public ClassLoader run() {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+
+ clazz = Class.forName(name, true, ccl);
+ } catch (Exception e) {
+ log.debug("Failed to load the class " + name + " with context class loader " + e);
+ }
+
+ if (null == clazz) {
+ ClassLoader scl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+ {
+ public ClassLoader run() {
+ return ClassLoader.getSystemClassLoader();
+ }
+ });
+
+ try {
+ clazz = Class.forName(name, true, scl);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ return clazz;
+ }
+}
diff --git a/src/main/java/org/apache/ws/scout/transport/AxisTransport.java b/src/main/java/org/apache/ws/scout/transport/AxisTransport.java
index c30f95a..967d276 100644
--- a/src/main/java/org/apache/ws/scout/transport/AxisTransport.java
+++ b/src/main/java/org/apache/ws/scout/transport/AxisTransport.java
@@ -19,6 +19,9 @@
import java.net.URI;
import java.util.Vector;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
import org.apache.axis.AxisFault;
import org.apache.axis.Message;
import org.apache.axis.client.Call;
@@ -28,6 +31,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ws.scout.registry.RegistryException;
+import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
@@ -43,7 +47,7 @@
private static Log log = LogFactory.getLog(AxisTransport.class);
public Element send(Element request,URI endpointURL)
- throws RegistryException
+ throws TransportException
{
Service service = null;
Call call = null;
@@ -73,11 +77,11 @@
response = msg.getSOAPEnvelope().getFirstBody().getAsDOM();
}
catch (Exception ex) {
- throw new RegistryException(ex);
+ throw new TransportException(ex);
}
}
catch (Exception ex) {
- throw new RegistryException(ex);
+ throw new TransportException(ex);
}
if (log.isDebugEnabled()) {
@@ -89,7 +93,7 @@
}
public String send(String request,URI endpointURL)
- throws RegistryException
+ throws TransportException
{
Service service = null;
Call call = null;
@@ -116,11 +120,11 @@
response = msg.getSOAPEnvelope().getFirstBody().getAsString();
}
catch (Exception ex) {
- throw new RegistryException(ex);
+ throw new TransportException(ex);
}
}
catch (Exception ex) {
- throw new RegistryException(ex);
+ throw new TransportException(ex);
}
log.debug("\nResponse message:\n" + response);
diff --git a/src/main/java/org/apache/ws/scout/transport/JAXRTransportException.java b/src/main/java/org/apache/ws/scout/transport/JAXRTransportException.java
new file mode 100644
index 0000000..4a2dc6d
--- /dev/null
+++ b/src/main/java/org/apache/ws/scout/transport/JAXRTransportException.java
@@ -0,0 +1,4 @@
+package org.apache.ws.scout.transport;
+
+public class JAXRTransportException extends Exception {
+}
diff --git a/src/main/java/org/apache/ws/scout/transport/LocalTransport.java b/src/main/java/org/apache/ws/scout/transport/LocalTransport.java
index bff62f7..5924443 100644
--- a/src/main/java/org/apache/ws/scout/transport/LocalTransport.java
+++ b/src/main/java/org/apache/ws/scout/transport/LocalTransport.java
@@ -44,7 +44,7 @@
* Sends an element and returns an element.
*/
public Element send(Element request,URI endpointURI)
- throws RegistryException
+ throws TransportException
{
Element response = null;
@@ -64,7 +64,7 @@
response = (Element) node.getFirstChild();
}
catch (Exception ex) {
- throw new RegistryException(ex);
+ throw new TransportException(ex);
}
if (log.isDebugEnabled()) {
log.debug("\nResponse message:\n" + XMLUtils.convertNodeToXMLString(response));
@@ -76,7 +76,7 @@
* Sends an XML, responds with an XML.
*/
public String send(String request,URI endpointURI)
- throws RegistryException
+ throws TransportException
{
String response = null;
log.debug("\nRequest message:\n" + request);
@@ -87,7 +87,7 @@
Element element = document.getDocumentElement();
response= XMLUtils.convertNodeToXMLString(send(element, endpointURI));
} catch (Exception ex) {
- throw new RegistryException(ex);
+ throw new TransportException(ex);
}
log.debug("\nResponse message:\n" + response);
return response;
diff --git a/src/main/java/org/apache/ws/scout/transport/RMITransport.java b/src/main/java/org/apache/ws/scout/transport/RMITransport.java
index e250f74..7f56f3a 100644
--- a/src/main/java/org/apache/ws/scout/transport/RMITransport.java
+++ b/src/main/java/org/apache/ws/scout/transport/RMITransport.java
@@ -47,7 +47,7 @@
* Sends an element and returns an element.
*/
public Element send(Element request,URI endpointURI)
- throws RegistryException
+ throws TransportException
{
Element response = null;
@@ -88,7 +88,7 @@
response = (Element) node.getFirstChild();
}
catch (Exception ex) {
- throw new RegistryException(ex);
+ throw new TransportException(ex);
}
if (log.isDebugEnabled()) {
log.debug("\nResponse message:\n" + XMLUtils.convertNodeToXMLString(response));
@@ -100,7 +100,7 @@
* Sends an XML, responds with an XML.
*/
public String send(String request,URI endpointURI)
- throws RegistryException
+ throws TransportException
{
String response = null;
log.debug("\nRequest message:\n" + request);
@@ -111,7 +111,7 @@
Element element = document.getDocumentElement();
response= XMLUtils.convertNodeToXMLString(send(element, endpointURI));
} catch (Exception ex) {
- throw new RegistryException(ex);
+ throw new TransportException(ex);
}
log.debug("\nResponse message:\n" + response);
return response;
diff --git a/src/main/java/org/apache/ws/scout/transport/Transport.java b/src/main/java/org/apache/ws/scout/transport/Transport.java
index 158531a..665cb46 100644
--- a/src/main/java/org/apache/ws/scout/transport/Transport.java
+++ b/src/main/java/org/apache/ws/scout/transport/Transport.java
@@ -30,8 +30,8 @@
public interface Transport
{
Element send(Element request,URI endPointURI)
- throws RegistryException;
+ throws TransportException;
String send(String request,URI endpointURI)
- throws RegistryException;
+ throws TransportException;
}
diff --git a/src/main/java/org/apache/ws/scout/transport/TransportException.java b/src/main/java/org/apache/ws/scout/transport/TransportException.java
new file mode 100644
index 0000000..6b28443
--- /dev/null
+++ b/src/main/java/org/apache/ws/scout/transport/TransportException.java
@@ -0,0 +1,7 @@
+package org.apache.ws.scout.transport;
+
+public class TransportException extends Exception {
+ public TransportException(Exception e) {
+ super(e);
+ }
+}
diff --git a/src/main/java/org/apache/ws/scout/util/ScoutJaxrUddiV3Helper.java b/src/main/java/org/apache/ws/scout/util/ScoutJaxrUddiV3Helper.java
new file mode 100644
index 0000000..7122ed7
--- /dev/null
+++ b/src/main/java/org/apache/ws/scout/util/ScoutJaxrUddiV3Helper.java
@@ -0,0 +1,931 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ws.scout.util;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.xml.registry.JAXRException;
+import javax.xml.registry.infomodel.Association;
+import javax.xml.registry.infomodel.Classification;
+import javax.xml.registry.infomodel.ClassificationScheme;
+import javax.xml.registry.infomodel.Concept;
+import javax.xml.registry.infomodel.EmailAddress;
+import javax.xml.registry.infomodel.ExternalIdentifier;
+import javax.xml.registry.infomodel.ExternalLink;
+import javax.xml.registry.infomodel.InternationalString;
+import javax.xml.registry.infomodel.Key;
+import javax.xml.registry.infomodel.LocalizedString;
+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.SpecificationLink;
+import javax.xml.registry.infomodel.TelephoneNumber;
+import javax.xml.registry.infomodel.User;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.uddi.api_v3.*;
+import org.apache.ws.scout.registry.infomodel.InternationalStringImpl;
+
+/**
+ * Helper class that does Jaxr->UDDI Mapping
+ *
+ * @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>
+ * @author <a href="mailto:tcunning@apache.org">Tom Cunningham</a>
+ */
+public class ScoutJaxrUddiV3Helper
+{
+ private static final String UDDI_ORG_TYPES = "uuid:C1ACF26D-9672-4404-9D70-39B756E62AB4";
+ private static Log log = LogFactory.getLog(ScoutJaxrUddiV3Helper.class);
+ private static ObjectFactory objectFactory = new ObjectFactory();
+
+ /**
+ * Get UDDI Address given JAXR Postal Address
+ */
+ public static Address getAddress(PostalAddress postalAddress) throws JAXRException {
+ Address address = objectFactory.createAddress();
+
+ AddressLine[] addarr = new AddressLine[6];
+
+ String stnum = postalAddress.getStreetNumber();
+ String st = postalAddress.getStreet();
+ String city = postalAddress.getCity();
+ String country = postalAddress.getCountry();
+ String code = postalAddress.getPostalCode();
+ String state = postalAddress.getStateOrProvince();
+
+ AddressLine stnumAL = objectFactory.createAddressLine();
+ stnumAL.setKeyName("STREET_NUMBER");
+ if (stnum != null) {
+ stnumAL.setKeyValue(stnum);
+ }
+
+ AddressLine stAL = objectFactory.createAddressLine();
+ stAL.setKeyName("STREET");
+ if (st != null) {
+ stAL.setKeyValue(st);
+ }
+
+ AddressLine cityAL = objectFactory.createAddressLine();
+ cityAL.setKeyName("CITY");
+ if (city != null) {
+ cityAL.setKeyValue(city);
+ }
+
+ AddressLine countryAL = objectFactory.createAddressLine();
+ countryAL.setKeyName("COUNTRY");
+ if (country != null) {
+ countryAL.setKeyValue(country);
+ }
+
+ AddressLine codeAL = objectFactory.createAddressLine();
+ codeAL.setKeyName("POSTALCODE");
+ if (code != null) {
+ codeAL.setKeyValue(code);
+ }
+
+ AddressLine stateAL = objectFactory.createAddressLine();
+ stateAL.setKeyName("STATE");
+ if (state != null) {
+ stateAL.setKeyValue(state);
+ }
+
+ // Add the AddressLine to vector
+ addarr[0] = stnumAL;
+ addarr[1] = stAL;
+ addarr[2] = cityAL;
+ addarr[3] = countryAL;
+ addarr[4] = codeAL;
+ addarr[5] = stateAL;
+
+ address.getAddressLine().addAll(Arrays.asList(addarr));
+
+ return address;
+ }
+
+ 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 {
+ 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
+
+ // 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 (tid.getTModelInstanceInfo().size() != 0) {
+ bt.setTModelInstanceDetails(tid);
+ }
+ log.debug("BindingTemplate=" + bt.toString());
+ } catch (Exception ud) {
+ throw new JAXRException("Apache JAXR Impl:", ud);
+ }
+ return bt;
+ }
+
+ public static PublisherAssertion getPubAssertionFromJAXRAssociation(
+ Association association) throws JAXRException {
+ PublisherAssertion pa = objectFactory.createPublisherAssertion();
+ try {
+ if (association.getSourceObject().getKey() != null &&
+ association.getSourceObject().getKey().getId() != null) {
+ pa.setFromKey(association.getSourceObject().getKey().getId());
+ }
+
+ if (association.getTargetObject().getKey() != null &&
+ association.getTargetObject().getKey().getId() != null) {
+ pa.setToKey(association.getTargetObject().getKey().getId());
+ }
+ Concept c = association.getAssociationType();
+ String v = c.getValue();
+ KeyedReference kr = objectFactory.createKeyedReference();
+ Key key = c.getKey();
+ if (key == null) {
+ // TODO:Need to check this. If the concept is a predefined
+ // enumeration, the key can be the parent classification scheme
+ key = c.getClassificationScheme().getKey();
+ }
+ if (key != null && key.getId() != null) {
+ kr.setTModelKey(key.getId());
+ }
+ kr.setKeyName("Concept");
+
+ if (v != null) {
+ kr.setKeyValue(v);
+ }
+
+ pa.setKeyedReference(kr);
+ } catch (Exception ud) {
+ throw new JAXRException("Apache JAXR Impl:", ud);
+ }
+ return pa;
+ }
+
+ public static PublisherAssertion getPubAssertionFromJAXRAssociationKey(
+ String key) throws JAXRException {
+ PublisherAssertion pa = objectFactory.createPublisherAssertion();
+ try {
+ StringTokenizer token = new StringTokenizer(key, ":");
+ if (token.hasMoreTokens()) {
+ pa.setFromKey(getToken(token.nextToken()));
+ pa.setToKey(getToken(token.nextToken()));
+ KeyedReference kr = objectFactory.createKeyedReference();
+ // Sometimes the Key is UUID:something
+ String str = getToken(token.nextToken());
+ if ("UUID".equals(str))
+ str += ":" + getToken(token.nextToken());
+ kr.setTModelKey(str);
+ kr.setKeyName(getToken(token.nextToken()));
+ kr.setKeyValue(getToken(token.nextToken()));
+ pa.setKeyedReference(kr);
+ }
+
+ } catch (Exception ud) {
+ throw new JAXRException("Apache JAXR Impl:", ud);
+ }
+ return pa;
+ }
+
+ public static BusinessService getBusinessServiceFromJAXRService(
+ Service service) throws JAXRException {
+ BusinessService bs = objectFactory.createBusinessService();
+ try {
+ InternationalString iname = service.getName();
+
+ addNames(bs.getName(), iname);
+
+ InternationalString idesc = service.getDescription();
+
+ addDescriptions(bs.getDescription(), idesc);
+
+ Organization o = service.getProvidingOrganization();
+
+ /*
+ * there may not always be a key...
+ */
+ if (o != null) {
+ Key k = o.getKey();
+
+ if (k != null && k.getId() != null) {
+ bs.setBusinessKey(k.getId());
+ }
+
+ } else {
+ /*
+ * gmj - I *think* this is the right thing to do
+ */
+ throw new JAXRException(
+ "Service has no associated organization");
+ }
+
+ if (service.getKey() != null && service.getKey().getId() != null) {
+ bs.setServiceKey(service.getKey().getId());
+ } else {
+ bs.setServiceKey("");
+ }
+
+ CategoryBag catBag = getCategoryBagFromClassifications(service.getClassifications());
+ if (catBag!=null) {
+ bs.setCategoryBag(catBag);
+ }
+
+ //Add the ServiceBinding information
+ BindingTemplates bt = getBindingTemplates(service.getServiceBindings());
+ if (bt != null) {
+ bs.setBindingTemplates(bt);
+ }
+
+ log.debug("BusinessService=" + bs.toString());
+ } catch (Exception ud) {
+ throw new JAXRException("Apache JAXR Impl:", ud);
+ }
+ return bs;
+ }
+
+ public static TModel getTModelFromJAXRClassificationScheme(
+ ClassificationScheme classificationScheme) throws JAXRException {
+ TModel tm = objectFactory.createTModel();
+ try {
+ /*
+ * a fresh scheme might not have a key
+ */
+
+ Key k = classificationScheme.getKey();
+
+ if (k != null && k.getId() != null) {
+ tm.setTModelKey(k.getId());
+ } else {
+ tm.setTModelKey("");
+ }
+
+ /*
+ * There's no reason to believe these are here either
+ */
+
+ Slot s = classificationScheme.getSlot("authorizedName");
+/*
+ if (s != null && s.getName() != null) {
+ tm.setAuthorizedName(s.getName());
+ }
+*/
+ s = classificationScheme.getSlot("operator");
+/*
+ if (s != null && s.getName() != null) {
+ tm.setOperator(s.getName());
+ }
+*/
+ InternationalString iname = classificationScheme.getName();
+
+ tm.setName(getFirstName(iname));
+
+ InternationalString idesc = classificationScheme.getDescription();
+
+ addDescriptions(tm.getDescription(), idesc);
+
+ IdentifierBag idBag = getIdentifierBagFromExternalIdentifiers(classificationScheme.getExternalIdentifiers());
+ if (idBag!=null) {
+ tm.setIdentifierBag(idBag);
+ }
+ CategoryBag catBag = getCategoryBagFromClassifications(classificationScheme.getClassifications());
+ if (catBag!=null) {
+ tm.setCategoryBag(catBag);
+ }
+
+ // ToDO: overviewDoc
+ } catch (Exception ud) {
+ throw new JAXRException("Apache JAXR Impl:", ud);
+ }
+ return tm;
+ }
+
+ public static TModel getTModelFromJAXRConcept(Concept concept)
+ throws JAXRException {
+ TModel tm = objectFactory.createTModel();
+ if (concept == null)
+ return null;
+ try {
+ Key key = concept.getKey();
+ if (key != null && key.getId() != null)
+ tm.setTModelKey(key.getId());
+ Slot sl1 = concept.getSlot("authorizedName");
+ /*
+ if (sl1 != null && sl1.getName() != null)
+ tm.setAuthorizedName(sl1.getName());
+
+ Slot sl2 = concept.getSlot("operator");
+ if (sl2 != null && sl2.getName() != null)
+ tm.setOperator(sl2.getName());
+ */
+ InternationalString iname = concept.getName();
+
+ tm.setName(getFirstName(iname));
+
+ InternationalString idesc = concept.getDescription();
+
+ addDescriptions(tm.getDescription(), idesc);
+
+// External Links
+ Collection<ExternalLink> externalLinks = concept.getExternalLinks();
+ if(externalLinks != null && externalLinks.size() > 0)
+ {
+ tm.getOverviewDoc().add(getOverviewDocFromExternalLink((ExternalLink)externalLinks.iterator().next()));
+ }
+
+ IdentifierBag idBag = getIdentifierBagFromExternalIdentifiers(concept.getExternalIdentifiers());
+ if (idBag!=null) {
+ tm.setIdentifierBag(idBag);
+ }
+ CategoryBag catBag = getCategoryBagFromClassifications(concept.getClassifications());
+ if (catBag!=null) {
+ tm.setCategoryBag(catBag);
+ }
+
+ } catch (Exception ud) {
+ throw new JAXRException("Apache JAXR Impl:", ud);
+ }
+ return tm;
+ }
+
+ private static void addDescriptions(List<Description> descripions, InternationalString idesc) throws JAXRException {
+ if (idesc != null) {
+ for (Object o : idesc.getLocalizedStrings()) {
+ LocalizedString locName = (LocalizedString) o;
+ Description desc = objectFactory.createDescription();
+ descripions.add(desc);
+ desc.setValue(locName.getValue());
+ desc.setLang(locName.getLocale().getLanguage());
+ }
+ }
+ }
+
+ private static Name getFirstName(InternationalString iname) throws JAXRException {
+ for (Object o : iname.getLocalizedStrings()) {
+ LocalizedString locName = (LocalizedString) o;
+ Name name = objectFactory.createName();
+ name.setValue(locName.getValue());
+ name.setLang(locName.getLocale().getLanguage());
+ return name;
+ }
+ return null;
+ }
+ private static void addNames(List<Name> names, InternationalString iname) throws JAXRException {
+ for (Object o : iname.getLocalizedStrings()) {
+ LocalizedString locName = (LocalizedString) o;
+ Name name = objectFactory.createName();
+ name.setValue(locName.getValue());
+ name.setLang(locName.getLocale().getLanguage());
+ names.add(name);
+ }
+ }
+
+ public static BusinessEntity getBusinessEntityFromJAXROrg(Organization organization)
+ throws JAXRException {
+ BusinessEntity biz = objectFactory.createBusinessEntity();
+ BusinessServices bss = objectFactory.createBusinessServices();
+ BusinessService[] barr = new BusinessService[0];
+
+ try {
+ // 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;
+ }
+
+ /**
+ *
+ * Convert JAXR User Object to UDDI Contact
+ */
+ 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;
+ }
+
+ private static String getToken(String tokenstr) {
+ // Token can have the value NULL which need to be converted into null
+ if (tokenstr.equals("NULL"))
+ tokenstr = "";
+ return tokenstr;
+ }
+
+ private static String getUseType(String accessuri) {
+ String acc = accessuri.toLowerCase();
+ String uri = "other";
+ if (acc.startsWith("http:"))
+ uri = "http:";
+ else if (acc.startsWith("https:"))
+ uri = "https:";
+ else if (acc.startsWith("ftp:"))
+ uri = "ftp:";
+ else if (acc.startsWith("phone:"))
+ uri = "phone:";
+
+ 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
+ * name/value pair of the categorization is held in the Concept for internal classifications and the Classification for external (bypassing
+ * the Concept entirely).
+ *
+ * The translation to UDDI is simple. Relevant objects have a category bag which contains a bunch of KeyedReferences (name/value pairs).
+ * These KeyedReferences optionally refer to a tModel that identifies the type of category (translates to the ClassificationScheme key). If
+ * this is set and the tModel doesn't exist in the UDDI registry, then an invalid key error will occur when trying to save the object.
+ *
+ * @param classifications classifications to turn into categories
+ * @throws JAXRException
+ */
+ public static CategoryBag getCategoryBagFromClassifications(Collection classifications) throws JAXRException {
+ try {
+ if (classifications == null || classifications.size()==0)
+ return null;
+
+ // Classifications
+ CategoryBag cbag = objectFactory.createCategoryBag();
+ Iterator classiter = classifications.iterator();
+ while (classiter.hasNext()) {
+ Classification classification = (Classification) classiter.next();
+ if (classification != null ) {
+ KeyedReference keyr = objectFactory.createKeyedReference();
+ cbag.getKeyedReference().add(keyr);
+
+ InternationalStringImpl iname = null;
+ String value = null;
+ ClassificationScheme scheme = classification.getClassificationScheme();
+ 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) {
+ throw new JAXRException("Apache JAXR Impl:", ud);
+ }
+ }
+
+ public static TModelBag getTModelBagFromSpecifications(Collection specifications) throws JAXRException {
+ try {
+ if (specifications == null || specifications.size()==0)
+ return null;
+
+ // Classifications
+ TModelBag tbag = objectFactory.createTModelBag();
+ Iterator speciter = specifications.iterator();
+ while (speciter.hasNext()) {
+ RegistryObject registryobject = (RegistryObject) speciter.next();
+ if (registryobject instanceof SpecificationLink) {
+ SpecificationLink specificationlink = (SpecificationLink) registryobject;
+ if (specificationlink.getSpecificationObject() != null) {
+ RegistryObject ro = specificationlink.getSpecificationObject();
+ if (ro.getKey() != null) {
+ Key key = ro.getKey();
+ tbag.getTModelKey().add(key.toString());
+ }
+ }
+ } else {
+ log.info("ebXML case - the RegistryObject is an ExtrinsicObject, Not implemented");
+ }
+ }
+ return tbag;
+ } catch (Exception ud) {
+ throw new JAXRException("Apache JAXR Impl:", ud);
+ }
+ }
+
+
+ /**
+ * Adds the objects identifiers from JAXR's external identifier collection
+ *
+ * @param identifiers external identifiers to turn into identifiers
+ * @throws JAXRException
+ */
+ public static IdentifierBag getIdentifierBagFromExternalIdentifiers(Collection identifiers) throws JAXRException {
+ try {
+ if (identifiers == null || identifiers.size()==0)
+ return null;
+
+ // Identifiers
+ IdentifierBag ibag = objectFactory.createIdentifierBag();
+ Iterator iditer = identifiers.iterator();
+ while (iditer.hasNext()) {
+ ExternalIdentifier extid = (ExternalIdentifier) iditer.next();
+ if (extid != null ) {
+ KeyedReference keyr = objectFactory.createKeyedReference();
+ ibag.getKeyedReference().add(keyr);
+
+ InternationalStringImpl iname = (InternationalStringImpl) ((RegistryObject) extid).getName();
+ String value = extid.getValue();
+ ClassificationScheme scheme = extid.getIdentificationScheme();
+
+ 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 ibag;
+ } catch (Exception ud) {
+ throw new JAXRException("Apache JAXR Impl:", ud);
+ }
+ }
+
+ 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());
+ od.setOverviewURL(ourl);
+ }
+ InternationalString extDesc = link.getDescription();
+ if(extDesc != null) {
+ Description description = objectFactory.createDescription();
+ od.getDescription().add(description);
+ description.setValue(extDesc.getValue());
+ }
+ return od;
+ }
+
+ private static BindingTemplates getBindingTemplates(Collection serviceBindings)
+ throws JAXRException {
+ BindingTemplates bt = null;
+ if(serviceBindings != null && serviceBindings.size() > 0) {
+ bt = objectFactory.createBindingTemplates();
+ Iterator iter = serviceBindings.iterator();
+ int currLoc = 0;
+ BindingTemplate[] bindingTemplateArray = new BindingTemplate[serviceBindings.size()];
+ while(iter.hasNext()) {
+ ServiceBinding sb = (ServiceBinding)iter.next();
+ bindingTemplateArray[currLoc] = getBindingTemplateFromJAXRSB(sb);
+ currLoc++;
+ }
+ if (bindingTemplateArray != null) {
+ bt.getBindingTemplate().addAll(Arrays.asList(bindingTemplateArray));
+ }
+ }
+ return bt;
+ }
+}
diff --git a/src/main/java/org/apache/ws/scout/util/ScoutUddiV3JaxrHelper.java b/src/main/java/org/apache/ws/scout/util/ScoutUddiV3JaxrHelper.java
new file mode 100644
index 0000000..d49358f
--- /dev/null
+++ b/src/main/java/org/apache/ws/scout/util/ScoutUddiV3JaxrHelper.java
@@ -0,0 +1,601 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ws.scout.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+
+import javax.xml.registry.JAXRException;
+import javax.xml.registry.LifeCycleManager;
+import javax.xml.registry.infomodel.Association;
+import javax.xml.registry.infomodel.Classification;
+import javax.xml.registry.infomodel.ClassificationScheme;
+import javax.xml.registry.infomodel.Concept;
+import javax.xml.registry.infomodel.EmailAddress;
+import javax.xml.registry.infomodel.ExternalIdentifier;
+import javax.xml.registry.infomodel.ExternalLink;
+import javax.xml.registry.infomodel.InternationalString;
+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.SpecificationLink;
+import javax.xml.registry.infomodel.TelephoneNumber;
+import javax.xml.registry.infomodel.User;
+
+import org.uddi.api_v3.*;
+import org.apache.ws.scout.registry.infomodel.AssociationImpl;
+import org.apache.ws.scout.registry.infomodel.ClassificationImpl;
+import org.apache.ws.scout.registry.infomodel.ClassificationSchemeImpl;
+import org.apache.ws.scout.registry.infomodel.ConceptImpl;
+import org.apache.ws.scout.registry.infomodel.EmailAddressImpl;
+import org.apache.ws.scout.registry.infomodel.ExternalIdentifierImpl;
+import org.apache.ws.scout.registry.infomodel.ExternalLinkImpl;
+import org.apache.ws.scout.registry.infomodel.InternationalStringImpl;
+import org.apache.ws.scout.registry.infomodel.KeyImpl;
+import org.apache.ws.scout.registry.infomodel.OrganizationImpl;
+import org.apache.ws.scout.registry.infomodel.PersonNameImpl;
+import org.apache.ws.scout.registry.infomodel.PostalAddressImpl;
+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.TelephoneNumberImpl;
+import org.apache.ws.scout.registry.infomodel.UserImpl;
+
+/**
+ * Helper class that does UDDI->Jaxr Mapping
+ *
+ * @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:tcunning@apache.org">Tom Cunningham</a>
+ */
+public class ScoutUddiV3JaxrHelper
+{
+ public static Association getAssociation(Collection orgs,
+ LifeCycleManager lcm)
+ throws JAXRException
+ {
+ Association asso = new AssociationImpl(lcm);
+ Object[] arr = orgs.toArray();
+ asso.setSourceObject((RegistryObject)arr[0]);
+ asso.setTargetObject((RegistryObject)arr[1]);
+ return asso;
+ }
+
+ public static Organization getOrganization(BusinessEntity businessEntity,
+ LifeCycleManager lifeCycleManager)
+ throws JAXRException
+ {
+ List<Name> namesList = businessEntity.getName();
+ Name n = null;
+ if (namesList.size()>0) n = namesList.get(0);
+
+ List<Description> descriptionList = businessEntity.getDescription();
+ Description desc =null;
+ if (descriptionList.size()>0) desc = descriptionList.get(0);
+
+ Organization org = new OrganizationImpl(lifeCycleManager);
+ if(n != null ) {
+ org.setName(getIString(n.getLang(), n.getValue(), lifeCycleManager));
+ }
+ if( desc != null) {
+ org.setDescription(getIString(desc.getLang(), desc.getValue(), lifeCycleManager));
+ }
+ org.setKey(lifeCycleManager.createKey(businessEntity.getBusinessKey()));
+
+ //Set Services also
+ BusinessServices services = businessEntity.getBusinessServices();
+ if(services != null)
+ {
+ List<BusinessService> bizServiceList = services.getBusinessService();
+ for (BusinessService businessService : bizServiceList) {
+ org.addService(getService(businessService, lifeCycleManager));
+ }
+ }
+
+ /*
+ * 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 = businessEntity.getContacts();
+ if(contacts != null)
+ {
+ List<Contact> contactList = contacts.getContact();
+ if (contactList!=null) {
+ boolean isFirst=true;
+ for (Contact contact : contactList) {
+ User user = new UserImpl(null);
+ List<PersonName> pname = contact.getPersonName();
+ if (pname != null && pname.size() > 0) {
+ String name = pname.get(0).getValue();
+ user.setPersonName(new PersonNameImpl(name));
+ }
+ if (isFirst) {
+ isFirst=false;
+ org.setPrimaryContact(user);
+ } else {
+ org.addUser(user);
+ }
+ }
+ }
+ }
+
+ //External Links
+ DiscoveryURLs durls = businessEntity.getDiscoveryURLs();
+ if (durls != null)
+ {
+ List<DiscoveryURL> discoveryURL_List = durls.getDiscoveryURL();
+ for (DiscoveryURL discoveryURL : discoveryURL_List) {
+ ExternalLink link = new ExternalLinkImpl(lifeCycleManager);
+ link.setExternalURI(discoveryURL.getValue());
+ org.addExternalLink(link);
+ }
+ }
+
+ org.addExternalIdentifiers(getExternalIdentifiers(businessEntity.getIdentifierBag(), lifeCycleManager));
+ org.addClassifications(getClassifications(businessEntity.getCategoryBag(), lifeCycleManager));
+
+ return org;
+ }
+
+
+ public static Organization getOrganization(BusinessDetail bizdetail,
+ LifeCycleManager lifeCycleManager)
+ throws JAXRException
+ {
+ List<BusinessEntity> bizEntityList = bizdetail.getBusinessEntity();
+ if (bizEntityList.size() != 1) {
+ throw new JAXRException("Unexpected count of organizations in BusinessDetail: " + bizEntityList.size());
+ }
+ BusinessEntity entity = bizEntityList.get(0);
+ Name n = null;
+ if (entity.getName().size()>0) n = entity.getName().get(0);
+
+ List<Description> descriptionList = entity.getDescription();
+ Description desc =null;
+ if (descriptionList.size()>0) desc = descriptionList.get(0);
+
+ Organization org = new OrganizationImpl(lifeCycleManager);
+ if( n != null ) {
+ org.setName(getIString(n.getLang(), n.getValue(), lifeCycleManager));
+ }
+ if( desc != null ) {
+ org.setDescription(getIString(desc.getLang(), desc.getValue(), lifeCycleManager));
+ }
+ org.setKey(lifeCycleManager.createKey(entity.getBusinessKey()));
+
+ //Set Services also
+ BusinessServices services = entity.getBusinessServices();
+ if (services != null) {
+ List<BusinessService> bizServiceList = services.getBusinessService();
+ for (BusinessService businessService : bizServiceList) {
+ org.addService(getService(businessService, lifeCycleManager));
+ }
+ }
+
+ /*
+ * 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();
+ if (contacts != null) {
+ List<Contact> contactList = contacts.getContact();
+ boolean isFirst=true;
+ for (Contact contact : contactList) {
+ User user = new UserImpl(null);
+ List<PersonName> pnames = (List<PersonName>) contact.getPersonName();
+ String pname = null;
+ if (pnames != null && pnames.size() > 0) {
+ PersonName personname = pnames.get(0);
+ pname = personname.getValue();
+ }
+ user.setType(contact.getUseType());
+ user.setPersonName(new PersonNameImpl(pname));
+
+ List<Email> emailList = contact.getEmail();
+ ArrayList<EmailAddress> tempEmails = new ArrayList<EmailAddress>();
+ for (Email email : emailList) {
+ tempEmails.add(new EmailAddressImpl(email.getValue(), null));
+ }
+ user.setEmailAddresses(tempEmails);
+
+ List<Address> addressList = contact.getAddress();
+ ArrayList<PostalAddress> tempAddresses = new ArrayList<PostalAddress>();
+ for (Address address : addressList) {
+ ArrayList<AddressLine> addressLineList = new ArrayList<AddressLine>(address.getAddressLine());
+ AddressLine[] alines = new AddressLine[addressLineList.size()];
+ addressLineList.toArray(alines);
+
+ PostalAddress pa = getPostalAddress(alines);
+ tempAddresses.add(pa);
+ }
+ user.setPostalAddresses(tempAddresses);
+
+ List<Phone> phoneList = contact.getPhone();
+ ArrayList<TelephoneNumber> tempPhones = new ArrayList<TelephoneNumber>();
+ for (Phone phone : phoneList) {
+ TelephoneNumberImpl tni = new TelephoneNumberImpl();
+ tni.setType(phone.getUseType());
+ tni.setNumber(phone.getValue());
+ tempPhones.add(tni);
+ }
+ user.setTelephoneNumbers(tempPhones);
+ if (isFirst) {
+ isFirst=false;
+ org.setPrimaryContact(user);
+ } else {
+ org.addUser(user);
+ }
+ }
+ }
+ //External Links
+ DiscoveryURLs durls = entity.getDiscoveryURLs();
+ if (durls != null)
+ {
+ List<DiscoveryURL> discoveryURL_List = durls.getDiscoveryURL();
+ for (DiscoveryURL discoveryURL : discoveryURL_List) {
+ ExternalLink link = new ExternalLinkImpl(lifeCycleManager);
+ link.setExternalURI(discoveryURL.getValue());
+ org.addExternalLink(link);
+ }
+ }
+
+ org.addExternalIdentifiers(getExternalIdentifiers(entity.getIdentifierBag(), lifeCycleManager));
+ org.addClassifications(getClassifications(entity.getCategoryBag(), lifeCycleManager));
+
+ return org;
+ }
+
+ private static PostalAddress getPostalAddress(AddressLine[] addressLineArr) throws JAXRException {
+ PostalAddress pa = new PostalAddressImpl();
+ HashMap<String, String> hm = new HashMap<String, String>();
+ for (AddressLine anAddressLineArr : addressLineArr) {
+ hm.put(anAddressLineArr.getKeyName(), anAddressLineArr.getKeyValue());
+ }
+
+ if (hm.containsKey("STREET_NUMBER")) {
+ pa.setStreetNumber(hm.get("STREET_NUMBER"));
+ }
+
+ if (hm.containsKey("STREET")) {
+ pa.setStreet(hm.get("STREET"));
+ }
+
+ if (hm.containsKey("CITY")) {
+ pa.setCity(hm.get("CITY"));
+ }
+
+ if (hm.containsKey("COUNTRY")) {
+ pa.setCountry(hm.get("COUNTRY"));
+ }
+
+ if (hm.containsKey("POSTALCODE")) {
+ pa.setPostalCode(hm.get("POSTALCODE"));
+ }
+
+ if (hm.containsKey("STATE")) {
+ pa.setStateOrProvince(hm.get("STATE"));
+ }
+
+ return pa;
+ }
+
+ private static InternationalString getIString(String lang, String str, LifeCycleManager lifeCycleManager)
+ throws JAXRException
+ {
+ if (str!=null) {
+ return lifeCycleManager.createInternationalString(getLocale(lang), str);
+ } else {
+ return null;
+ }
+ }
+
+ public static InternationalString getIString(String str, LifeCycleManager lifeCycleManager)
+ throws JAXRException
+ {
+ return lifeCycleManager.createInternationalString(str);
+ }
+
+ public static Service getService(BusinessService businessService, LifeCycleManager lifeCycleManager)
+ throws JAXRException
+ {
+ Service serve = new ServiceImpl(lifeCycleManager);
+
+ String keystr = businessService.getServiceKey();
+
+ if (keystr != null)
+ {
+ serve.setKey(lifeCycleManager.createKey(keystr));
+ }
+
+ Name n = null;
+ if (businessService.getName().size()>0) n = businessService.getName().get(0);
+
+ if (n != null) {
+ String name = n.getValue();
+ serve.setName(lifeCycleManager.createInternationalString(getLocale(n.getLang()), name));
+ }
+
+ Description desc =null;
+ if (businessService.getDescription().size()>0) desc = businessService.getDescription().get(0);
+ if (desc != null ) {
+ serve.setDescription(lifeCycleManager.createInternationalString(getLocale(desc.getLang()), desc.getValue()));
+ }
+
+ //Populate the ServiceBindings for this Service
+ BindingTemplates bts = businessService.getBindingTemplates();
+ if (bts != null) {
+ List<BindingTemplate> bindingTemplateList = bts.getBindingTemplate();
+ for (BindingTemplate bindingTemplate : bindingTemplateList) {
+ serve.addServiceBinding(getServiceBinding(bindingTemplate, lifeCycleManager));
+ }
+ }
+ serve.addClassifications(getClassifications(businessService.getCategoryBag(), lifeCycleManager));
+
+ return serve;
+ }
+
+ public static Service getService(ServiceInfo serviceInfo, LifeCycleManager lifeCycleManager)
+ throws JAXRException
+ {
+ Service service = new ServiceImpl(lifeCycleManager);
+
+ String keystr = serviceInfo.getServiceKey();
+
+ if (keystr != null)
+ {
+ service.setKey(lifeCycleManager.createKey(keystr));
+ }
+
+ Name n = null;
+ if (serviceInfo.getName().size()>0) n = serviceInfo.getName().get(0);
+ if (n != null) {
+ String name = n.getValue();
+ service.setName(lifeCycleManager.createInternationalString(getLocale(n.getLang()), name));
+ }
+ return service;
+ }
+
+ public static ServiceBinding getServiceBinding(BindingTemplate businessTemplate, LifeCycleManager lifeCycleManager)
+ throws JAXRException
+ {
+ ServiceBinding serviceBinding = new ServiceBindingImpl(lifeCycleManager);
+
+ String keystr = businessTemplate.getServiceKey();
+ if (keystr != null)
+ {
+ Service svc = new ServiceImpl(lifeCycleManager);
+ svc.setKey(lifeCycleManager.createKey(keystr));
+ ((ServiceBindingImpl)serviceBinding).setService(svc);
+ }
+ String bindingKey = businessTemplate.getBindingKey();
+ if(bindingKey != null) serviceBinding.setKey(new KeyImpl(bindingKey));
+
+ //Access URI
+ AccessPoint access = businessTemplate.getAccessPoint();
+ if (access != null) serviceBinding.setAccessURI(access.getValue());
+
+ //Description
+ Description desc = null;
+ if (businessTemplate.getDescription().size()>0) desc = businessTemplate.getDescription().get(0);
+ if (desc!=null) {
+ serviceBinding.setDescription(new InternationalStringImpl(desc.getValue()));
+ }
+ /**Section D.10 of JAXR 1.0 Specification */
+
+ TModelInstanceDetails details = businessTemplate.getTModelInstanceDetails();
+ if (details != null) {
+ List<TModelInstanceInfo> tmodelInstanceInfoList = details.getTModelInstanceInfo();
+
+ for (TModelInstanceInfo info: tmodelInstanceInfoList)
+ {
+ if (info!=null && info.getInstanceDetails()!=null) {
+ InstanceDetails idetails = info.getInstanceDetails();
+ Collection<ExternalLink> elinks = getExternalLinks(idetails.getOverviewDoc(),lifeCycleManager);
+ SpecificationLink slink = new SpecificationLinkImpl(lifeCycleManager);
+ slink.addExternalLinks(elinks);
+ serviceBinding.addSpecificationLink(slink);
+
+ ConceptImpl c = new ConceptImpl(lifeCycleManager);
+ c.setExternalLinks(elinks);
+ c.setKey(lifeCycleManager.createKey(info.getTModelKey()));
+ c.setName(lifeCycleManager.createInternationalString(idetails.getInstanceParms()));
+ c.setValue(idetails.getInstanceParms());
+
+ slink.setSpecificationObject(c);
+ }
+ }
+ }
+ HostingRedirector hr = businessTemplate.getHostingRedirector();
+ if(hr != null)
+ {
+ ServiceBinding sb = lifeCycleManager.createServiceBinding();
+ sb.setKey(new KeyImpl(hr.getBindingKey()));
+ serviceBinding.setTargetBinding(sb);
+ }
+
+ return serviceBinding;
+ }
+
+ public static Concept getConcept(TModelDetail tModelDetail, LifeCycleManager lifeCycleManager)
+ throws JAXRException
+ {
+ Concept concept = new ConceptImpl(lifeCycleManager);
+ List<TModel> tmodelList = tModelDetail.getTModel();
+ for (TModel tmodel : tmodelList) {
+ concept.setKey(lifeCycleManager.createKey(tmodel.getTModelKey()));
+ concept.setName(lifeCycleManager.createInternationalString(getLocale(tmodel.getName().getLang()),
+ tmodel.getName().getValue()));
+
+ Description desc = getDescription(tmodel);
+ if( desc != null ) {
+ concept.setDescription(lifeCycleManager.createInternationalString(getLocale(desc.getLang()),
+ desc.getValue()));
+ }
+
+ concept.addExternalIdentifiers(getExternalIdentifiers(tmodel.getIdentifierBag(), lifeCycleManager));
+ concept.addClassifications(getClassifications(tmodel.getCategoryBag(), lifeCycleManager));
+ }
+ return concept;
+ }
+
+ public static Concept getConcept(TModel tmodel, LifeCycleManager lifeCycleManager)
+ throws JAXRException
+ {
+ Concept concept = new ConceptImpl(lifeCycleManager);
+ concept.setKey(lifeCycleManager.createKey(tmodel.getTModelKey()));
+ concept.setName(lifeCycleManager.createInternationalString(getLocale(tmodel.getName().getLang()),
+ tmodel.getName().getValue()));
+
+ Description desc = getDescription(tmodel);
+ if (desc != null) {
+ concept.setDescription(lifeCycleManager.createInternationalString(getLocale(desc.getLang()),
+ desc.getValue()));
+ }
+
+ concept.addExternalIdentifiers(getExternalIdentifiers(tmodel.getIdentifierBag(), lifeCycleManager));
+ concept.addClassifications(getClassifications(tmodel.getCategoryBag(), lifeCycleManager));
+
+ return concept;
+ }
+
+ public static Concept getConcept(TModelInfo tModelInfo, LifeCycleManager lifeCycleManager)
+ throws JAXRException
+ {
+ Concept concept = new ConceptImpl(lifeCycleManager);
+ concept.setKey(lifeCycleManager.createKey(tModelInfo.getTModelKey()));
+ concept.setName(lifeCycleManager.createInternationalString(getLocale(tModelInfo.getName().getLang()),
+ tModelInfo.getName().getValue()));
+
+ return concept;
+ }
+
+ private static Description getDescription( TModel tmodel )
+ {
+ Description desc = null;
+ if (tmodel.getDescription().size()>0) desc=tmodel.getDescription().get(0);
+ return desc;
+ }
+
+ /**
+ * Classifications - going to assume all are external since UDDI does not use "Concepts".
+ * @param categoryBag categories
+ * @param lifeCycleManager lifecycleManager
+ * @return Collection Classifications
+ * @throws JAXRException on error
+ */
+ public static Collection getClassifications(CategoryBag categoryBag, LifeCycleManager lifeCycleManager)
+ throws JAXRException {
+ Collection<Classification> classifications = null;
+ if (categoryBag != null) {
+ classifications = new ArrayList<Classification>();
+ List<KeyedReference> keyedReferenceList = categoryBag.getKeyedReference();
+ for (KeyedReference keyedReference : keyedReferenceList) {
+ Classification classification = new ClassificationImpl(lifeCycleManager);
+ classification.setValue(keyedReference.getKeyValue());
+ classification.setName(new InternationalStringImpl(keyedReference.getKeyName()));
+ String tmodelKey = keyedReference.getTModelKey();
+ if (tmodelKey != null) {
+ ClassificationScheme scheme = new ClassificationSchemeImpl(lifeCycleManager);
+ scheme.setKey(new KeyImpl(tmodelKey));
+ classification.setClassificationScheme(scheme);
+ }
+ classifications.add(classification);
+ }
+ }
+ return classifications;
+ }
+
+ public static Collection<ExternalLink> getExternalLinks(List<OverviewDoc> overviewDocs, LifeCycleManager lifeCycleManager)
+ throws JAXRException
+ {
+ ArrayList<ExternalLink> alist = new ArrayList<ExternalLink>();
+ if((overviewDocs != null) && (overviewDocs.size() != 0))
+ {
+ Iterator docIter = overviewDocs.iterator();
+ while (docIter.hasNext()) {
+ OverviewDoc overviewDoc = (OverviewDoc) docIter.next();
+ String descStr = "";
+ Description desc = null;
+ if (overviewDoc.getDescription().size()>0) desc = overviewDoc.getDescription().get(0);
+ if (desc !=null) descStr = desc.getValue();
+ alist.add(lifeCycleManager.createExternalLink(overviewDoc.getOverviewURL().toString(),descStr));
+
+ }
+ }
+ return alist;
+ }
+
+ /**
+ * External Identifiers
+ * @param identifierBag identifiers
+ * @param lifeCycleManager lifecycleManager
+ * @return Collection ExternalIdentifier
+ * @throws JAXRException on error
+ */
+
+ public static Collection getExternalIdentifiers(IdentifierBag identifierBag, LifeCycleManager lifeCycleManager)
+ throws JAXRException {
+ Collection<ExternalIdentifier> extidentifiers = null;
+ if (identifierBag != null) {
+ extidentifiers = new ArrayList<ExternalIdentifier>();
+
+ List<KeyedReference> keyedReferenceList = identifierBag.getKeyedReference();
+ for (KeyedReference keyedReference : keyedReferenceList) {
+ ExternalIdentifier extId = new ExternalIdentifierImpl(lifeCycleManager);
+ extId.setValue(keyedReference.getKeyValue());
+ extId.setName(new InternationalStringImpl(keyedReference.getKeyName()));
+
+ String tmodelKey = keyedReference.getTModelKey();
+ if (tmodelKey != null) {
+ ClassificationScheme scheme = new ClassificationSchemeImpl(lifeCycleManager);
+ scheme.setKey(new KeyImpl(tmodelKey));
+ extId.setIdentificationScheme(scheme);
+ }
+ extidentifiers.add(extId);
+ }
+ }
+ return extidentifiers;
+ }
+
+ private static Locale getLocale(String lang) {
+ if (lang == null || lang.trim().length() == 0) {
+ return Locale.getDefault();
+ } else if (lang.equalsIgnoreCase(Locale.getDefault().getLanguage())) {
+ return Locale.getDefault();
+ } else {
+ return new Locale(lang);
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/org/apache/ws/scout/BaseTestCase.java b/src/test/java/org/apache/ws/scout/BaseTestCase.java
index 5f04ca5..389653c 100644
--- a/src/test/java/org/apache/ws/scout/BaseTestCase.java
+++ b/src/test/java/org/apache/ws/scout/BaseTestCase.java
@@ -27,6 +27,7 @@
import javax.xml.registry.ConnectionFactory;
import javax.xml.registry.JAXRException;
+import org.apache.ws.scout.registry.RegistryImpl;
/**
* Test to check Jaxr Publish
* Open source UDDI Browser <http://www.uddibrowser.org>
@@ -43,6 +44,8 @@
protected BusinessQueryManager bqm;
//Set some default values
+ protected String uddiversion = RegistryImpl.DEFAULT_UDDI_VERSION;
+ protected String uddinamespace = RegistryImpl.DEFAULT_UDDI_NAMESPACE;
protected String userid = System.getProperty("uddi.test.uid") == null ? "jdoe" : System.getProperty("uddi.test.uid");
protected String passwd = System.getProperty("uddi.test.pass") == null ? "password" : System.getProperty("uddi.test.pass");
@@ -68,6 +71,7 @@
final String INQUERY_URI = scoutProperties.getProperty("inquery.uri");
final String PUBLISH_URI = scoutProperties.getProperty("publish.uri");
+ final String SECURITY_URI = scoutProperties.getProperty("security.uri");
final String TRANSPORT_CLASS = scoutProperties.getProperty("transport.class");
if (scoutProperties.getProperty("userid")!=null) {
@@ -84,6 +88,14 @@
passwd = scoutProperties.getProperty("password2");
}
+ if (scoutProperties.getProperty("scout.proxy.uddiVersion") != null)
+ {
+ uddiversion = scoutProperties.getProperty("scout.proxy.uddiVersion");
+ }
+ if (scoutProperties.getProperty("scout.proxy.uddiNamespace") != null) {
+ uddinamespace = scoutProperties.getProperty("scout.proxy.uddiNamespace");
+ }
+
// Define connection configuration properties
// To query, you need only the query URL
Properties props = new Properties();
@@ -96,12 +108,20 @@
System.getProperty("javax.xml.registry.lifeCycleManagerURL") == null ?
PUBLISH_URI :
System.getProperty("javax.xml.registry.lifeCycleManagerURL"));
+ if ("3.0".equals(uddiversion)) {
+ props.setProperty("javax.xml.registry.securityManagerURL",
+ System.getProperty("javax.xml.registry.securityManagerURL") == null ?
+ SECURITY_URI :
+ System.getProperty("javax.xml.registry.securityManagerURL"));
+ }
props.setProperty("javax.xml.registry.factoryFactoryClass",
"org.apache.ws.scout.? it isregistry.ConnectionFactoryImpl");
props.setProperty("scout.proxy.transportClass", TRANSPORT_CLASS);
props.setProperty("javax.xml.registry.uddi.maxRows", String.valueOf(maxRows));
-
+ props.setProperty("scout.proxy.uddiVersion", uddiversion);
+ props.setProperty("scout.proxy.uddiNamespace", uddinamespace);
+
// Create the connection, passing it the configuration properties
ConnectionFactory factory = ConnectionFactory.newInstance();
factory.setProperties(props);
diff --git a/src/test/java/org/apache/ws/scout/Finder.java b/src/test/java/org/apache/ws/scout/Finder.java
index ff63b8b..5fc8d12 100644
--- a/src/test/java/org/apache/ws/scout/Finder.java
+++ b/src/test/java/org/apache/ws/scout/Finder.java
@@ -31,6 +31,7 @@
import javax.xml.registry.infomodel.Key;
import javax.xml.registry.infomodel.Service;
import javax.xml.registry.infomodel.ServiceBinding;
+import javax.xml.registry.infomodel.SpecificationLink;
/**
* Find RegistryObjects
@@ -41,10 +42,18 @@
public class Finder
{
private BusinessQueryManager bqm;
+ private String uddiVersion;
public Finder(BusinessQueryManager bqm) {
super();
this.bqm = bqm;
+ this.uddiVersion = "2.0";
+ }
+
+ public Finder(BusinessQueryManager bqm, String version) {
+ super();
+ this.bqm = bqm;
+ this.uddiVersion = version;
}
public Collection findOrganizationsByName(String queryStr) throws JAXRException {
@@ -52,8 +61,11 @@
Collection<String> findQualifiers = new ArrayList<String>();
findQualifiers.add(FindQualifier.SORT_BY_NAME_ASC);
Collection<String> namePatterns = new ArrayList<String>();
- namePatterns.add("%" + queryStr + "%");
-
+ if ("3.0".equals(uddiVersion)) {
+ namePatterns.add(queryStr);
+ } else {
+ namePatterns.add("%" + queryStr + "%");
+ }
// Find based upon qualifier type and values
System.out.println("\n-- searching the registry --\n");
BulkResponse response =
@@ -72,8 +84,11 @@
Collection<String> findQualifiers = new ArrayList<String>();
findQualifiers.add(FindQualifier.SORT_BY_NAME_ASC);
Collection<String> namePatterns = new ArrayList<String>();
- namePatterns.add("%" + queryStr + "%");
-
+ if ("3.0".equals(uddiVersion)) {
+ namePatterns.add(queryStr);
+ } else {
+ namePatterns.add("%" + queryStr + "%");
+ }
// Find based upon qualifier type and values
System.out.println("\n-- searching the registry --\n");
BulkResponse response =
@@ -90,7 +105,7 @@
Collection<String> findQualifiers = new ArrayList<String>();
findQualifiers.add(FindQualifier.SORT_BY_NAME_ASC);
Collection<String> namePatterns = new ArrayList<String>();
- namePatterns.add("%" + queryStr + "%");
+ namePatterns.add(queryStr);
// Find based upon qualifier type and values
System.out.println("\n-- searching the registry --\n");
@@ -99,6 +114,9 @@
namePatterns,
null,
null);
+ if ((response == null) || (response.getCollection() == null) || (response.getCollection().size() ==0) ) {
+ return null;
+ }
return (ClassificationScheme) response.getCollection().iterator().next();
}
@@ -160,4 +178,35 @@
return serviceBindings;
}
+ @SuppressWarnings("unchecked")
+ public Collection<ServiceBinding> findServiceBindings(Key serviceKey, Classification classification) throws JAXRException
+ {
+ Collection<ServiceBinding> serviceBindings=null;
+ Collection<String> findQualifiers = new ArrayList<String>();
+ findQualifiers.add(FindQualifier.SORT_BY_NAME_ASC);
+ Collection<Classification> classifications = new ArrayList<Classification>();
+ classifications.add(classification);
+ BulkResponse bulkResponse = bqm.findServiceBindings(serviceKey,findQualifiers,classifications,null);
+ if (bulkResponse.getStatus()==JAXRResponse.STATUS_SUCCESS){
+ serviceBindings = (Collection<ServiceBinding>) bulkResponse.getCollection();
+ }
+ return serviceBindings;
+ }
+
+
+
+ @SuppressWarnings("unchecked")
+ public Collection<ServiceBinding> findServiceBindings(Key serviceKey, SpecificationLink specLink) throws JAXRException
+ {
+ Collection<ServiceBinding> serviceBindings=null;
+ Collection<String> findQualifiers = new ArrayList<String>();
+ findQualifiers.add(FindQualifier.SORT_BY_NAME_ASC);
+ Collection<SpecificationLink> specifications = new ArrayList<SpecificationLink>();
+ specifications.add(specLink);
+ BulkResponse bulkResponse = bqm.findServiceBindings(serviceKey,findQualifiers,null,specifications);
+ if (bulkResponse.getStatus()==JAXRResponse.STATUS_SUCCESS){
+ serviceBindings = (Collection<ServiceBinding>) bulkResponse.getCollection();
+ }
+ return serviceBindings;
+ }
}
diff --git a/src/test/java/org/apache/ws/scout/registry/BusinessLifeCyleManagerlTest.java b/src/test/java/org/apache/ws/scout/registry/BusinessLifeCyleManagerlTest.java
index 6829a81..8a961aa 100644
--- a/src/test/java/org/apache/ws/scout/registry/BusinessLifeCyleManagerlTest.java
+++ b/src/test/java/org/apache/ws/scout/registry/BusinessLifeCyleManagerlTest.java
@@ -28,6 +28,7 @@
import org.junit.Before;
import org.junit.Test;
+
/**
* Tests the BusinessLifecycleManagerImpl class
*/
diff --git a/src/test/java/org/apache/ws/scout/registry/BusinessQueryManagerTest.java b/src/test/java/org/apache/ws/scout/registry/BusinessQueryManagerTest.java
index aca48fb..66282e1 100644
--- a/src/test/java/org/apache/ws/scout/registry/BusinessQueryManagerTest.java
+++ b/src/test/java/org/apache/ws/scout/registry/BusinessQueryManagerTest.java
@@ -13,7 +13,7 @@
public void testFindClassificationSchemeByName() throws JAXRException {
- BusinessQueryManager blm = new BusinessQueryManagerImpl(new RegistryServiceImpl(null, null, -1));
+ BusinessQueryManager blm = new BusinessQueryManagerV3Impl(new RegistryServiceImpl(null, null, -1, "3.0"));
ClassificationScheme scheme = blm.findClassificationSchemeByName(null, "AssociationType");
assertNotNull(scheme);
diff --git a/src/test/java/org/apache/ws/scout/registry/LifeCycleManagerTest.java b/src/test/java/org/apache/ws/scout/registry/LifeCycleManagerTest.java
index f12d0ac..35fa68b 100644
--- a/src/test/java/org/apache/ws/scout/registry/LifeCycleManagerTest.java
+++ b/src/test/java/org/apache/ws/scout/registry/LifeCycleManagerTest.java
@@ -260,6 +260,6 @@
}
protected void setUp() throws Exception {
super.setUp();
- manager = new ConcreteLifeCycleManager(new RegistryServiceImpl(null, null, -1));
+ manager = new ConcreteLifeCycleManager(new RegistryServiceImpl(null, null, -1, "3.0"));
}
}
diff --git a/src/test/java/org/apache/ws/scout/registry/RegistryServiceTest.java b/src/test/java/org/apache/ws/scout/registry/RegistryServiceTest.java
index 0df976a..55dbb70 100644
--- a/src/test/java/org/apache/ws/scout/registry/RegistryServiceTest.java
+++ b/src/test/java/org/apache/ws/scout/registry/RegistryServiceTest.java
@@ -37,7 +37,7 @@
@Before
public void setUp() throws Exception {
- registry = new RegistryServiceImpl(null, null, -1);
+ registry = new RegistryServiceImpl(null, null, -1, "3.0");
}
@Test
diff --git a/src/test/java/org/apache/ws/scout/registry/qa/JAXR030AssociationsTest.java b/src/test/java/org/apache/ws/scout/registry/qa/JAXR030AssociationsTest.java
index 2660b47..6ce7cea 100644
--- a/src/test/java/org/apache/ws/scout/registry/qa/JAXR030AssociationsTest.java
+++ b/src/test/java/org/apache/ws/scout/registry/qa/JAXR030AssociationsTest.java
@@ -230,9 +230,13 @@
Collection<String> findQualifiers = new ArrayList<String>();
findQualifiers.add(FindQualifier.SORT_BY_NAME_ASC);
Collection<String> namePatterns = new ArrayList<String>();
- namePatterns.add("%" + tempSrcOrgName + "%");
- namePatterns.add("%" + tempTgtOrgName + "%");
-
+ if ("3.0".equals(uddiversion)) {
+ namePatterns.add(tempSrcOrgName);
+ namePatterns.add(tempTgtOrgName);
+ } else {
+ namePatterns.add("%" + tempSrcOrgName + "%");
+ namePatterns.add("%" + tempTgtOrgName + "%");
+ }
// Find based upon qualifier type and values
System.out.println("\n-- searching the registry --\n");
BulkResponse response = bqm.findOrganizations(findQualifiers,
diff --git a/src/test/java/org/apache/ws/scout/registry/qa/JAXR050ServiceBindingTest.java b/src/test/java/org/apache/ws/scout/registry/qa/JAXR050ServiceBindingTest.java
index b69c6bc..7589a99 100644
--- a/src/test/java/org/apache/ws/scout/registry/qa/JAXR050ServiceBindingTest.java
+++ b/src/test/java/org/apache/ws/scout/registry/qa/JAXR050ServiceBindingTest.java
@@ -106,9 +106,19 @@
System.out.println("\nCreating service binding...\n");
Key sbKey = createServiceBinding(tmpSvc);
+
+
+ SpecificationLink specLink = blm.createSpecificationLink();
+ Concept concept = null;
+ if ("3.0".equals(uddiversion)) {
+ concept = (Concept)bqm.getRegistryObject("uddi:uddi.org:findqualifier:orlikekeys", BusinessLifeCycleManager.CONCEPT);
+ } else {
+ concept = (Concept)bqm.getRegistryObject("uuid:AD61DE98-4DB8-31B2-A299-A2373DC97212",BusinessLifeCycleManager.CONCEPT);
+ }
+ specLink.setSpecificationObject(concept);
//find serviceBinding
- Collection<ServiceBinding> serviceBindings2 = finder.findServiceBindings(tmpSvcKey );
+ Collection<ServiceBinding> serviceBindings2 = finder.findServiceBindings(tmpSvcKey, specLink);
@SuppressWarnings("unused")
ServiceBinding serviceBinding2 = serviceBindings2.iterator().next();
@@ -141,11 +151,16 @@
RegistryService rs = connection.getRegistryService();
bqm = rs.getBusinessQueryManager();
- Concept concept = (Concept)bqm.getRegistryObject("uuid:AD61DE98-4DB8-31B2-A299-A2373DC97212",BusinessLifeCycleManager.CONCEPT);
+ Concept concept = null;
+ if ("3.0".equals(uddiversion)) {
+ concept = (Concept)bqm.getRegistryObject("uddi:uddi.org:findqualifier:orlikekeys", BusinessLifeCycleManager.CONCEPT);
+ } else {
+ concept = (Concept)bqm.getRegistryObject("uuid:AD61DE98-4DB8-31B2-A299-A2373DC97212",BusinessLifeCycleManager.CONCEPT);
+ }
+
specLink.setSpecificationObject(concept);
serviceBinding.addSpecificationLink(specLink);
-
ArrayList<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>();
serviceBindings.add(serviceBinding);
diff --git a/src/test/java/org/apache/ws/scout/registry/qa/JAXR060RegistryTest.java b/src/test/java/org/apache/ws/scout/registry/qa/JAXR060RegistryTest.java
index 96b8d6a..b78199b 100644
--- a/src/test/java/org/apache/ws/scout/registry/qa/JAXR060RegistryTest.java
+++ b/src/test/java/org/apache/ws/scout/registry/qa/JAXR060RegistryTest.java
@@ -125,7 +125,7 @@
{
RegistryService rs = connection.getRegistryService();
bqm = rs.getBusinessQueryManager();
- Finder finder = new Finder(bqm);
+ Finder finder = new Finder(bqm, uddiversion);
Collection<Organization> orgs = finder.findOrganizationsByName("Red Hat/JBossESB");
Organization org = orgs.iterator().next();
assertEquals("Red Hat/JBossESB", org.getName().getValue());
@@ -135,7 +135,7 @@
try {
RegistryService rs = connection.getRegistryService();
bqm = rs.getBusinessQueryManager();
- Finder finder = new Finder(bqm);
+ Finder finder = new Finder(bqm, uddiversion);
Collection<Organization> orgs = finder.findOrganizationsByName("Not Existing Org");
assertEquals(0, orgs.size());
} catch (JAXRException je) {
@@ -145,7 +145,7 @@
try {
RegistryService rs = connection.getRegistryService();
bqm = rs.getBusinessQueryManager();
- Finder finder = new Finder(bqm);
+ Finder finder = new Finder(bqm, uddiversion);
Collection<Organization> orgs = finder.findOrganizationsByName("Red Hat/JBossESB");
Organization organization = orgs.iterator().next();
@@ -173,7 +173,7 @@
RegistryService rs = connection.getRegistryService();
bqm = rs.getBusinessQueryManager();
blm = rs.getBusinessLifeCycleManager();
- Finder finder = new Finder(bqm);
+ Finder finder = new Finder(bqm, uddiversion);
//Find the service
Service service = finder.findService("registry","Registry Test ServiceName", blm);
assertEquals("Registry Test ServiceName", service.getName().getValue());
@@ -185,7 +185,7 @@
RegistryService rs = connection.getRegistryService();
bqm = rs.getBusinessQueryManager();
blm = rs.getBusinessLifeCycleManager();
- Finder finder = new Finder(bqm);
+ Finder finder = new Finder(bqm, uddiversion);
//Find the service
Service service = finder.findService("registry","Registry Test ServiceName", blm);
@@ -210,7 +210,7 @@
assertEquals(BulkResponse.STATUS_SUCCESS, br2.getStatus());
//Delete one binding
- Collection<ServiceBinding> serviceBindings2 = finder.findServiceBindings(service.getKey());
+ Collection<ServiceBinding> serviceBindings2 = finder.findServiceBindings(service.getKey(),classification);
if ((serviceBindings2 != null) && (serviceBindings2.iterator() != null)
&& (serviceBindings2.iterator().hasNext())) {
ServiceBinding serviceBinding2 = serviceBindings2.iterator().next();
@@ -225,7 +225,7 @@
{
RegistryService rs = connection.getRegistryService();
bqm = rs.getBusinessQueryManager();
- Finder finder = new Finder(bqm);
+ Finder finder = new Finder(bqm, uddiversion);
Collection<Organization> orgs = finder.findOrganizationsByName("Red Hat/JBossESB");
Organization org = orgs.iterator().next();
//Listing out the services and their Bindings
@@ -259,7 +259,7 @@
RegistryService rs = connection.getRegistryService();
bqm = rs.getBusinessQueryManager();
blm = rs.getBusinessLifeCycleManager();
- Finder finder = new Finder(bqm);
+ Finder finder = new Finder(bqm, uddiversion);
//Find the service
Service service = finder.findService("registry","Registry Test ServiceName", blm);
Remover remover = new Remover(blm);
@@ -273,7 +273,7 @@
RegistryService rs = connection.getRegistryService();
bqm = rs.getBusinessQueryManager();
blm = rs.getBusinessLifeCycleManager();
- Finder finder = new Finder(bqm);
+ Finder finder = new Finder(bqm, uddiversion);
Collection<Organization> orgs = finder.findOrganizationsByName("Red Hat/JBossESB");
Organization org = orgs.iterator().next();
Remover remover = new Remover(blm);
diff --git a/src/test/resources/scoutv3.properties-example b/src/test/resources/scoutv3.properties-example
new file mode 100644
index 0000000..cda6ef8
--- /dev/null
+++ b/src/test/resources/scoutv3.properties-example
@@ -0,0 +1,36 @@
+########################################################################################################
+# TRANSPORT
+########################################################################################################
+#local transport
+#inquery.uri =org.apache.juddi.registry.local.InquiryService#inquire
+#publish.uri =org.apache.juddi.registry.local.PublishService#publish
+#transport.class =org.apache.ws.scout.transport.LocalTransport
+#rmi transport
+#inquery.uri =jnp://localhost:1099/InquiryService?org.apache.juddi.registry.rmi.Inquiry#inquire
+#publish.uri =jnp://localhost:1099/PublishService?org.apache.juddi.registry.rmi.Publish#publish
+#transport.class =org.apache.ws.scout.transport.RMITransport
+#axis transport
+inquery.uri =http://localhost:8080/juddi/services/inquiry
+publish.uri =http://localhost:8080/juddi/services/publish
+security.uri =http://localhost:8080/juddi/services/security
+transport.class =org.apache.ws.scout.transport.AxisTransport
+scout.proxy.uddiVersion=3.0
+scout.proxy.uddiNamespace=urn:uddi-org:api_v3
+#axis2 transport
+#inquery.uri =http://localhost:8080/juddi/inquiry
+#publish.uri =http://localhost:8080/juddi/publish
+#transport.class =org.apache.ws.scout.transport.Axis2Transport
+#soap transport
+#inquery.uri =http://kstam.int.atl.jboss.com:9901/uddi/inquiry_v2
+#publish.uri =http://kstam.int.atl.jboss.com:9901/uddi/publish_v2
+#transport.class =org.apache.ws.scout.transport.AxisTransport
+#userid =Administrator
+#password =password
+#
+########################################################################################################
+# SECURITY
+########################################################################################################
+userid =root
+password =root
+
+javax.xml.registry.uddi.maxRows=10