0001: /*
0002: * Copyright 2001-2004 The Apache Software Foundation.
0003: *
0004: * Licensed under the Apache License, Version 2.0 (the "License");
0005: * you may not use this file except in compliance with the License.
0006: * You may obtain a copy of the License at
0007: *
0008: * http://www.apache.org/licenses/LICENSE-2.0
0009: *
0010: * Unless required by applicable law or agreed to in writing, software
0011: * distributed under the License is distributed on an "AS IS" BASIS,
0012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0013: * See the License for the specific language governing permissions and
0014: * limitations under the License.
0015: */
0016: package org.apache.ws.scout.registry;
0017:
0018: import java.io.IOException;
0019: import java.net.URI;
0020: import java.net.URISyntaxException;
0021: import java.util.Properties;
0022:
0023: import javax.xml.namespace.QName;
0024: import javax.xml.parsers.DocumentBuilder;
0025: import javax.xml.parsers.DocumentBuilderFactory;
0026: import javax.xml.parsers.ParserConfigurationException;
0027:
0028: import org.apache.ws.scout.transport.Transport;
0029: import org.apache.ws.scout.uddi.AssertionStatusReport;
0030: import org.apache.ws.scout.uddi.AssertionStatusReportDocument;
0031: import org.apache.ws.scout.uddi.AuthToken;
0032: import org.apache.ws.scout.uddi.AuthTokenDocument;
0033: import org.apache.ws.scout.uddi.BindingDetail;
0034: import org.apache.ws.scout.uddi.BindingDetailDocument;
0035: import org.apache.ws.scout.uddi.BindingTemplate;
0036: import org.apache.ws.scout.uddi.BusinessDetail;
0037: import org.apache.ws.scout.uddi.BusinessDetailDocument;
0038: import org.apache.ws.scout.uddi.BusinessEntity;
0039: import org.apache.ws.scout.uddi.BusinessList;
0040: import org.apache.ws.scout.uddi.BusinessListDocument;
0041: import org.apache.ws.scout.uddi.BusinessService;
0042: import org.apache.ws.scout.uddi.CategoryBag;
0043: import org.apache.ws.scout.uddi.DeleteBinding;
0044: import org.apache.ws.scout.uddi.DeleteBindingDocument;
0045: import org.apache.ws.scout.uddi.DeleteBusiness;
0046: import org.apache.ws.scout.uddi.DeleteBusinessDocument;
0047: import org.apache.ws.scout.uddi.DeletePublisherAssertions;
0048: import org.apache.ws.scout.uddi.DeletePublisherAssertionsDocument;
0049: import org.apache.ws.scout.uddi.DeleteService;
0050: import org.apache.ws.scout.uddi.DeleteServiceDocument;
0051: import org.apache.ws.scout.uddi.DeleteTModel;
0052: import org.apache.ws.scout.uddi.DeleteTModelDocument;
0053: import org.apache.ws.scout.uddi.DiscoveryURLs;
0054: import org.apache.ws.scout.uddi.DispositionReport;
0055: import org.apache.ws.scout.uddi.DispositionReportDocument;
0056: import org.apache.ws.scout.uddi.FindBinding;
0057: import org.apache.ws.scout.uddi.FindBindingDocument;
0058: import org.apache.ws.scout.uddi.FindBusiness;
0059: import org.apache.ws.scout.uddi.FindBusinessDocument;
0060: import org.apache.ws.scout.uddi.FindQualifiers;
0061: import org.apache.ws.scout.uddi.FindService;
0062: import org.apache.ws.scout.uddi.FindServiceDocument;
0063: import org.apache.ws.scout.uddi.FindTModel;
0064: import org.apache.ws.scout.uddi.FindTModelDocument;
0065: import org.apache.ws.scout.uddi.GetAssertionStatusReport;
0066: import org.apache.ws.scout.uddi.GetAssertionStatusReportDocument;
0067: import org.apache.ws.scout.uddi.GetAuthToken;
0068: import org.apache.ws.scout.uddi.GetAuthTokenDocument;
0069: import org.apache.ws.scout.uddi.GetBusinessDetail;
0070: import org.apache.ws.scout.uddi.GetBusinessDetailDocument;
0071: import org.apache.ws.scout.uddi.GetPublisherAssertions;
0072: import org.apache.ws.scout.uddi.GetPublisherAssertionsDocument;
0073: import org.apache.ws.scout.uddi.GetServiceDetail;
0074: import org.apache.ws.scout.uddi.GetServiceDetailDocument;
0075: import org.apache.ws.scout.uddi.GetTModelDetail;
0076: import org.apache.ws.scout.uddi.GetTModelDetailDocument;
0077: import org.apache.ws.scout.uddi.IdentifierBag;
0078: import org.apache.ws.scout.uddi.Name;
0079: import org.apache.ws.scout.uddi.PublisherAssertion;
0080: import org.apache.ws.scout.uddi.PublisherAssertions;
0081: import org.apache.ws.scout.uddi.PublisherAssertionsDocument;
0082: import org.apache.ws.scout.uddi.SaveBinding;
0083: import org.apache.ws.scout.uddi.SaveBindingDocument;
0084: import org.apache.ws.scout.uddi.SaveBusiness;
0085: import org.apache.ws.scout.uddi.SaveBusinessDocument;
0086: import org.apache.ws.scout.uddi.SaveService;
0087: import org.apache.ws.scout.uddi.SaveServiceDocument;
0088: import org.apache.ws.scout.uddi.SaveTModel;
0089: import org.apache.ws.scout.uddi.SaveTModelDocument;
0090: import org.apache.ws.scout.uddi.ServiceDetail;
0091: import org.apache.ws.scout.uddi.ServiceDetailDocument;
0092: import org.apache.ws.scout.uddi.ServiceList;
0093: import org.apache.ws.scout.uddi.ServiceListDocument;
0094: import org.apache.ws.scout.uddi.SetPublisherAssertions;
0095: import org.apache.ws.scout.uddi.SetPublisherAssertionsDocument;
0096: import org.apache.ws.scout.uddi.TModel;
0097: import org.apache.ws.scout.uddi.TModelBag;
0098: import org.apache.ws.scout.uddi.TModelDetail;
0099: import org.apache.ws.scout.uddi.TModelDetailDocument;
0100: import org.apache.ws.scout.uddi.TModelList;
0101: import org.apache.ws.scout.uddi.TModelListDocument;
0102: import org.apache.xmlbeans.XmlCursor;
0103: import org.apache.xmlbeans.XmlException;
0104: import org.apache.xmlbeans.XmlObject;
0105: import org.w3c.dom.Document;
0106: import org.w3c.dom.Element;
0107: import org.w3c.dom.NodeList;
0108: import org.xml.sax.SAXException;
0109:
0110: /**
0111: * RegistryImpl is the implementation of IRegistry.
0112: *
0113: * <p>The execute() function signature has been changed slightly from the jUDDI
0114: * version, since the URL can no longer be decided dynamically (in an easy
0115: * enough manner) as we don't use jUDDI data types anymore.</p>
0116: *
0117: * <i>The function code is borrowed from jUDDI, with appropriate modifications so
0118: * that xmlbeans data types are used intead of jUDDI data types.</i>
0119: *
0120: */
0121:
0122: public class RegistryImpl implements IRegistry {
0123:
0124: public static final String INQUIRY_ENDPOINT_PROPERTY_NAME = "scout.proxy.inquiryURL";
0125: public static final String PUBLISH_ENDPOINT_PROPERTY_NAME = "scout.proxy.publishURL";
0126: public static final String ADMIN_ENDPOINT_PROPERTY_NAME = "scout.proxy.adminURL";
0127: public static final String TRANSPORT_CLASS_PROPERTY_NAME = "scout.proxy.transportClass";
0128: public static final String SECURITY_PROVIDER_PROPERTY_NAME = "scout.proxy.securityProvider";
0129: public static final String PROTOCOL_HANDLER_PROPERTY_NAME = "scout.proxy.protocolHandler";
0130: public static final String UDDI_VERSION_PROPERTY_NAME = "scout.proxy.uddiVersion";
0131: public static final String UDDI_NAMESPACE_PROPERTY_NAME = "scout.proxy.uddiNamespace";
0132:
0133: public static final String DEFAULT_INQUIRY_ENDPOINT = "http://localhost/juddi/inquiry";
0134: public static final String DEFAULT_PUBLISH_ENDPOINT = "http://localhost/juddi/publish";
0135: public static final String DEFAULT_ADMIN_ENDPOINT = "http://localhost/juddi/admin";
0136: public static final String DEFAULT_TRANSPORT_CLASS = "org.apache.ws.scout.transport.AxisTransport";
0137: public static final String DEFAULT_SECURITY_PROVIDER = "com.sun.net.ssl.internal.ssl.Provider";
0138: public static final String DEFAULT_PROTOCOL_HANDLER = "com.sun.net.ssl.internal.www.protocol";
0139: public static final String DEFAULT_UDDI_VERSION = "2.0";
0140: public static final String DEFAULT_UDDI_NAMESPACE = "urn:uddi-org:api_v2";
0141:
0142: private URI adminURI;
0143: private URI inquiryURI;
0144: private URI publishURI;
0145:
0146: private Transport transport;
0147:
0148: private String securityProvider;
0149: private String protocolHandler;
0150: private String uddiVersion;
0151: private String uddiNamespace;
0152:
0153: /**
0154: * Creates a new instance of RegistryImpl.
0155: */
0156: public RegistryImpl(Properties props) {
0157: super ();
0158:
0159: this .init(props);
0160: }
0161:
0162: /**
0163: *
0164: */
0165: private void init(Properties props) {
0166: // We need to have a non-null Properties
0167: // instance so initialization takes place.
0168: if (props == null)
0169: props = new Properties();
0170:
0171: // Override defaults with specific specific values
0172: try {
0173: String iURL = props
0174: .getProperty(INQUIRY_ENDPOINT_PROPERTY_NAME);
0175: if (iURL != null)
0176: this .setInquiryURI(new URI(iURL));
0177: else
0178: this .setInquiryURI(new URI(DEFAULT_INQUIRY_ENDPOINT));
0179:
0180: String pURL = props
0181: .getProperty(PUBLISH_ENDPOINT_PROPERTY_NAME);
0182: if (pURL != null)
0183: this .setPublishURI(new URI(pURL));
0184: else
0185: this .setPublishURI(new URI(DEFAULT_PUBLISH_ENDPOINT));
0186:
0187: String aURL = props
0188: .getProperty(ADMIN_ENDPOINT_PROPERTY_NAME);
0189: if (aURL != null)
0190: this .setAdminURI(new URI(aURL));
0191: else
0192: this .setAdminURI(new URI(DEFAULT_ADMIN_ENDPOINT));
0193: } catch (URISyntaxException muex) {
0194: muex.printStackTrace();
0195: }
0196:
0197: String secProvider = props
0198: .getProperty(SECURITY_PROVIDER_PROPERTY_NAME);
0199: if (secProvider != null)
0200: this .setSecurityProvider(secProvider);
0201: else
0202: this .setSecurityProvider(DEFAULT_SECURITY_PROVIDER);
0203:
0204: String protoHandler = props
0205: .getProperty(PROTOCOL_HANDLER_PROPERTY_NAME);
0206: if (protoHandler != null)
0207: this .setProtocolHandler(protoHandler);
0208: else
0209: this .setProtocolHandler(DEFAULT_PROTOCOL_HANDLER);
0210:
0211: String uddiVer = props.getProperty(UDDI_VERSION_PROPERTY_NAME);
0212: if (uddiVer != null)
0213: this .setUddiVersion(uddiVer);
0214: else
0215: this .setUddiVersion(DEFAULT_UDDI_VERSION);
0216:
0217: String uddiNS = props.getProperty(UDDI_NAMESPACE_PROPERTY_NAME);
0218: if (uddiNS != null)
0219: this .setUddiNamespace(uddiNS);
0220: else
0221: this .setUddiNamespace(DEFAULT_UDDI_NAMESPACE);
0222:
0223: String transClass = props
0224: .getProperty(TRANSPORT_CLASS_PROPERTY_NAME);
0225: if (transClass != null)
0226: this .setTransport(this .getTransport(transClass));
0227: else
0228: this .setTransport(this
0229: .getTransport(DEFAULT_TRANSPORT_CLASS));
0230: }
0231:
0232: /**
0233: *
0234: * @param uddiRequest
0235: * @return
0236: * @throws RegistryException
0237: */
0238: public String execute(String uddiRequest, String urltype)
0239: throws RegistryException {
0240: URI endPointURL = null;
0241: if (urltype.equalsIgnoreCase("INQUIRY"))
0242: endPointURL = this .getInquiryURI();
0243: else
0244: endPointURL = this .getPublishURI();
0245:
0246: // A SOAP request is made and a SOAP response
0247: // is returned.
0248:
0249: return transport.send(uddiRequest, endPointURL);
0250: }
0251:
0252: /**
0253: *
0254: */
0255: public XmlObject execute(XmlObject uddiRequest, URI endPointURI)
0256: throws RegistryException {
0257:
0258: Document doc;
0259: try {
0260: DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory
0261: .newInstance();
0262: docBuilderFactory.setNamespaceAware(true);
0263: DocumentBuilder docBuilder = docBuilderFactory
0264: .newDocumentBuilder();
0265: doc = docBuilder.parse(uddiRequest.newInputStream());
0266: } catch (SAXException saxe) {
0267: throw (new RegistryException(saxe));
0268: } catch (ParserConfigurationException pce) {
0269: throw (new RegistryException(pce));
0270: } catch (IOException ioe) {
0271: throw (new RegistryException(ioe));
0272: }
0273: Element request = doc.getDocumentElement();
0274:
0275: request.setAttribute("generic", this .getUddiVersion());
0276: //request.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns", this.getUddiNamespace());
0277: // A SOAP request is made and a SOAP response
0278: // is returned.
0279:
0280: Element response = transport.send(request, endPointURI);
0281:
0282: if (response.getNamespaceURI() == null) {
0283: response.setAttributeNS("http://www.w3.org/2000/xmlns/",
0284: "xmlns", this .getUddiNamespace());
0285: }
0286: // First, let's make sure that a response
0287: // (any response) is found in the SOAP Body.
0288:
0289: String responseName = response.getLocalName();
0290: if (responseName == null) {
0291: throw new RegistryException("Unsupported response "
0292: + "from registry. A value was not present.");
0293: }
0294:
0295: // Let's now try to determine which UDDI response
0296: // we received and unmarshal it appropriately or
0297: // throw a RegistryException if it's unknown.
0298: // Well, we have now determined that something was
0299: // returned and it is "a something" that we know
0300: // about so let's unmarshal it into a RegistryObject
0301: // Next, let's make sure we didn't recieve a SOAP
0302: // Fault. If it is a SOAP Fault then throw it
0303: // immediately.
0304:
0305: XmlObject uddiResponse = null;
0306: try {
0307: uddiResponse = XmlObject.Factory.parse(response);
0308: XmlCursor cursor = uddiResponse.newCursor();
0309: cursor.toNextToken();
0310: //set the namespace if it is empty here. This is needed for the find_element_user to work.
0311: if ("".equals(cursor.getName().getNamespaceURI())) {
0312: cursor.setName(new QName(this .getUddiNamespace(),
0313: cursor.getName().getLocalPart()));
0314: //there seems to have a bug in setName and it will set the next Start with xmlns="".
0315: //The workaround is to set it to uddiNamespace when it is empty.
0316: while (cursor.hasNextToken()) {
0317: cursor.toNextToken();
0318: if (cursor.isStart()) {
0319: if ("".equals(cursor.getName()
0320: .getNamespaceURI())) {
0321: cursor.setName(new QName(this
0322: .getUddiNamespace(), cursor
0323: .getName().getLocalPart()));
0324: }
0325: }
0326: }
0327: cursor.dispose();
0328: }
0329: } catch (XmlException xmle) {
0330: throw (new RegistryException(xmle));
0331: }
0332:
0333: if (responseName.toLowerCase().equals("fault")) {
0334: NodeList nodeList = null;
0335:
0336: // Child Elements
0337: String fCode = null;
0338: nodeList = response.getElementsByTagName("faultcode");
0339: if (nodeList.getLength() > 0)
0340: fCode = nodeList.item(0).getNodeValue();
0341:
0342: String fString = null;
0343: nodeList = response.getElementsByTagName("faultstring");
0344: if (nodeList.getLength() > 0)
0345: fString = nodeList.item(0).getNodeValue();
0346:
0347: String fActor = null;
0348: nodeList = response.getElementsByTagName("faultactor");
0349: if (nodeList.getLength() > 0)
0350: fActor = nodeList.item(0).getNodeValue();
0351:
0352: DispositionReport dispRpt = null;
0353:
0354: nodeList = response.getElementsByTagName("detail");
0355: if (nodeList.getLength() > 0) {
0356: nodeList = ((Element) nodeList.item(0))
0357: .getElementsByTagName("dispositionReport");
0358: if (nodeList.getLength() > 0) {
0359: XmlObject dispRptObj = null;
0360: try {
0361: dispRptObj = XmlObject.Factory
0362: .parse((Element) nodeList.item(0));
0363: } catch (XmlException xmle) {
0364: throw (new RegistryException(xmle));
0365: }
0366: XmlObject o = dispRptObj
0367: .changeType(DispositionReportDocument.type);
0368: dispRpt = ((DispositionReportDocument) o)
0369: .getDispositionReport();
0370: }
0371: }
0372:
0373: RegistryException e = new RegistryException(fCode, fString,
0374: fActor, dispRpt);
0375:
0376: // FIXME: This should be removed after testing!
0377: System.err.println("SOAP message:");
0378: System.err.println(uddiResponse.xmlText());
0379:
0380: // Create RegistryException instance and return
0381: throw e;
0382: }
0383:
0384: return uddiResponse;
0385: }
0386:
0387: /**
0388: * @return Returns the adminURL.
0389: */
0390: public URI getAdminURI() {
0391: return this .adminURI;
0392: }
0393:
0394: /**
0395: * @param url
0396: * The adminURL to set.
0397: */
0398: public void setAdminURI(URI url) {
0399: this .adminURI = url;
0400: }
0401:
0402: /**
0403: * @return Returns the inquiryURL.
0404: */
0405: public URI getInquiryURI() {
0406: return this .inquiryURI;
0407: }
0408:
0409: /**
0410: * @param inquiryURI
0411: * The inquiryURI to set.
0412: */
0413: public void setInquiryURI(URI inquiryURI) {
0414: this .inquiryURI = inquiryURI;
0415: }
0416:
0417: /**
0418: * @return Returns the protocolHandler.
0419: */
0420: public String getProtocolHandler() {
0421: return this .protocolHandler;
0422: }
0423:
0424: /**
0425: * @param protocolHandler
0426: * The protocolHandler to set.
0427: */
0428: public void setProtocolHandler(String protocolHandler) {
0429: this .protocolHandler = protocolHandler;
0430: }
0431:
0432: /**
0433: * @return Returns the publishURL.
0434: */
0435: public URI getPublishURI() {
0436: return this .publishURI;
0437: }
0438:
0439: /**
0440: * @param publishURI
0441: * The publishURI to set.
0442: */
0443: public void setPublishURI(URI publishURI) {
0444: this .publishURI = publishURI;
0445: }
0446:
0447: /**
0448: * @return Returns the securityProvider.
0449: */
0450: public String getSecurityProvider() {
0451: return this .securityProvider;
0452: }
0453:
0454: /**
0455: * @param securityProvider
0456: * The securityProvider to set.
0457: */
0458: public void setSecurityProvider(String securityProvider) {
0459: this .securityProvider = securityProvider;
0460: }
0461:
0462: /**
0463: * @return Returns the transport.
0464: */
0465: public Transport getTransport() {
0466: return transport;
0467: }
0468:
0469: /**
0470: * @param transport
0471: * The transport to set.
0472: */
0473: public void setTransport(Transport transport) {
0474: this .transport = transport;
0475: }
0476:
0477: /**
0478: * @return Returns the uddiNS.
0479: */
0480: public String getUddiNamespace() {
0481: return this .uddiNamespace;
0482: }
0483:
0484: /**
0485: * @param uddiNS
0486: * The uddiNS to set.
0487: */
0488: public void setUddiNamespace(String uddiNS) {
0489: this .uddiNamespace = uddiNS;
0490: }
0491:
0492: /**
0493: * @return Returns the uddiVersion.
0494: */
0495: public String getUddiVersion() {
0496: return this .uddiVersion;
0497: }
0498:
0499: /**
0500: * @param uddiVersion
0501: * The uddiVersion to set.
0502: */
0503: public void setUddiVersion(String uddiVersion) {
0504: this .uddiVersion = uddiVersion;
0505: }
0506:
0507: /**
0508: * "Used to remove an existing bindingTemplate from the bindingTemplates
0509: * collection that is part of a specified businessService structure."
0510: *
0511: * @exception RegistryException;
0512: */
0513: public DispositionReport deleteBinding(String authInfo,
0514: String[] bindingKeyArray) throws RegistryException {
0515: DeleteBindingDocument doc = DeleteBindingDocument.Factory
0516: .newInstance();
0517: DeleteBinding request = doc.addNewDeleteBinding();
0518:
0519: if (authInfo != null) {
0520: request.setAuthInfo(authInfo);
0521: }
0522:
0523: if (bindingKeyArray != null) {
0524: request.setBindingKeyArray(bindingKeyArray);
0525: }
0526:
0527: DispositionReport dr;
0528: XmlObject o = execute(doc, this .getPublishURI()).changeType(
0529: DispositionReportDocument.type);
0530: dr = ((DispositionReportDocument) o).getDispositionReport();
0531:
0532: return dr;
0533: }
0534:
0535: /**
0536: * "Used to delete registered businessEntity information from the registry."
0537: *
0538: * @exception RegistryException;
0539: */
0540: public DispositionReport deleteBusiness(String authInfo,
0541: String[] businessKeyArray) throws RegistryException {
0542: DeleteBusinessDocument doc = DeleteBusinessDocument.Factory
0543: .newInstance();
0544: DeleteBusiness request = doc.addNewDeleteBusiness();
0545:
0546: if (authInfo != null) {
0547: request.setAuthInfo(authInfo);
0548: }
0549:
0550: if (businessKeyArray != null) {
0551: request.setBusinessKeyArray(businessKeyArray);
0552: }
0553:
0554: DispositionReport dr;
0555: XmlObject o = execute(doc, this .getPublishURI()).changeType(
0556: DispositionReportDocument.type);
0557: dr = ((DispositionReportDocument) o).getDispositionReport();
0558:
0559: return dr;
0560: }
0561:
0562: /**
0563: * @exception RegistryException;
0564: */
0565: public DispositionReport deletePublisherAssertions(String authInfo,
0566: PublisherAssertion[] assertionArray)
0567: throws RegistryException {
0568: DeletePublisherAssertionsDocument doc = DeletePublisherAssertionsDocument.Factory
0569: .newInstance();
0570: DeletePublisherAssertions request = doc
0571: .addNewDeletePublisherAssertions();
0572:
0573: if (authInfo != null) {
0574: request.setAuthInfo(authInfo);
0575: }
0576:
0577: if (assertionArray != null) {
0578: request.setPublisherAssertionArray(assertionArray);
0579: }
0580:
0581: DispositionReport dr;
0582: XmlObject o = execute(doc, this .getPublishURI()).changeType(
0583: DispositionReportDocument.type);
0584: dr = ((DispositionReportDocument) o).getDispositionReport();
0585:
0586: return dr;
0587: }
0588:
0589: /**
0590: * "Used to delete an existing businessService from the businessServices
0591: * collection that is part of a specified businessEntity."
0592: *
0593: * @exception RegistryException;
0594: */
0595: public DispositionReport deleteService(String authInfo,
0596: String[] serviceKeyArray) throws RegistryException {
0597: DeleteServiceDocument doc = DeleteServiceDocument.Factory
0598: .newInstance();
0599: DeleteService request = doc.addNewDeleteService();
0600:
0601: if (authInfo != null) {
0602: request.setAuthInfo(authInfo);
0603: }
0604:
0605: if (serviceKeyArray != null) {
0606: request.setServiceKeyArray(serviceKeyArray);
0607: }
0608:
0609: DispositionReport dr;
0610: XmlObject o = execute(doc, this .getPublishURI()).changeType(
0611: DispositionReportDocument.type);
0612: dr = ((DispositionReportDocument) o).getDispositionReport();
0613:
0614: return dr;
0615: }
0616:
0617: /**
0618: * "Used to delete registered information about a tModel. If there are any
0619: * references to a tModel when this call is made, the tModel will be marked
0620: * deleted instead of being physically removed."
0621: *
0622: * @exception RegistryException;
0623: */
0624: public DispositionReport deleteTModel(String authInfo,
0625: String[] tModelKeyArray) throws RegistryException {
0626: DeleteTModelDocument doc = DeleteTModelDocument.Factory
0627: .newInstance();
0628: DeleteTModel request = doc.addNewDeleteTModel();
0629:
0630: if (authInfo != null) {
0631: request.setAuthInfo(authInfo);
0632: }
0633:
0634: if (tModelKeyArray != null) {
0635: request.setTModelKeyArray(tModelKeyArray);
0636: }
0637:
0638: DispositionReport dr;
0639: XmlObject o = execute(doc, this .getPublishURI()).changeType(
0640: DispositionReportDocument.type);
0641: dr = ((DispositionReportDocument) o).getDispositionReport();
0642:
0643: return dr;
0644: }
0645:
0646: /**
0647: * Used to locate information about one or more businesses. Returns a
0648: * businessList message that matches the conditions specified.
0649: *
0650: * @exception RegistryException;
0651: */
0652: public BusinessList findBusiness(Name[] nameArray,
0653: DiscoveryURLs discoveryURLs, IdentifierBag identifierBag,
0654: CategoryBag categoryBag, TModelBag tModelBag,
0655: FindQualifiers findQualifiers, int maxRows)
0656: throws RegistryException {
0657: FindBusinessDocument doc = FindBusinessDocument.Factory
0658: .newInstance();
0659: FindBusiness request = doc.addNewFindBusiness();
0660:
0661: if (nameArray != null) {
0662: request.setNameArray(nameArray);
0663: }
0664:
0665: if (discoveryURLs != null) {
0666: request.setDiscoveryURLs(discoveryURLs);
0667: }
0668:
0669: if (identifierBag != null) {
0670: request.setIdentifierBag(identifierBag);
0671: }
0672:
0673: if (categoryBag != null) {
0674: request.setCategoryBag(categoryBag);
0675: }
0676:
0677: if (tModelBag != null) {
0678: request.setTModelBag(tModelBag);
0679: }
0680:
0681: if (findQualifiers != null) {
0682: request.setFindQualifiers(findQualifiers);
0683: }
0684:
0685: request.setMaxRows(maxRows);
0686:
0687: BusinessList bl;
0688: XmlObject o = execute(doc, this .getInquiryURI()).changeType(
0689: BusinessListDocument.type);
0690: bl = ((BusinessListDocument) o).getBusinessList();
0691:
0692: return bl;
0693: }
0694:
0695: /**
0696: * "Used to locate specific bindings within a registered businessService.
0697: * Returns a bindingDetail message."
0698: *
0699: * @exception RegistryException
0700: */
0701: public BindingDetail findBinding(String serviceKey,
0702: CategoryBag categoryBag, TModelBag tModelBag,
0703: FindQualifiers findQualifiers, int maxRows)
0704: throws RegistryException {
0705: // FIXME: Juddi's methods also set category bag (per uddi spec v3).
0706: // However, we are sticking to v2 for now, so categorybag doesn't
0707: // exist under FindBinding. It is fine for now, since the incoming
0708: // parameter value is always null anyways -- but this may change
0709: // in the future.
0710:
0711: FindBindingDocument doc = FindBindingDocument.Factory
0712: .newInstance();
0713: FindBinding request = doc.addNewFindBinding();
0714:
0715: if (serviceKey != null) {
0716: request.setServiceKey(serviceKey);
0717: }
0718:
0719: if (tModelBag != null) {
0720: request.setTModelBag(tModelBag);
0721: }
0722:
0723: if (findQualifiers != null) {
0724: request.setFindQualifiers(findQualifiers);
0725: }
0726: request.setMaxRows(maxRows);
0727:
0728: BindingDetail bd;
0729: XmlObject o = execute(doc, this .getInquiryURI()).changeType(
0730: BindingDetailDocument.type);
0731: bd = ((BindingDetailDocument) o).getBindingDetail();
0732:
0733: return bd;
0734: }
0735:
0736: /**
0737: * "Used to locate specific services within a registered businessEntity.
0738: * Return a serviceList message." From the XML spec (API, p18) it appears
0739: * that the name, categoryBag, and tModelBag arguments are mutually
0740: * exclusive.
0741: *
0742: * @exception RegistryException;
0743: */
0744: public ServiceList findService(String businessKey,
0745: Name[] nameArray, CategoryBag categoryBag,
0746: TModelBag tModelBag, FindQualifiers findQualifiers,
0747: int maxRows) throws RegistryException {
0748: FindServiceDocument doc = FindServiceDocument.Factory
0749: .newInstance();
0750: FindService request = doc.addNewFindService();
0751:
0752: if (businessKey != null) {
0753: request.setBusinessKey(businessKey);
0754: }
0755:
0756: if (nameArray != null) {
0757: request.setNameArray(nameArray);
0758: }
0759:
0760: if (categoryBag != null) {
0761: request.setCategoryBag(categoryBag);
0762: }
0763:
0764: if (tModelBag != null) {
0765: request.setTModelBag(tModelBag);
0766: }
0767:
0768: if (findQualifiers != null) {
0769: request.setFindQualifiers(findQualifiers);
0770: }
0771:
0772: request.setMaxRows(maxRows);
0773:
0774: ServiceList sl;
0775: XmlObject o = execute(doc, this .getInquiryURI()).changeType(
0776: ServiceListDocument.type);
0777: sl = ((ServiceListDocument) o).getServiceList();
0778:
0779: return sl;
0780: }
0781:
0782: /**
0783: * "Used to locate one or more tModel information structures. Returns a
0784: * tModelList structure."
0785: *
0786: * @exception RegistryException;
0787: */
0788: public TModelList findTModel(String name, CategoryBag categoryBag,
0789: IdentifierBag identifierBag, FindQualifiers findQualifiers,
0790: int maxRows) throws RegistryException {
0791: FindTModelDocument doc = FindTModelDocument.Factory
0792: .newInstance();
0793: FindTModel request = doc.addNewFindTModel();
0794:
0795: Name n = Name.Factory.newInstance();
0796:
0797: if (name != null) {
0798: n.setStringValue(name);
0799: }
0800:
0801: request.setName(n);
0802:
0803: if (categoryBag != null) {
0804: request.setCategoryBag(categoryBag);
0805: }
0806:
0807: if (identifierBag != null) {
0808: request.setIdentifierBag(identifierBag);
0809: }
0810:
0811: if (findQualifiers != null) {
0812: request.setFindQualifiers(findQualifiers);
0813: }
0814:
0815: request.setMaxRows(maxRows);
0816:
0817: TModelList tml;
0818: XmlObject o = execute(doc, this .getInquiryURI()).changeType(
0819: TModelListDocument.type);
0820: tml = ((TModelListDocument) o).getTModelList();
0821:
0822: return tml;
0823: }
0824:
0825: /**
0826: * @exception RegistryException;
0827: */
0828: public AssertionStatusReport getAssertionStatusReport(
0829: String authInfo, String completionStatus)
0830: throws RegistryException {
0831: GetAssertionStatusReportDocument doc = GetAssertionStatusReportDocument.Factory
0832: .newInstance();
0833: GetAssertionStatusReport request = doc
0834: .addNewGetAssertionStatusReport();
0835:
0836: if (authInfo != null) {
0837: request.setAuthInfo(authInfo);
0838: }
0839:
0840: if (completionStatus != null) {
0841: request.setCompletionStatus(completionStatus);
0842: }
0843:
0844: AssertionStatusReport asr;
0845: XmlObject o = execute(doc, this .getPublishURI()).changeType(
0846: AssertionStatusReportDocument.type);
0847: asr = ((AssertionStatusReportDocument) o)
0848: .getAssertionStatusReport();
0849:
0850: return asr;
0851: }
0852:
0853: /**
0854: * "Used to request an authentication token from an Operator Site.
0855: * Authentication tokens are required to use all other APIs defined in the
0856: * publishers API. This server serves as the program's equivalent of a login
0857: * request."
0858: *
0859: * @exception RegistryException;
0860: */
0861: public AuthToken getAuthToken(String userID, String cred)
0862: throws RegistryException {
0863: GetAuthTokenDocument doc = GetAuthTokenDocument.Factory
0864: .newInstance();
0865: GetAuthToken request = doc.addNewGetAuthToken();
0866:
0867: if (userID != null) {
0868: request.setUserID(userID);
0869: }
0870:
0871: if (cred != null) {
0872: request.setCred(cred);
0873: }
0874:
0875: AuthToken at;
0876: XmlObject o = execute(doc, this .getPublishURI()).changeType(
0877: AuthTokenDocument.type);
0878: at = ((AuthTokenDocument) o).getAuthToken();
0879:
0880: return at;
0881: }
0882:
0883: /**
0884: * Used to get the full businessEntity information for a particular business
0885: * entity. Returns a businessDetail message.
0886: *
0887: * @exception RegistryException;
0888: */
0889: public BusinessDetail getBusinessDetail(String businessKey)
0890: throws RegistryException {
0891: String[] keys = new String[1];
0892: keys[0] = businessKey;
0893:
0894: return getBusinessDetail(keys);
0895: }
0896:
0897: /**
0898: * "Used to get the full businessEntity information for one or more
0899: * businesses. Returns a businessDetail message."
0900: *
0901: * @exception RegistryException;
0902: */
0903: public BusinessDetail getBusinessDetail(String[] businessKeyArray)
0904: throws RegistryException {
0905: GetBusinessDetailDocument doc = GetBusinessDetailDocument.Factory
0906: .newInstance();
0907: GetBusinessDetail request = doc.addNewGetBusinessDetail();
0908:
0909: if (businessKeyArray != null) {
0910: request.setBusinessKeyArray(businessKeyArray);
0911: }
0912:
0913: BusinessDetail bd;
0914: XmlObject o = execute(doc, this .getInquiryURI()).changeType(
0915: BusinessDetailDocument.type);
0916: bd = ((BusinessDetailDocument) o).getBusinessDetail();
0917:
0918: return bd;
0919: }
0920:
0921: /**
0922: * @exception RegistryException;
0923: */
0924: public PublisherAssertions getPublisherAssertions(String authInfo)
0925: throws RegistryException {
0926: GetPublisherAssertionsDocument doc = GetPublisherAssertionsDocument.Factory
0927: .newInstance();
0928: GetPublisherAssertions request = doc
0929: .addNewGetPublisherAssertions();
0930:
0931: if (authInfo != null) {
0932: request.setAuthInfo(authInfo);
0933: }
0934:
0935: PublisherAssertions pa;
0936: XmlObject o = execute(doc, this .getPublishURI()).changeType(
0937: PublisherAssertionsDocument.type);
0938: pa = ((PublisherAssertionsDocument) o).getPublisherAssertions();
0939:
0940: return pa;
0941: }
0942:
0943: /**
0944: * "Used to get full details for a particular registered businessService.
0945: * Returns a serviceDetail message."
0946: *
0947: * @exception RegistryException;
0948: */
0949: public ServiceDetail getServiceDetail(String serviceKey)
0950: throws RegistryException {
0951: String[] keys = new String[1];
0952: keys[0] = serviceKey;
0953:
0954: return getServiceDetail(keys);
0955: }
0956:
0957: /**
0958: * "Used to get full details for a given set of registered businessService
0959: * data. Returns a serviceDetail message."
0960: *
0961: * @exception RegistryException;
0962: */
0963: public ServiceDetail getServiceDetail(String[] serviceKeyArray)
0964: throws RegistryException {
0965: GetServiceDetailDocument doc = GetServiceDetailDocument.Factory
0966: .newInstance();
0967: GetServiceDetail request = doc.addNewGetServiceDetail();
0968:
0969: if (serviceKeyArray != null) {
0970: request.setServiceKeyArray(serviceKeyArray);
0971: }
0972:
0973: ServiceDetail sd;
0974: XmlObject o = execute(doc, this .getInquiryURI()).changeType(
0975: ServiceDetailDocument.type);
0976: sd = ((ServiceDetailDocument) o).getServiceDetail();
0977:
0978: return sd;
0979: }
0980:
0981: /**
0982: * "Used to get full details for a particular registered TModel. Returns a
0983: * tModelDetail message."
0984: *
0985: * @exception RegistryException;
0986: */
0987: public TModelDetail getTModelDetail(String tModelKey)
0988: throws RegistryException {
0989: String[] keys = new String[1];
0990: keys[0] = tModelKey;
0991:
0992: return getTModelDetail(keys);
0993: }
0994:
0995: /**
0996: * "Used to get full details for a given set of registered tModel data.
0997: * Returns a tModelDetail message."
0998: *
0999: * @exception RegistryException;
1000: */
1001: public TModelDetail getTModelDetail(String[] tModelKeyArray)
1002: throws RegistryException {
1003: GetTModelDetailDocument doc = GetTModelDetailDocument.Factory
1004: .newInstance();
1005: GetTModelDetail request = doc.addNewGetTModelDetail();
1006:
1007: if (tModelKeyArray != null) {
1008: request.setTModelKeyArray(tModelKeyArray);
1009: }
1010:
1011: TModelDetail tmd;
1012: XmlObject o = execute(doc, this .getInquiryURI()).changeType(
1013: TModelDetailDocument.type);
1014: tmd = ((TModelDetailDocument) o).getTModelDetail();
1015:
1016: return tmd;
1017: }
1018:
1019: /**
1020: * @exception RegistryException;
1021: */
1022: public PublisherAssertions setPublisherAssertions(String authInfo,
1023: PublisherAssertion[] assertionArray)
1024: throws RegistryException {
1025: SetPublisherAssertionsDocument doc = SetPublisherAssertionsDocument.Factory
1026: .newInstance();
1027: SetPublisherAssertions request = doc
1028: .addNewSetPublisherAssertions();
1029:
1030: if (authInfo != null) {
1031: request.setAuthInfo(authInfo);
1032: }
1033:
1034: if (assertionArray != null) {
1035: request.setPublisherAssertionArray(assertionArray);
1036: }
1037:
1038: PublisherAssertions pa;
1039: XmlObject o = execute(doc, this .getPublishURI()).changeType(
1040: PublisherAssertionsDocument.type);
1041: pa = ((PublisherAssertionsDocument) o).getPublisherAssertions();
1042:
1043: return pa;
1044: }
1045:
1046: /**
1047: * "Used to register new bindingTemplate information or update existing
1048: * bindingTemplate information. Use this to control information about
1049: * technical capabilities exposed by a registered business."
1050: *
1051: * @exception RegistryException;
1052: */
1053: public BindingDetail saveBinding(String authInfo,
1054: BindingTemplate[] bindingArray) throws RegistryException {
1055: SaveBindingDocument doc = SaveBindingDocument.Factory
1056: .newInstance();
1057: SaveBinding request = doc.addNewSaveBinding();
1058:
1059: if (authInfo != null) {
1060: request.setAuthInfo(authInfo);
1061: }
1062:
1063: if (bindingArray != null) {
1064: request.setBindingTemplateArray(bindingArray);
1065: }
1066:
1067: BindingDetail bd;
1068: XmlObject o = execute(doc, this .getPublishURI()).changeType(
1069: BindingDetailDocument.type);
1070: bd = ((BindingDetailDocument) o).getBindingDetail();
1071:
1072: return bd;
1073: }
1074:
1075: /**
1076: * "Used to register new businessEntity information or update existing
1077: * businessEntity information. Use this to control the overall information
1078: * about the entire business. Of the save_x APIs this one has the broadest
1079: * effect."
1080: *
1081: * @exception RegistryException;
1082: */
1083: public BusinessDetail saveBusiness(String authInfo,
1084: BusinessEntity[] businessArray) throws RegistryException {
1085: SaveBusinessDocument doc = SaveBusinessDocument.Factory
1086: .newInstance();
1087: SaveBusiness request = doc.addNewSaveBusiness();
1088:
1089: if (authInfo != null) {
1090: request.setAuthInfo(authInfo);
1091: }
1092:
1093: if (businessArray != null) {
1094: request.setBusinessEntityArray(businessArray);
1095: }
1096:
1097: BusinessDetail bd;
1098: XmlObject o = execute(doc, this .getPublishURI()).changeType(
1099: BusinessDetailDocument.type);
1100: bd = ((BusinessDetailDocument) o).getBusinessDetail();
1101:
1102: return bd;
1103: }
1104:
1105: /**
1106: * "Used to register or update complete information about a businessService
1107: * exposed by a specified businessEntity."
1108: *
1109: * @exception RegistryException;
1110: */
1111: public ServiceDetail saveService(String authInfo,
1112: BusinessService[] serviceArray) throws RegistryException {
1113: SaveServiceDocument doc = SaveServiceDocument.Factory
1114: .newInstance();
1115: SaveService request = doc.addNewSaveService();
1116:
1117: if (authInfo != null) {
1118: request.setAuthInfo(authInfo);
1119: }
1120:
1121: if (serviceArray != null) {
1122: request.setBusinessServiceArray(serviceArray);
1123: }
1124:
1125: ServiceDetail sd;
1126: XmlObject o = execute(doc, this .getPublishURI()).changeType(
1127: ServiceDetailDocument.type);
1128: sd = ((ServiceDetailDocument) o).getServiceDetail();
1129:
1130: return sd;
1131: }
1132:
1133: /**
1134: * "Used to register or update complete information about a tModel."
1135: *
1136: * @exception RegistryException;
1137: */
1138: public TModelDetail saveTModel(String authInfo, TModel[] tModelArray)
1139: throws RegistryException {
1140: SaveTModelDocument doc = SaveTModelDocument.Factory
1141: .newInstance();
1142: SaveTModel request = doc.addNewSaveTModel();
1143:
1144: if (authInfo != null) {
1145: request.setAuthInfo(authInfo);
1146: }
1147:
1148: if (tModelArray != null) {
1149: request.setTModelArray(tModelArray);
1150: }
1151:
1152: TModelDetail tmd;
1153: XmlObject o = execute(doc, this .getPublishURI()).changeType(
1154: TModelDetailDocument.type);
1155: tmd = ((TModelDetailDocument) o).getTModelDetail();
1156:
1157: return tmd;
1158: }
1159:
1160: /**
1161: * Returns an implementation of Transport based on the className passed in.
1162: * If a null value is passed then the default Transport implementation
1163: * "org.apache.ws.scout.transport.AxisTransport" is created and returned.
1164: *
1165: * @return Transport
1166: */
1167: public Transport getTransport(String className) {
1168: Transport transport = null;
1169: Class transportClass = null;
1170:
1171: // If a Transport class name isn't supplied use
1172: // the default Transport implementation.
1173: if (className == null)
1174: className = DEFAULT_TRANSPORT_CLASS;
1175:
1176: try {
1177: // instruct class loader to load the TransportFactory
1178: transportClass = getClassForName(className);
1179: } catch (ClassNotFoundException cnfex) {
1180: cnfex.printStackTrace();
1181: }
1182:
1183: try {
1184: // try to instantiate the TransportFactory
1185: transport = (Transport) transportClass.newInstance();
1186: } catch (java.lang.Exception ex) {
1187: ex.printStackTrace();
1188: }
1189:
1190: return transport;
1191: }
1192:
1193: /**
1194: *
1195: * @param name
1196: * @return The class object for the name given
1197: * @throws ClassNotFoundException
1198: * @throws NoClassDefFoundError
1199: */
1200: public static Class getClassForName(String name)
1201: throws ClassNotFoundException, NoClassDefFoundError {
1202: Class clazz = null;
1203:
1204: try {
1205: // log.info("Using the Context ClassLoader");
1206: ClassLoader ccl = Thread.currentThread()
1207: .getContextClassLoader();
1208: clazz = Class.forName(name, true, ccl);
1209: } catch (Exception e) {
1210: //log.warn("Failed to load the class " + name + " with context
1211: //class loader " + e);
1212: }
1213:
1214: if (null == clazz) {
1215: ClassLoader scl = ClassLoader.getSystemClassLoader();
1216:
1217: try {
1218: clazz = Class.forName(name, true, scl);
1219: } catch (Exception e) {
1220: e.printStackTrace();
1221: }
1222: }
1223:
1224: return clazz;
1225: }
1226: }
|