You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juddi.apache.org by tc...@apache.org on 2009/09/12 06:12:50 UTC
svn commit: r814108 - in /webservices/juddi/trunk:
juddi-core/src/main/java/org/apache/juddi/local/ uddi-client/
uddi-client/src/main/java/org/uddi/api_v3/client/local/
Author: tcunning
Date: Sat Sep 12 04:12:50 2009
New Revision: 814108
URL: http://svn.apache.org/viewvc?rev=814108&view=rev
Log:
JUDDI-277
Move local transport to uddi-client.
Added:
webservices/juddi/trunk/uddi-client/src/main/java/org/uddi/api_v3/client/local/
webservices/juddi/trunk/uddi-client/src/main/java/org/uddi/api_v3/client/local/RequestHandler.java
webservices/juddi/trunk/uddi-client/src/main/java/org/uddi/api_v3/client/local/UDDIInquiryService.java
webservices/juddi/trunk/uddi-client/src/main/java/org/uddi/api_v3/client/local/UDDIPublicationService.java
webservices/juddi/trunk/uddi-client/src/main/java/org/uddi/api_v3/client/local/UDDISecurityService.java
Removed:
webservices/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/local/
Modified:
webservices/juddi/trunk/uddi-client/pom.xml
Modified: webservices/juddi/trunk/uddi-client/pom.xml
URL: http://svn.apache.org/viewvc/webservices/juddi/trunk/uddi-client/pom.xml?rev=814108&r1=814107&r2=814108&view=diff
==============================================================================
--- webservices/juddi/trunk/uddi-client/pom.xml (original)
+++ webservices/juddi/trunk/uddi-client/pom.xml Sat Sep 12 04:12:50 2009
@@ -93,7 +93,6 @@
<groupId>org.apache.juddi</groupId>
<artifactId>juddi-core</artifactId>
<version>3.0.0.SNAPSHOT</version>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.juddi</groupId>
Added: webservices/juddi/trunk/uddi-client/src/main/java/org/uddi/api_v3/client/local/RequestHandler.java
URL: http://svn.apache.org/viewvc/webservices/juddi/trunk/uddi-client/src/main/java/org/uddi/api_v3/client/local/RequestHandler.java?rev=814108&view=auto
==============================================================================
--- webservices/juddi/trunk/uddi-client/src/main/java/org/uddi/api_v3/client/local/RequestHandler.java (added)
+++ webservices/juddi/trunk/uddi-client/src/main/java/org/uddi/api_v3/client/local/RequestHandler.java Sat Sep 12 04:12:50 2009
@@ -0,0 +1,313 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.uddi.api_v3.client.local;
+
+import java.rmi.Remote;
+import java.util.Vector;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.juddi.error.ErrorMessage;
+import org.apache.juddi.error.FatalErrorException;
+import org.apache.juddi.error.RegistryException;
+import org.apache.juddi.error.UDDIErrorHelper;
+import org.apache.juddi.error.UnsupportedException;
+import org.apache.juddi.util.JAXBMarshaller;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * @author Tom Cunningham (tcunning@apache.org)
+ * @author Kurt Stam (kurt.stam@redhat.com)
+ */
+public class RequestHandler implements Runnable
+{
+ // private reference to the webapp's logger.
+ private static Log log = LogFactory.getLog(RequestHandler.class);
+
+ // XML Document Builder
+ private static DocumentBuilder docBuilder = null;
+
+ private volatile String version;
+ private volatile String operation;
+ private volatile Element uddiReq;
+ private volatile Node response;
+ private volatile String exception;
+ private volatile Remote portType;
+
+ /**
+ * Grab the local name of the UDDI request element
+ * from the UDDI Request. If a value isn't returned
+ * (either null or an empty String is returned) then
+ * throw a FatalError exception. This is probably a
+ * configuration problem related to the XML Parser
+ * that jUDDI is using.
+ * @param uddiReq
+ * @return
+ * @throws Exception
+ */
+ public String getOperation(Element uddiReq) throws Exception
+ {
+ if (uddiReq == null)
+ throw new FatalErrorException(new ErrorMessage("errors.local.soapnotfound"));
+
+ String operation = uddiReq.getLocalName();
+ if ((operation == null) || (operation.trim().length() == 0))
+ throw new FatalErrorException(new ErrorMessage("errors.local.serviceoperation"));
+ setOperation(operation);
+ return operation;
+ }
+ /**
+ * Grab the generic attribute value (version value). If
+ * one isn't specified or the value specified is not "2.0"
+ * then throw an exception (this value must be specified
+ * for all UDDI requests and currently only vesion 2.0
+ * UDDI requests are supported).
+ *
+ * @param uddiReq
+ * @return
+ * @throws Exception
+ */
+ public String getVersion(Element uddiReq, String operation) throws Exception
+ {
+ String version = uddiReq.getAttribute("generic");
+ if (version == null)
+ throw new FatalErrorException(new ErrorMessage("errors.local.generic"));
+ setVersion(version);
+ return version;
+ }
+
+ public static String getText(Element element)
+ {
+ StringBuffer textBuffer = new StringBuffer();
+
+ NodeList nodeList = element.getChildNodes();
+ for (int i=0; i<nodeList.getLength(); i++)
+ {
+ if (nodeList.item(i).getNodeType() == Element.TEXT_NODE)
+ textBuffer.append(nodeList.item(i).getNodeValue());
+ }
+
+ return textBuffer.toString().trim();
+ }
+
+
+ public void run()
+ {
+ try
+ {
+ // Lookup the appropriate XML handler. Throw an
+ // UnsupportedException if one could not be located.
+ String reqString = getText(uddiReq);
+ Object uddiReqObj = JAXBMarshaller.unmarshallFromString(reqString, "org.uddi.api_v3");
+
+
+
+ // Lookup the appropriate response handler which will
+ // be used to marshal the UDDI object into the appropriate
+ // xml format.
+
+ /*
+ IHandler responseHandler = maker.lookup(uddiResObj.getClass().getName());
+ if (responseHandler == null)
+ throw new FatalErrorException("The response object " +
+ "type is unknown: " +uddiResObj.getClass().getName());
+ */
+
+ // Create a new 'temp' XML element to use as a container
+ // in which to marshal the UDDI response data into.
+
+ /*
+ DocumentBuilder docBuilder = getDocumentBuilder();
+ Document document = docBuilder.newDocument();
+ Element element = document.createElement("temp");
+ */
+ // Lookup the appropriate response handler and marshal
+ // the juddi object into the appropriate xml format (we
+ // only support UDDI v2.0 at this time). Attach the
+ // results to the body of the SOAP response.
+
+ //responseHandler.marshal(uddiResObj,element);
+
+ // Grab a reference to the 'temp' element's
+ // only child here (this has the effect of
+ // discarding the temp element) and append
+ // this child to the soap response body
+ //document.appendChild(element.getFirstChild());
+ //setResponse(document);
+ throw new FatalErrorException(new ErrorMessage(""));
+ }
+ catch (RegistryException rex)
+ {
+ log.error(rex.getMessage());
+
+ // All RegistryException and subclasses of RegistryException
+ // should contain values for populating a SOAP Fault as well
+ // as a UDDI DispositionReport with specific information
+ // about the problem.
+ // SOAP Fault values
+ //String faultCode = rex.getFaultCode();
+ //String faultString = rex.getFaultString();
+ //String faultActor = rex.getFaultActor();
+
+ // UDDI DispositionReport values
+ //String errno = null;
+ //String errCode = null;
+ //String errText = null;
+ /*
+ DispositionReport dispRpt = rex.getDispositionReport();
+ if (dispRpt != null)
+ {
+ Result result = null;
+ ErrInfo errInfo = null;
+
+ Vector results = dispRpt.getResultVector();
+ if ((results != null) && (!results.isEmpty()))
+ result = (Result)results.elementAt(0);
+
+ if (result != null)
+ {
+ errno = String.valueOf(result.getErrno()); // UDDI Result errno
+ errInfo = result.getErrInfo();
+
+ if (errInfo != null)
+ {
+ errCode = errInfo.getErrCode(); // UDDI ErrInfo errCode
+ errText = errInfo.getErrMsg(); // UDDI ErrInfo errMsg
+ }
+ }
+ }
+ */
+ // We should have everything we need to assemble
+ // the SOAPFault so lets piece it together and
+ // send it on it's way.
+ String fault = null;
+ //String fault = "faultCode=" + faultCode + ", faultString=" + faultString
+ //+ ", faultActor=" + faultActor + ", errno=" + errno + ", errCode=" + errCode
+ //+ ", errText=" + errText;
+ setException(fault);
+
+ }
+ catch(Exception ex) // Catch any other exceptions
+ {
+ log.error(ex.getMessage());
+
+ // Because something occured that jUDDI wasn't expecting
+ // let's set default SOAP Fault values. Since SOAPExceptions
+ // here are most likely XML validation errors let's blame the
+ // client by placing "Client" in the Fault Code and pass
+ // the Exception message back to the client.
+
+ String faultCode = "Server";
+ String faultString = ex.getMessage();
+ String faultActor = null;
+
+ // Let's set default values for the UDDI DispositionReport
+ // here. While we didn't catch a RegistryException (or
+ // subclass) but we're going to be friendly and include a
+ // FatalError DispositionReport within the SOAP Fault anyway.
+
+ String errno = String.valueOf(UDDIErrorHelper.E_FATAL_ERROR);
+ String errCode = UDDIErrorHelper.lookupErrCode(UDDIErrorHelper.E_FATAL_ERROR);
+ String errText = UDDIErrorHelper.lookupErrText(UDDIErrorHelper.E_FATAL_ERROR) +
+ " An internal UDDI server error has " +
+ "occurred. Please report this error " +
+ "to the UDDI server administrator.";
+
+ // We should have everything we need to assemble
+ // the SOAPFault so lets piece it together and
+ // send it on it's way.
+ String fault = "faultCode=" + faultCode + ", faultString=" + faultString
+ + ", faultActor=" + faultActor + ", errno=" + errno + ", errCode=" + errCode
+ + ", errText=" + errText;
+ setException(fault);
+ }
+ }
+
+ /**
+ *
+ */
+ private DocumentBuilder getDocumentBuilder()
+ {
+ if (docBuilder == null)
+ docBuilder = createDocumentBuilder();
+ return docBuilder;
+ }
+
+ /**
+ *
+ */
+ private synchronized DocumentBuilder createDocumentBuilder()
+ {
+ if (docBuilder != null)
+ return docBuilder;
+
+ try {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ //factory.setValidating(true);
+
+ docBuilder = factory.newDocumentBuilder();
+ }
+ catch(ParserConfigurationException pcex) {
+ pcex.printStackTrace();
+ }
+
+ return docBuilder;
+ }
+public String getOperation() {
+ return operation;
+}
+public void setOperation(String operation) {
+ this.operation = operation;
+}
+public Node getResponse() {
+ return response;
+}
+public void setResponse(Node response) {
+ this.response = response;
+}
+public Element getUddiReq() {
+ return uddiReq;
+}
+public void setUddiReq(Element uddiReq) {
+ this.uddiReq = uddiReq;
+}
+public Remote getPortType() {
+ return portType;
+}
+public void setPortType(Remote portType) {
+ this.portType = portType;
+}
+public String getVersion() {
+ return version;
+}
+public void setVersion(String version) {
+ this.version = version;
+}
+public String getException() {
+ return exception;
+}
+public void setException(String exception) {
+ this.exception = exception;
+}
+}
\ No newline at end of file
Added: webservices/juddi/trunk/uddi-client/src/main/java/org/uddi/api_v3/client/local/UDDIInquiryService.java
URL: http://svn.apache.org/viewvc/webservices/juddi/trunk/uddi-client/src/main/java/org/uddi/api_v3/client/local/UDDIInquiryService.java?rev=814108&view=auto
==============================================================================
--- webservices/juddi/trunk/uddi-client/src/main/java/org/uddi/api_v3/client/local/UDDIInquiryService.java (added)
+++ webservices/juddi/trunk/uddi-client/src/main/java/org/uddi/api_v3/client/local/UDDIInquiryService.java Sat Sep 12 04:12:50 2009
@@ -0,0 +1,87 @@
+package org.uddi.api_v3.client.local;
+
+import java.util.HashMap;
+
+import org.apache.juddi.Registry;
+import org.apache.juddi.api.impl.UDDIInquiryImpl;
+import org.apache.juddi.error.ErrorMessage;
+import org.apache.juddi.error.FatalErrorException;
+import org.apache.juddi.error.RegistryException;
+import org.apache.juddi.error.UnsupportedException;
+import org.uddi.api_v3.client.transport.InVMTransport;
+import org.uddi.v3_service.UDDIInquiryPortType;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * @author Tom Cunningham (tcunning@apache.org)
+ */
+public class UDDIInquiryService {
+ private static final long serialVersionUID = 1L;
+ private UDDIInquiryImpl inquiry = new UDDIInquiryImpl();
+
+ private HashMap<String, String> operations = null;
+
+ public UDDIInquiryService() {
+ super();
+ operations = new HashMap<String, String>();
+ operations.put("find_business", "findBusiness");
+ operations.put("find_service", "findService");
+ operations.put("find_binding", "findBinding");
+ operations.put("find_tmodel", "findTModel");
+ operations.put("find_relatedbusinesses", "findRelatedBusinesses");
+ operations.put("get_businessdetail", "getBusinessDetail");
+ operations.put("get_servicedetail", "getServiceDetail");
+ operations.put("get_bindingdetail", "getBindingDetail");
+ operations.put("get_tmodeldetail", "getTModelDetail");
+ operations.put("get_operationalInfo", "getOperationalInfo");
+ }
+
+
+ //Verify that the appropriate endpoint was targeted for
+ // this service request. The validateRequest method will
+ // throw an UnsupportedException if anything's amiss.
+ public void validateRequest(String operation,String version, Element uddiReq)
+ throws RegistryException
+ {
+ // If the value
+ // specified is not "2.0" then throw an exception (this
+ // value must be specified for all UDDI requests and
+ // only version 2.0 UDDI requests are supported by
+ // this endpoint).
+ if (version == null)
+ throw new FatalErrorException(new ErrorMessage("errors.local.generic"));
+
+ if ((operation == null) || (operation.trim().length() == 0))
+ throw new FatalErrorException(new ErrorMessage("errors.local.operation.notidentified"));
+
+ else if (!operations.containsKey(operation.toLowerCase()))
+ throw new UnsupportedException(new ErrorMessage("errors.local.inquiry.notsupported"));
+ }
+
+ public Node inquire(Element uddiReq) throws Exception{
+
+ Registry.start();
+ InVMTransport invmtransport = new InVMTransport();
+ UDDIInquiryPortType inquiry = invmtransport.getUDDIInquiryService();
+
+ //new RequestHandler on it's own thread
+ RequestHandler requestHandler = new RequestHandler();
+ requestHandler.setUddiReq(uddiReq);
+ requestHandler.setPortType(inquiry);
+
+ String operation = requestHandler.getOperation(uddiReq);
+ String version = requestHandler.getVersion(uddiReq,operation);
+ validateRequest(operation, version, uddiReq);
+ Thread thread = new Thread(requestHandler, "WorkThread");
+ thread.start();
+ thread.join();
+
+ if (requestHandler.getException()!=null) {
+ throw new Exception(requestHandler.getException());
+ }
+
+ return requestHandler.getResponse();
+ }
+
+}
Added: webservices/juddi/trunk/uddi-client/src/main/java/org/uddi/api_v3/client/local/UDDIPublicationService.java
URL: http://svn.apache.org/viewvc/webservices/juddi/trunk/uddi-client/src/main/java/org/uddi/api_v3/client/local/UDDIPublicationService.java?rev=814108&view=auto
==============================================================================
--- webservices/juddi/trunk/uddi-client/src/main/java/org/uddi/api_v3/client/local/UDDIPublicationService.java (added)
+++ webservices/juddi/trunk/uddi-client/src/main/java/org/uddi/api_v3/client/local/UDDIPublicationService.java Sat Sep 12 04:12:50 2009
@@ -0,0 +1,82 @@
+package org.uddi.api_v3.client.local;
+
+import java.util.HashMap;
+
+import org.apache.juddi.Registry;
+import org.apache.juddi.error.ErrorMessage;
+import org.apache.juddi.error.FatalErrorException;
+import org.apache.juddi.error.RegistryException;
+import org.apache.juddi.error.UnsupportedException;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * @author Tom Cunningham (tcunning@apache.org)
+ */
+public class UDDIPublicationService {
+
+ // collection of valid operations
+
+
+ private HashMap<String, String> operations = null;
+
+
+ public UDDIPublicationService() {
+ super();
+ operations = new HashMap<String, String>();
+ operations.put("get_registeredInfo", "getRegisteredInfo");
+ operations.put("save_business", "saveBusiness");
+ operations.put("save_service", "saveService");
+ operations.put("save_binding", "saveBinding");
+ operations.put("save_tmodel", "saveTModel");
+ operations.put("delete_business", "deleteBusiness");
+ operations.put("delete_service", "deleteService");
+ operations.put("delete_binding", "deleteBinding");
+ operations.put("delete_tmodel", "deleteTModel");
+ operations.put("add_publisherassertions", "addPublisherAssertions");
+ operations.put("set_publisherassertions", "setPublisherAssertions");
+ operations.put("get_publisherassertions", "getPublisherAssertions");
+ operations.put("delete_publisherassertions", "deletePublisherAssertions");
+ operations.put("get_assertionstatusreport", "getAssertionStatusReport");
+ }
+
+ public void validateRequest(String operation,String version,Element uddiReq)
+ throws RegistryException
+
+ {
+
+ if (version == null)
+ throw new FatalErrorException(new ErrorMessage("errors.local.generic"));
+
+ if ((operation == null) || (operation.trim().length() == 0))
+ throw new FatalErrorException(new ErrorMessage("errors.local.operation.notidentified"));
+
+ else if (!operations.containsKey(operation.toLowerCase()))
+ throw new UnsupportedException(new ErrorMessage("errors.local.publish.notsupported"));
+
+ }
+
+
+
+ public Node publish(Element uddiReq) throws Exception
+ {
+ Registry.start();
+
+ //new RequestHandler on it's own thread
+ RequestHandler requestHandler = new RequestHandler();
+ requestHandler.setUddiReq(uddiReq);
+ String operation = requestHandler.getOperation(uddiReq);
+ String version = requestHandler.getVersion(uddiReq, operation);
+ validateRequest(operation, version, uddiReq);
+
+ Thread thread = new Thread(requestHandler, "WorkThread");
+ thread.start();
+ thread.join();
+
+ if (requestHandler.getException()!=null) {
+ throw new Exception(requestHandler.getException());
+ }
+
+ return requestHandler.getResponse();
+ }
+}
Added: webservices/juddi/trunk/uddi-client/src/main/java/org/uddi/api_v3/client/local/UDDISecurityService.java
URL: http://svn.apache.org/viewvc/webservices/juddi/trunk/uddi-client/src/main/java/org/uddi/api_v3/client/local/UDDISecurityService.java?rev=814108&view=auto
==============================================================================
--- webservices/juddi/trunk/uddi-client/src/main/java/org/uddi/api_v3/client/local/UDDISecurityService.java (added)
+++ webservices/juddi/trunk/uddi-client/src/main/java/org/uddi/api_v3/client/local/UDDISecurityService.java Sat Sep 12 04:12:50 2009
@@ -0,0 +1,70 @@
+package org.uddi.api_v3.client.local;
+
+import java.util.HashMap;
+
+import org.apache.juddi.Registry;
+import org.apache.juddi.error.ErrorMessage;
+import org.apache.juddi.error.FatalErrorException;
+import org.apache.juddi.error.RegistryException;
+import org.apache.juddi.error.UnsupportedException;
+import org.uddi.api_v3.client.transport.InVMTransport;
+import org.uddi.v3_service.UDDISecurityPortType;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * @author Tom Cunningham (tcunning@apache.org)
+ * @author Kurt Stam (kurt.stam@redhat.com)
+ */
+public class UDDISecurityService {
+
+ // collection of valid operations
+ private HashMap<String, String> operations = null;
+
+ public UDDISecurityService() {
+ super();
+ operations = new HashMap<String, String>();
+ operations.put("get_authtoken", "getAuthToken");
+ operations.put("discard_authToken", "discardAuthToken");
+ }
+
+ public void validateRequest(String operation,String version,Element uddiReq)
+ throws RegistryException
+ {
+ if (version == null)
+ throw new FatalErrorException(new ErrorMessage("errors.local.generic"));
+
+ if ((operation == null) || (operation.trim().length() == 0))
+ throw new FatalErrorException(new ErrorMessage("errors.local.operation.notidentified"));
+
+ else if (!operations.containsKey(operation.toLowerCase()))
+ throw new UnsupportedException(new ErrorMessage("errors.local.security.notsupported"));
+
+ }
+
+ public Node secure(Element uddiReq) throws Exception
+ {
+ Registry.start();
+ InVMTransport invmtransport = new InVMTransport();
+ UDDISecurityPortType security = invmtransport.getUDDISecurityService();
+
+ //new RequestHandler on it's own thread
+ RequestHandler requestHandler = new RequestHandler();
+ requestHandler.setUddiReq(uddiReq);
+ requestHandler.setPortType(security);
+
+ String operation = requestHandler.getOperation(uddiReq);
+ String version = requestHandler.getVersion(uddiReq, operation);
+ validateRequest(operation, version, uddiReq);
+
+ Thread thread = new Thread(requestHandler, "WorkThread");
+ thread.start();
+ thread.join();
+
+ if (requestHandler.getException()!=null) {
+ throw new Exception(requestHandler.getException());
+ }
+
+ return requestHandler.getResponse();
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: juddi-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: juddi-cvs-help@ws.apache.org