juddi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jfa...@apache.org
Subject svn commit: r767349 - in /webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi: api/impl/ mapping/ validation/
Date Wed, 22 Apr 2009 02:20:50 GMT
Author: jfaath
Date: Wed Apr 22 02:20:49 2009
New Revision: 767349

URL: http://svn.apache.org/viewvc?rev=767349&view=rev
Log:
working on getSubscriptionResults, completed the find_* filters

Modified:
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/InquiryHelper.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIInquiryImpl.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDISubscriptionImpl.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/mapping/MappingModelToApi.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/validation/ValidateSubscription.java

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/InquiryHelper.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/InquiryHelper.java?rev=767349&r1=767348&r2=767349&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/InquiryHelper.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/InquiryHelper.java
Wed Apr 22 02:20:49 2009
@@ -17,6 +17,7 @@
 package org.apache.juddi.api.impl;
 
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 import javax.persistence.EntityManager;
@@ -24,6 +25,10 @@
 import org.apache.juddi.error.ErrorMessage;
 import org.apache.juddi.error.InvalidKeyPassedException;
 import org.apache.juddi.mapping.MappingModelToApi;
+import org.apache.juddi.query.FetchBindingTemplatesQuery;
+import org.apache.juddi.query.FetchBusinessEntitiesQuery;
+import org.apache.juddi.query.FetchBusinessServicesQuery;
+import org.apache.juddi.query.FetchTModelsQuery;
 import org.apache.juddi.query.FindBindingByCategoryGroupQuery;
 import org.apache.juddi.query.FindBindingByCategoryQuery;
 import org.apache.juddi.query.FindBindingByTModelKeyQuery;
@@ -42,17 +47,22 @@
 import org.apache.juddi.query.FindTModelByIdentifierQuery;
 import org.apache.juddi.query.FindTModelByNameQuery;
 import org.apache.juddi.query.util.FindQualifiers;
+import org.uddi.api_v3.BindingDetail;
+import org.uddi.api_v3.BusinessList;
 import org.uddi.api_v3.Direction;
 import org.uddi.api_v3.FindBinding;
 import org.uddi.api_v3.FindBusiness;
 import org.uddi.api_v3.FindRelatedBusinesses;
 import org.uddi.api_v3.FindService;
 import org.uddi.api_v3.FindTModel;
+import org.uddi.api_v3.ListDescription;
+import org.uddi.api_v3.ServiceList;
 import org.uddi.api_v3.TModelBag;
+import org.uddi.api_v3.TModelList;
 import org.uddi.v3_service.DispositionReportFaultMessage;
 
 /**
- * Used to extrapolate out inquiry functionality as it is used in more than one spot.
+ * Used to factor out inquiry functionality as it is used in more than one spot.
  * 
  * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
  */
@@ -74,6 +84,36 @@
 		return keysFound;
 	}
 	
+	public static BindingDetail getBindingDetailFromKeys(FindBinding body, FindQualifiers findQualifiers,
EntityManager em, List<?> keysFound) throws DispositionReportFaultMessage {
+		return getBindingDetailFromKeys(body, findQualifiers, em, keysFound, null, null);
+	}
+	
+	public static BindingDetail getBindingDetailFromKeys(FindBinding body, FindQualifiers findQualifiers,
EntityManager em, List<?> keysFound, Date modifiedAfter, Date modifiedBefore) throws
DispositionReportFaultMessage {
+		BindingDetail result = new BindingDetail();
+		ListDescription listDesc = new ListDescription();
+		result.setListDescription(listDesc);
+		
+		// Sort and retrieve the final results with paging taken into account
+		List<?> queryResults = FetchBindingTemplatesQuery.select(em, findQualifiers, keysFound,
body.getMaxRows(), body.getListHead(), listDesc);
+
+		for (Object item : queryResults) {
+			org.apache.juddi.model.BindingTemplate modelBindingTemplate = (org.apache.juddi.model.BindingTemplate)item;
+			org.uddi.api_v3.BindingTemplate apiBindingTemplate = new org.uddi.api_v3.BindingTemplate();
+			
+			if (modifiedAfter != null && modifiedAfter.after(modelBindingTemplate.getModifiedIncludingChildren()))
+				continue;
+			
+			if (modifiedBefore != null && modifiedBefore.before(modelBindingTemplate.getModifiedIncludingChildren()))
+				continue;
+			
+			MappingModelToApi.mapBindingTemplate(modelBindingTemplate, apiBindingTemplate);
+			
+			result.getBindingTemplate().add(apiBindingTemplate);
+		}
+		
+		return result;
+	}	
+	
 	public static List<?> findBusiness(FindBusiness body, FindQualifiers findQualifiers,
EntityManager em) throws DispositionReportFaultMessage {
 
 		List<?> keysFound = null;
@@ -115,6 +155,38 @@
 		return keysFound;
 	}
 
+	public static BusinessList getBusinessListFromKeys(FindBusiness body, FindQualifiers findQualifiers,
EntityManager em, List<?> keysFound) throws DispositionReportFaultMessage {
+		return getBusinessListFromKeys(body, findQualifiers, em, keysFound, null, null);
+	}
+	
+	public static BusinessList getBusinessListFromKeys(FindBusiness body, FindQualifiers findQualifiers,
EntityManager em, List<?> keysFound, Date modifiedAfter, Date modifiedBefore) throws
DispositionReportFaultMessage {
+		BusinessList result = new BusinessList();
+		ListDescription listDesc = new ListDescription();
+		result.setListDescription(listDesc);
+
+		// Sort and retrieve the final results taking paging into account
+		List<?> queryResults = FetchBusinessEntitiesQuery.select(em, findQualifiers, keysFound,
body.getMaxRows(), body.getListHead(), listDesc);
+		if (queryResults != null && queryResults.size() > 0)
+			result.setBusinessInfos(new org.uddi.api_v3.BusinessInfos());
+
+		for (Object item : queryResults) {
+			org.apache.juddi.model.BusinessEntity modelBusinessEntity = (org.apache.juddi.model.BusinessEntity)item;
+			org.uddi.api_v3.BusinessInfo apiBusinessInfo = new org.uddi.api_v3.BusinessInfo();
+			
+			if (modifiedAfter != null && modifiedAfter.after(modelBusinessEntity.getModifiedIncludingChildren()))
+				continue;
+			
+			if (modifiedBefore != null && modifiedBefore.before(modelBusinessEntity.getModifiedIncludingChildren()))
+				continue;
+			
+			MappingModelToApi.mapBusinessInfo(modelBusinessEntity, apiBusinessInfo);
+			
+			result.getBusinessInfos().getBusinessInfo().add(apiBusinessInfo);
+		}
+		
+		return result;
+	}
+	
 	public static List<?> findService(FindService body, FindQualifiers findQualifiers,
EntityManager em) throws DispositionReportFaultMessage {
 
 		List<?> keysFound = null;
@@ -132,6 +204,39 @@
 		
 		return keysFound;
 	}
+	
+	public static ServiceList getServiceListFromKeys(FindService body, FindQualifiers findQualifiers,
EntityManager em, List<?> keysFound) throws DispositionReportFaultMessage {
+		return getServiceListFromKeys(body, findQualifiers, em, keysFound, null, null);
+	}
+
+	public static ServiceList getServiceListFromKeys(FindService body, FindQualifiers findQualifiers,
EntityManager em, List<?> keysFound, Date modifiedAfter, Date modifiedBefore) throws
DispositionReportFaultMessage {
+		ServiceList result = new ServiceList();
+		ListDescription listDesc = new ListDescription();
+		result.setListDescription(listDesc);
+		
+		// Sort and retrieve the final results taking paging into account
+		List<?> queryResults = FetchBusinessServicesQuery.select(em, findQualifiers, keysFound,
body.getMaxRows(), body.getListHead(), listDesc);
+		if (queryResults != null && queryResults.size() > 0)
+			result.setServiceInfos(new org.uddi.api_v3.ServiceInfos());
+
+		for (Object item : queryResults) {
+			org.apache.juddi.model.BusinessService modelBusinessService = (org.apache.juddi.model.BusinessService)item;
+			
+			if (modifiedAfter != null && modifiedAfter.after(modelBusinessService.getModifiedIncludingChildren()))
+				continue;
+			
+			if (modifiedBefore != null && modifiedBefore.before(modelBusinessService.getModifiedIncludingChildren()))
+				continue;
+				
+			org.uddi.api_v3.ServiceInfo apiServiceInfo = new org.uddi.api_v3.ServiceInfo();
+			
+			MappingModelToApi.mapServiceInfo(modelBusinessService, apiServiceInfo);
+			
+			result.getServiceInfos().getServiceInfo().add(apiServiceInfo);
+		}
+		
+		return result;
+	}
 
 	public static List<?> findTModel(FindTModel body, FindQualifiers findQualifiers, EntityManager
em) throws DispositionReportFaultMessage {
 		List<?> keysFound = null;
@@ -143,6 +248,38 @@
 		
 		return keysFound;
 	}
+
+	public static TModelList getTModelListFromKeys(FindTModel body, FindQualifiers findQualifiers,
EntityManager em, List<?> keysFound) throws DispositionReportFaultMessage {
+		return getTModelListFromKeys(body, findQualifiers, em, keysFound, null, null);
+	}
+	
+	public static TModelList getTModelListFromKeys(FindTModel body, FindQualifiers findQualifiers,
EntityManager em, List<?> keysFound, Date modifiedAfter, Date modifiedBefore) throws
DispositionReportFaultMessage {
+		TModelList result = new TModelList();
+		ListDescription listDesc = new ListDescription();
+		result.setListDescription(listDesc);
+
+		// Sort and retrieve the final results taking paging into account
+		List<?> queryResults = FetchTModelsQuery.select(em, findQualifiers, keysFound, body.getMaxRows(),
body.getListHead(), listDesc);
+		if (queryResults != null && queryResults.size() > 0)
+			result.setTModelInfos(new org.uddi.api_v3.TModelInfos());
+		
+		for (Object item : queryResults) {
+			org.apache.juddi.model.Tmodel modelTModel = (org.apache.juddi.model.Tmodel)item;
+			org.uddi.api_v3.TModelInfo apiTModelInfo = new org.uddi.api_v3.TModelInfo();
+			
+			if (modifiedAfter != null && modifiedAfter.after(modelTModel.getModifiedIncludingChildren()))
+				continue;
+			
+			if (modifiedBefore != null && modifiedBefore.before(modelTModel.getModifiedIncludingChildren()))
+				continue;
+			
+			MappingModelToApi.mapTModelInfo(modelTModel, apiTModelInfo);
+			
+			result.getTModelInfos().getTModelInfo().add(apiTModelInfo);
+		}
+		
+		return result;
+	}
 	
 	
 	/*

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIInquiryImpl.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIInquiryImpl.java?rev=767349&r1=767348&r2=767349&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIInquiryImpl.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIInquiryImpl.java
Wed Apr 22 02:20:49 2009
@@ -24,10 +24,6 @@
 
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.juddi.mapping.MappingModelToApi;
-import org.apache.juddi.query.FetchBindingTemplatesQuery;
-import org.apache.juddi.query.FetchBusinessEntitiesQuery;
-import org.apache.juddi.query.FetchBusinessServicesQuery;
-import org.apache.juddi.query.FetchTModelsQuery;
 import org.apache.juddi.query.PersistenceManager;
 import org.apache.juddi.validation.ValidateInquiry;
 import org.apache.juddi.config.AppConfig;
@@ -89,21 +85,7 @@
 		
 		List<?> keysFound = InquiryHelper.findBinding(body, findQualifiers, em);
 
-		BindingDetail result = new BindingDetail();
-		ListDescription listDesc = new ListDescription();
-		result.setListDescription(listDesc);
-		
-		// Sort and retrieve the final results with paging taken into account
-		List<?> queryResults = FetchBindingTemplatesQuery.select(em, findQualifiers, keysFound,
body.getMaxRows(), body.getListHead(), listDesc);
-
-		for (Object item : queryResults) {
-			org.apache.juddi.model.BindingTemplate modelBindingTemplate = (org.apache.juddi.model.BindingTemplate)item;
-			org.uddi.api_v3.BindingTemplate apiBindingTemplate = new org.uddi.api_v3.BindingTemplate();
-			
-			MappingModelToApi.mapBindingTemplate(modelBindingTemplate, apiBindingTemplate);
-			
-			result.getBindingTemplate().add(apiBindingTemplate);
-		}
+		BindingDetail result = InquiryHelper.getBindingDetailFromKeys(body, findQualifiers, em,
keysFound);
 		
 		tx.commit();
 		em.close();
@@ -128,23 +110,7 @@
 
 		List<?> keysFound = InquiryHelper.findBusiness(body, findQualifiers, em);
 
-		BusinessList result = new BusinessList();
-		ListDescription listDesc = new ListDescription();
-		result.setListDescription(listDesc);
-
-		// Sort and retrieve the final results taking paging into account
-		List<?> queryResults = FetchBusinessEntitiesQuery.select(em, findQualifiers, keysFound,
body.getMaxRows(), body.getListHead(), listDesc);
-		if (queryResults != null && queryResults.size() > 0)
-			result.setBusinessInfos(new org.uddi.api_v3.BusinessInfos());
-
-		for (Object item : queryResults) {
-			org.apache.juddi.model.BusinessEntity modelBusinessEntity = (org.apache.juddi.model.BusinessEntity)item;
-			org.uddi.api_v3.BusinessInfo apiBusinessInfo = new org.uddi.api_v3.BusinessInfo();
-			
-			MappingModelToApi.mapBusinessInfo(modelBusinessEntity, apiBusinessInfo);
-			
-			result.getBusinessInfos().getBusinessInfo().add(apiBusinessInfo);
-		}
+		BusinessList result = InquiryHelper.getBusinessListFromKeys(body, findQualifiers, em, keysFound);
 		
 		tx.commit();
 		em.close();
@@ -198,9 +164,7 @@
 		em.close();
 		
 		return result;
-		
 	}
-	
 
 	public ServiceList findService(FindService body)
 			throws DispositionReportFaultMessage {
@@ -219,23 +183,7 @@
 
 		List<?> keysFound = InquiryHelper.findService(body, findQualifiers, em);
 
-		ServiceList result = new ServiceList();
-		ListDescription listDesc = new ListDescription();
-		result.setListDescription(listDesc);
-		
-		// Sort and retrieve the final results taking paging into account
-		List<?> queryResults = FetchBusinessServicesQuery.select(em, findQualifiers, keysFound,
body.getMaxRows(), body.getListHead(), listDesc);
-		if (queryResults != null && queryResults.size() > 0)
-			result.setServiceInfos(new org.uddi.api_v3.ServiceInfos());
-
-		for (Object item : queryResults) {
-			org.apache.juddi.model.BusinessService modelBusinessService = (org.apache.juddi.model.BusinessService)item;
-			org.uddi.api_v3.ServiceInfo apiServiceInfo = new org.uddi.api_v3.ServiceInfo();
-			
-			MappingModelToApi.mapServiceInfo(modelBusinessService, apiServiceInfo);
-			
-			result.getServiceInfos().getServiceInfo().add(apiServiceInfo);
-		}
+		ServiceList result = InquiryHelper.getServiceListFromKeys(body, findQualifiers, em, keysFound);
 		
 		tx.commit();
 		em.close();
@@ -260,23 +208,7 @@
 
 		List<?> keysFound = InquiryHelper.findTModel(body, findQualifiers, em);
 
-		TModelList result = new TModelList();
-		ListDescription listDesc = new ListDescription();
-		result.setListDescription(listDesc);
-
-		// Sort and retrieve the final results taking paging into account
-		List<?> queryResults = FetchTModelsQuery.select(em, findQualifiers, keysFound, body.getMaxRows(),
body.getListHead(), listDesc);
-		if (queryResults != null && queryResults.size() > 0)
-			result.setTModelInfos(new org.uddi.api_v3.TModelInfos());
-		
-		for (Object item : queryResults) {
-			org.apache.juddi.model.Tmodel modelTModel = (org.apache.juddi.model.Tmodel)item;
-			org.uddi.api_v3.TModelInfo apiTModelInfo = new org.uddi.api_v3.TModelInfo();
-			
-			MappingModelToApi.mapTModelInfo(modelTModel, apiTModelInfo);
-			
-			result.getTModelInfos().getTModelInfo().add(apiTModelInfo);
-		}
+		TModelList result = InquiryHelper.getTModelListFromKeys(body, findQualifiers, em, keysFound);
 		
 		tx.commit();
 		em.close();

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDISubscriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDISubscriptionImpl.java?rev=767349&r1=767348&r2=767349&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDISubscriptionImpl.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDISubscriptionImpl.java
Wed Apr 22 02:20:49 2009
@@ -18,6 +18,7 @@
 package org.apache.juddi.api.impl;
 
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.GregorianCalendar;
 import java.util.List;
 
@@ -29,8 +30,17 @@
 import javax.xml.datatype.DatatypeFactory;
 import javax.xml.ws.Holder;
 
+import org.uddi.api_v3.BindingDetail;
+import org.uddi.api_v3.BusinessList;
+import org.uddi.api_v3.FindBinding;
+import org.uddi.api_v3.FindBusiness;
+import org.uddi.api_v3.FindService;
+import org.uddi.api_v3.FindTModel;
+import org.uddi.api_v3.ServiceList;
+import org.uddi.api_v3.TModelList;
 import org.uddi.sub_v3.DeleteSubscription;
 import org.uddi.sub_v3.GetSubscriptionResults;
+import org.uddi.sub_v3.KeyBag;
 import org.uddi.sub_v3.Subscription;
 import org.uddi.sub_v3.SubscriptionFilter;
 import org.uddi.sub_v3.SubscriptionResultsList;
@@ -84,20 +94,179 @@
 
 	public SubscriptionResultsList getSubscriptionResults(
 			GetSubscriptionResults body) throws DispositionReportFaultMessage {
-		
-		// TODO JUDDI-178: Perform necessary authentication logic
-		@SuppressWarnings("unused")
-		String authInfo = body.getAuthInfo();
-		
+
 		EntityManager em = PersistenceManager.getEntityManager();
         EntityTransaction tx = em.getTransaction();
         tx.begin();
+		
+		UddiEntityPublisher publisher = this.getEntityPublisher(em, body.getAuthInfo());
+		new ValidateSubscription(publisher).validateGetSubscriptionResults(em, body);
+		
+		org.apache.juddi.model.Subscription modelSubscription = em.find(org.apache.juddi.model.Subscription.class,
body.getSubscriptionKey());
+		SubscriptionFilter subscriptionFilter = null;
+		try {
+			subscriptionFilter = (SubscriptionFilter)JAXBMarshaller.unmarshallFromString(modelSubscription.getSubscriptionFilter(),
JAXBMarshaller.PACKAGE_SUBSCRIPTION);
+		} 
+		catch (JAXBException e) {
+			logger.error("JAXB Exception while unmarshalling subscription filter", e);
+			throw new FatalErrorException(new ErrorMessage("errors.Unspecified"));
+		}
+
+		SubscriptionResultsList result = new SubscriptionResultsList();
+		
+		if (subscriptionFilter.getFindBinding() != null) {
+			//Get the current matching keys
+			List<?> currentMatchingKeys = getSubscriptionMatches(subscriptionFilter, em);
+
+			// See if there's any missing keys by comparing against the previous matches.  If so,
they missing keys are added to the KeyBag and
+			// then added to the result
+			List<String> missingKeys = getMissingKeys(currentMatchingKeys, modelSubscription.getSubscriptionMatches());
+			if (missingKeys != null && missingKeys.size() > 0) {
+				KeyBag missingKeyBag = new KeyBag();
+				for (String key : missingKeys)
+					missingKeyBag.getBindingKey().add(key);
+				
+				result.getKeyBag().add(missingKeyBag);
+			}
+			
+			// Re-setting the subscription matches to the new matching key collection
+			modelSubscription.getSubscriptionMatches().clear();
+			for (Object key : currentMatchingKeys) {
+				SubscriptionMatch subMatch = new SubscriptionMatch(modelSubscription, (String)key);
+				modelSubscription.getSubscriptionMatches().add(subMatch);
+			}
+			
+			// Now, finding the necessary entities, within the coverage period limits
+			FindBinding fb = subscriptionFilter.getFindBinding();
+			org.apache.juddi.query.util.FindQualifiers findQualifiers = new org.apache.juddi.query.util.FindQualifiers();
+			findQualifiers.mapApiFindQualifiers(fb.getFindQualifiers());
+			
+			Date startPointDate = new Date(body.getCoveragePeriod().getStartPoint().toGregorianCalendar().getTimeInMillis());
+			Date endPointDate = new Date(body.getCoveragePeriod().getEndPoint().toGregorianCalendar().getTimeInMillis());
+			
+			BindingDetail bindingDetail = InquiryHelper.getBindingDetailFromKeys(fb, findQualifiers,
em, currentMatchingKeys, startPointDate, endPointDate);
+			
+			result.setBindingDetail(bindingDetail);
+			
+		}
+		if (subscriptionFilter.getFindBusiness() != null) {
+			//Get the current matching keys
+			List<?> currentMatchingKeys = getSubscriptionMatches(subscriptionFilter, em);
 
+			List<String> missingKeys = getMissingKeys(currentMatchingKeys, modelSubscription.getSubscriptionMatches());
+			if (missingKeys != null && missingKeys.size() > 0) {
+				KeyBag missingKeyBag = new KeyBag();
+				for (String key : missingKeys)
+					missingKeyBag.getBusinessKey().add(key);
+
+				result.getKeyBag().add(missingKeyBag);
+			}
+			
+			// Re-setting the subscription matches to the new matching key collection
+			modelSubscription.getSubscriptionMatches().clear();
+			for (Object key : currentMatchingKeys) {
+				SubscriptionMatch subMatch = new SubscriptionMatch(modelSubscription, (String)key);
+				modelSubscription.getSubscriptionMatches().add(subMatch);
+			}
+			
+			// Now, finding the necessary entities, within the coverage period limits
+			FindBusiness fb = subscriptionFilter.getFindBusiness();
+			org.apache.juddi.query.util.FindQualifiers findQualifiers = new org.apache.juddi.query.util.FindQualifiers();
+			findQualifiers.mapApiFindQualifiers(fb.getFindQualifiers());
+			
+			Date startPointDate = new Date(body.getCoveragePeriod().getStartPoint().toGregorianCalendar().getTimeInMillis());
+			Date endPointDate = new Date(body.getCoveragePeriod().getEndPoint().toGregorianCalendar().getTimeInMillis());
+			
+			BusinessList businessList = InquiryHelper.getBusinessListFromKeys(fb, findQualifiers,
em, currentMatchingKeys, startPointDate, endPointDate);
+			
+			result.setBusinessList(businessList);
+			
+		}
+		if (subscriptionFilter.getFindService() != null) {
+			//Get the current matching keys
+			List<?> currentMatchingKeys = getSubscriptionMatches(subscriptionFilter, em);
+
+			List<String> missingKeys = getMissingKeys(currentMatchingKeys, modelSubscription.getSubscriptionMatches());
+			if (missingKeys != null && missingKeys.size() > 0) {
+				KeyBag missingKeyBag = new KeyBag();
+				for (String key : missingKeys)
+					missingKeyBag.getServiceKey().add(key);
+
+				result.getKeyBag().add(missingKeyBag);
+			}
+			
+			// Re-setting the subscription matches to the new matching key collection
+			modelSubscription.getSubscriptionMatches().clear();
+			for (Object key : currentMatchingKeys) {
+				SubscriptionMatch subMatch = new SubscriptionMatch(modelSubscription, (String)key);
+				modelSubscription.getSubscriptionMatches().add(subMatch);
+			}
+			
+			// Now, finding the necessary entities, within the coverage period limits
+			FindService fs = subscriptionFilter.getFindService();
+			org.apache.juddi.query.util.FindQualifiers findQualifiers = new org.apache.juddi.query.util.FindQualifiers();
+			findQualifiers.mapApiFindQualifiers(fs.getFindQualifiers());
+			
+			Date startPointDate = new Date(body.getCoveragePeriod().getStartPoint().toGregorianCalendar().getTimeInMillis());
+			Date endPointDate = new Date(body.getCoveragePeriod().getEndPoint().toGregorianCalendar().getTimeInMillis());
+			
+			ServiceList serviceList = InquiryHelper.getServiceListFromKeys(fs, findQualifiers, em,
currentMatchingKeys, startPointDate, endPointDate);
+			
+			result.setServiceList(serviceList);
+		}
+		if (subscriptionFilter.getFindTModel() != null) {
+			//Get the current matching keys
+			List<?> currentMatchingKeys = getSubscriptionMatches(subscriptionFilter, em);
+
+			List<String> missingKeys = getMissingKeys(currentMatchingKeys, modelSubscription.getSubscriptionMatches());
+			if (missingKeys != null && missingKeys.size() > 0) {
+				KeyBag missingKeyBag = new KeyBag();
+				for (String key : missingKeys)
+					missingKeyBag.getTModelKey().add(key);
+
+				result.getKeyBag().add(missingKeyBag);
+			}
+			
+			// Re-setting the subscription matches to the new matching key collection
+			modelSubscription.getSubscriptionMatches().clear();
+			for (Object key : currentMatchingKeys) {
+				SubscriptionMatch subMatch = new SubscriptionMatch(modelSubscription, (String)key);
+				modelSubscription.getSubscriptionMatches().add(subMatch);
+			}
+			
+			// Now, finding the necessary entities, within the coverage period limits
+			FindTModel ft = subscriptionFilter.getFindTModel();
+			org.apache.juddi.query.util.FindQualifiers findQualifiers = new org.apache.juddi.query.util.FindQualifiers();
+			findQualifiers.mapApiFindQualifiers(ft.getFindQualifiers());
+			
+			Date startPointDate = new Date(body.getCoveragePeriod().getStartPoint().toGregorianCalendar().getTimeInMillis());
+			Date endPointDate = new Date(body.getCoveragePeriod().getEndPoint().toGregorianCalendar().getTimeInMillis());
+			
+			TModelList tmodelList = InquiryHelper.getTModelListFromKeys(ft, findQualifiers, em, currentMatchingKeys,
startPointDate, endPointDate);
+			
+			result.setTModelList(tmodelList);
+			
+		}
+		if (subscriptionFilter.getFindRelatedBusinesses() != null) {
+		}
+		if (subscriptionFilter.getGetBindingDetail() != null) {
+		}
+		if (subscriptionFilter.getGetBusinessDetail() != null) {
+		}
+		if (subscriptionFilter.getGetServiceDetail() != null) {
+		}
+		if (subscriptionFilter.getGetTModelDetail() != null) {
+		}
+		if (subscriptionFilter.getGetAssertionStatusReport() != null) {
+		}
+		
+		
+		
         tx.commit();
         em.close();
-        return null;
-	}
 
+        return result;
+	}
 
 	@SuppressWarnings("unchecked")
 	public List<Subscription> getSubscriptions(String authInfo)
@@ -287,4 +456,15 @@
 		
 	}
 	
+	private List<String> getMissingKeys(List<?> currentMatchingKeys, List<SubscriptionMatch>
subscriptionMatches) {
+
+		List<String> result = new ArrayList<String>(subscriptionMatches.size());
+		for (SubscriptionMatch subMatch : subscriptionMatches)
+			result.add(subMatch.getEntityKey());
+		
+		result.removeAll(currentMatchingKeys);
+		
+		return result;
+	}
+	
 }

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/mapping/MappingModelToApi.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/mapping/MappingModelToApi.java?rev=767349&r1=767348&r2=767349&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/mapping/MappingModelToApi.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/mapping/MappingModelToApi.java
Wed Apr 22 02:20:49 2009
@@ -744,7 +744,7 @@
 		apiSubscription.setNotificationInterval(converStringToDuration(modelSubscription.getNotificationInterval()));
 
 		try {
-			SubscriptionFilter existingFilter = (SubscriptionFilter)JAXBMarshaller.unmarshallFromString(modelSubscription.getSubscriptionFilter(),
"org.uddi.sub_v3");
+			SubscriptionFilter existingFilter = (SubscriptionFilter)JAXBMarshaller.unmarshallFromString(modelSubscription.getSubscriptionFilter(),
JAXBMarshaller.PACKAGE_SUBSCRIPTION);
 			apiSubscription.setSubscriptionFilter(existingFilter);
 		} 
 		catch (JAXBException e) {

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/validation/ValidateSubscription.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/validation/ValidateSubscription.java?rev=767349&r1=767348&r2=767349&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/validation/ValidateSubscription.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/validation/ValidateSubscription.java
Wed Apr 22 02:20:49 2009
@@ -17,6 +17,8 @@
 
  package org.apache.juddi.validation;
 
+import java.util.Date;
+import java.util.GregorianCalendar;
 import java.util.HashSet;
 import java.util.List;
 
@@ -25,13 +27,16 @@
 import org.apache.juddi.error.ErrorMessage;
 import org.apache.juddi.error.FatalErrorException;
 import org.apache.juddi.error.InvalidKeyPassedException;
+import org.apache.juddi.error.InvalidTimeException;
 import org.apache.juddi.error.KeyUnavailableException;
 import org.apache.juddi.error.UserMismatchException;
 import org.apache.juddi.error.ValueNotAllowedException;
 import org.apache.juddi.keygen.KeyGenerator;
 import org.apache.juddi.keygen.KeyGeneratorFactory;
 import org.apache.juddi.model.UddiEntityPublisher;
+import org.uddi.sub_v3.CoveragePeriod;
 import org.uddi.sub_v3.DeleteSubscription;
+import org.uddi.sub_v3.GetSubscriptionResults;
 import org.uddi.sub_v3.SubscriptionFilter;
 import org.uddi.v3_service.DispositionReportFaultMessage;
 
@@ -158,7 +163,6 @@
 
 		}
 		
-		
 	}
 	
 	public void validateDeleteSubscription(EntityManager em, DeleteSubscription body) throws
DispositionReportFaultMessage {
@@ -187,4 +191,37 @@
 			
 		}
 	}
+
+	public void validateGetSubscriptionResults(EntityManager em, GetSubscriptionResults body)
throws DispositionReportFaultMessage {
+		// No null input
+		if (body == null)
+			throw new FatalErrorException(new ErrorMessage("errors.NullInput"));
+		
+		String subscriptionKey = body.getSubscriptionKey();
+		if (subscriptionKey == null || subscriptionKey.length() == 0)
+			throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.NullKey", subscriptionKey));
+		
+		Object obj = em.find(org.apache.juddi.model.Subscription.class, subscriptionKey);
+		if (obj == null)
+			throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.SubscriptionNotFound",
subscriptionKey));
+		
+		Date expiresAfter = ((org.apache.juddi.model.Subscription)obj).getExpiresAfter();
+		Date now = new Date();
+		if (expiresAfter.getTime() < now.getTime())
+			throw new InvalidKeyPassedException(new ErrorMessage("errors.getsubscriptionresult.SubscriptionExpired",
subscriptionKey));
+		
+		CoveragePeriod coveragePeriod = body.getCoveragePeriod();
+		if (coveragePeriod == null)
+			throw new InvalidTimeException(new ErrorMessage("errors.getsubscriptionresult.NullCoveragePeriod"));
+		
+		if (coveragePeriod.getStartPoint() == null || coveragePeriod.getEndPoint() == null)
+			throw new InvalidTimeException(new ErrorMessage("errors.getsubscriptionresult.InvalidDateInCoveragePeriod"));
+		
+		GregorianCalendar startPoint = coveragePeriod.getStartPoint().toGregorianCalendar();
+		GregorianCalendar endPoint = coveragePeriod.getEndPoint().toGregorianCalendar();
+		if (startPoint.getTimeInMillis() > endPoint.getTimeInMillis())
+			throw new InvalidTimeException(new ErrorMessage("errors.getsubscriptionresult.StartPointAfterEndPoint",
startPoint.toString()));
+		
+		
+	}
 }



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


Mime
View raw message