juddi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tcunn...@apache.org
Subject svn commit: r758149 - in /webservices/juddi/branches/v3_trunk/juddi-core/src: main/java/org/apache/juddi/api/impl/ main/java/org/apache/juddi/mapping/ test/java/org/apache/juddi/api/impl/
Date Wed, 25 Mar 2009 05:54:08 GMT
Author: tcunning
Date: Wed Mar 25 05:54:06 2009
New Revision: 758149

URL: http://svn.apache.org/viewvc?rev=758149&view=rev
Log:
JUDDI-206
Initial check in of some changes for save_subscription - subscribed objects
are not resolved nor are filters saved.

Modified:
    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/MappingApiToModel.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_080_SubscriberSaveTest.java

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=758149&r1=758148&r2=758149&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 Mar 25 05:54:06 2009
@@ -31,6 +31,7 @@
 import org.uddi.sub_v3.SubscriptionResultsList;
 import org.uddi.v3_service.DispositionReportFaultMessage;
 import org.uddi.v3_service.UDDISubscriptionPortType;
+import org.apache.juddi.mapping.MappingApiToModel;
 import org.apache.juddi.query.PersistenceManager;
 
 
@@ -98,7 +99,21 @@
         EntityManager em = PersistenceManager.getEntityManager();
         EntityTransaction tx = em.getTransaction();
         tx.begin();
-                
+        
+        if (subscription != null) {
+	        List<org.uddi.sub_v3.Subscription> apiSubscriptionList = subscription.value;
+	        for (org.uddi.sub_v3.Subscription apiSubscription : apiSubscriptionList) {
+	        	org.apache.juddi.model.Subscription modelSubscription = new org.apache.juddi.model.Subscription();
+	        	if ((apiSubscription.getSubscriptionKey() != null) 
+	        			&& (!"".equals(apiSubscription.getSubscriptionKey()))) {
+	        		modelSubscription = em.find(org.apache.juddi.model.Subscription.class, 
+	        				apiSubscription.getSubscriptionKey());
+	        	}
+	        	MappingApiToModel.mapSubscription(apiSubscription, modelSubscription);
+		        em.persist(modelSubscription);	        
+	        }
+        }
+	        
         tx.commit();
         em.close();
 
@@ -108,10 +123,24 @@
 			SaveSubscription subscription)
 			throws DispositionReportFaultMessage {
 
+        List<org.uddi.sub_v3.Subscription> apiSubscriptionList = subscription.getSubscription();
+		
         EntityManager em = PersistenceManager.getEntityManager();
         EntityTransaction tx = em.getTransaction();
         tx.begin();
-                
+        if (apiSubscriptionList != null) {
+	        for (org.uddi.sub_v3.Subscription apiSubscription : apiSubscriptionList) {
+	        	org.apache.juddi.model.Subscription modelSubscription = null;
+	        	if ((apiSubscription.getSubscriptionKey() != null) 
+	        			&& (!"".equals(apiSubscription.getSubscriptionKey()))) {
+	        		modelSubscription = em.find(org.apache.juddi.model.Subscription.class, 
+	        				apiSubscription.getSubscriptionKey());
+	        	}
+	        	MappingApiToModel.mapSubscription(apiSubscription, modelSubscription);    
+		        em.persist(modelSubscription);
+	        }
+        }
+        
         tx.commit();
         em.close();
 	}

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/mapping/MappingApiToModel.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/mapping/MappingApiToModel.java?rev=758149&r1=758148&r2=758149&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/mapping/MappingApiToModel.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/mapping/MappingApiToModel.java
Wed Mar 25 05:54:06 2009
@@ -534,9 +534,22 @@
 
 	public static void mapSubscription(org.uddi.sub_v3.Subscription apiSubscription,
 			org.apache.juddi.model.Subscription modelSubscription) throws DispositionReportFaultMessage
{
-		modelSubscription.setBindingKey(apiSubscription.getBindingKey());
-		modelSubscription.setSubscriptionKey(apiSubscription.getSubscriptionKey());
-		modelSubscription.setNotificationInterval(apiSubscription.getNotificationInterval().toString());
+		if ((apiSubscription.getSubscriptionKey() != null) && (!"".equals(apiSubscription.getSubscriptionKey())))
{
+			// if the apiSubscription has a key, this is a renewal or update - we don't want to change
all of the fields, 
+			// just the ones that have been provided to update the record
+			if (apiSubscription.getBindingKey() != null) {
+				modelSubscription.setBindingKey(apiSubscription.getBindingKey());
+			}
+			
+			if (apiSubscription.getNotificationInterval() != null) {
+				modelSubscription.setNotificationInterval(apiSubscription.getNotificationInterval().toString());
+			}
+			
+		} else {
+			// No key provided, assume that this is a new subscription and map all fields
+			modelSubscription.setBindingKey(apiSubscription.getBindingKey());
+			modelSubscription.setNotificationInterval(apiSubscription.getNotificationInterval().toString());
+		}
 	}
 	
 }

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_080_SubscriberSaveTest.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_080_SubscriberSaveTest.java?rev=758149&r1=758148&r2=758149&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_080_SubscriberSaveTest.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_080_SubscriberSaveTest.java
Wed Mar 25 05:54:06 2009
@@ -14,8 +14,18 @@
  */
 package org.apache.juddi.api.impl;
 
+import org.apache.log4j.Logger;
+import org.junit.Assert;
+import org.junit.BeforeClass;
 import org.junit.Test;
+import org.uddi.api_v3.tck.TckBusiness;
+import org.uddi.api_v3.tck.TckPublisher;
+import org.uddi.api_v3.tck.TckPublisherAssertion;
+import org.uddi.api_v3.tck.TckSecurity;
 import org.uddi.api_v3.tck.TckSubscriber;
+import org.uddi.api_v3.tck.TckTModel;
+import org.uddi.v3_service.DispositionReportFaultMessage;
+import org.uddi.v3_service.UDDISecurityPortType;
 
 /**
  * @author <a href="mailto:tcunningh@apache.org">Tom Cunningham</a>
@@ -24,7 +34,10 @@
 public class API_080_SubscriberSaveTest 
 {
 	private TckSubscriber tckSubscriber = new TckSubscriber(new UDDISubscriptionImpl(), new
UDDISecurityImpl());
+	private static Logger logger = Logger.getLogger(API_060_PublisherAssertionTest.class);
 	
+	private static API_080_SubscriberSaveTest api010  = new API_080_SubscriberSaveTest();
+
 	@Test
 	public void saveSubscriber() {
 		tckSubscriber.saveSubscriber();



---------------------------------------------------------------------
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