[jboss-svn-commits] JBL Code SVN: r33315 - in labs/jbossesb/trunk/product/tools/systinet: src/main/java/org/jboss/soa/esb/registry and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Jun 2 13:06:20 EDT 2010
Author: tcunning
Date: 2010-06-02 13:06:19 -0400 (Wed, 02 Jun 2010)
New Revision: 33315
Added:
labs/jbossesb/trunk/product/tools/systinet/README
labs/jbossesb/trunk/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/systinet/
labs/jbossesb/trunk/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/systinet/CallDemarcation.java
labs/jbossesb/trunk/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/systinet/InquiryService.java
labs/jbossesb/trunk/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/systinet/PublishService.java
labs/jbossesb/trunk/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/systinet/RequestHandler.java
labs/jbossesb/trunk/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/systinet/RequestUtil.java
Modified:
labs/jbossesb/trunk/product/tools/systinet/build.xml
Log:
JBESB-2783
Commit the new Systinet Transport.
Added: labs/jbossesb/trunk/product/tools/systinet/README
===================================================================
--- labs/jbossesb/trunk/product/tools/systinet/README (rev 0)
+++ labs/jbossesb/trunk/product/tools/systinet/README 2010-06-02 17:06:19 UTC (rev 33315)
@@ -0,0 +1,7 @@
+This directory contains a scout transport and jUDDI-style Inquiry/Publish
+services in order to run a colocated Systinet registry.
+
+A couple of notes :
+- this is designed to be run on a JBoss 4 AS
+- this is designed to work with UDDI v2 calls
+
Modified: labs/jbossesb/trunk/product/tools/systinet/build.xml
===================================================================
--- labs/jbossesb/trunk/product/tools/systinet/build.xml 2010-06-02 17:03:51 UTC (rev 33314)
+++ labs/jbossesb/trunk/product/tools/systinet/build.xml 2010-06-02 17:06:19 UTC (rev 33315)
@@ -1,13 +1,10 @@
<project name="jon-build" default="deploy" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant">
<property name="build.dir" location="build"/>
- <property name="classes.dir" location="${build.dir}/classes"/>
+ <property name="classes.dir" value="${build.dir}/classes"/>
+ <property name="classpath.dir" location="../../../antlib"/>
- <property name="product.dir" location="../.."/>
- <property name="product.build.dir" location="${product.dir}/build"/>
- <property name="product.lib.dir" location="${product.build.dir}/lib"/>
- <property name="jbossesb.lib.dir" location="${product.build.dir}/jbossesb/lib"/>
-
+ <property name="soap.classes.dir" location="${basedir}/../../services/soap/build/classes"/>
<property name="esb.transport.jar.version" value="1.0"/>
<property name="esb.transport.jar.name" value="jbossesb-transport-${esb.transport.jar.version}.jar"/>
<property name="esb.transport.client.jar.name" value="jbossesb-transport-client-${esb.transport.jar.version}.jar"/>
@@ -18,12 +15,19 @@
<property name="java.dir" location="${src.dir}/java"/>
<property name="resources.dir" location="${src.dir}/resources"/>
+ <property file="systinet.properties"/>
+
<target name="clean">
<delete dir="${build.dir}"/>
</target>
- <path id="classpath">
- <fileset dir="${product.lib.dir}" includes="servlet-api-*.jar"/>
+ <path id="classpath">
+ <fileset dir="${jboss.home.dir}/server/default/deploy/jbossesb.sar/lib"
+ includes="**/*.jar"/>
+ <fileset dir="${jboss.home.dir}/server/default/lib"
+ includes="**/*.jar"/>
+ <fileset dir="${systinet.reg.dir}/lib" includes="**/*.jar"/>
+ <fileset dir="${systinet.reg.dir}/app/uddi" includes="**/*.jar"/>
</path>
<target name="compile-transport">
@@ -35,22 +39,29 @@
<target name="jar-transport" depends="compile-transport">
<echo message="Plugin version is ${esb.transport.jar.version}"/>
<jar destfile="${esb.transport.jar}">
- <fileset dir="${classes.dir}"/>
- <fileset dir="${resources.dir}"/>
+ <fileset dir="${classes.dir}">
+ <include name="org/jboss/soa/esb/registry/systinet/*"/>
+ </fileset>
</jar>
+ <!--
<jar destfile="${esb.client.transport.jar}">
<fileset dir="${classes.dir}">
- <include name="**/Inquiry.class"/>
- <include name="**/Publish.class"/>
+ <include name="org/jboss/soa/esb/registry/systinet/SystinetTransport.class"/>
</fileset>
<fileset dir="${resources.dir}"/>
</jar>
+ -->
</target>
<target name="deploy" depends="jar-transport">
- <copy todir="${jbossesb.lib.dir}">
- <fileset file="${esb.transport.jar}"/>
- <fileset file="${esb.client.transport.jar}"/>
- </copy>
+ <copy file="${esb.transport.jar}"
+ overwrite="true"
+ todir="${jboss.home.dir}/server/default/deploy/jbossesb.sar/registry.war/WEB-INF/lib"/>
+<!--
+ <copy file="${esb.client.transport.jar}"
+ overwrite="true"
+ todir="${jboss.home.dir}/server/default/deploy/jbossesb.sar/lib"/>
+-->
</target>
+
</project>
Added: labs/jbossesb/trunk/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/systinet/CallDemarcation.java
===================================================================
--- labs/jbossesb/trunk/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/systinet/CallDemarcation.java (rev 0)
+++ labs/jbossesb/trunk/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/systinet/CallDemarcation.java 2010-06-02 17:06:19 UTC (rev 33315)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.registry.systinet;
+
+import com.systinet.wasp.webservice.CallContextImpl;
+import com.systinet.wasp.webservice.CurrentImpl;
+import org.idoox.transport.server.ServerConnection;
+import org.idoox.wasp.Context;
+import org.idoox.wasp.SecurityHelper;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+* Contains functions that must be used demarcate calls
+* to internal Systinet registry APIs.
+*/
+public class CallDemarcation {
+ /**
+ * Return the call context
+ */
+ private static CallContextImpl getCallContext() {
+ CurrentImpl current = (CurrentImpl)Context.getInstance(org.systinet.wasp.webservice.ICurrent.class);
+ // get SSJ's current contexts
+
+ // get thread local state (InheritableThreadLocal)
+ CurrentImpl.ThreadLocals threadLocals = current.getThreadLocals();
+ // get or initialize call context
+ CallContextImpl callCtx = (CallContextImpl)threadLocals.callContext;
+ if (callCtx == null){
+ callCtx = new CallContextImpl(new HashMap(5), new HashMap(5));
+ threadLocals.callContext = callCtx;
+ }
+ return callCtx;
+ }
+
+ /**
+ * Called before using registry's internal APIs, a threadlocal state
+ * is authenticated by a username/password.
+ * @param userName userName to authenticate
+ * @param password password to authenticate with
+ */
+ public static void beginCall(String userName, String password) throws Exception {
+ boolean auth = SecurityHelper.authenticateClient(userName, password, SecurityHelper.HttpBasic);
+ if (!auth) {
+ throw new Exception("Could not authenticate Systinet transport client");
+ }
+
+ CallContextImpl callCtx = getCallContext();
+ callCtx.beginCall();
+ }
+
+ /**
+ * End the call.
+ */
+ public static void endCall(){
+ CallContextImpl callCtx = getCallContext();
+ callCtx.endCall();
+ }
+}
Added: labs/jbossesb/trunk/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/systinet/InquiryService.java
===================================================================
--- labs/jbossesb/trunk/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/systinet/InquiryService.java (rev 0)
+++ labs/jbossesb/trunk/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/systinet/InquiryService.java 2010-06-02 17:06:19 UTC (rev 33315)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.registry.systinet;
+
+import java.util.Hashtable;
+
+import javax.xml.soap.SOAPMessage;
+
+import org.apache.juddi.IRegistry;
+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;
+
+/**
+ * InquiryService takes a request and calls the RequestHandler to execute the UDDI call
+ *
+ * @author Tom Cunningham (tcunning at redhat.com)
+ */
+public class InquiryService {
+ private Hashtable operations = null;
+ private RequestUtil util = null;
+
+ public InquiryService() {
+ super();
+ util = RequestUtil.getInstance();
+ operations = util.getInquiryQueries();
+ }
+
+ public Hashtable getOperations() {
+ return operations;
+ }
+
+ //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("A UDDI generic attribute " +
+ "value was not found for UDDI request: "+operation+" (The " +
+ "'generic' attribute must be present)");
+ else if (!version.equals(IRegistry.UDDI_V2_GENERIC))
+ throw new UnsupportedException("Only UDDI v2 " +
+ "requests are currently supported. The generic attribute value " +
+ "received was: "+version);
+
+ if ((operation == null) || (operation.trim().length() == 0))
+ throw new FatalErrorException("The UDDI service operation " +
+ "could not be identified.");
+ }
+
+ public Node inquire(Element uddiReq) throws Exception {
+ 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: labs/jbossesb/trunk/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/systinet/PublishService.java
===================================================================
--- labs/jbossesb/trunk/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/systinet/PublishService.java (rev 0)
+++ labs/jbossesb/trunk/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/systinet/PublishService.java 2010-06-02 17:06:19 UTC (rev 33315)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.registry.systinet;
+
+import java.util.TreeSet;
+
+import org.apache.juddi.IRegistry;
+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;
+
+import javax.xml.soap.SOAPMessage;
+import org.systinet.uddi.client.v2.struct.*;
+
+import java.util.Hashtable;
+
+/**
+ * PublishService takes a request and calls the RequestHandler to execute the UDDI call
+ *
+ * @author Tom Cunningham (tcunning at redhat.com)
+ */
+public class PublishService
+{
+ public RequestUtil util;
+ public Hashtable operations;
+
+ public PublishService() {
+ super();
+ util = RequestUtil.getInstance();
+ operations = util.getPublishQueries();
+ }
+
+ 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("A UDDI generic attribute " +
+ "value was not found for UDDI request: "+operation+" (The " +
+ "'generic' attribute must be present)");
+ else if (!version.equals(IRegistry.UDDI_V2_GENERIC))
+ throw new UnsupportedException("Only UDDI v2 " +
+ "requests are currently supported. The generic attribute value " +
+ "received was: "+version);
+
+ if ((operation == null) || (operation.trim().length() == 0))
+ throw new FatalErrorException("The UDDI service operation " +
+ "could not be identified.");
+ }
+
+ public Node publish(Element uddiReq) throws Exception
+ {
+ 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: labs/jbossesb/trunk/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/systinet/RequestHandler.java
===================================================================
--- labs/jbossesb/trunk/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/systinet/RequestHandler.java (rev 0)
+++ labs/jbossesb/trunk/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/systinet/RequestHandler.java 2010-06-02 17:06:19 UTC (rev 33315)
@@ -0,0 +1,433 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.registry.systinet;
+
+import java.util.Vector;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPPart;
+import javax.xml.soap.SOAPMessage;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.juddi.datatype.RegistryObject;
+import org.apache.juddi.datatype.response.DispositionReport;
+import org.apache.juddi.datatype.response.ErrInfo;
+import org.apache.juddi.datatype.response.Result;
+import org.apache.juddi.error.BusyException;
+import org.apache.juddi.error.FatalErrorException;
+import org.apache.juddi.error.RegistryException;
+import org.apache.juddi.error.UnsupportedException;
+import org.apache.juddi.handler.HandlerMaker;
+import org.apache.juddi.handler.IHandler;
+import org.apache.juddi.registry.RegistryEngine;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import com.systinet.wasp.webservice.ServiceClientImpl;
+import org.systinet.wasp.webservice.ServiceClient;
+import com.systinet.wasp.client.XMLInvocationHelperImpl;
+import org.systinet.wasp.client.XMLInvocationHelper;
+import com.systinet.saaj.soap.WaspSOAPMessageFactoryImpl;
+import org.systinet.uddi.client.base.UDDIObject;
+import javax.xml.soap.SOAPElement;
+
+import org.idoox.wasp.Context;
+import org.idoox.webservice.client.WebServiceLookup;
+import org.systinet.uddi.client.v2.Publish;
+import org.systinet.uddi.client.v2.Inquire;
+import org.systinet.uddi.client.base.UDDIObject;
+
+import org.idoox.webservice.client.WebServiceLookup;
+
+// imports of WASP security
+import org.idoox.security.AuthResult;
+import org.idoox.security.Credentials;
+import org.idoox.security.PrincipalAuthenticator;
+import org.idoox.security.client.Current;
+import org.systinet.uddi.client.v2.UDDIException;
+
+import org.jboss.soa.esb.common.Configuration;
+import org.jboss.soa.esb.common.Environment;
+import org.jboss.soa.esb.common.ModulePropertyManager;
+
+/**
+ * RequestHandler makes a UDDI call and returns the UDDI response in a threaded manner.
+ *
+ * @author Tom Cunningham (tcunning at 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 ServiceClient serviceClient;
+
+ private volatile String user;
+ private volatile String password;
+ private volatile String version;
+ private volatile String operation;
+ private volatile Element uddiReq;
+ private volatile Node response;
+ private volatile String exception;
+
+ private static final String FROM_XML = "fromXML";
+ private static final String TO_XML = "toXML";
+ private static final String DEFAULT_USER = "jbossesb";
+
+ private Inquire inquiry;
+ private Publish publish;
+
+
+ public RequestHandler() {
+ inquiry =
+ (Inquire) Context.getInstance(Inquire.class);
+ publish =
+ (Publish) Context.getInstance(Publish.class);
+
+ String esbuser = ModulePropertyManager.getPropertyManager(ModulePropertyManager.REGISTRY_MODULE).getProperty(Environment.REGISTRY_USER);
+ String esbpassword = ModulePropertyManager.getPropertyManager(ModulePropertyManager.REGISTRY_MODULE).getProperty(Environment.REGISTRY_PASSWORD);
+
+ setUser(esbuser);
+ setPassword (esbpassword);
+ }
+
+ /**
+ * 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("A UDDI request was not " +
+ "found in the SOAP message.");
+
+ String operation = uddiReq.getLocalName();
+ if ((operation == null) || (operation.trim().length() == 0))
+ throw new FatalErrorException("The UDDI service operation " +
+ "could not be identified.");
+ 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("A UDDI generic attribute " +
+ "value was not found for UDDI request: "+operation+" (The " +
+ "'generic' attribute must be present)");
+ setVersion(version);
+ return version;
+ }
+
+ public void run()
+ {
+ try
+ {
+ RequestUtil util = RequestUtil.getInstance();
+ String api = util.getApi(operation);
+ if (util.INQUIRY_API.equals(api)) {
+ Class c = inquiry.getClass();
+ Method m = c.getMethod(operation,
+ (Class)util.getInquiryQueries().get(operation.toLowerCase()));
+
+ // Change the jUDDI UDDI req to a Systinet one
+ Class clazz = (Class)util.getInquiryQueries().get(operation.toLowerCase());
+ Object obj = clazz.newInstance();
+ Method fromXML = clazz.getMethod(FROM_XML, org.w3c.dom.Element.class);
+ UDDIObject uddiobj = (UDDIObject)fromXML.invoke(obj, uddiReq);
+
+ CallDemarcation.beginCall(user, password);
+ UDDIObject object = (UDDIObject) m.invoke(inquiry, uddiobj);
+ CallDemarcation.endCall();
+
+ DocumentBuilder docBuilder = getDocumentBuilder();
+ Document document = docBuilder.newDocument();
+
+ Class responseClass = (Class) util.getInquiryReturnTypes().get(operation.toLowerCase());
+ Method toXML = responseClass.getMethod(TO_XML, org.w3c.dom.Document.class);
+
+ Element elem = (Element) toXML.invoke(object, document);
+ document.appendChild(elem);
+ setResponse(document);
+ } else if (util.PUBLISH_API.equals(api)) {
+ Class c = publish.getClass();
+ Method m = c.getMethod(operation,
+ (Class)util.getPublishQueries().get(operation.toLowerCase()));
+
+ // Change the jUDDI UDDI req to a Systinet one
+ Class clazz = (Class)util.getPublishQueries().get(operation.toLowerCase());
+ Object obj = clazz.newInstance();
+ Method fromXML = clazz.getMethod(FROM_XML, org.w3c.dom.Element.class);
+ UDDIObject uddiobj = (UDDIObject)fromXML.invoke(obj, uddiReq);
+
+ CallDemarcation.beginCall(user, password);
+ UDDIObject object = (UDDIObject) m.invoke(publish, uddiobj);
+ CallDemarcation.endCall();
+
+ DocumentBuilder docBuilder = getDocumentBuilder();
+ Document document = docBuilder.newDocument();
+
+ Class responseClass = (Class) util.getPublishReturnTypes().get(operation.toLowerCase());
+ Method toXML = responseClass.getMethod(TO_XML, org.w3c.dom.Document.class);
+
+ Element pubElem = (Element) toXML.invoke(object, document);
+ document.appendChild(pubElem);
+ setResponse(document);
+ } else {
+ setException("Operation " + operation + " was not found in the inquiry "
+ + "or the publication API.");
+ }
+ }
+ 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 = "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 Systinet 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 = null;
+ String faultActor = null;
+ String errno = null;
+ String errCode = null;
+ String errText = null;
+
+ if (ex instanceof InvocationTargetException) {
+ InvocationTargetException ite = (InvocationTargetException) ex;
+ if (ite.getTargetException() != null) {
+ faultString = ite.getTargetException().getMessage();
+ if (ite.getTargetException() instanceof UDDIException) {
+ UDDIException uddi = (UDDIException) ite.getTargetException();
+ errno = (new Integer(uddi.getErrno())).toString();
+ errCode = uddi.getFaultCode();
+ errText = uddi.getFaultString();
+ }
+ }
+ } else {
+ faultString = ex.getMessage();
+ 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.
+
+ errno = String.valueOf(Result.E_FATAL_ERROR);
+ errCode = Result.lookupErrCode(Result.E_FATAL_ERROR);
+ errText = Result.lookupErrText(Result.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 String getUser() {
+ return user;
+ }
+
+ public void setUser(String user) {
+ this.user = user;
+ }
+
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getUsername() {
+ return user;
+ }
+
+ public void setUsername(String version) {
+ this.user = user;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+
+ public String getException() {
+ return exception;
+ }
+
+ public void setException(String exception) {
+ this.exception = exception;
+ }
+}
\ No newline at end of file
Added: labs/jbossesb/trunk/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/systinet/RequestUtil.java
===================================================================
--- labs/jbossesb/trunk/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/systinet/RequestUtil.java (rev 0)
+++ labs/jbossesb/trunk/product/tools/systinet/src/main/java/org/jboss/soa/esb/registry/systinet/RequestUtil.java 2010-06-02 17:06:19 UTC (rev 33315)
@@ -0,0 +1,154 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.registry.systinet;
+
+import java.util.Enumeration;
+
+import java.util.Hashtable;
+import org.systinet.uddi.client.v2.struct.*;
+
+/**
+ * RequestUtil is a utility class which contains a few mappings of UDDI calls :
+ *
+ * inquiryQueries maps UDDI request function -> corresponding Systinet request class.
+ * publishQueries maps UDDI publication requests functions -> corresponding Systinet request class
+ * apiChooser maps request functions -> inquiry/publish API
+ * inquiryReturnTypes maps the UDDI inquiry function -> corresponding Systinet response class
+ * publishReturnTypes maps the UDDI publish function -> corresponding Systinet response class
+ *
+ * @author Tom Cunningham (tcunning at redhat.com)
+ */
+public class RequestUtil {
+ private Hashtable inquiryQueries;
+ private Hashtable publishQueries;
+ private Hashtable inquiryReturnTypes;
+ private Hashtable publishReturnTypes;
+ private Hashtable apiChooser;
+
+ public static final String INQUIRY_API = "inquiry";
+ public static final String PUBLISH_API = "publish";
+
+ static private RequestUtil instance = null;
+
+ private RequestUtil() {
+ inquiryQueries = new Hashtable();
+ inquiryQueries.put("find_business", org.systinet.uddi.client.v2.struct.Find_business.class);
+ inquiryQueries.put("find_service", org.systinet.uddi.client.v2.struct.Find_service.class);
+ inquiryQueries.put("find_binding", org.systinet.uddi.client.v2.struct.Find_binding.class);
+ inquiryQueries.put("find_tmodel", org.systinet.uddi.client.v2.struct.Find_tModel.class);
+ inquiryQueries.put("find_relatedbusinesses", org.systinet.uddi.client.v2.struct.Find_relatedBusinesses.class);
+ inquiryQueries.put("get_businessdetail", org.systinet.uddi.client.v2.struct.Get_businessDetail.class);
+ inquiryQueries.put("get_businessdetailext", org.systinet.uddi.client.v2.struct.Get_businessDetailExt.class);
+ inquiryQueries.put("get_servicedetail", org.systinet.uddi.client.v2.struct.Get_serviceDetail.class);
+ inquiryQueries.put("get_bindingdetail", org.systinet.uddi.client.v2.struct.Get_bindingDetail.class);
+ inquiryQueries.put("get_tmodeldetail", org.systinet.uddi.client.v2.struct.Get_tModelDetail.class);
+
+ publishQueries = new Hashtable();
+ publishQueries.put("get_authtoken", org.systinet.uddi.client.v2.struct.Get_authToken.class);
+ publishQueries.put("get_registeredinfo", org.systinet.uddi.client.v2.struct.Get_registeredInfo.class);
+ publishQueries.put("discard_authtoken", org.systinet.uddi.client.v2.struct.Discard_authToken.class);
+ publishQueries.put("save_business", org.systinet.uddi.client.v2.struct.Save_business.class);
+ publishQueries.put("save_service", org.systinet.uddi.client.v2.struct.Save_service.class);
+ publishQueries.put("save_binding", org.systinet.uddi.client.v2.struct.Save_binding.class);
+ publishQueries.put("save_tmodel", org.systinet.uddi.client.v2.struct.Save_tModel.class);
+ publishQueries.put("delete_business", org.systinet.uddi.client.v2.struct.Delete_business.class);
+ publishQueries.put("delete_service", org.systinet.uddi.client.v2.struct.Delete_service.class);
+ publishQueries.put("delete_binding", org.systinet.uddi.client.v2.struct.Delete_binding.class);
+ publishQueries.put("delete_tmodel", org.systinet.uddi.client.v2.struct.Find_service.class);
+ publishQueries.put("add_publisherassertions", org.systinet.uddi.client.v2.struct.Add_publisherAssertions.class);
+ publishQueries.put("set_publisherassertions", org.systinet.uddi.client.v2.struct.Set_publisherAssertions.class);
+ publishQueries.put("get_publisherassertions", org.systinet.uddi.client.v2.struct.Get_publisherAssertions.class);
+ publishQueries.put("delete_publisherassertions", org.systinet.uddi.client.v2.struct.Delete_publisherAssertions.class);
+ publishQueries.put("get_assertionstatusreport", org.systinet.uddi.client.v2.struct.Get_assertionStatusReport.class);
+
+ inquiryReturnTypes = new Hashtable();
+ inquiryReturnTypes.put("find_business", org.systinet.uddi.client.v2.struct.BusinessList.class);
+ inquiryReturnTypes.put("find_service", org.systinet.uddi.client.v2.struct.ServiceList.class);
+ inquiryReturnTypes.put("find_binding", org.systinet.uddi.client.v2.struct.BindingDetail.class);
+ inquiryReturnTypes.put("find_tmodel", org.systinet.uddi.client.v2.struct.TModelList.class);
+ inquiryReturnTypes.put("find_relatedbusinesses", org.systinet.uddi.client.v2.struct.RelatedBusinessesList.class);
+ inquiryReturnTypes.put("get_businessdetail", org.systinet.uddi.client.v2.struct.BusinessDetail.class);
+ inquiryReturnTypes.put("get_businessdetailext", org.systinet.uddi.client.v2.struct.BusinessDetailExt.class);
+ inquiryReturnTypes.put("get_servicedetail", org.systinet.uddi.client.v2.struct.ServiceDetail.class);
+ inquiryReturnTypes.put("get_bindingdetail", org.systinet.uddi.client.v2.struct.BindingDetail.class);
+ inquiryReturnTypes.put("get_tmodeldetail", org.systinet.uddi.client.v2.struct.TModelDetail.class);
+
+ publishReturnTypes = new Hashtable();
+ publishReturnTypes.put("get_authtoken", org.systinet.uddi.client.v2.struct.AuthToken.class);
+ publishReturnTypes.put("get_registeredinfo", org.systinet.uddi.client.v2.struct.RegisteredInfo.class);
+ publishReturnTypes.put("discard_authtoken", org.systinet.uddi.client.v2.struct.DispositionReport.class);
+ publishReturnTypes.put("save_business", org.systinet.uddi.client.v2.struct.BusinessDetail.class);
+ publishReturnTypes.put("save_service", org.systinet.uddi.client.v2.struct.ServiceDetail.class);
+ publishReturnTypes.put("save_binding", org.systinet.uddi.client.v2.struct.BindingDetail.class);
+ publishReturnTypes.put("save_tmodel", org.systinet.uddi.client.v2.struct.TModelDetail.class);
+ publishReturnTypes.put("delete_business", org.systinet.uddi.client.v2.struct.DispositionReport.class);
+ publishReturnTypes.put("delete_service", org.systinet.uddi.client.v2.struct.DispositionReport.class);
+ publishReturnTypes.put("delete_binding", org.systinet.uddi.client.v2.struct.DispositionReport.class);
+ publishReturnTypes.put("delete_tmodel", org.systinet.uddi.client.v2.struct.DispositionReport.class);
+ publishReturnTypes.put("add_publisherassertions", org.systinet.uddi.client.v2.struct.DispositionReport.class);
+ publishReturnTypes.put("set_publisherassertions", org.systinet.uddi.client.v2.struct.PublisherAssertions.class);
+ publishReturnTypes.put("get_publisherassertions", org.systinet.uddi.client.v2.struct.PublisherAssertions.class);
+ publishReturnTypes.put("delete_publisherassertions", org.systinet.uddi.client.v2.struct.DispositionReport.class);
+ publishReturnTypes.put("get_assertionstatusreport", org.systinet.uddi.client.v2.struct.AssertionStatusReport.class);
+
+
+ apiChooser = new Hashtable();
+ Enumeration e = inquiryQueries.keys();
+ while (e.hasMoreElements()) {
+ String query = (String) e.nextElement();
+ apiChooser.put(query, INQUIRY_API);
+ }
+
+ e = publishQueries.keys();
+ while (e.hasMoreElements()) {
+ String query = (String) e.nextElement();
+ apiChooser.put(query, PUBLISH_API);
+ }
+ }
+
+ public static RequestUtil getInstance() {
+ if (instance == null) {
+ instance = new RequestUtil();
+ }
+ return instance;
+ }
+
+ public String getApi (String operation) throws Exception {
+ return (String) apiChooser.get(operation.toLowerCase());
+ }
+
+ public Hashtable getInquiryReturnTypes() {
+ return inquiryReturnTypes;
+ }
+
+ public Hashtable getPublishReturnTypes() {
+ return publishReturnTypes;
+ }
+
+ public Hashtable getInquiryQueries() {
+ return inquiryQueries;
+ }
+
+ public Hashtable getPublishQueries() {
+ return publishQueries;
+ }
+}
More information about the jboss-svn-commits
mailing list