ws-scout-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tcunn...@apache.org
Subject svn commit: r934962 - in /webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry: AuthTokenSingleton.java AuthTokenV3Singleton.java BusinessLifeCycleManagerImpl.java BusinessLifeCycleManagerV3Impl.java
Date Fri, 16 Apr 2010 15:32:19 GMT
Author: tcunning
Date: Fri Apr 16 15:32:19 2010
New Revision: 934962

URL: http://svn.apache.org/viewvc?rev=934962&view=rev
Log:
SCOUT-95
Add first stage of caching authtokens.    Still need to use the singletons
and add BusinessQueryManager support for caching.

Added:
    webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/AuthTokenSingleton.java
    webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/AuthTokenV3Singleton.java
Modified:
    webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerImpl.java
    webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerV3Impl.java

Added: webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/AuthTokenSingleton.java
URL: http://svn.apache.org/viewvc/webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/AuthTokenSingleton.java?rev=934962&view=auto
==============================================================================
--- webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/AuthTokenSingleton.java
(added)
+++ webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/AuthTokenSingleton.java
Fri Apr 16 15:32:19 2010
@@ -0,0 +1,42 @@
+package org.apache.ws.scout.registry;
+
+import java.util.Hashtable;
+import org.apache.ws.scout.model.uddi.v2.AuthToken;
+
+public class AuthTokenSingleton {
+	private static AuthTokenSingleton instance = new AuthTokenSingleton();
+	private static Hashtable cachedAuthTokenHash = new Hashtable();
+	
+	private AuthTokenSingleton() {
+		cachedAuthTokenHash = new Hashtable();
+	}
+
+	public static AuthToken getToken(String username) {
+		if (instance == null) {
+			instance = new AuthTokenSingleton();
+		}
+
+		if (cachedAuthTokenHash.containsKey(username)) 
+			return (AuthToken) cachedAuthTokenHash.get(username);
+	
+		return null;
+	} 	
+	
+	public synchronized static void addAuthToken(String username, 
+			AuthToken token) {
+		if (instance == null) {
+			instance = new AuthTokenSingleton();
+		}
+		cachedAuthTokenHash.put(username, token);
+	}
+	
+	public synchronized static void deleteAuthToken(String username) {
+		if (instance == null) {
+			instance = new AuthTokenSingleton();
+		} else {
+			if (cachedAuthTokenHash.containsKey(username)) {
+				cachedAuthTokenHash.remove(username);
+			}
+		}
+	}
+}
\ No newline at end of file

Added: webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/AuthTokenV3Singleton.java
URL: http://svn.apache.org/viewvc/webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/AuthTokenV3Singleton.java?rev=934962&view=auto
==============================================================================
--- webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/AuthTokenV3Singleton.java
(added)
+++ webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/AuthTokenV3Singleton.java
Fri Apr 16 15:32:19 2010
@@ -0,0 +1,41 @@
+package org.apache.ws.scout.registry;
+
+import java.util.Hashtable;
+import org.uddi.api_v3.AuthToken;
+
+public class AuthTokenV3Singleton {
+	private static AuthTokenV3Singleton instance = new AuthTokenV3Singleton();
+	private static Hashtable cachedAuthTokenHash = new Hashtable();
+	
+	private AuthTokenV3Singleton() {
+		cachedAuthTokenHash = new Hashtable();
+	}
+
+	public static AuthToken getInstance(String username) {
+		if (instance == null) {
+			instance = new AuthTokenV3Singleton();
+		}
+		if (cachedAuthTokenHash.containsKey(username)) 
+			return (AuthToken)cachedAuthTokenHash.get(username);
+	
+		return null;
+	} 	
+	
+	public synchronized static void addAuthToken(String username, 
+			AuthToken token) {
+		if (instance == null) {
+			instance = new AuthTokenV3Singleton();
+		}
+		cachedAuthTokenHash.put(username, token);
+	}
+	
+	public synchronized static void deleteAuthToken(String username) {
+		if (instance == null) {
+			instance = new AuthTokenV3Singleton();
+		} else {
+			if (cachedAuthTokenHash.containsKey(username)) {
+				cachedAuthTokenHash.remove(username);
+			}
+		}
+	}
+}
\ No newline at end of file

Modified: webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerImpl.java
URL: http://svn.apache.org/viewvc/webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerImpl.java?rev=934962&r1=934961&r2=934962&view=diff
==============================================================================
--- webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerImpl.java
(original)
+++ webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerImpl.java
Fri Apr 16 15:32:19 2010
@@ -21,6 +21,7 @@ import java.net.PasswordAuthentication;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
+import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.LinkedHashSet;
 import java.util.List;
@@ -93,12 +94,18 @@ public class BusinessLifeCycleManagerImp
 
 	private Log log = LogFactory.getLog(this.getClass());
     
+    private static Hashtable cachedAuthTokenHash = null;
+	
     private transient ObjectFactory objectFactory = new ObjectFactory();
 	
     public BusinessLifeCycleManagerImpl(RegistryService registry) {
-        super(registry);
+    	super(registry);
+        
         if(objectFactory == null)
         	objectFactory = new ObjectFactory();
+        
+        if (cachedAuthTokenHash == null) 
+        	cachedAuthTokenHash = new Hashtable();
     }
 
     /**
@@ -570,32 +577,117 @@ public class BusinessLifeCycleManagerImp
         Object regobj;
         if(op.equalsIgnoreCase("SAVE_ASSOCIATION"))
         {
-            regobj = ireg.setPublisherAssertions(token.getAuthInfo(), (PublisherAssertion[])
dataarray);
-        } else
-        if (op.equalsIgnoreCase("SAVE_SERVICE")) {
-            regobj = ireg.saveService(token.getAuthInfo(), (BusinessService[])dataarray);
+        	try {
+        		regobj = ireg.setPublisherAssertions(token.getAuthInfo(), (PublisherAssertion[])
dataarray);
+        	} catch (RegistryException rve) {
+        		String username = getUsernameFromCredentials(connection.getCredentials());
+        		if (cachedAuthTokenHash.containsKey(username)) {
+        			cachedAuthTokenHash.remove(username);
+        		}
+        		token = getAuthToken(connection, ireg);
+        		regobj = ireg.setPublisherAssertions(token.getAuthInfo(), (PublisherAssertion[])
dataarray);
+        	}
+        } 
+        else if (op.equalsIgnoreCase("SAVE_SERVICE")) {
+        	try {
+        		regobj = ireg.saveService(token.getAuthInfo(), (BusinessService[])dataarray);
+        	} catch (RegistryException rve) {
+        		String username = getUsernameFromCredentials(connection.getCredentials());
+        		if (cachedAuthTokenHash.containsKey(username)) {
+        			cachedAuthTokenHash.remove(username);
+        		}
+        		token = getAuthToken(connection, ireg);
+        		regobj = ireg.saveService(token.getAuthInfo(), (BusinessService[])dataarray);
+        	}
         }
         else if (op.equalsIgnoreCase("SAVE_SERVICE_BINDING")) {
-            regobj = ireg.saveBinding(token.getAuthInfo(), (BindingTemplate[]) dataarray);
+        	try {
+        		regobj = ireg.saveBinding(token.getAuthInfo(), (BindingTemplate[]) dataarray);
+        	} catch (RegistryException rve) {
+        		String username = getUsernameFromCredentials(connection.getCredentials());
+        		if (cachedAuthTokenHash.containsKey(username)) {
+        			cachedAuthTokenHash.remove(username);
+        		}
+        		token = getAuthToken(connection, ireg);
+        		regobj = ireg.saveBinding(token.getAuthInfo(), (BindingTemplate[]) dataarray);
       		
+        	}
         }
         else if (op.equalsIgnoreCase("SAVE_ORG")) {
-            regobj = ireg.saveBusiness(token.getAuthInfo(), (BusinessEntity[]) dataarray);
+        	try {
+        		regobj = ireg.saveBusiness(token.getAuthInfo(), (BusinessEntity[]) dataarray);
+        	} catch (RegistryException rve) {
+        		String username = getUsernameFromCredentials(connection.getCredentials());
+        		if (cachedAuthTokenHash.containsKey(username)) {
+        			cachedAuthTokenHash.remove(username);
+        		}
+        		token = getAuthToken(connection, ireg);
+        		regobj = ireg.saveBusiness(token.getAuthInfo(), (BusinessEntity[]) dataarray);
+        	}
         }
         else if (op.equalsIgnoreCase("SAVE_TMODEL")) {
-            regobj = ireg.saveTModel(token.getAuthInfo(), (TModel[]) dataarray);
+        	try {
+        		regobj = ireg.saveTModel(token.getAuthInfo(), (TModel[]) dataarray);
+        	} catch (RegistryException rve) {
+        		String username = getUsernameFromCredentials(connection.getCredentials());
+        		if (cachedAuthTokenHash.containsKey(username)) {
+        			cachedAuthTokenHash.remove(username);
+        		}
+        		token = getAuthToken(connection, ireg);
+        		regobj = ireg.saveTModel(token.getAuthInfo(), (TModel[]) dataarray);
+        	}
         }
         else if (op.equalsIgnoreCase("DELETE_ORG")) {
-            clearPublisherAssertions(token.getAuthInfo(), ireg);
-            regobj = ireg.deleteBusiness(token.getAuthInfo(), (String[]) dataarray);
+            try {
+                clearPublisherAssertions(token.getAuthInfo(), ireg);
+            	regobj = ireg.deleteBusiness(token.getAuthInfo(), (String[]) dataarray);
+        	} catch (RegistryException rve) {
+        		String username = getUsernameFromCredentials(connection.getCredentials());
+        		if (cachedAuthTokenHash.containsKey(username)) {
+        			cachedAuthTokenHash.remove(username);
+        		}
+        		token = getAuthToken(connection, ireg);
+                clearPublisherAssertions(token.getAuthInfo(), ireg);
+        		regobj = ireg.deleteBusiness(token.getAuthInfo(), (String[]) dataarray);
+        	}
         }
         else if (op.equalsIgnoreCase("DELETE_SERVICE")) {
-            regobj = ireg.deleteService(token.getAuthInfo(), (String[]) dataarray);
+        	try {
+        		regobj = ireg.deleteService(token.getAuthInfo(), (String[]) dataarray);
+	    	} catch (RegistryException rve) {
+	    		String username = getUsernameFromCredentials(connection.getCredentials());
+	    		if (cachedAuthTokenHash.containsKey(username)) {
+	    			cachedAuthTokenHash.remove(username);
+	    		}
+	    		token = getAuthToken(connection, ireg);
+	            clearPublisherAssertions(token.getAuthInfo(), ireg);
+        		regobj = ireg.deleteService(token.getAuthInfo(), (String[]) dataarray);
+	    	}
         }
         else if (op.equalsIgnoreCase("DELETE_SERVICEBINDING")) {
-            regobj = ireg.deleteBinding(token.getAuthInfo(), (String[]) dataarray);
+        	try	{
+        		regobj = ireg.deleteBinding(token.getAuthInfo(), (String[]) dataarray);
+	    	} catch (RegistryException rve) {
+	    		String username = getUsernameFromCredentials(connection.getCredentials());
+	    		if (cachedAuthTokenHash.containsKey(username)) {
+	    			cachedAuthTokenHash.remove(username);
+	    		}
+	    		token = getAuthToken(connection, ireg);
+	            clearPublisherAssertions(token.getAuthInfo(), ireg);
+        		regobj = ireg.deleteBinding(token.getAuthInfo(), (String[]) dataarray);
+	    	}
         }
         else if (op.equalsIgnoreCase("DELETE_CONCEPT")) {
-            regobj = ireg.deleteTModel(token.getAuthInfo(), (String[]) dataarray);
+            try {
+            	regobj = ireg.deleteTModel(token.getAuthInfo(), (String[]) dataarray);
+	    	} catch (RegistryException rve) {
+	    		String username = getUsernameFromCredentials(connection.getCredentials());
+	    		if (cachedAuthTokenHash.containsKey(username)) {
+	    			cachedAuthTokenHash.remove(username);
+	    		}
+	    		token = getAuthToken(connection, ireg);
+	            clearPublisherAssertions(token.getAuthInfo(), ireg);
+            	regobj = ireg.deleteTModel(token.getAuthInfo(), (String[]) dataarray);
+	    	}
         }
         else if (op.equalsIgnoreCase("DELETE_ASSOCIATION")) {
            int len = ((String[]) dataarray).length;
@@ -605,7 +697,17 @@ public class BusinessLifeCycleManagerImp
                String keystr = ((String[])dataarray)[i];
                paarr[i] = ScoutJaxrUddiHelper.getPubAssertionFromJAXRAssociationKey(keystr);
             }
-            regobj = ireg.deletePublisherAssertions(token.getAuthInfo(), paarr);
+            try {
+                regobj = ireg.deletePublisherAssertions(token.getAuthInfo(), paarr);
+            } catch (RegistryException rve) {
+	    		String username = getUsernameFromCredentials(connection.getCredentials());
+	    		if (cachedAuthTokenHash.containsKey(username)) {
+	    			cachedAuthTokenHash.remove(username);
+	    		}
+	    		token = getAuthToken(connection, ireg);
+	            clearPublisherAssertions(token.getAuthInfo(), ireg);
+	            regobj = ireg.deletePublisherAssertions(token.getAuthInfo(), paarr);
+	    	}
         }
         else if (op.equalsIgnoreCase("DELETE_CLASSIFICATIONSCHEME")) {
             regobj = ireg.deleteTModel(token.getAuthInfo(), (String[]) dataarray);
@@ -724,7 +826,19 @@ public class BusinessLifeCycleManagerImp
         return bulk;
     }
 
-
+    private String getUsernameFromCredentials(Set credentials) {
+        String username = "", pwd = "";
+                
+        if (credentials != null) {
+        	Iterator it = credentials.iterator();
+        	while (it.hasNext()) {
+        		PasswordAuthentication pass = (PasswordAuthentication) it.next();
+        		username = pass.getUserName();
+        	}
+        }
+        return username;
+    }
+    
     /**
      * Get the Auth Token from the registry
      *
@@ -734,18 +848,22 @@ public class BusinessLifeCycleManagerImp
      * @throws JAXRException
      */
     private AuthToken getAuthToken(ConnectionImpl connection, IRegistry ireg)
-            throws JAXRException {
+            throws JAXRException {    	
         Set creds = connection.getCredentials();
         String username = "", pwd = "";
         if (creds != null) {
         	Iterator it = creds.iterator();
         	while (it.hasNext()) {
         		PasswordAuthentication pass = (PasswordAuthentication) it.next();
-        		username = pass.getUserName();
+        		username = pass.getUserName	();
         		pwd = new String(pass.getPassword());
         	}
         }
 
+        if ((cachedAuthTokenHash != null) && (cachedAuthTokenHash.containsKey(username)))
{
+        	return (AuthToken) cachedAuthTokenHash.get(username);
+        }
+        
         AuthToken token = null;
         try {
             token = ireg.getAuthToken(username, pwd);
@@ -754,6 +872,7 @@ public class BusinessLifeCycleManagerImp
         { 
             throw new JAXRException(e);
         }
+        cachedAuthTokenHash.put(username, token);
         return token;
     }
 

Modified: webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerV3Impl.java
URL: http://svn.apache.org/viewvc/webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerV3Impl.java?rev=934962&r1=934961&r2=934962&view=diff
==============================================================================
--- webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerV3Impl.java
(original)
+++ webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerV3Impl.java
Fri Apr 16 15:32:19 2010
@@ -21,6 +21,7 @@ import java.net.PasswordAuthentication;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
+import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.LinkedHashSet;
 import java.util.List;
@@ -95,10 +96,14 @@ public class BusinessLifeCycleManagerV3I
     
     private transient ObjectFactory objectFactory = new ObjectFactory();
 	
+    private static Hashtable cachedAuthTokenHash = null;
+    
     public BusinessLifeCycleManagerV3Impl(RegistryService registry) {
         super(registry);
         if(objectFactory == null)
         	objectFactory = new ObjectFactory();
+        if (cachedAuthTokenHash == null) 
+        	cachedAuthTokenHash = new Hashtable();
     }
 
     /**
@@ -569,46 +574,150 @@ public class BusinessLifeCycleManagerV3I
 
         Object regobj;
         if(op.equalsIgnoreCase("SAVE_ASSOCIATION"))
-        {
-            regobj = ireg.setPublisherAssertions(token.getAuthInfo(), (PublisherAssertion[])
dataarray);
-        } else
-        if (op.equalsIgnoreCase("SAVE_SERVICE")) {
-            regobj = ireg.saveService(token.getAuthInfo(), (BusinessService[])dataarray);
+        { 	
+        	try {
+        		regobj = ireg.setPublisherAssertions(token.getAuthInfo(), (PublisherAssertion[])
dataarray);
+        	} catch (RegistryV3Exception rve) {
+        		String username = getUsernameFromCredentials(connection.getCredentials());
+        		if (cachedAuthTokenHash.containsKey(username)) {
+        			cachedAuthTokenHash.remove(username);
+        		}
+        		token = getAuthToken(connection, ireg);
+        		regobj = ireg.setPublisherAssertions(token.getAuthInfo(), (PublisherAssertion[])
dataarray);
+        	}
+        } else if (op.equalsIgnoreCase("SAVE_SERVICE")) {
+        	try {
+        		regobj = ireg.saveService(token.getAuthInfo(), (BusinessService[])dataarray);
+        	} catch (RegistryV3Exception rve) {
+        		String username = getUsernameFromCredentials(connection.getCredentials());
+        		if (cachedAuthTokenHash.containsKey(username)) {
+        			cachedAuthTokenHash.remove(username);
+        		}
+        		token = getAuthToken(connection, ireg);
+        		regobj = ireg.saveService(token.getAuthInfo(), (BusinessService[])dataarray);
+        	}
         }
         else if (op.equalsIgnoreCase("SAVE_SERVICE_BINDING")) {
-            regobj = ireg.saveBinding(token.getAuthInfo(), (BindingTemplate[]) dataarray);
+        	try {
+        		regobj = ireg.saveBinding(token.getAuthInfo(), (BindingTemplate[]) dataarray);
+        	} catch (RegistryV3Exception rve) {
+        		String username = getUsernameFromCredentials(connection.getCredentials());
+        		if (cachedAuthTokenHash.containsKey(username)) {
+        			cachedAuthTokenHash.remove(username);
+        		}
+        		token = getAuthToken(connection, ireg);
+        		regobj = ireg.saveBinding(token.getAuthInfo(), (BindingTemplate[]) dataarray);
       		
+        	}
         }
         else if (op.equalsIgnoreCase("SAVE_ORG")) {
-            regobj = ireg.saveBusiness(token.getAuthInfo(), (BusinessEntity[]) dataarray);
+        	try {
+        		regobj = ireg.saveBusiness(token.getAuthInfo(), (BusinessEntity[]) dataarray);
+        	} catch (RegistryV3Exception rve) {
+        		String username = getUsernameFromCredentials(connection.getCredentials());
+        		if (cachedAuthTokenHash.containsKey(username)) {
+        			cachedAuthTokenHash.remove(username);
+        		}
+        		token = getAuthToken(connection, ireg);
+        		regobj = ireg.saveBusiness(token.getAuthInfo(), (BusinessEntity[]) dataarray);
+        	}
         }
         else if (op.equalsIgnoreCase("SAVE_TMODEL")) {
-            regobj = ireg.saveTModel(token.getAuthInfo(), (TModel[]) dataarray);
+        	try {
+        		regobj = ireg.saveTModel(token.getAuthInfo(), (TModel[]) dataarray);
+        	} catch (RegistryV3Exception rve) {
+        		String username = getUsernameFromCredentials(connection.getCredentials());
+        		if (cachedAuthTokenHash.containsKey(username)) {
+        			cachedAuthTokenHash.remove(username);
+        		}
+        		token = getAuthToken(connection, ireg);
+        		regobj = ireg.saveTModel(token.getAuthInfo(), (TModel[]) dataarray);
+        	}
         }
         else if (op.equalsIgnoreCase("DELETE_ORG")) {
-            clearPublisherAssertions(token.getAuthInfo(), ireg);
-            regobj = ireg.deleteBusiness(token.getAuthInfo(), (String[]) dataarray);
+            try {
+                clearPublisherAssertions(token.getAuthInfo(), ireg);
+            	regobj = ireg.deleteBusiness(token.getAuthInfo(), (String[]) dataarray);
+        	} catch (RegistryV3Exception rve) {
+        		String username = getUsernameFromCredentials(connection.getCredentials());
+        		if (cachedAuthTokenHash.containsKey(username)) {
+        			cachedAuthTokenHash.remove(username);
+        		}
+        		token = getAuthToken(connection, ireg);
+                clearPublisherAssertions(token.getAuthInfo(), ireg);
+        		regobj = ireg.deleteBusiness(token.getAuthInfo(), (String[]) dataarray);
+        	}
         }
         else if (op.equalsIgnoreCase("DELETE_SERVICE")) {
-            regobj = ireg.deleteService(token.getAuthInfo(), (String[]) dataarray);
+        	try {
+        		regobj = ireg.deleteService(token.getAuthInfo(), (String[]) dataarray);
+	    	} catch (RegistryV3Exception rve) {
+	    		String username = getUsernameFromCredentials(connection.getCredentials());
+	    		if (cachedAuthTokenHash.containsKey(username)) {
+	    			cachedAuthTokenHash.remove(username);
+	    		}
+	    		token = getAuthToken(connection, ireg);
+	            clearPublisherAssertions(token.getAuthInfo(), ireg);
+        		regobj = ireg.deleteService(token.getAuthInfo(), (String[]) dataarray);
+	    	}
         }
         else if (op.equalsIgnoreCase("DELETE_SERVICEBINDING")) {
-            regobj = ireg.deleteBinding(token.getAuthInfo(), (String[]) dataarray);
+        	try	{
+        		regobj = ireg.deleteBinding(token.getAuthInfo(), (String[]) dataarray);
+	    	} catch (RegistryV3Exception rve) {
+	    		String username = getUsernameFromCredentials(connection.getCredentials());
+	    		if (cachedAuthTokenHash.containsKey(username)) {
+	    			cachedAuthTokenHash.remove(username);
+	    		}
+	    		token = getAuthToken(connection, ireg);
+	            clearPublisherAssertions(token.getAuthInfo(), ireg);
+        		regobj = ireg.deleteBinding(token.getAuthInfo(), (String[]) dataarray);
+	    	}
         }
         else if (op.equalsIgnoreCase("DELETE_CONCEPT")) {
-            regobj = ireg.deleteTModel(token.getAuthInfo(), (String[]) dataarray);
+            try {
+            	regobj = ireg.deleteTModel(token.getAuthInfo(), (String[]) dataarray);
+	    	} catch (RegistryV3Exception rve) {
+	    		String username = getUsernameFromCredentials(connection.getCredentials());
+	    		if (cachedAuthTokenHash.containsKey(username)) {
+	    			cachedAuthTokenHash.remove(username);
+	    		}
+	    		token = getAuthToken(connection, ireg);
+	            clearPublisherAssertions(token.getAuthInfo(), ireg);
+            	regobj = ireg.deleteTModel(token.getAuthInfo(), (String[]) dataarray);
+	    	}
         }
         else if (op.equalsIgnoreCase("DELETE_ASSOCIATION")) {
-           int len = ((String[]) dataarray).length;
+        	int len = ((String[]) dataarray).length;
             PublisherAssertion[] paarr = new PublisherAssertion[len];
             for(int i=0;i<len;i++)
             {
                String keystr = ((String[])dataarray)[i];
                paarr[i] = ScoutJaxrUddiV3Helper.getPubAssertionFromJAXRAssociationKey(keystr);
             }
-            regobj = ireg.deletePublisherAssertions(token.getAuthInfo(), paarr);
+            try {
+            	regobj = ireg.deletePublisherAssertions(token.getAuthInfo(), paarr);
+            } catch (RegistryV3Exception rve) {
+	    		String username = getUsernameFromCredentials(connection.getCredentials());
+	    		if (cachedAuthTokenHash.containsKey(username)) {
+	    			cachedAuthTokenHash.remove(username);
+	    		}
+	    		token = getAuthToken(connection, ireg);
+	            clearPublisherAssertions(token.getAuthInfo(), ireg);
+            	regobj = ireg.deletePublisherAssertions(token.getAuthInfo(), paarr);
+	    	}
         }
         else if (op.equalsIgnoreCase("DELETE_CLASSIFICATIONSCHEME")) {
-            regobj = ireg.deleteTModel(token.getAuthInfo(), (String[]) dataarray);
+        	try {
+        		regobj = ireg.deleteTModel(token.getAuthInfo(), (String[]) dataarray);
+	    	} catch (RegistryV3Exception rve) {
+	    		String username = getUsernameFromCredentials(connection.getCredentials());
+	    		if (cachedAuthTokenHash.containsKey(username)) {
+	    			cachedAuthTokenHash.remove(username);
+	    		}
+	    		token = getAuthToken(connection, ireg);
+	            clearPublisherAssertions(token.getAuthInfo(), ireg);
+        		regobj = ireg.deleteTModel(token.getAuthInfo(), (String[]) dataarray);
+	    	}	        		
         }
         else {
             throw new JAXRException("Unsupported operation:" + op);
@@ -763,6 +872,18 @@ public class BusinessLifeCycleManagerV3I
         return bulk;
     }
 
+    private String getUsernameFromCredentials(Set credentials) {
+        String username = "", pwd = "";
+                
+        if (credentials != null) {
+        	Iterator it = credentials.iterator();
+        	while (it.hasNext()) {
+        		PasswordAuthentication pass = (PasswordAuthentication) it.next();
+        		username = pass.getUserName();
+        	}
+        }
+        return username;
+    }
 
     /**
      * Get the Auth Token from the registry
@@ -774,8 +895,10 @@ public class BusinessLifeCycleManagerV3I
      */
     private AuthToken getAuthToken(ConnectionImpl connection, IRegistryV3 ireg)
             throws JAXRException {
-        Set creds = connection.getCredentials();
+    	
+    	Set creds = connection.getCredentials();
         String username = "", pwd = "";
+                
         if (creds != null) {
         	Iterator it = creds.iterator();
         	while (it.hasNext()) {
@@ -785,6 +908,11 @@ public class BusinessLifeCycleManagerV3I
         	}
         }
 
+        if ((cachedAuthTokenHash != null) && (cachedAuthTokenHash.containsKey(username)))
{
+        	return (AuthToken) cachedAuthTokenHash.get(username);
+        }
+        
+        
         AuthToken token = null;
         try {
             token = ireg.getAuthToken(username, pwd);
@@ -793,7 +921,8 @@ public class BusinessLifeCycleManagerV3I
         { 
             throw new JAXRException(e);
         }
-        return token;
+        cachedAuthTokenHash.put(username, token);
+        return token;	
     }
 
     private PublisherAssertion getPublisherAssertion(AssertionStatusItem asi)



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


Mime
View raw message