You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juddi.apache.org by al...@apache.org on 2013/06/07 20:37:05 UTC

svn commit: r1490776 - in /juddi/trunk: bin/ juddi-core-openjpa/ juddi-core/ juddi-core/src/main/java/org/apache/juddi/api/impl/rest/ juddiv3-war/JAX-WS/CXF/WEB-INF/

Author: alexoree
Date: Fri Jun  7 18:37:00 2013
New Revision: 1490776

URL: http://svn.apache.org/r1490776
Log:
JUDDI-599 Adding JAX-RS service for Inquiry getXXXDetails(String id)

Added:
    juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/rest/
    juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/rest/UDDIInquiryJAXRS.java
Modified:
    juddi/trunk/bin/cryptor-dev.bat
    juddi/trunk/juddi-core-openjpa/pom.xml
    juddi/trunk/juddi-core/pom.xml
    juddi/trunk/juddiv3-war/JAX-WS/CXF/WEB-INF/beans.xml

Modified: juddi/trunk/bin/cryptor-dev.bat
URL: http://svn.apache.org/viewvc/juddi/trunk/bin/cryptor-dev.bat?rev=1490776&r1=1490775&r2=1490776&view=diff
==============================================================================
--- juddi/trunk/bin/cryptor-dev.bat (original)
+++ juddi/trunk/bin/cryptor-dev.bat Fri Jun  7 18:37:00 2013
@@ -1 +1 @@
-java -cp ../juddi-tomcat/target/tomcat/apache-tomcat-6.0.26/webapps/juddiv3/WEB-INF/lib/* org.apache.juddi.v3.auth.CrytorUtil org.apache.juddi.cryptor.DefaultCryptor
\ No newline at end of file
+java -cp ../juddi-tomcat/target/tomcat/apache-tomcat-6.0.26/webapps/juddiv3/WEB-INF/lib/juddi-core-3.2.0-SNAPSHOT.jar;../juddi-tomcat/target/tomcat/apache-tomcat-6.0.26/webapps/juddiv3/WEB-INF/lib/uddi-ws-3.2.0-SNAPSHOT.jar;../juddi-tomcat/target/tomcat/apache-tomcat-6.0.26/webapps/juddiv3/WEB-INF/lib/commons-logging-api-1.1.jar;../juddi-tomcat/target/tomcat/apache-tomcat-6.0.26/webapps/juddiv3/WEB-INF/lib/commons-configuration-1.6.jar;../juddi-tomcat/target/tomcat/apache-tomcat-6.0.26/webapps/juddiv3/WEB-INF/lib/commons-lang-2.4.jar;../juddi-tomcat/target/tomcat/apache-tomcat-6.0.26/webapps/juddiv3/WEB-INF/lib/commons-collections-3.2.1.jar;../juddi-tomcat/target/tomcat/apache-tomcat-6.0.26/webapps/juddiv3/WEB-INF/lib/commons-codec-1.3.jar;../juddi-tomcat/target/tomcat/apache-tomcat-6.0.26/webapps/juddiv3/WEB-INF/classes/* org.apache.juddi.v3.auth.CrytorUtil org.apache.juddi.cryptor.DefaultCryptor
\ No newline at end of file

Modified: juddi/trunk/juddi-core-openjpa/pom.xml
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core-openjpa/pom.xml?rev=1490776&r1=1490775&r2=1490776&view=diff
==============================================================================
--- juddi/trunk/juddi-core-openjpa/pom.xml (original)
+++ juddi/trunk/juddi-core-openjpa/pom.xml Fri Jun  7 18:37:00 2013
@@ -35,7 +35,7 @@
 				<version>1.4.0</version>
 				<configuration>
 				<instructions>
-				<Export-Package>org.apache.juddi, org.apache.juddi.api, org.apache.juddi.api.impl, org.apache.juddi.api.util, org.apache.juddi.config, org.apache.juddi.config, org.apache.juddi.cryptor, org.apache.juddi.keygen, org.apache.juddi.mapping, org.apache.juddi.model, org.apache.juddi.query, org.apache.juddi.query.util, org.apache.juddi.rmi, org.apache.juddi.subscription, org.apache.juddi.subscription.notify, org.apache.juddi.validation, org.apache.juddi.v3.auth, org.apache.juddi.v3.error</Export-Package>
+				<Export-Package>org.apache.juddi, org.apache.juddi.api, org.apache.juddi.api.impl, org.apache.juddi.api.impl.rest,org.apache.juddi.api.util, org.apache.juddi.config, org.apache.juddi.config, org.apache.juddi.cryptor, org.apache.juddi.keygen, org.apache.juddi.mapping, org.apache.juddi.model, org.apache.juddi.query, org.apache.juddi.query.util, org.apache.juddi.rmi, org.apache.juddi.subscription, org.apache.juddi.subscription.notify, org.apache.juddi.validation, org.apache.juddi.v3.auth, org.apache.juddi.v3.error</Export-Package>
 				<Include-Resource>juddi_install_data=target/classes/juddi_install_data, target/classes/messages.properties</Include-Resource>
 				</instructions>
 				</configuration>

Modified: juddi/trunk/juddi-core/pom.xml
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/pom.xml?rev=1490776&r1=1490775&r2=1490776&view=diff
==============================================================================
--- juddi/trunk/juddi-core/pom.xml (original)
+++ juddi/trunk/juddi-core/pom.xml Fri Jun  7 18:37:00 2013
@@ -27,7 +27,9 @@
 				<configuration>
 					<instructions>
 						<Export-Package>org.apache.juddi, org.apache.juddi.api,
-							org.apache.juddi.api.impl, org.apache.juddi.api.util,
+							org.apache.juddi.api.impl,
+							org.apache.juddi.api.impl.rest,
+							org.apache.juddi.api.util,
 							org.apache.juddi.config, org.apache.juddi.config,
 							org.apache.juddi.cryptor, org.apache.juddi.keygen,
 							org.apache.juddi.mapping, org.apache.juddi.model,

Added: juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/rest/UDDIInquiryJAXRS.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/rest/UDDIInquiryJAXRS.java?rev=1490776&view=auto
==============================================================================
--- juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/rest/UDDIInquiryJAXRS.java (added)
+++ juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/rest/UDDIInquiryJAXRS.java Fri Jun  7 18:37:00 2013
@@ -0,0 +1,144 @@
+/*
+ * Copyright 2013 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.juddi.api.impl.rest;
+
+import javax.ws.rs.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.juddi.api.impl.UDDIInquiryImpl;
+import org.apache.juddi.v3.error.UDDIErrorHelper;
+import org.uddi.api_v3.*;
+import org.uddi.v3_service.DispositionReportFaultMessage;
+
+/**
+ * UDDI Inquiry functions via a JAX-RS REST API. It's basically a wrapper for
+ * the REST fans to access UDDI from a URL pattern
+ *
+ * @author Alex O'Ree
+ */
+@Path("/")
+@Produces("application/xml")
+public class UDDIInquiryJAXRS {
+
+    private static org.apache.juddi.api.impl.UDDIInquiryImpl inquiry = new UDDIInquiryImpl();
+    private static Log log = LogFactory.getLog(UDDIInquiryJAXRS.class);
+
+    /**
+     *
+     * @param id
+     * @return
+     */
+    @GET
+    @Path("/JSON/businessDetail/{id}")
+    @Produces("application/json")
+    public org.uddi.api_v3.BusinessEntity getBusinessDetailJSON(@PathParam("id") String id) throws WebApplicationException {
+        return getBusinessDetail(id);
+    }
+
+    @GET
+    @Path("/XML/businessDetail/{id}")
+    @Produces("application/xml")
+    public org.uddi.api_v3.BusinessEntity getBusinessDetailXML(@PathParam("id") String id) throws WebApplicationException {
+        return getBusinessDetail(id);
+    }
+
+    private org.uddi.api_v3.BusinessEntity getBusinessDetail(String id) {
+        GetBusinessDetail gbd = new GetBusinessDetail();
+        gbd.getBusinessKey().add(id);
+        BusinessDetail businessDetail;
+        try {
+            businessDetail = inquiry.getBusinessDetail(gbd);
+            return businessDetail.getBusinessEntity().get(0);
+        } catch (DispositionReportFaultMessage ex) {
+            HandleException(ex);
+        }
+        return null;
+    }
+
+    @GET
+    @Path("/XML/tModelDetail/{id}")
+    @Produces("application/xml")
+    public org.uddi.api_v3.TModel getTModelDetailXML(@PathParam("id") String id) throws WebApplicationException {
+        return getTModelDetail(id);
+    }
+
+    @GET
+    @Path("/JSON/tModelDetail/{id}")
+    @Produces("application/json")
+    public org.uddi.api_v3.TModel getTModelDetailJSON(@PathParam("id") String id) throws WebApplicationException {
+        return getTModelDetail(id);
+    }
+
+    private org.uddi.api_v3.TModel getTModelDetail(String id) {
+        GetTModelDetail gbd = new GetTModelDetail();
+        gbd.getTModelKey().add(id);
+
+        try {
+            TModelDetail tModelDetail = inquiry.getTModelDetail(gbd);
+            return tModelDetail.getTModel().get(0);
+        } catch (DispositionReportFaultMessage ex) {
+            HandleException(ex);
+        }
+        return null;
+    }
+
+    @GET
+    @Path("/XML/serviceDetail/{id}")
+    @Produces("application/json")
+    public org.uddi.api_v3.BusinessService getServiceDetailJSON(@PathParam("id") String id) throws WebApplicationException {
+        return getServiceDetail(id);
+    }
+
+    @GET
+    @Path("/XML/serviceDetail/{id}")
+    @Produces("application/xml")
+    public org.uddi.api_v3.BusinessService getServiceDetailXML(@PathParam("id") String id) throws WebApplicationException {
+        return getServiceDetail(id);
+    }
+
+    private BusinessService getServiceDetail(String id) {
+        GetServiceDetail gbd = new GetServiceDetail();
+        gbd.getServiceKey().add(id);
+
+        try {
+            ServiceDetail serviceDetail = inquiry.getServiceDetail(gbd);
+            return serviceDetail.getBusinessService().get(0);
+        } catch (DispositionReportFaultMessage ex) {
+            HandleException(ex);
+        }
+        return null;
+    }
+
+    private static void HandleException(DispositionReportFaultMessage ex) throws WebApplicationException {
+        if (ex == null) {
+            throw new WebApplicationException(500);
+        }
+        log.error(ex);
+        if (ex.getFaultInfo() == null) {
+            throw new WebApplicationException(500);
+        }
+        if (ex.getFaultInfo().countainsErrorCode(UDDIErrorHelper.lookupErrCode(UDDIErrorHelper.E_AUTH_TOKEN_EXPIRED))) {
+            throw new WebApplicationException(ex, 401);
+        }
+        if (ex.getFaultInfo().countainsErrorCode(UDDIErrorHelper.lookupErrCode(UDDIErrorHelper.E_AUTH_TOKEN_REQUIRED))) {
+            throw new WebApplicationException(ex, 401);
+        }
+        if (ex.getFaultInfo().countainsErrorCode(UDDIErrorHelper.lookupErrCode(UDDIErrorHelper.E_FATAL_ERROR))) {
+            throw new WebApplicationException(ex, 500);
+        }
+        throw new WebApplicationException(ex, 400);
+    }
+}

Modified: juddi/trunk/juddiv3-war/JAX-WS/CXF/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/juddi/trunk/juddiv3-war/JAX-WS/CXF/WEB-INF/beans.xml?rev=1490776&r1=1490775&r2=1490776&view=diff
==============================================================================
--- juddi/trunk/juddiv3-war/JAX-WS/CXF/WEB-INF/beans.xml (original)
+++ juddi/trunk/juddiv3-war/JAX-WS/CXF/WEB-INF/beans.xml Fri Jun  7 18:37:00 2013
@@ -20,8 +20,12 @@
 <beans xmlns="http://www.springframework.org/schema/beans" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns:jaxws="http://cxf.apache.org/jaxws"
-  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
-
+	    xmlns:jaxrs="http://cxf.apache.org/jaxrs"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+  http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
+  
+  ">
+ 
   <import resource="classpath:META-INF/cxf/cxf.xml" />
   <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
   <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
@@ -90,4 +94,11 @@
     </jaxws:properties>
   </jaxws:endpoint>
 
+    <jaxrs:server id="inquiryRestService" address="/inquiryRest">
+    <jaxrs:serviceBeans>
+      <ref bean="inquiryRest" />
+    </jaxrs:serviceBeans>
+  </jaxrs:server>
+  <bean id="inquiryRest" class="org.apache.juddi.api.impl.rest.UDDIInquiryJAXRS" />
+  
 </beans>



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@juddi.apache.org
For additional commands, e-mail: commits-help@juddi.apache.org