juddi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tcunn...@apache.org
Subject svn commit: r1052016 - /juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIInquiryImpl.java
Date Wed, 22 Dec 2010 18:06:31 GMT
Author: tcunning
Date: Wed Dec 22 18:06:31 2010
New Revision: 1052016

URL: http://svn.apache.org/viewvc?rev=1052016&view=rev
Log:
JUDDI-432
If we get no results back, and if the businessKey/serviceKey is not null,
then check to see if the businessKey/serviceKey actually exists.    If it
doesn't, throw an E_InvalidKeyPassed (spelled out in sections 5.1.12.4
and 5.1.9.4).

Changes here were made to FindBinding and FindService.

Modified:
    juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIInquiryImpl.java

Modified: juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIInquiryImpl.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIInquiryImpl.java?rev=1052016&r1=1052015&r2=1052016&view=diff
==============================================================================
--- juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIInquiryImpl.java (original)
+++ juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIInquiryImpl.java Wed
Dec 22 18:06:31 2010
@@ -1,12 +1,12 @@
 /*
  * Copyright 2001-2008 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.
@@ -18,20 +18,21 @@
 package org.apache.juddi.api.impl;
 
 import java.util.List;
+
 import javax.jws.WebService;
-import javax.persistence.EntityTransaction;
 import javax.persistence.EntityManager;
+import javax.persistence.EntityTransaction;
 
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.juddi.config.AppConfig;
+import org.apache.juddi.config.PersistenceManager;
+import org.apache.juddi.config.Property;
 import org.apache.juddi.mapping.MappingModelToApi;
 import org.apache.juddi.v3.error.ErrorMessage;
 import org.apache.juddi.v3.error.InvalidKeyPassedException;
 import org.apache.juddi.validation.ValidateInquiry;
-import org.apache.juddi.config.AppConfig;
-import org.apache.juddi.config.PersistenceManager;
-import org.apache.juddi.config.Property;
 import org.uddi.api_v3.BindingDetail;
 import org.uddi.api_v3.BusinessDetail;
 import org.uddi.api_v3.BusinessList;
@@ -58,33 +59,46 @@ import org.uddi.v3_service.UDDIInquiryPo
 /**
  * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
  */
-@WebService(serviceName="UDDIInquiryService", 
+@WebService(serviceName="UDDIInquiryService",
 			endpointInterface="org.uddi.v3_service.UDDIInquiryPortType",
 			targetNamespace = "urn:uddi-org:v3_service")
 public class UDDIInquiryImpl extends AuthenticatedService implements UDDIInquiryPortType
{
 
 	private static Log log = LogFactory.getLog(UDDIInquiryImpl.class);
 
-	public BindingDetail findBinding(FindBinding body)
+	@Override
+    public BindingDetail findBinding(FindBinding body)
 			throws DispositionReportFaultMessage {
 
 		new ValidateInquiry(null).validateFindBinding(body);
-		
+
 		EntityManager em = PersistenceManager.getEntityManager();
 		EntityTransaction tx = em.getTransaction();
 		try {
 			tx.begin();
-	
+
 			if (isAuthenticated())
 				this.getEntityPublisher(em, body.getAuthInfo());
-			
+
 			org.apache.juddi.query.util.FindQualifiers findQualifiers = new org.apache.juddi.query.util.FindQualifiers();
 			findQualifiers.mapApiFindQualifiers(body.getFindQualifiers());
-			
+
 			List<?> keysFound = InquiryHelper.findBinding(body, findQualifiers, em);
-	
+
+			if (keysFound.size() == 0) {
+			    if (body.getServiceKey() != null) {
+			        // Check that we were passed a valid serviceKey per
+        			// 5.1.12.4 of the UDDI v3 spec
+        			String serviceKey = body.getServiceKey();
+        			org.apache.juddi.model.BusinessService modelBusinessService = em.find(org.apache.juddi.model.BusinessService.class,
serviceKey);
+        	                if (modelBusinessService == null)
+        	                    throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.ServiceNotFound",
serviceKey));
+
+			    }
+			}
 			BindingDetail result = InquiryHelper.getBindingDetailFromKeys(body, findQualifiers, em,
keysFound);
 			tx.commit();
+
 			return result;
 		} finally {
 			if (tx.isActive()) {
@@ -94,26 +108,27 @@ public class UDDIInquiryImpl extends Aut
 		}
 	}
 
-	public BusinessList findBusiness(FindBusiness body)
+	@Override
+    public BusinessList findBusiness(FindBusiness body)
 			throws DispositionReportFaultMessage {
 
 		new ValidateInquiry(null).validateFindBusiness(body);
-		
+
 		EntityManager em = PersistenceManager.getEntityManager();
 		EntityTransaction tx = em.getTransaction();
 		try {
 			tx.begin();
-	
+
 			if (isAuthenticated())
 				this.getEntityPublisher(em, body.getAuthInfo());
-			
+
 			org.apache.juddi.query.util.FindQualifiers findQualifiers = new org.apache.juddi.query.util.FindQualifiers();
 			findQualifiers.mapApiFindQualifiers(body.getFindQualifiers());
-	
+
 			List<?> keysFound = InquiryHelper.findBusiness(body, findQualifiers, em);
-	
+
 			BusinessList result = InquiryHelper.getBusinessListFromKeys(body, findQualifiers, em,
keysFound);
-			
+
 			tx.commit();
 			return result;
 		} finally {
@@ -124,26 +139,27 @@ public class UDDIInquiryImpl extends Aut
 		}
 	}
 
-	public RelatedBusinessesList findRelatedBusinesses(FindRelatedBusinesses body) 
+	@Override
+    public RelatedBusinessesList findRelatedBusinesses(FindRelatedBusinesses body)
 			throws DispositionReportFaultMessage {
 
 		new ValidateInquiry(null).validateFindRelatedBusinesses(body, false);
-		
+
 		EntityManager em = PersistenceManager.getEntityManager();
 		EntityTransaction tx = em.getTransaction();
 		try {
 			tx.begin();
-	
+
 			if (isAuthenticated())
 				this.getEntityPublisher(em, body.getAuthInfo());
-			
+
 			// TODO: findQualifiers aren't really used for this call, except maybe for sorting.  Sorting
must be done in Java due to the retrieval method used.  Right now
 			// no sorting is performed.
 			org.apache.juddi.query.util.FindQualifiers findQualifiers = new org.apache.juddi.query.util.FindQualifiers();
 			findQualifiers.mapApiFindQualifiers(body.getFindQualifiers());
-			
+
 			RelatedBusinessesList result = InquiryHelper.getRelatedBusinessesList(body, em);
-			
+
 			tx.commit();
 			return result;
 		} finally {
@@ -154,26 +170,39 @@ public class UDDIInquiryImpl extends Aut
 		}
 	}
 
-	public ServiceList findService(FindService body)
+	@Override
+    public ServiceList findService(FindService body)
 			throws DispositionReportFaultMessage {
 
 		new ValidateInquiry(null).validateFindService(body);
-		
+
 		EntityManager em = PersistenceManager.getEntityManager();
 		EntityTransaction tx = em.getTransaction();
 		try {
 			tx.begin();
-			
+
 			if (isAuthenticated())
 				this.getEntityPublisher(em, body.getAuthInfo());
-			
+
 			org.apache.juddi.query.util.FindQualifiers findQualifiers = new org.apache.juddi.query.util.FindQualifiers();
 			findQualifiers.mapApiFindQualifiers(body.getFindQualifiers());
-	
+
 			List<?> keysFound = InquiryHelper.findService(body, findQualifiers, em);
-	
+
+		        if (keysFound.size() == 0) {
+		            if (body.getBusinessKey() != null) {
+		                // Check that we were passed a valid serviceKey per
+        	                // 5.1.12.4 of the UDDI v3 spec
+        	                String businessKey = body.getBusinessKey();
+        	                org.apache.juddi.model.BusinessEntity modelBusinessEntity = em.find(org.apache.juddi.model.BusinessEntity.class,
businessKey);
+        	                if (modelBusinessEntity == null) {
+        	                    throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.ServiceNotFound",
businessKey));
+        	                }
+		            }
+		        }
+
 			ServiceList result = InquiryHelper.getServiceListFromKeys(body, findQualifiers, em, keysFound);
-			
+
 			tx.commit();
 			return result;
 		} finally {
@@ -184,26 +213,27 @@ public class UDDIInquiryImpl extends Aut
 		}
 	}
 
-	public TModelList findTModel(FindTModel body)
+	@Override
+    public TModelList findTModel(FindTModel body)
 			throws DispositionReportFaultMessage {
 
 		new ValidateInquiry(null).validateFindTModel(body, false);
-		
+
 		EntityManager em = PersistenceManager.getEntityManager();
 		EntityTransaction tx = em.getTransaction();
 		try {
 			tx.begin();
-	
+
 			if (isAuthenticated())
 				this.getEntityPublisher(em, body.getAuthInfo());
-			
+
 			org.apache.juddi.query.util.FindQualifiers findQualifiers = new org.apache.juddi.query.util.FindQualifiers();
 			findQualifiers.mapApiFindQualifiers(body.getFindQualifiers());
-	
+
 			List<?> keysFound = InquiryHelper.findTModel(body, findQualifiers, em);
-	
+
 			TModelList result = InquiryHelper.getTModelListFromKeys(body, findQualifiers, em, keysFound);
-			
+
 			tx.commit();
 			return result;
 		} finally {
@@ -214,35 +244,36 @@ public class UDDIInquiryImpl extends Aut
 		}
 	}
 
-	public BindingDetail getBindingDetail(GetBindingDetail body)
+	@Override
+    public BindingDetail getBindingDetail(GetBindingDetail body)
 			throws DispositionReportFaultMessage {
 
 		new ValidateInquiry(null).validateGetBindingDetail(body);
-		
+
 		EntityManager em = PersistenceManager.getEntityManager();
 		EntityTransaction tx = em.getTransaction();
 		try {
 			tx.begin();
-	
+
 			if (isAuthenticated())
 				this.getEntityPublisher(em, body.getAuthInfo());
-			
+
 			BindingDetail result = new BindingDetail();
-	
+
 			List<String> bindingKeyList = body.getBindingKey();
 			for (String bindingKey : bindingKeyList) {
-				
+
 				org.apache.juddi.model.BindingTemplate modelBindingTemplate = em.find(org.apache.juddi.model.BindingTemplate.class,
bindingKey);
 				if (modelBindingTemplate == null)
 					throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.BindingTemplateNotFound",
bindingKey));
-				
+
 				org.uddi.api_v3.BindingTemplate apiBindingTemplate = new org.uddi.api_v3.BindingTemplate();
-				
+
 				MappingModelToApi.mapBindingTemplate(modelBindingTemplate, apiBindingTemplate);
-				
+
 				result.getBindingTemplate().add(apiBindingTemplate);
 			}
-	
+
 			tx.commit();
 			return result;
 		} finally {
@@ -253,35 +284,36 @@ public class UDDIInquiryImpl extends Aut
 		}
 	}
 
-	public BusinessDetail getBusinessDetail(GetBusinessDetail body)
+	@Override
+    public BusinessDetail getBusinessDetail(GetBusinessDetail body)
 			throws DispositionReportFaultMessage {
-		
+
 		new ValidateInquiry(null).validateGetBusinessDetail(body);
-		
+
 		EntityManager em = PersistenceManager.getEntityManager();
 		EntityTransaction tx = em.getTransaction();
 		try {
 			tx.begin();
-	
+
 			if (isAuthenticated())
 				this.getEntityPublisher(em, body.getAuthInfo());
-			
+
 			BusinessDetail result = new BusinessDetail();
-			
+
 			List<String> businessKeyList = body.getBusinessKey();
 			for (String businessKey : businessKeyList) {
-				
+
 				org.apache.juddi.model.BusinessEntity modelBusinessEntity = em.find(org.apache.juddi.model.BusinessEntity.class,
businessKey);
 				if (modelBusinessEntity == null)
 					throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.BusinessNotFound",
businessKey));
-				
+
 				org.uddi.api_v3.BusinessEntity apiBusinessEntity = new org.uddi.api_v3.BusinessEntity();
-				
+
 				MappingModelToApi.mapBusinessEntity(modelBusinessEntity, apiBusinessEntity);
-				
+
 				result.getBusinessEntity().add(apiBusinessEntity);
 			}
-	
+
 			tx.commit();
 			return result;
 		} finally {
@@ -292,7 +324,8 @@ public class UDDIInquiryImpl extends Aut
 		}
 	}
 
-	public OperationalInfos getOperationalInfo(GetOperationalInfo body)
+	@Override
+    public OperationalInfos getOperationalInfo(GetOperationalInfo body)
 			throws DispositionReportFaultMessage {
 
 		new ValidateInquiry(null).validateGetOperationalInfo(body);
@@ -301,26 +334,26 @@ public class UDDIInquiryImpl extends Aut
 		EntityTransaction tx = em.getTransaction();
 		try {
 			tx.begin();
-	
+
 			if (isAuthenticated())
 				this.getEntityPublisher(em, body.getAuthInfo());
-			
+
 			OperationalInfos result = new OperationalInfos();
-			
+
 			List<String> entityKeyList = body.getEntityKey();
 			for (String entityKey : entityKeyList) {
-				
+
 				org.apache.juddi.model.UddiEntity modelUddiEntity = em.find(org.apache.juddi.model.UddiEntity.class,
entityKey);
 				if (modelUddiEntity == null)
 					throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.EntityNotFound",
entityKey));
-				
+
 				org.uddi.api_v3.OperationalInfo apiOperationalInfo = new org.uddi.api_v3.OperationalInfo();
-				
+
 				MappingModelToApi.mapOperationalInfo(modelUddiEntity, apiOperationalInfo);
-				
+
 				result.getOperationalInfo().add(apiOperationalInfo);
 			}
-	
+
 			tx.commit();
 			return result;
 		} finally {
@@ -331,38 +364,39 @@ public class UDDIInquiryImpl extends Aut
 		}
 	}
 
-	public ServiceDetail getServiceDetail(GetServiceDetail body)
+	@Override
+    public ServiceDetail getServiceDetail(GetServiceDetail body)
 			throws DispositionReportFaultMessage {
 
 		new ValidateInquiry(null).validateGetServiceDetail(body);
-		
+
 		EntityManager em = PersistenceManager.getEntityManager();
 		EntityTransaction tx = em.getTransaction();
 		try {
 			tx.begin();
-	
+
 			if (isAuthenticated())
 				this.getEntityPublisher(em, body.getAuthInfo());
-			
+
 			ServiceDetail result = new ServiceDetail();
-	
+
 			List<String> serviceKeyList = body.getServiceKey();
 			for (String serviceKey : serviceKeyList) {
-				
+
 				org.apache.juddi.model.BusinessService modelBusinessService = em.find(org.apache.juddi.model.BusinessService.class,
serviceKey);
 				if (modelBusinessService == null)
 					throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.ServiceNotFound",
serviceKey));
-				
+
 				org.uddi.api_v3.BusinessService apiBusinessService = new org.uddi.api_v3.BusinessService();
-				
+
 				MappingModelToApi.mapBusinessService(modelBusinessService, apiBusinessService);
-				
+
 				result.getBusinessService().add(apiBusinessService);
 			}
-	
+
 			tx.commit();
 			return result;
-			
+
 		} finally {
 			if (tx.isActive()) {
 				tx.rollback();
@@ -371,7 +405,8 @@ public class UDDIInquiryImpl extends Aut
 		}
 	}
 
-	public TModelDetail getTModelDetail(GetTModelDetail body)
+	@Override
+    public TModelDetail getTModelDetail(GetTModelDetail body)
 			throws DispositionReportFaultMessage {
 
 		new ValidateInquiry(null).validateGetTModelDetail(body);
@@ -380,28 +415,28 @@ public class UDDIInquiryImpl extends Aut
 		EntityTransaction tx = em.getTransaction();
 		try {
 			tx.begin();
-	
+
 			if (isAuthenticated())
 				this.getEntityPublisher(em, body.getAuthInfo());
-			
+
 			TModelDetail result = new TModelDetail();
-			
+
 			List<String> tmodelKeyList = body.getTModelKey();
 			for (String tmodelKey : tmodelKeyList) {
-				
+
 				org.apache.juddi.model.Tmodel modelTModel = em.find(org.apache.juddi.model.Tmodel.class,
tmodelKey);
 				if (modelTModel == null) {
 					throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.TModelNotFound",
tmodelKey));
 				}
-				
+
 				org.uddi.api_v3.TModel apiTModel = new org.uddi.api_v3.TModel();
-				
+
 				MappingModelToApi.mapTModel(modelTModel, apiTModel);
-				
+
 				result.getTModel().add(apiTModel);
 			}
-	
-			tx.commit();	
+
+			tx.commit();
 			return result;
 		} finally {
 			if (tx.isActive()) {



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


Mime
View raw message