1 16 package org.apache.juddi.function; 17 18 import org.apache.juddi.datastore.DataStore; 19 import org.apache.juddi.datatype.publisher.Publisher; 20 import org.apache.juddi.datatype.request.AuthInfo; 21 import org.apache.juddi.error.AuthTokenExpiredException; 22 import org.apache.juddi.error.AuthTokenRequiredException; 23 import org.apache.juddi.error.RegistryException; 24 import org.apache.juddi.registry.RegistryEngine; 25 26 29 public abstract class AbstractFunction implements IFunction 30 { 31 protected RegistryEngine registry = null; 33 34 37 protected AbstractFunction(RegistryEngine registry) 38 { 39 this.registry = registry; 40 } 41 42 45 public RegistryEngine getRegistry() 46 { 47 return this.registry; 48 } 49 50 53 public void setRegistry(RegistryEngine registry) 54 { 55 this.registry = registry; 56 } 57 58 61 protected Publisher getPublisher(AuthInfo authInfo,DataStore dataStore) 62 throws RegistryException 63 { 64 Publisher publisher = null; 65 66 if ((authInfo == null) || (authInfo.getValue() == null)) 67 throw new AuthTokenRequiredException("authToken: null"); 68 69 String authToken = authInfo.getValue(); 70 if (authToken.trim().length() == 0) 71 throw new AuthTokenRequiredException("authToken: "+authToken); 72 73 publisher = dataStore.getAuthTokenPublisher(authToken); 74 if (publisher == null) 75 throw new AuthTokenRequiredException("authToken: "+authToken); 76 77 if (dataStore.isAuthTokenExpired(authToken)) 78 throw new AuthTokenExpiredException("authToken: "+authToken); 79 80 dataStore.touchAuthToken(authToken); 83 84 return publisher; 85 } 86 } | Popular Tags |