You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scout-dev@ws.apache.org by an...@apache.org on 2009/07/21 04:29:26 UTC
svn commit: r796122 [7/8] - in /webservices/scout/branches/v1.1: ./
jaxr-api/ scout/ scout/src/main/java/org/apache/ws/scout/model/
scout/src/main/java/org/apache/ws/scout/model/uddi/
scout/src/main/java/org/apache/ws/scout/model/uddi/v2/ scout/src/mai...
Modified: webservices/scout/branches/v1.1/scout/src/main/java/org/apache/ws/scout/registry/RegistryImpl.java
URL: http://svn.apache.org/viewvc/webservices/scout/branches/v1.1/scout/src/main/java/org/apache/ws/scout/registry/RegistryImpl.java?rev=796122&r1=796121&r2=796122&view=diff
==============================================================================
--- webservices/scout/branches/v1.1/scout/src/main/java/org/apache/ws/scout/registry/RegistryImpl.java (original)
+++ webservices/scout/branches/v1.1/scout/src/main/java/org/apache/ws/scout/registry/RegistryImpl.java Tue Jul 21 02:29:23 2009
@@ -15,93 +15,69 @@
*/
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.util.Arrays;
import java.util.Properties;
-import javax.xml.namespace.QName;
+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.ws.scout.model.uddi.v2.AssertionStatusReport;
+import org.apache.ws.scout.model.uddi.v2.AuthToken;
+import org.apache.ws.scout.model.uddi.v2.BindingDetail;
+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.BusinessList;
+import org.apache.ws.scout.model.uddi.v2.BusinessService;
+import org.apache.ws.scout.model.uddi.v2.CategoryBag;
+import org.apache.ws.scout.model.uddi.v2.DeleteBinding;
+import org.apache.ws.scout.model.uddi.v2.DeleteBusiness;
+import org.apache.ws.scout.model.uddi.v2.DeletePublisherAssertions;
+import org.apache.ws.scout.model.uddi.v2.DeleteService;
+import org.apache.ws.scout.model.uddi.v2.DeleteTModel;
+import org.apache.ws.scout.model.uddi.v2.DiscoveryURLs;
+import org.apache.ws.scout.model.uddi.v2.DispositionReport;
+import org.apache.ws.scout.model.uddi.v2.FindBinding;
+import org.apache.ws.scout.model.uddi.v2.FindBusiness;
+import org.apache.ws.scout.model.uddi.v2.FindQualifiers;
+import org.apache.ws.scout.model.uddi.v2.FindService;
+import org.apache.ws.scout.model.uddi.v2.FindTModel;
+import org.apache.ws.scout.model.uddi.v2.GetAssertionStatusReport;
+import org.apache.ws.scout.model.uddi.v2.GetAuthToken;
+import org.apache.ws.scout.model.uddi.v2.GetBusinessDetail;
+import org.apache.ws.scout.model.uddi.v2.GetPublisherAssertions;
+import org.apache.ws.scout.model.uddi.v2.GetRegisteredInfo;
+import org.apache.ws.scout.model.uddi.v2.GetServiceDetail;
+import org.apache.ws.scout.model.uddi.v2.GetTModelDetail;
+import org.apache.ws.scout.model.uddi.v2.IdentifierBag;
+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.RegisteredInfo;
+import org.apache.ws.scout.model.uddi.v2.SaveBinding;
+import org.apache.ws.scout.model.uddi.v2.SaveBusiness;
+import org.apache.ws.scout.model.uddi.v2.SaveService;
+import org.apache.ws.scout.model.uddi.v2.SaveTModel;
+import org.apache.ws.scout.model.uddi.v2.ServiceDetail;
+import org.apache.ws.scout.model.uddi.v2.ServiceList;
+import org.apache.ws.scout.model.uddi.v2.SetPublisherAssertions;
+import org.apache.ws.scout.model.uddi.v2.TModel;
+import org.apache.ws.scout.model.uddi.v2.TModelBag;
+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.uddi.AssertionStatusReport;
-import org.apache.ws.scout.uddi.AssertionStatusReportDocument;
-import org.apache.ws.scout.uddi.AuthToken;
-import org.apache.ws.scout.uddi.AuthTokenDocument;
-import org.apache.ws.scout.uddi.BindingDetail;
-import org.apache.ws.scout.uddi.BindingDetailDocument;
-import org.apache.ws.scout.uddi.BindingTemplate;
-import org.apache.ws.scout.uddi.BusinessDetail;
-import org.apache.ws.scout.uddi.BusinessDetailDocument;
-import org.apache.ws.scout.uddi.BusinessEntity;
-import org.apache.ws.scout.uddi.BusinessList;
-import org.apache.ws.scout.uddi.BusinessListDocument;
-import org.apache.ws.scout.uddi.BusinessService;
-import org.apache.ws.scout.uddi.CategoryBag;
-import org.apache.ws.scout.uddi.DeleteBinding;
-import org.apache.ws.scout.uddi.DeleteBindingDocument;
-import org.apache.ws.scout.uddi.DeleteBusiness;
-import org.apache.ws.scout.uddi.DeleteBusinessDocument;
-import org.apache.ws.scout.uddi.DeletePublisherAssertions;
-import org.apache.ws.scout.uddi.DeletePublisherAssertionsDocument;
-import org.apache.ws.scout.uddi.DeleteService;
-import org.apache.ws.scout.uddi.DeleteServiceDocument;
-import org.apache.ws.scout.uddi.DeleteTModel;
-import org.apache.ws.scout.uddi.DeleteTModelDocument;
-import org.apache.ws.scout.uddi.DiscoveryURLs;
-import org.apache.ws.scout.uddi.DispositionReport;
-import org.apache.ws.scout.uddi.DispositionReportDocument;
-import org.apache.ws.scout.uddi.FindBinding;
-import org.apache.ws.scout.uddi.FindBindingDocument;
-import org.apache.ws.scout.uddi.FindBusiness;
-import org.apache.ws.scout.uddi.FindBusinessDocument;
-import org.apache.ws.scout.uddi.FindQualifiers;
-import org.apache.ws.scout.uddi.FindService;
-import org.apache.ws.scout.uddi.FindServiceDocument;
-import org.apache.ws.scout.uddi.FindTModel;
-import org.apache.ws.scout.uddi.FindTModelDocument;
-import org.apache.ws.scout.uddi.GetAssertionStatusReport;
-import org.apache.ws.scout.uddi.GetAssertionStatusReportDocument;
-import org.apache.ws.scout.uddi.GetAuthToken;
-import org.apache.ws.scout.uddi.GetAuthTokenDocument;
-import org.apache.ws.scout.uddi.GetBusinessDetail;
-import org.apache.ws.scout.uddi.GetBusinessDetailDocument;
-import org.apache.ws.scout.uddi.GetPublisherAssertions;
-import org.apache.ws.scout.uddi.GetPublisherAssertionsDocument;
-import org.apache.ws.scout.uddi.GetServiceDetail;
-import org.apache.ws.scout.uddi.GetServiceDetailDocument;
-import org.apache.ws.scout.uddi.GetTModelDetail;
-import org.apache.ws.scout.uddi.GetTModelDetailDocument;
-import org.apache.ws.scout.uddi.IdentifierBag;
-import org.apache.ws.scout.uddi.Name;
-import org.apache.ws.scout.uddi.PublisherAssertion;
-import org.apache.ws.scout.uddi.PublisherAssertions;
-import org.apache.ws.scout.uddi.PublisherAssertionsDocument;
-import org.apache.ws.scout.uddi.SaveBinding;
-import org.apache.ws.scout.uddi.SaveBindingDocument;
-import org.apache.ws.scout.uddi.SaveBusiness;
-import org.apache.ws.scout.uddi.SaveBusinessDocument;
-import org.apache.ws.scout.uddi.SaveService;
-import org.apache.ws.scout.uddi.SaveServiceDocument;
-import org.apache.ws.scout.uddi.SaveTModel;
-import org.apache.ws.scout.uddi.SaveTModelDocument;
-import org.apache.ws.scout.uddi.ServiceDetail;
-import org.apache.ws.scout.uddi.ServiceDetailDocument;
-import org.apache.ws.scout.uddi.ServiceList;
-import org.apache.ws.scout.uddi.ServiceListDocument;
-import org.apache.ws.scout.uddi.SetPublisherAssertions;
-import org.apache.ws.scout.uddi.SetPublisherAssertionsDocument;
-import org.apache.ws.scout.uddi.TModel;
-import org.apache.ws.scout.uddi.TModelBag;
-import org.apache.ws.scout.uddi.TModelDetail;
-import org.apache.ws.scout.uddi.TModelDetailDocument;
-import org.apache.ws.scout.uddi.TModelList;
-import org.apache.ws.scout.uddi.TModelListDocument;
-import org.apache.xmlbeans.XmlCursor;
-import org.apache.xmlbeans.XmlException;
-import org.apache.xmlbeans.XmlObject;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -149,6 +125,11 @@
private String protocolHandler;
private String uddiVersion;
private String uddiNamespace;
+
+ private ObjectFactory objectFactory = new ObjectFactory();
+
+ private Marshaller marshaller = null;
+ private Unmarshaller unmarshaller = null;
/**
* Creates a new instance of RegistryImpl.
@@ -220,6 +201,17 @@
this.setTransport(this.getTransport(transClass));
else
this.setTransport(this.getTransport(DEFAULT_TRANSPORT_CLASS));
+
+ try
+ {
+ JAXBContext context = JAXBContext.newInstance(new Class[] {ObjectFactory.class});
+ this.marshaller = context.createMarshaller();
+ this.unmarshaller = context.createUnmarshaller();
+ }
+ catch(JAXBException e)
+ {
+ throw new RuntimeException(e);
+ }
}
/**
@@ -245,21 +237,26 @@
/**
*
*/
- public XmlObject execute(XmlObject uddiRequest, URI endPointURI)
+ public JAXBElement<?> execute(JAXBElement<?> uddiRequest, URI endPointURI)
throws RegistryException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
Document doc;
try {
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
docBuilderFactory.setNamespaceAware(true);
DocumentBuilder docBuilder= docBuilderFactory.newDocumentBuilder();
- doc = docBuilder.parse(uddiRequest.newInputStream());
+ this.marshaller.marshal(uddiRequest, baos);
+ doc = docBuilder.parse(new ByteArrayInputStream(baos.toByteArray()));
} catch (SAXException saxe) {
throw (new RegistryException(saxe));
} catch (ParserConfigurationException pce) {
throw (new RegistryException(pce));
} catch (IOException ioe) {
throw (new RegistryException(ioe));
+ } catch (JAXBException ioe) {
+ throw (new RegistryException(ioe));
}
Element request = doc.getDocumentElement();
@@ -292,27 +289,10 @@
// Fault. If it is a SOAP Fault then throw it
// immediately.
- XmlObject uddiResponse = null;
+ JAXBElement<?> uddiResponse = null;
try {
- uddiResponse = XmlObject.Factory.parse(response);
- XmlCursor cursor = uddiResponse.newCursor();
- cursor.toNextToken();
- //set the namespace if it is empty here. This is needed for the find_element_user to work.
- if ("".equals(cursor.getName().getNamespaceURI())) {
- cursor.setName(new QName(this.getUddiNamespace(), cursor.getName().getLocalPart()));
- //there seems to have a bug in setName and it will set the next Start with xmlns="".
- //The workaround is to set it to uddiNamespace when it is empty.
- while (cursor.hasNextToken()) {
- cursor.toNextToken();
- if (cursor.isStart()) {
- if ("".equals(cursor.getName().getNamespaceURI())) {
- cursor.setName(new QName(this.getUddiNamespace(), cursor.getName().getLocalPart()));
- }
- }
- }
- cursor.dispose();
- }
- } catch (XmlException xmle) {
+ uddiResponse = (JAXBElement<?>) unmarshaller.unmarshal(response);
+ } catch (JAXBException xmle) {
throw (new RegistryException(xmle));
}
@@ -342,24 +322,19 @@
nodeList = ((Element) nodeList.item(0))
.getElementsByTagName("dispositionReport");
if (nodeList.getLength() > 0) {
- XmlObject dispRptObj = null;
+ JAXBElement<DispositionReport> dispRptObj = null;
try {
- dispRptObj = XmlObject.Factory.parse((Element) nodeList
+ dispRptObj = (JAXBElement<DispositionReport>) unmarshaller.unmarshal((Element) nodeList
.item(0));
- } catch (XmlException xmle) {
+ } catch (JAXBException xmle) {
throw (new RegistryException(xmle));
}
- XmlObject o = dispRptObj.changeType(DispositionReportDocument.type);
- dispRpt = ((DispositionReportDocument) o).getDispositionReport();
+ dispRpt = dispRptObj.getValue();
}
}
RegistryException e = new RegistryException(fCode, fString, fActor, dispRpt);
-
- // FIXME: This should be removed after testing!
- System.err.println("SOAP message:");
- System.err.println(uddiResponse.xmlText());
-
+
// Create RegistryException instance and return
throw e;
}
@@ -495,21 +470,19 @@
*/
public DispositionReport deleteBinding(String authInfo,
String[] bindingKeyArray) throws RegistryException {
- DeleteBindingDocument doc = DeleteBindingDocument.Factory.newInstance();
- DeleteBinding request = doc.addNewDeleteBinding();
+ DeleteBinding request = this.objectFactory.createDeleteBinding();
if (authInfo != null) {
request.setAuthInfo(authInfo);
}
if (bindingKeyArray != null) {
- request.setBindingKeyArray(bindingKeyArray);
+ request.getBindingKey().addAll(Arrays.asList(bindingKeyArray));
}
DispositionReport dr;
- XmlObject o = execute(doc, this.getPublishURI()).changeType(
- DispositionReportDocument.type);
- dr = ((DispositionReportDocument) o).getDispositionReport();
+ JAXBElement<?> o = execute(this.objectFactory.createDeleteBinding(request), this.getPublishURI());
+ dr = (DispositionReport) o.getValue();;
return dr;
}
@@ -521,22 +494,19 @@
*/
public DispositionReport deleteBusiness(String authInfo,
String[] businessKeyArray) throws RegistryException {
- DeleteBusinessDocument doc = DeleteBusinessDocument.Factory
- .newInstance();
- DeleteBusiness request = doc.addNewDeleteBusiness();
-
+ DeleteBusiness request = this.objectFactory.createDeleteBusiness();
+
if (authInfo != null) {
request.setAuthInfo(authInfo);
}
if (businessKeyArray != null) {
- request.setBusinessKeyArray(businessKeyArray);
+ request.getBusinessKey().addAll(Arrays.asList(businessKeyArray));
}
DispositionReport dr;
- XmlObject o = execute(doc, this.getPublishURI()).changeType(
- DispositionReportDocument.type);
- dr = ((DispositionReportDocument) o).getDispositionReport();
+ JAXBElement<?> o = execute(this.objectFactory.createDeleteBusiness(request), this.getPublishURI());
+ dr = (DispositionReport) o.getValue();
return dr;
}
@@ -546,23 +516,20 @@
*/
public DispositionReport deletePublisherAssertions(String authInfo,
PublisherAssertion[] assertionArray) throws RegistryException {
- DeletePublisherAssertionsDocument doc = DeletePublisherAssertionsDocument.Factory
- .newInstance();
- DeletePublisherAssertions request = doc
- .addNewDeletePublisherAssertions();
+ DeletePublisherAssertions request = this.objectFactory.createDeletePublisherAssertions();
if (authInfo != null) {
request.setAuthInfo(authInfo);
}
if (assertionArray != null) {
- request.setPublisherAssertionArray(assertionArray);
+ request.getPublisherAssertion().addAll(Arrays.asList(assertionArray));
}
DispositionReport dr;
- XmlObject o = execute(doc, this.getPublishURI()).changeType(
- DispositionReportDocument.type);
- dr = ((DispositionReportDocument) o).getDispositionReport();
+ JAXBElement<?> o = execute(this.objectFactory.createDeletePublisherAssertions(request),
+ this.getPublishURI());
+ dr = (DispositionReport) o.getValue();
return dr;
}
@@ -575,21 +542,20 @@
*/
public DispositionReport deleteService(String authInfo,
String[] serviceKeyArray) throws RegistryException {
- DeleteServiceDocument doc = DeleteServiceDocument.Factory.newInstance();
- DeleteService request = doc.addNewDeleteService();
-
+ DeleteService request = this.objectFactory.createDeleteService();
+
if (authInfo != null) {
request.setAuthInfo(authInfo);
}
if (serviceKeyArray != null) {
- request.setServiceKeyArray(serviceKeyArray);
+ request.getServiceKey().addAll(Arrays.asList(serviceKeyArray));
}
DispositionReport dr;
- XmlObject o = execute(doc, this.getPublishURI()).changeType(
- DispositionReportDocument.type);
- dr = ((DispositionReportDocument) o).getDispositionReport();
+ JAXBElement<?> o = execute(this.objectFactory.createDeleteService(request),
+ this.getPublishURI());
+ dr = (DispositionReport) o.getValue();
return dr;
}
@@ -603,21 +569,20 @@
*/
public DispositionReport deleteTModel(String authInfo,
String[] tModelKeyArray) throws RegistryException {
- DeleteTModelDocument doc = DeleteTModelDocument.Factory.newInstance();
- DeleteTModel request = doc.addNewDeleteTModel();
+ DeleteTModel request = this.objectFactory.createDeleteTModel();
if (authInfo != null) {
request.setAuthInfo(authInfo);
}
if (tModelKeyArray != null) {
- request.setTModelKeyArray(tModelKeyArray);
+ request.getTModelKey().addAll(Arrays.asList(tModelKeyArray));
}
DispositionReport dr;
- XmlObject o = execute(doc, this.getPublishURI()).changeType(
- DispositionReportDocument.type);
- dr = ((DispositionReportDocument) o).getDispositionReport();
+ JAXBElement<?> o = execute(this.objectFactory.createDeleteTModel(request),
+ this.getPublishURI());
+ dr = (DispositionReport) o.getValue();
return dr;
}
@@ -633,11 +598,10 @@
CategoryBag categoryBag, TModelBag tModelBag,
FindQualifiers findQualifiers, int maxRows)
throws RegistryException {
- FindBusinessDocument doc = FindBusinessDocument.Factory.newInstance();
- FindBusiness request = doc.addNewFindBusiness();
+ FindBusiness request = this.objectFactory.createFindBusiness();
if (nameArray != null) {
- request.setNameArray(nameArray);
+ request.getName().addAll(Arrays.asList(nameArray));
}
if (discoveryURLs != null) {
@@ -655,7 +619,7 @@
if (tModelBag != null) {
request.setTModelBag(tModelBag);
} else {
- request.setTModelBag(TModelBag.Factory.newInstance());
+ request.setTModelBag(this.objectFactory.createTModelBag());
}
if (findQualifiers != null) {
@@ -665,9 +629,9 @@
request.setMaxRows(maxRows);
BusinessList bl;
- XmlObject o = execute(doc, this.getInquiryURI()).changeType(
- BusinessListDocument.type);
- bl = ((BusinessListDocument) o).getBusinessList();
+ JAXBElement<?> o = execute(this.objectFactory.createFindBusiness(request),
+ this.getInquiryURI());
+ bl = (BusinessList) o.getValue();
return bl;
}
@@ -688,8 +652,7 @@
// parameter value is always null anyways -- but this may change
// in the future.
- FindBindingDocument doc = FindBindingDocument.Factory.newInstance();
- FindBinding request = doc.addNewFindBinding();
+ FindBinding request = this.objectFactory.createFindBinding();
if (serviceKey != null) {
request.setServiceKey(serviceKey);
@@ -698,10 +661,9 @@
if (tModelBag != null) {
request.setTModelBag(tModelBag);
} else {
- TModelBag tmb = TModelBag.Factory.newInstance();
- tmb.setTModelKeyArray(new String[1]);
+ TModelBag tmb = this.objectFactory.createTModelBag();
request.setTModelBag(tmb);
- }
+ }
if (findQualifiers != null) {
request.setFindQualifiers(findQualifiers);
@@ -709,9 +671,9 @@
request.setMaxRows(maxRows);
BindingDetail bd;
- XmlObject o = execute(doc, this.getInquiryURI()).changeType(
- BindingDetailDocument.type);
- bd = ((BindingDetailDocument) o).getBindingDetail();
+ JAXBElement<?> o = execute(this.objectFactory.createFindBinding(request),
+ this.getInquiryURI());
+ bd = (BindingDetail) o.getValue();
return bd;
}
@@ -728,15 +690,14 @@
CategoryBag categoryBag, TModelBag tModelBag,
FindQualifiers findQualifiers, int maxRows)
throws RegistryException {
- FindServiceDocument doc = FindServiceDocument.Factory.newInstance();
- FindService request = doc.addNewFindService();
+ FindService request = this.objectFactory.createFindService();
if (businessKey != null) {
request.setBusinessKey(businessKey);
}
if (nameArray != null) {
- request.setNameArray(nameArray);
+ request.getName().addAll(Arrays.asList(nameArray));
}
if (categoryBag != null) {
@@ -754,9 +715,9 @@
request.setMaxRows(maxRows);
ServiceList sl;
- XmlObject o = execute(doc, this.getInquiryURI()).changeType(
- ServiceListDocument.type);
- sl = ((ServiceListDocument) o).getServiceList();
+ JAXBElement<?> o = execute(this.objectFactory.createFindService(request),
+ this.getInquiryURI());
+ sl = (ServiceList) o.getValue();
return sl;
}
@@ -770,16 +731,15 @@
public TModelList findTModel(String name, CategoryBag categoryBag,
IdentifierBag identifierBag, FindQualifiers findQualifiers,
int maxRows) throws RegistryException {
- FindTModelDocument doc = FindTModelDocument.Factory.newInstance();
- FindTModel request = doc.addNewFindTModel();
+ FindTModel request = this.objectFactory.createFindTModel();
- Name n = Name.Factory.newInstance();
+ Name jaxbName = this.objectFactory.createName();
if (name != null) {
- n.setStringValue(name);
+ jaxbName.setValue(name);
}
- request.setName(n);
+ request.setName(jaxbName);
if (categoryBag != null) {
request.setCategoryBag(categoryBag);
@@ -796,9 +756,9 @@
request.setMaxRows(maxRows);
TModelList tml;
- XmlObject o = execute(doc, this.getInquiryURI()).changeType(
- TModelListDocument.type);
- tml = ((TModelListDocument) o).getTModelList();
+ JAXBElement<?> o = execute(this.objectFactory.createFindTModel(request),
+ this.getInquiryURI());
+ tml = (TModelList) o.getValue();
return tml;
}
@@ -808,9 +768,7 @@
*/
public AssertionStatusReport getAssertionStatusReport(String authInfo,
String completionStatus) throws RegistryException {
- GetAssertionStatusReportDocument doc = GetAssertionStatusReportDocument.Factory
- .newInstance();
- GetAssertionStatusReport request = doc.addNewGetAssertionStatusReport();
+ GetAssertionStatusReport request = this.objectFactory.createGetAssertionStatusReport();
if (authInfo != null) {
request.setAuthInfo(authInfo);
@@ -821,9 +779,9 @@
}
AssertionStatusReport asr;
- XmlObject o = execute(doc, this.getPublishURI()).changeType(
- AssertionStatusReportDocument.type);
- asr = ((AssertionStatusReportDocument) o).getAssertionStatusReport();
+ JAXBElement<?> o = execute(this.objectFactory.createGetAssertionStatusReport(request),
+ this.getPublishURI());
+ asr = (AssertionStatusReport) o.getValue();
return asr;
}
@@ -838,8 +796,7 @@
*/
public AuthToken getAuthToken(String userID, String cred)
throws RegistryException {
- GetAuthTokenDocument doc = GetAuthTokenDocument.Factory.newInstance();
- GetAuthToken request = doc.addNewGetAuthToken();
+ GetAuthToken request = this.objectFactory.createGetAuthToken();
if (userID != null) {
request.setUserID(userID);
@@ -850,9 +807,9 @@
}
AuthToken at;
- XmlObject o = execute(doc, this.getPublishURI()).changeType(
- AuthTokenDocument.type);
- at = ((AuthTokenDocument) o).getAuthToken();
+ JAXBElement<?> o = execute(this.objectFactory.createGetAuthToken(request),
+ this.getPublishURI());
+ at = (AuthToken) o.getValue();
return at;
}
@@ -879,19 +836,16 @@
*/
public BusinessDetail getBusinessDetail(String[] businessKeyArray)
throws RegistryException {
- GetBusinessDetailDocument doc = GetBusinessDetailDocument.Factory
- .newInstance();
- GetBusinessDetail request = doc.addNewGetBusinessDetail();
+ GetBusinessDetail request = this.objectFactory.createGetBusinessDetail();
if (businessKeyArray != null) {
- request.setBusinessKeyArray(businessKeyArray);
+ request.getBusinessKey().addAll(Arrays.asList(businessKeyArray));
}
BusinessDetail bd;
- XmlObject o = execute(doc, this.getInquiryURI()).changeType(
- BusinessDetailDocument.type);
- bd = ((BusinessDetailDocument) o).getBusinessDetail();
-
+ JAXBElement<?> o = execute(this.objectFactory.createGetBusinessDetail(request),
+ this.getInquiryURI());
+ bd = (BusinessDetail) o.getValue();
return bd;
}
@@ -900,23 +854,40 @@
*/
public PublisherAssertions getPublisherAssertions(String authInfo)
throws RegistryException {
- GetPublisherAssertionsDocument doc = GetPublisherAssertionsDocument.Factory
- .newInstance();
- GetPublisherAssertions request = doc.addNewGetPublisherAssertions();
+ GetPublisherAssertions request = this.objectFactory.createGetPublisherAssertions();
if (authInfo != null) {
request.setAuthInfo(authInfo);
}
PublisherAssertions pa;
- XmlObject o = execute(doc, this.getPublishURI()).changeType(
- PublisherAssertionsDocument.type);
- pa = ((PublisherAssertionsDocument) o).getPublisherAssertions();
+ JAXBElement<?> o = execute(this.objectFactory.createGetPublisherAssertions(request),
+ this.getPublishURI());
+ pa = (PublisherAssertions) o.getValue();
return pa;
}
/**
+ * @exception RegistryException;
+ */
+ public RegisteredInfo getRegisteredInfo(String authInfo)
+ throws RegistryException {
+ 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."
*
@@ -938,18 +909,16 @@
*/
public ServiceDetail getServiceDetail(String[] serviceKeyArray)
throws RegistryException {
- GetServiceDetailDocument doc = GetServiceDetailDocument.Factory
- .newInstance();
- GetServiceDetail request = doc.addNewGetServiceDetail();
+ GetServiceDetail request = this.objectFactory.createGetServiceDetail();
if (serviceKeyArray != null) {
- request.setServiceKeyArray(serviceKeyArray);
+ request.getServiceKey().addAll(Arrays.asList(serviceKeyArray));
}
ServiceDetail sd;
- XmlObject o = execute(doc, this.getInquiryURI()).changeType(
- ServiceDetailDocument.type);
- sd = ((ServiceDetailDocument) o).getServiceDetail();
+ JAXBElement<?> o = execute(this.objectFactory.createGetServiceDetail(request),
+ this.getInquiryURI());
+ sd = (ServiceDetail) o.getValue();
return sd;
}
@@ -976,18 +945,16 @@
*/
public TModelDetail getTModelDetail(String[] tModelKeyArray)
throws RegistryException {
- GetTModelDetailDocument doc = GetTModelDetailDocument.Factory
- .newInstance();
- GetTModelDetail request = doc.addNewGetTModelDetail();
+ GetTModelDetail request = this.objectFactory.createGetTModelDetail();
if (tModelKeyArray != null) {
- request.setTModelKeyArray(tModelKeyArray);
+ request.getTModelKey().addAll(Arrays.asList(tModelKeyArray));
}
TModelDetail tmd;
- XmlObject o = execute(doc, this.getInquiryURI()).changeType(
- TModelDetailDocument.type);
- tmd = ((TModelDetailDocument) o).getTModelDetail();
+ JAXBElement<?> o = execute(this.objectFactory.createGetTModelDetail(request),
+ this.getInquiryURI());
+ tmd = (TModelDetail) o.getValue();
return tmd;
}
@@ -997,22 +964,20 @@
*/
public PublisherAssertions setPublisherAssertions(String authInfo,
PublisherAssertion[] assertionArray) throws RegistryException {
- SetPublisherAssertionsDocument doc = SetPublisherAssertionsDocument.Factory
- .newInstance();
- SetPublisherAssertions request = doc.addNewSetPublisherAssertions();
+ SetPublisherAssertions request = this.objectFactory.createSetPublisherAssertions();
if (authInfo != null) {
request.setAuthInfo(authInfo);
}
if (assertionArray != null) {
- request.setPublisherAssertionArray(assertionArray);
+ request.getPublisherAssertion().addAll(Arrays.asList(assertionArray));
}
PublisherAssertions pa;
- XmlObject o = execute(doc, this.getPublishURI()).changeType(
- PublisherAssertionsDocument.type);
- pa = ((PublisherAssertionsDocument) o).getPublisherAssertions();
+ JAXBElement<?> o = execute(this.objectFactory.createSetPublisherAssertions(request),
+ this.getPublishURI());
+ pa = (PublisherAssertions) o.getValue();
return pa;
}
@@ -1026,21 +991,20 @@
*/
public BindingDetail saveBinding(String authInfo,
BindingTemplate[] bindingArray) throws RegistryException {
- SaveBindingDocument doc = SaveBindingDocument.Factory.newInstance();
- SaveBinding request = doc.addNewSaveBinding();
+ SaveBinding request = this.objectFactory.createSaveBinding();
if (authInfo != null) {
request.setAuthInfo(authInfo);
}
if (bindingArray != null) {
- request.setBindingTemplateArray(bindingArray);
+ request.getBindingTemplate().addAll(Arrays.asList(bindingArray));
}
BindingDetail bd;
- XmlObject o = execute(doc, this.getPublishURI()).changeType(
- BindingDetailDocument.type);
- bd = ((BindingDetailDocument) o).getBindingDetail();
+ JAXBElement<?> o = execute(this.objectFactory.createSaveBinding(request),
+ this.getPublishURI());
+ bd = (BindingDetail) o.getValue();
return bd;
}
@@ -1055,21 +1019,20 @@
*/
public BusinessDetail saveBusiness(String authInfo,
BusinessEntity[] businessArray) throws RegistryException {
- SaveBusinessDocument doc = SaveBusinessDocument.Factory.newInstance();
- SaveBusiness request = doc.addNewSaveBusiness();
+ SaveBusiness request = this.objectFactory.createSaveBusiness();
if (authInfo != null) {
request.setAuthInfo(authInfo);
}
if (businessArray != null) {
- request.setBusinessEntityArray(businessArray);
+ request.getBusinessEntity().addAll(Arrays.asList(businessArray));
}
BusinessDetail bd;
- XmlObject o = execute(doc, this.getPublishURI()).changeType(
- BusinessDetailDocument.type);
- bd = ((BusinessDetailDocument) o).getBusinessDetail();
+ JAXBElement<?> o = execute(this.objectFactory.createSaveBusiness(request),
+ this.getPublishURI());
+ bd = (BusinessDetail) o.getValue();
return bd;
}
@@ -1082,21 +1045,20 @@
*/
public ServiceDetail saveService(String authInfo,
BusinessService[] serviceArray) throws RegistryException {
- SaveServiceDocument doc = SaveServiceDocument.Factory.newInstance();
- SaveService request = doc.addNewSaveService();
+ SaveService request = this.objectFactory.createSaveService();
if (authInfo != null) {
request.setAuthInfo(authInfo);
}
if (serviceArray != null) {
- request.setBusinessServiceArray(serviceArray);
+ request.getBusinessService().addAll(Arrays.asList(serviceArray));
}
ServiceDetail sd;
- XmlObject o = execute(doc, this.getPublishURI()).changeType(
- ServiceDetailDocument.type);
- sd = ((ServiceDetailDocument) o).getServiceDetail();
+ JAXBElement<?> o = execute(this.objectFactory.createSaveService(request),
+ this.getPublishURI());
+ sd = (ServiceDetail) o.getValue();
return sd;
}
@@ -1108,22 +1070,20 @@
*/
public TModelDetail saveTModel(String authInfo, TModel[] tModelArray)
throws RegistryException {
- SaveTModelDocument doc = SaveTModelDocument.Factory.newInstance();
- SaveTModel request = doc.addNewSaveTModel();
+ SaveTModel request = this.objectFactory.createSaveTModel();
if (authInfo != null) {
request.setAuthInfo(authInfo);
}
if (tModelArray != null) {
- request.setTModelArray(tModelArray);
+ request.getTModel().addAll(Arrays.asList(tModelArray));
}
TModelDetail tmd;
- XmlObject o = execute(doc, this.getPublishURI()).changeType(
- TModelDetailDocument.type);
- tmd = ((TModelDetailDocument) o).getTModelDetail();
-
+ JAXBElement<?> o = execute(this.objectFactory.createSaveTModel(request),
+ this.getPublishURI());
+ tmd = (TModelDetail) o.getValue();
return tmd;
}
@@ -1186,7 +1146,7 @@
try {
clazz = Class.forName(name, true, scl);
} catch (Exception e) {
- e.printStackTrace();
+ throw new RuntimeException(e);
}
}
Modified: webservices/scout/branches/v1.1/scout/src/main/java/org/apache/ws/scout/registry/infomodel/AssociationImpl.java
URL: http://svn.apache.org/viewvc/webservices/scout/branches/v1.1/scout/src/main/java/org/apache/ws/scout/registry/infomodel/AssociationImpl.java?rev=796122&r1=796121&r2=796122&view=diff
==============================================================================
--- webservices/scout/branches/v1.1/scout/src/main/java/org/apache/ws/scout/registry/infomodel/AssociationImpl.java (original)
+++ webservices/scout/branches/v1.1/scout/src/main/java/org/apache/ws/scout/registry/infomodel/AssociationImpl.java Tue Jul 21 02:29:23 2009
@@ -125,7 +125,7 @@
}
catch (JAXRException e)
{
- e.printStackTrace();
+ throw new RuntimeException(e);
}
if(id != null) key = new KeyImpl(id);
Modified: webservices/scout/branches/v1.1/scout/src/main/java/org/apache/ws/scout/registry/infomodel/ServiceImpl.java
URL: http://svn.apache.org/viewvc/webservices/scout/branches/v1.1/scout/src/main/java/org/apache/ws/scout/registry/infomodel/ServiceImpl.java?rev=796122&r1=796121&r2=796122&view=diff
==============================================================================
--- webservices/scout/branches/v1.1/scout/src/main/java/org/apache/ws/scout/registry/infomodel/ServiceImpl.java (original)
+++ webservices/scout/branches/v1.1/scout/src/main/java/org/apache/ws/scout/registry/infomodel/ServiceImpl.java Tue Jul 21 02:29:23 2009
@@ -20,9 +20,12 @@
import java.util.Collection;
import java.util.Iterator;
+import javax.xml.registry.BusinessQueryManager;
import javax.xml.registry.JAXRException;
import javax.xml.registry.LifeCycleManager;
+import javax.xml.registry.RegistryService;
import javax.xml.registry.UnexpectedObjectException;
+import javax.xml.registry.infomodel.Key;
import javax.xml.registry.infomodel.Organization;
import javax.xml.registry.infomodel.Service;
import javax.xml.registry.infomodel.ServiceBinding;
@@ -38,7 +41,8 @@
private Organization org = null;
private Collection<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>();
-
+ private String orgKey = null;
+
/**
* Creates a new instance of ServiceImpl
*/
@@ -72,7 +76,18 @@
public Organization getProvidingOrganization()
throws JAXRException
{
- if (org == null) return super.getSubmittingOrganization();
+ if (org == null) {
+ if (super.getSubmittingOrganization() != null) {
+ return super.getSubmittingOrganization();
+ } else {
+ RegistryService rs = super.getLifeCycleManager().getRegistryService();
+ BusinessQueryManager bqm = rs.getBusinessQueryManager();
+ Organization o = (Organization) bqm.getRegistryObject(orgKey,
+ LifeCycleManager.ORGANIZATION);
+ setProvidingOrganization(o);
+ return o;
+ }
+ }
return org;
}
@@ -98,4 +113,12 @@
{
this.org = organization;
}
+
+ public void setSubmittingOrganizationKey(String key) {
+ orgKey = key;
+ }
+
+ public String getSubmittingOrganizationKey() {
+ return orgKey;
+ }
}
Modified: webservices/scout/branches/v1.1/scout/src/main/java/org/apache/ws/scout/util/ScoutJaxrUddiHelper.java
URL: http://svn.apache.org/viewvc/webservices/scout/branches/v1.1/scout/src/main/java/org/apache/ws/scout/util/ScoutJaxrUddiHelper.java?rev=796122&r1=796121&r2=796122&view=diff
==============================================================================
--- webservices/scout/branches/v1.1/scout/src/main/java/org/apache/ws/scout/util/ScoutJaxrUddiHelper.java (original)
+++ webservices/scout/branches/v1.1/scout/src/main/java/org/apache/ws/scout/util/ScoutJaxrUddiHelper.java Tue Jul 21 02:29:23 2009
@@ -16,7 +16,7 @@
*/
package org.apache.ws.scout.util;
-import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.StringTokenizer;
@@ -44,36 +44,36 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.ws.scout.model.uddi.v2.AccessPoint;
+import org.apache.ws.scout.model.uddi.v2.Address;
+import org.apache.ws.scout.model.uddi.v2.AddressLine;
+import org.apache.ws.scout.model.uddi.v2.BindingTemplate;
+import org.apache.ws.scout.model.uddi.v2.BindingTemplates;
+import org.apache.ws.scout.model.uddi.v2.BusinessEntity;
+import org.apache.ws.scout.model.uddi.v2.BusinessService;
+import org.apache.ws.scout.model.uddi.v2.BusinessServices;
+import org.apache.ws.scout.model.uddi.v2.CategoryBag;
+import org.apache.ws.scout.model.uddi.v2.Contact;
+import org.apache.ws.scout.model.uddi.v2.Contacts;
+import org.apache.ws.scout.model.uddi.v2.Description;
+import org.apache.ws.scout.model.uddi.v2.DiscoveryURL;
+import org.apache.ws.scout.model.uddi.v2.DiscoveryURLs;
+import org.apache.ws.scout.model.uddi.v2.Email;
+import org.apache.ws.scout.model.uddi.v2.HostingRedirector;
+import org.apache.ws.scout.model.uddi.v2.IdentifierBag;
+import org.apache.ws.scout.model.uddi.v2.InstanceDetails;
+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.OverviewDoc;
+import org.apache.ws.scout.model.uddi.v2.Phone;
+import org.apache.ws.scout.model.uddi.v2.PublisherAssertion;
+import org.apache.ws.scout.model.uddi.v2.TModel;
+import org.apache.ws.scout.model.uddi.v2.TModelBag;
+import org.apache.ws.scout.model.uddi.v2.TModelInstanceDetails;
+import org.apache.ws.scout.model.uddi.v2.TModelInstanceInfo;
+import org.apache.ws.scout.model.uddi.v2.URLType;
import org.apache.ws.scout.registry.infomodel.InternationalStringImpl;
-import org.apache.ws.scout.uddi.AccessPoint;
-import org.apache.ws.scout.uddi.Address;
-import org.apache.ws.scout.uddi.AddressLine;
-import org.apache.ws.scout.uddi.BindingTemplate;
-import org.apache.ws.scout.uddi.BindingTemplates;
-import org.apache.ws.scout.uddi.BusinessEntity;
-import org.apache.ws.scout.uddi.BusinessService;
-import org.apache.ws.scout.uddi.BusinessServices;
-import org.apache.ws.scout.uddi.CategoryBag;
-import org.apache.ws.scout.uddi.Contact;
-import org.apache.ws.scout.uddi.Contacts;
-import org.apache.ws.scout.uddi.Description;
-import org.apache.ws.scout.uddi.DiscoveryURL;
-import org.apache.ws.scout.uddi.DiscoveryURLs;
-import org.apache.ws.scout.uddi.Email;
-import org.apache.ws.scout.uddi.HostingRedirector;
-import org.apache.ws.scout.uddi.IdentifierBag;
-import org.apache.ws.scout.uddi.InstanceDetails;
-import org.apache.ws.scout.uddi.KeyedReference;
-import org.apache.ws.scout.uddi.Name;
-import org.apache.ws.scout.uddi.OverviewDoc;
-import org.apache.ws.scout.uddi.Phone;
-import org.apache.ws.scout.uddi.PublisherAssertion;
-import org.apache.ws.scout.uddi.TModel;
-import org.apache.ws.scout.uddi.TModelBag;
-import org.apache.ws.scout.uddi.TModelInstanceDetails;
-import org.apache.ws.scout.uddi.TModelInstanceInfo;
-import org.apache.ws.scout.uddi.URLType;
-import org.apache.xmlbeans.XmlObject;
/**
* Helper class that does Jaxr->UDDI Mapping
@@ -86,52 +86,54 @@
{
private static final String UDDI_ORG_TYPES = "uuid:C1ACF26D-9672-4404-9D70-39B756E62AB4";
private static Log log = LogFactory.getLog(ScoutJaxrUddiHelper.class);
+ private static ObjectFactory objectFactory = new ObjectFactory();
+
/**
* Get UDDI Address given JAXR Postal Address
*/
- public static Address getAddress(PostalAddress post) throws JAXRException {
- Address address = Address.Factory.newInstance();
+ public static Address getAddress(PostalAddress postalAddress) throws JAXRException {
+ Address address = objectFactory.createAddress();
AddressLine[] addarr = new AddressLine[6];
- String stnum = post.getStreetNumber();
- String st = post.getStreet();
- String city = post.getCity();
- String country = post.getCountry();
- String code = post.getPostalCode();
- String state = post.getStateOrProvince();
+ 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 = AddressLine.Factory.newInstance();
+ AddressLine stnumAL = objectFactory.createAddressLine();
stnumAL.setKeyName("STREET_NUMBER");
if (stnum != null) {
stnumAL.setKeyValue(stnum);
}
- AddressLine stAL = AddressLine.Factory.newInstance();
+ AddressLine stAL = objectFactory.createAddressLine();
stAL.setKeyName("STREET");
if (st != null) {
stAL.setKeyValue(st);
}
- AddressLine cityAL = AddressLine.Factory.newInstance();
+ AddressLine cityAL = objectFactory.createAddressLine();
cityAL.setKeyName("CITY");
if (city != null) {
cityAL.setKeyValue(city);
}
- AddressLine countryAL = AddressLine.Factory.newInstance();
+ AddressLine countryAL = objectFactory.createAddressLine();
countryAL.setKeyName("COUNTRY");
if (country != null) {
countryAL.setKeyValue(country);
}
- AddressLine codeAL = AddressLine.Factory.newInstance();
+ AddressLine codeAL = objectFactory.createAddressLine();
codeAL.setKeyName("POSTALCODE");
if (code != null) {
codeAL.setKeyValue(code);
}
- AddressLine stateAL = AddressLine.Factory.newInstance();
+ AddressLine stateAL = objectFactory.createAddressLine();
stateAL.setKeyName("STATE");
if (state != null) {
stateAL.setKeyValue(state);
@@ -145,32 +147,32 @@
addarr[4] = codeAL;
addarr[5] = stateAL;
- address.setAddressLineArray(addarr);
+ address.getAddressLine().addAll(Arrays.asList(addarr));
return address;
}
public static BindingTemplate getBindingTemplateFromJAXRSB(
- ServiceBinding serve) throws JAXRException {
- BindingTemplate bt = BindingTemplate.Factory.newInstance();
- if (serve.getKey() != null && serve.getKey().getId() != null) {
- bt.setBindingKey(serve.getKey().getId());
+ 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 = serve.getAccessURI();
+ String accessuri = serviceBinding.getAccessURI();
if (accessuri != null) {
- AccessPoint ap = AccessPoint.Factory.newInstance();
- ap.setURLType(getURLType(accessuri));
- ap.setStringValue(accessuri);
- bt.setAccessPoint(ap);
+ AccessPoint accessPoint = objectFactory.createAccessPoint();
+ accessPoint.setURLType(getURLType(accessuri));
+ accessPoint.setValue(accessuri);
+ bt.setAccessPoint(accessPoint);
}
- ServiceBinding sb = serve.getTargetBinding();
+ ServiceBinding sb = serviceBinding.getTargetBinding();
if (sb != null) {
- HostingRedirector red = HostingRedirector.Factory.newInstance();
+ HostingRedirector red = objectFactory.createHostingRedirector();
Key key = sb.getKey();
if (key != null && key.getId() != null) {
red.setBindingKey(key.getId());
@@ -178,58 +180,66 @@
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 = serve.getService();
+ Service svc = serviceBinding.getService();
if (svc != null && svc.getKey() != null && svc.getKey().getId() != null) {
bt.setServiceKey(svc.getKey().getId());
}
- InternationalString idesc = ((RegistryObject) serve).getDescription();
+ InternationalString idesc = ((RegistryObject) serviceBinding).getDescription();
if (idesc != null) {
for (LocalizedString locName : idesc.getLocalizedStrings()) {
- Description desc = bt.addNewDescription();
- desc.setStringValue(locName.getValue());
+ Description desc = objectFactory.createDescription();
+ bt.getDescription().add(desc);
+ desc.setValue(locName.getValue());
desc.setLang(locName.getLocale().getLanguage());
}
}
// SpecificationLink
- Collection<SpecificationLink> slcol = serve.getSpecificationLinks();
- TModelInstanceDetails tid = TModelInstanceDetails.Factory
- .newInstance();
+ 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 = tid
- .addNewTModelInstanceInfo();
+ 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 (LocalizedString locDesc : specificationObject.getDescription().getLocalizedStrings()) {
- Description description = emptyTInfo.addNewDescription();
- description.setStringValue(locDesc.getValue());
+ 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 = emptyTInfo.addNewInstanceDetails();
+ InstanceDetails ids = objectFactory.createInstanceDetails();
+ emptyTInfo.setInstanceDetails(ids);
if (link.getDescription()!=null) {
- Description description = ids.addNewDescription();
- description.setStringValue(link.getDescription().getValue());
+ Description description = objectFactory.createDescription();
+ ids.getDescription().add(description);
+ description.setValue(link.getDescription().getValue());
}
if (link.getExternalURI()!=null) {
- OverviewDoc overviewDoc = ids.addNewOverviewDoc();
+ OverviewDoc overviewDoc = objectFactory.createOverviewDoc();
+ ids.setOverviewDoc(overviewDoc);
overviewDoc.setOverviewURL(link.getExternalURI());
}
}
@@ -246,21 +256,21 @@
}
public static PublisherAssertion getPubAssertionFromJAXRAssociation(
- Association assc) throws JAXRException {
- PublisherAssertion pa = PublisherAssertion.Factory.newInstance();
+ Association association) throws JAXRException {
+ PublisherAssertion pa = objectFactory.createPublisherAssertion();
try {
- if (assc.getSourceObject().getKey() != null &&
- assc.getSourceObject().getKey().getId() != null) {
- pa.setFromKey(assc.getSourceObject().getKey().getId());
+ if (association.getSourceObject().getKey() != null &&
+ association.getSourceObject().getKey().getId() != null) {
+ pa.setFromKey(association.getSourceObject().getKey().getId());
}
- if (assc.getTargetObject().getKey() != null &&
- assc.getTargetObject().getKey().getId() != null) {
- pa.setToKey(assc.getTargetObject().getKey().getId());
+ if (association.getTargetObject().getKey() != null &&
+ association.getTargetObject().getKey().getId() != null) {
+ pa.setToKey(association.getTargetObject().getKey().getId());
}
- Concept c = assc.getAssociationType();
+ Concept c = association.getAssociationType();
String v = c.getValue();
- KeyedReference kr = KeyedReference.Factory.newInstance();
+ KeyedReference kr = objectFactory.createKeyedReference();
Key key = c.getKey();
if (key == null) {
// TODO:Need to check this. If the concept is a predefined
@@ -294,13 +304,13 @@
public static PublisherAssertion getPubAssertionFromJAXRAssociationKey(
String key) throws JAXRException {
- PublisherAssertion pa = PublisherAssertion.Factory.newInstance();
+ 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 = KeyedReference.Factory.newInstance();
+ KeyedReference kr = objectFactory.createKeyedReference();
// Sometimes the Key is UUID:something
String str = getToken(token.nextToken());
if ("UUID".equals(str))
@@ -318,28 +328,30 @@
}
public static BusinessService getBusinessServiceFromJAXRService(
- Service serve) throws JAXRException {
- BusinessService bs = BusinessService.Factory.newInstance();
+ Service service) throws JAXRException {
+ BusinessService bs = objectFactory.createBusinessService();
try {
- InternationalString iname = ((RegistryObject) serve).getName();
+ InternationalString iname = ((RegistryObject) service).getName();
for (LocalizedString locName : iname.getLocalizedStrings()) {
- Name name = bs.addNewName();
- name.setStringValue(locName.getValue());
+ Name name = objectFactory.createName();
+ bs.getName().add(name);
+ name.setValue(locName.getValue());
name.setLang(locName.getLocale().getLanguage());
}
- InternationalString idesc = ((RegistryObject) serve).getDescription();
+ InternationalString idesc = ((RegistryObject) service).getDescription();
if (idesc != null) {
for (LocalizedString locName : idesc.getLocalizedStrings()) {
- Description desc = bs.addNewDescription();
- desc.setStringValue(locName.getValue());
+ Description desc = objectFactory.createDescription();
+ bs.getDescription().add(desc);
+ desc.setValue(locName.getValue());
desc.setLang(locName.getLocale().getLanguage());
}
}
- Organization o = serve.getProvidingOrganization();
+ Organization o = service.getProvidingOrganization();
/*
* there may not always be a key...
@@ -359,19 +371,19 @@
"Service has no associated organization");
}
- if (serve.getKey() != null && serve.getKey().getId() != null) {
- bs.setServiceKey(serve.getKey().getId());
+ if (service.getKey() != null && service.getKey().getId() != null) {
+ bs.setServiceKey(service.getKey().getId());
} else {
bs.setServiceKey("");
}
- CategoryBag catBag = getCategoryBagFromClassifications(serve.getClassifications());
+ CategoryBag catBag = getCategoryBagFromClassifications(service.getClassifications());
if (catBag!=null) {
bs.setCategoryBag(catBag);
}
//Add the ServiceBinding information
- BindingTemplates bt = getBindingTemplates(serve.getServiceBindings());
+ BindingTemplates bt = getBindingTemplates(service.getServiceBindings());
if (bt != null) {
bs.setBindingTemplates(bt);
}
@@ -384,14 +396,14 @@
}
public static TModel getTModelFromJAXRClassificationScheme(
- ClassificationScheme scheme) throws JAXRException {
- TModel tm = TModel.Factory.newInstance();
+ ClassificationScheme classificationScheme) throws JAXRException {
+ TModel tm = objectFactory.createTModel();
try {
/*
* a fresh scheme might not have a key
*/
- Key k = scheme.getKey();
+ Key k = classificationScheme.getKey();
if (k != null && k.getId() != null) {
tm.setTModelKey(k.getId());
@@ -403,41 +415,43 @@
* There's no reason to believe these are here either
*/
- Slot s = scheme.getSlot("authorizedName");
+ Slot s = classificationScheme.getSlot("authorizedName");
if (s != null && s.getName() != null) {
tm.setAuthorizedName(s.getName());
}
- s = scheme.getSlot("operator");
+ s = classificationScheme.getSlot("operator");
if (s != null && s.getName() != null) {
tm.setOperator(s.getName());
}
- InternationalString iname = ((RegistryObject) scheme).getName();
+ InternationalString iname = ((RegistryObject) classificationScheme).getName();
for (LocalizedString locName : iname.getLocalizedStrings()) {
- Name name = tm.addNewName();
- name.setStringValue(locName.getValue());
+ Name name = objectFactory.createName();
+ tm.setName(name);
+ name.setValue(locName.getValue());
name.setLang(locName.getLocale().getLanguage());
}
- InternationalString idesc = ((RegistryObject) scheme).getDescription();
+ InternationalString idesc = ((RegistryObject) classificationScheme).getDescription();
if (idesc != null) {
for (LocalizedString locName : idesc.getLocalizedStrings()) {
- Description desc = tm.addNewDescription();
- desc.setStringValue(locName.getValue());
+ Description desc = objectFactory.createDescription();
+ tm.getDescription().add(desc);
+ desc.setValue(locName.getValue());
desc.setLang(locName.getLocale().getLanguage());
}
}
- IdentifierBag idBag = getIdentifierBagFromExternalIdentifiers(scheme.getExternalIdentifiers());
+ IdentifierBag idBag = getIdentifierBagFromExternalIdentifiers(classificationScheme.getExternalIdentifiers());
if (idBag!=null) {
tm.setIdentifierBag(idBag);
}
- CategoryBag catBag = getCategoryBagFromClassifications(scheme.getClassifications());
+ CategoryBag catBag = getCategoryBagFromClassifications(classificationScheme.getClassifications());
if (catBag!=null) {
tm.setCategoryBag(catBag);
}
@@ -449,52 +463,54 @@
return tm;
}
- public static TModel getTModelFromJAXRConcept(Concept scheme)
+ public static TModel getTModelFromJAXRConcept(Concept concept)
throws JAXRException {
- TModel tm = TModel.Factory.newInstance();
- if (scheme == null)
+ TModel tm = objectFactory.createTModel();
+ if (concept == null)
return null;
try {
- Key key = scheme.getKey();
+ Key key = concept.getKey();
if (key != null && key.getId() != null)
tm.setTModelKey(key.getId());
- Slot sl1 = scheme.getSlot("authorizedName");
+ Slot sl1 = concept.getSlot("authorizedName");
if (sl1 != null && sl1.getName() != null)
tm.setAuthorizedName(sl1.getName());
- Slot sl2 = scheme.getSlot("operator");
+ Slot sl2 = concept.getSlot("operator");
if (sl2 != null && sl2.getName() != null)
tm.setOperator(sl2.getName());
- InternationalString iname = ((RegistryObject) scheme).getName();
+ InternationalString iname = ((RegistryObject) concept).getName();
for (LocalizedString locName : iname.getLocalizedStrings()) {
- Name name = tm.addNewName();
- name.setStringValue(locName.getValue());
+ Name name = objectFactory.createName();
+ tm.setName(name);
+ name.setValue(locName.getValue());
name.setLang(locName.getLocale().getLanguage());
}
- InternationalString idesc = ((RegistryObject) scheme).getDescription();
+ InternationalString idesc = ((RegistryObject) concept).getDescription();
if (idesc != null) {
for (LocalizedString locName : idesc.getLocalizedStrings()) {
- Description desc = tm.addNewDescription();
- desc.setStringValue(locName.getValue());
+ Description desc = objectFactory.createDescription();
+ tm.getDescription().add(desc);
+ desc.setValue(locName.getValue());
desc.setLang(locName.getLocale().getLanguage());
}
}
// External Links
- Collection<ExternalLink> externalLinks = scheme.getExternalLinks();
+ Collection<ExternalLink> externalLinks = concept.getExternalLinks();
if(externalLinks != null && externalLinks.size() > 0)
{
tm.setOverviewDoc(getOverviewDocFromExternalLink((ExternalLink)externalLinks.iterator().next()));
}
- IdentifierBag idBag = getIdentifierBagFromExternalIdentifiers(scheme.getExternalIdentifiers());
+ IdentifierBag idBag = getIdentifierBagFromExternalIdentifiers(concept.getExternalIdentifiers());
if (idBag!=null) {
tm.setIdentifierBag(idBag);
}
- CategoryBag catBag = getCategoryBagFromClassifications(scheme.getClassifications());
+ CategoryBag catBag = getCategoryBagFromClassifications(concept.getClassifications());
if (catBag!=null) {
tm.setCategoryBag(catBag);
}
@@ -505,15 +521,15 @@
return tm;
}
- public static BusinessEntity getBusinessEntityFromJAXROrg(Organization org)
+ public static BusinessEntity getBusinessEntityFromJAXROrg(Organization organization)
throws JAXRException {
- BusinessEntity biz = BusinessEntity.Factory.newInstance();
- BusinessServices bss = BusinessServices.Factory.newInstance();
+ BusinessEntity biz = objectFactory.createBusinessEntity();
+ BusinessServices bss = objectFactory.createBusinessServices();
BusinessService[] barr = new BusinessService[0];
try {
// It may just be an update
- Key key = org.getKey();
+ Key key = organization.getKey();
if (key != null && key.getId() != null) {
biz.setBusinessKey(key.getId());
} else {
@@ -521,35 +537,37 @@
}
// Lets get the Organization attributes at the top level
- InternationalString iname = org.getName();
+ InternationalString iname = organization.getName();
if (iname != null) {
for (LocalizedString locName : iname.getLocalizedStrings()) {
- Name name = biz.addNewName();
- name.setStringValue(locName.getValue());
+ Name name = objectFactory.createName();
+ biz.getName().add(name);
+ name.setValue(locName.getValue());
name.setLang(locName.getLocale().getLanguage());
}
}
- InternationalString idesc = org.getDescription();
+ InternationalString idesc = organization.getDescription();
if (idesc != null) {
for (LocalizedString locName : idesc.getLocalizedStrings()) {
- Description desc = biz.addNewDescription();
- desc.setStringValue(locName.getValue());
+ Description desc = objectFactory.createDescription();
+ biz.getDescription().add(desc);
+ desc.setValue(locName.getValue());
desc.setLang(locName.getLocale().getLanguage());
}
}
- if (org.getPrimaryContact() != null &&
- org.getPrimaryContact().getPersonName()!= null &&
- org.getPrimaryContact().getPersonName().getFullName() != null) {
+ if (organization.getPrimaryContact() != null &&
+ organization.getPrimaryContact().getPersonName()!= null &&
+ organization.getPrimaryContact().getPersonName().getFullName() != null) {
- biz.setAuthorizedName(org.getPrimaryContact().getPersonName()
+ biz.setAuthorizedName(organization.getPrimaryContact().getPersonName()
.getFullName());
}
- Collection<Service> s = org.getServices();
+ Collection<Service> s = organization.getServices();
log.debug("?Org has services=" + s.isEmpty());
barr = new BusinessService[s.size()];
@@ -570,11 +588,11 @@
* that the first UDDI user is the primary contact
*/
- Contacts cts = Contacts.Factory.newInstance();
+ Contacts cts = objectFactory.createContacts();
Contact[] carr = new Contact[0];
- User primaryContact = org.getPrimaryContact();
- Collection<User> users = org.getUsers();
+ 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)
@@ -616,37 +634,39 @@
}
}
- bss.setBusinessServiceArray(barr);
+ bss.getBusinessService().addAll(Arrays.asList(barr));
if (carr.length>0) {
- cts.setContactArray(carr);
+ cts.getContact().addAll(Arrays.asList(carr));
biz.setContacts(cts);
}
biz.setBusinessServices(bss);
// External Links
- Iterator<ExternalLink> exiter = org.getExternalLinks().iterator();
+ 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 = biz.addNewDiscoveryURLs();
+ emptyDUs = objectFactory.createDiscoveryURLs();
+ biz.setDiscoveryURLs(emptyDUs);
first = false;
}
- DiscoveryURL emptyDU = emptyDUs.addNewDiscoveryURL();
+ DiscoveryURL emptyDU = objectFactory.createDiscoveryURL();
+ emptyDUs.getDiscoveryURL().add(emptyDU);
emptyDU.setUseType("businessEntityExt");
if (link.getExternalURI() != null) {
- emptyDU.setStringValue(link.getExternalURI());
+ emptyDU.setValue(link.getExternalURI());
}
}
- IdentifierBag idBag = getIdentifierBagFromExternalIdentifiers(org.getExternalIdentifiers());
+ IdentifierBag idBag = getIdentifierBagFromExternalIdentifiers(organization.getExternalIdentifiers());
if (idBag!=null) {
biz.setIdentifierBag(idBag);
}
- CategoryBag catBag = getCategoryBagFromClassifications(org.getClassifications());
+ CategoryBag catBag = getCategoryBagFromClassifications(organization.getClassifications());
if (catBag!=null) {
biz.setCategoryBag(catBag);
}
@@ -663,8 +683,7 @@
*/
public static Contact getContactFromJAXRUser(User user)
throws JAXRException {
- Contact ct = Contact.Factory.newInstance();
-
+ Contact ct = objectFactory.createContact();
if (user == null) {
return null;
}
@@ -702,16 +721,16 @@
int phonearrPos = 0;
while (it.hasNext()) {
TelephoneNumber t = (TelephoneNumber) it.next();
- Phone phone = Phone.Factory.newInstance();
+ 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.setStringValue(str);
+ phone.setValue(str);
} else {
- phone.setStringValue("");
+ phone.setValue("");
}
phonearr[phonearrPos] = phone;
@@ -727,10 +746,10 @@
int emailarrPos = 0;
while (iter.hasNext()) {
EmailAddress ea = (EmailAddress) iter.next();
- Email email = Email.Factory.newInstance();
+ Email email = objectFactory.createEmail();
if (ea.getAddress() != null) {
- email.setStringValue(ea.getAddress());
+ email.setValue(ea.getAddress());
}
// email.setText( ea.getAddress() );
@@ -741,9 +760,9 @@
emailarr[emailarrPos] = email;
emailarrPos++;
}
- ct.setAddressArray(addarr);
- ct.setPhoneArray(phonearr);
- ct.setEmailArray(emailarr);
+ 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);
}
@@ -757,9 +776,9 @@
return tokenstr;
}
- private static URLType.Enum getURLType(String accessuri) {
+ private static URLType getURLType(String accessuri) {
String acc = accessuri.toLowerCase();
- URLType.Enum uri = URLType.OTHER;
+ URLType uri = URLType.OTHER;
if (acc.startsWith("http:"))
uri = URLType.HTTP;
else if (acc.startsWith("https:"))
@@ -792,12 +811,13 @@
return null;
// Classifications
- CategoryBag cbag = (CategoryBag)(XmlObject.Factory.newInstance()).changeType(CategoryBag.type);
+ CategoryBag cbag = objectFactory.createCategoryBag();
Iterator classiter = classifications.iterator();
while (classiter.hasNext()) {
Classification classification = (Classification) classiter.next();
if (classification != null ) {
- KeyedReference keyr = cbag.addNewKeyedReference();
+ KeyedReference keyr = objectFactory.createKeyedReference();
+ cbag.getKeyedReference().add(keyr);
InternationalStringImpl iname = null;
String value = null;
@@ -852,7 +872,7 @@
return null;
// Classifications
- TModelBag tbag = TModelBag.Factory.newInstance();
+ TModelBag tbag = objectFactory.createTModelBag();
Iterator speciter = specifications.iterator();
while (speciter.hasNext()) {
SpecificationLink specification = (SpecificationLink) speciter.next();
@@ -860,7 +880,7 @@
RegistryObject ro = specification.getSpecificationObject();
if (ro.getKey() != null) {
Key key = ro.getKey();
- tbag.addTModelKey(key.toString());
+ tbag.getTModelKey().add(key.toString());
}
}
}
@@ -884,12 +904,13 @@
return null;
// Identifiers
- IdentifierBag ibag = (IdentifierBag)(XmlObject.Factory.newInstance()).changeType(IdentifierBag.type);
+ IdentifierBag ibag = objectFactory.createIdentifierBag();
Iterator iditer = identifiers.iterator();
while (iditer.hasNext()) {
ExternalIdentifier extid = (ExternalIdentifier) iditer.next();
if (extid != null ) {
- KeyedReference keyr = ibag.addNewKeyedReference();
+ KeyedReference keyr = objectFactory.createKeyedReference();
+ ibag.getKeyedReference().add(keyr);
InternationalStringImpl iname = (InternationalStringImpl) ((RegistryObject) extid).getName();
String value = extid.getValue();
@@ -918,14 +939,15 @@
private static OverviewDoc getOverviewDocFromExternalLink(ExternalLink link)
throws JAXRException
{
- OverviewDoc od = (OverviewDoc)(XmlObject.Factory.newInstance()).changeType(OverviewDoc.type);
+ OverviewDoc od = objectFactory.createOverviewDoc();
String url = link.getExternalURI();
if(url != null)
od.setOverviewURL(url);
InternationalString extDesc = link.getDescription();
if(extDesc != null) {
- Description description = od.addNewDescription();
- description.setStringValue(extDesc.getValue());
+ Description description = objectFactory.createDescription();
+ od.getDescription().add(description);
+ description.setValue(extDesc.getValue());
}
return od;
}
@@ -934,7 +956,7 @@
throws JAXRException {
BindingTemplates bt = null;
if(serviceBindings != null && serviceBindings.size() > 0) {
- bt = BindingTemplates.Factory.newInstance();
+ bt = objectFactory.createBindingTemplates();
Iterator iter = serviceBindings.iterator();
int currLoc = 0;
BindingTemplate[] bindingTemplateArray = new BindingTemplate[serviceBindings.size()];
@@ -944,7 +966,7 @@
currLoc++;
}
if (bindingTemplateArray != null) {
- bt.setBindingTemplateArray(bindingTemplateArray);
+ bt.getBindingTemplate().addAll(Arrays.asList(bindingTemplateArray));
}
}
return bt;
---------------------------------------------------------------------
To unsubscribe, e-mail: scout-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: scout-dev-help@ws.apache.org