You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ra...@apache.org on 2011/06/26 19:50:31 UTC

svn commit: r1139850 [2/7] - in /incubator/airavata/services/trunk/xregistry/src: ./ main/ main/java/ main/java/org/ main/java/org/apache/ main/java/org/apache/airavata/ main/java/org/apache/airavata/xregistry/ main/java/org/apache/airavata/xregistry/a...

Added: incubator/airavata/services/trunk/xregistry/src/main/java/org/apache/airavata/xregistry/client/Command.java
URL: http://svn.apache.org/viewvc/incubator/airavata/services/trunk/xregistry/src/main/java/org/apache/airavata/xregistry/client/Command.java?rev=1139850&view=auto
==============================================================================
--- incubator/airavata/services/trunk/xregistry/src/main/java/org/apache/airavata/xregistry/client/Command.java (added)
+++ incubator/airavata/services/trunk/xregistry/src/main/java/org/apache/airavata/xregistry/client/Command.java Sun Jun 26 17:50:29 2011
@@ -0,0 +1,72 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You 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.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.airavata.xregistry.client;
+
+import java.util.ArrayList;
+
+import org.apache.airavata.xregistry.XregistryException;
+
+
+public abstract class Command implements Comparable<Command>{
+    private String name;
+    private Object client;
+    private String help;
+    
+    public Command(String name, Object client) {
+        super();
+        this.name = name;
+        this.client = client;
+        this.help = name;
+    }
+    
+    public Command(String name, Object client,String help) {
+        super();
+        this.name = name;
+        this.client = client;
+        this.help = name  + " "+ help;
+    }
+    
+
+    public abstract String[]  handleCommand(ArrayList<String> args)throws XregistryException;
+
+    public Object getClient() {
+        return client;
+    }
+
+    public void setClient(Object client) {
+        this.client = client;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+    
+    
+    public String getHelp(){
+        return help;
+    }
+
+    public int compareTo(Command o) {
+        return name.compareTo(o.name);
+    }
+}
+

Added: incubator/airavata/services/trunk/xregistry/src/main/java/org/apache/airavata/xregistry/client/DocumentRegistryClient.java
URL: http://svn.apache.org/viewvc/incubator/airavata/services/trunk/xregistry/src/main/java/org/apache/airavata/xregistry/client/DocumentRegistryClient.java?rev=1139850&view=auto
==============================================================================
--- incubator/airavata/services/trunk/xregistry/src/main/java/org/apache/airavata/xregistry/client/DocumentRegistryClient.java (added)
+++ incubator/airavata/services/trunk/xregistry/src/main/java/org/apache/airavata/xregistry/client/DocumentRegistryClient.java Sun Jun 26 17:50:29 2011
@@ -0,0 +1,514 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You 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.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.airavata.xregistry.client;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.airavata.xregistry.XregistryConstants;
+import org.apache.airavata.xregistry.XregistryException;
+import org.apache.airavata.xregistry.context.GlobalContext;
+import org.apache.airavata.xregistry.doc.DocData;
+import org.apache.airavata.xregistry.impl.XregistryPortType;
+import org.apache.airavata.xregistry.utils.Utils;
+import org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException;
+
+import xregistry.generated.AddCapabilityDocument;
+import xregistry.generated.AddCapabilityDocument.AddCapability;
+import xregistry.generated.AddOGCEResourceDocument;
+import xregistry.generated.AddOGCEResourceDocument.AddOGCEResource;
+import xregistry.generated.AddResourceDocument;
+import xregistry.generated.AddResourceDocument.AddResource;
+import xregistry.generated.App2HostsDocument;
+import xregistry.generated.App2HostsResponseDocument;
+import xregistry.generated.CapabilityToken;
+import xregistry.generated.FindAppDescDocument;
+import xregistry.generated.FindAppDescResponseDocument;
+import xregistry.generated.FindAppDescResponseDocument.FindAppDescResponse.AppData;
+import xregistry.generated.FindHostsDocument;
+import xregistry.generated.FindHostsResponseDocument;
+import xregistry.generated.FindOGCEResourceDocument;
+import xregistry.generated.FindOGCEResourceDocument.FindOGCEResource;
+import xregistry.generated.FindOGCEResourceResponseDocument;
+import xregistry.generated.FindResourceDocument;
+import xregistry.generated.FindResourceResponseDocument;
+import xregistry.generated.FindServiceDescDocument;
+import xregistry.generated.FindServiceDescResponseDocument;
+import xregistry.generated.FindServiceInstanceDocument;
+import xregistry.generated.FindServiceInstanceResponseDocument;
+import xregistry.generated.GetAbstractWsdlDocument;
+import xregistry.generated.GetAbstractWsdlResponseDocument;
+import xregistry.generated.GetAppDescDocument;
+import xregistry.generated.GetAppDescDocument.GetAppDesc;
+import xregistry.generated.GetCapabilityDocument;
+import xregistry.generated.GetCapabilityDocument.GetCapability;
+import xregistry.generated.GetCapabilityResponseDocument;
+import xregistry.generated.GetConcreateWsdlDocument;
+import xregistry.generated.GetHostDescDocument;
+import xregistry.generated.GetOGCEResourceDocument;
+import xregistry.generated.GetOGCEResourceDocument.GetOGCEResource;
+import xregistry.generated.GetResourceDocument;
+import xregistry.generated.GetServiceDescDocument;
+import xregistry.generated.HostDescData;
+import xregistry.generated.IsAuthorizedToAcssesDocument;
+import xregistry.generated.IsAuthorizedToAcssesDocument.IsAuthorizedToAcsses;
+import xregistry.generated.IsAuthorizedToAcssesResponseDocument;
+import xregistry.generated.OGCEResourceData;
+import xregistry.generated.RegisterAppDescDocument;
+import xregistry.generated.RegisterConcreteWsdlDocument;
+import xregistry.generated.RegisterConcreteWsdlDocument.RegisterConcreteWsdl;
+import xregistry.generated.RegisterHostDescDocument;
+import xregistry.generated.RegisterServiceDescDocument;
+import xregistry.generated.RegisterServiceDescDocument.RegisterServiceDesc;
+import xregistry.generated.RemoveAppDescDocument;
+import xregistry.generated.RemoveAppDescDocument.RemoveAppDesc;
+import xregistry.generated.RemoveCapabilityDocument;
+import xregistry.generated.RemoveCapabilityDocument.RemoveCapability;
+import xregistry.generated.RemoveConcreteWsdlDocument;
+import xregistry.generated.RemoveHostDescDocument;
+import xregistry.generated.RemoveOGCEResourceDocument;
+import xregistry.generated.RemoveOGCEResourceDocument.RemoveOGCEResource;
+import xregistry.generated.RemoveResourceDocument;
+import xregistry.generated.RemoveServiceDescDocument;
+import xregistry.generated.ResourceData;
+import xregistry.generated.ServiceDescData;
+import xregistry.generated.WsdlData;
+import xsul.MLogger;
+import xsul.xwsif_runtime.WSIFClient;
+
+public class DocumentRegistryClient {
+    protected static MLogger log = MLogger.getLogger(XregistryConstants.LOGGER_NAME);
+    
+    private XregistryPortType proxy;
+    
+    /**  
+     * If this property is on, registry list only document own by the client. For most of the
+     * use cases user do not need to see shared documents and therefore we keep the property set by defualt.
+     */
+    private String userDN; 
+    
+    public DocumentRegistryClient(String registryServiceWsdlUrl) throws XregistryException{
+    	GlobalContext globalContext = new GlobalContext(true);
+     	String trustedCA = System.getProperty("ssl.hostcertsKeyFile");
+    	String hostCert =  System.getProperty("ssl.trustedCertsFile");
+		globalContext.setTrustedCertsFile(trustedCA);
+		globalContext.setHostcertsKeyFile(hostCert);
+	    WSIFClient client = Utils.createWSIFClient(globalContext, registryServiceWsdlUrl);
+        proxy = (XregistryPortType)client.generateDynamicStub(XregistryPortType.class);
+        userDN = globalContext.getUserDN();
+        System.out.println("Create Stub for "+ registryServiceWsdlUrl + " using "+ userDN);
+    }
+    public DocumentRegistryClient(GlobalContext context,String registryServiceWsdlUrl) throws XregistryException{
+        WSIFClient client = Utils.createWSIFClient(context, registryServiceWsdlUrl);
+        proxy = (XregistryPortType)client.generateDynamicStub(XregistryPortType.class);
+        userDN = context.getUserDN();
+        System.out.println("Create Stub for "+ registryServiceWsdlUrl + " using "+ userDN);
+    }
+    public String[]  app2Hosts(String appName) throws XregistryException {
+        App2HostsDocument document = App2HostsDocument.Factory.newInstance();
+        document.addNewApp2Hosts().setAppName(appName);
+        App2HostsResponseDocument responseDocument = proxy.app2Hosts(document);
+        return responseDocument.getApp2HostsResponse().getHostArray();
+    }
+    public void addCapability(String resource, String actor, boolean isUser, String action) throws XregistryException {
+        AddCapabilityDocument document = AddCapabilityDocument.Factory.newInstance();
+        AddCapability capability = document.addNewAddCapability();
+        capability.setResourceID(resource);
+        capability.setActor(actor);
+        capability.setIsActorAUser(isUser);
+        capability.setAction(action);
+        proxy.addCapability(document);
+    }
+    
+    /**
+     * This is the search method for capabilities, the null values can be defined for most values to allow a search. But one of the 
+     * resourceID or actor must present
+     * @param user
+     * @param resourceID
+     * @param actor and actorType - Both or non must precent .. can be Null
+     * @param action 
+     * @return
+     * @throws XregistryException
+     */
+    
+    public CapabilityToken[] findCapability(String resourceID, String actor, boolean actorType, String action) throws XregistryException {
+        GetCapabilityDocument document = GetCapabilityDocument.Factory.newInstance();
+        GetCapability getCapability = document.addNewGetCapability();
+        if(resourceID != null || actor != null){
+            getCapability.setUser(actor);
+            getCapability.setResourceID(resourceID);
+            getCapability.setActorType(actorType);
+            getCapability.setAction(action);
+            GetCapabilityResponseDocument capabilityResponse = proxy.getCapability(document);
+            return capabilityResponse.getGetCapabilityResponse().getTokenArray();
+        }else{
+            throw new XregistryException("one of the resourceID or actor must present");
+        }
+    }
+    
+    
+    
+    public void removeCapability(String resourceID,String actor) throws XregistryException{
+        RemoveCapabilityDocument document = RemoveCapabilityDocument.Factory.newInstance();
+        RemoveCapability removeCapability = document.addNewRemoveCapability();
+        removeCapability.setResourceID(resourceID);
+        removeCapability.setActor(actor);
+        proxy.removeCapability(document);
+    }
+    
+    
+    
+    
+    public org.apache.airavata.xregistry.doc.AppData[] findAppDesc(String query) throws XregistryException {
+        FindAppDescDocument document = FindAppDescDocument.Factory.newInstance();
+        document.addNewFindAppDesc().setAppNameSearchStr(query);
+        FindAppDescResponseDocument responseDocument = proxy.findAppDesc(document);
+        
+        AppData[] results = responseDocument.getFindAppDescResponse().getAppDataArray();
+        
+        
+        if(results != null){
+            List<org.apache.airavata.xregistry.doc.AppData> finalResults = new ArrayList<org.apache.airavata.xregistry.doc.AppData>();
+            for(int i = 0;i<results.length;i++){
+                try {
+					AppData xbeansData = results[i];
+					org.apache.airavata.xregistry.doc.AppData resultAppData = new org.apache.airavata.xregistry.doc.AppData(xbeansData.getName(),xbeansData.getOwner(),xbeansData.getHostName());
+					resultAppData.allowedAction = xbeansData.getAllowedAction();
+					resultAppData.resourceID = xbeansData.getName();
+					finalResults.add(resultAppData);
+				} catch (XmlValueOutOfRangeException e) {
+					log.severe("Problem with retrieving object : " + e.getLocalizedMessage(), e);
+				}    
+            }
+            return finalResults.toArray(new org.apache.airavata.xregistry.doc.AppData[0]);
+        }else{
+            return null;
+        }
+    }
+    public DocData[]  findHosts(String hostName) throws XregistryException {
+        FindHostsDocument document = FindHostsDocument.Factory.newInstance();
+        document.addNewFindHosts().setHostNameSearchStr(hostName);
+        FindHostsResponseDocument responseDocument = proxy.findHosts(document);
+        
+        HostDescData[] hostDescData =  responseDocument.getFindHostsResponse().getResultsArray();
+        if(hostDescData == null){
+            return null;
+        }
+
+        List<DocData> results = new ArrayList<DocData>();
+        for(int i = 0;i<hostDescData.length;i++){
+        	try {
+            HostDescData host = hostDescData[i];
+            DocData data = new DocData(new QName(host.getResourceID()),host.getOwner());
+            data.allowedAction = host.getAllowedAction();
+            data.resourceID = new QName(host.getResourceID());
+            results.add(data);
+        	} catch (XmlValueOutOfRangeException e) {
+				log.severe("Problem with retrieving object : " + e.getLocalizedMessage(), e);
+			}   
+        }
+        return results.toArray(new DocData[0]);
+    }
+    
+    public DocData[]  findResource(String resourceNameQuery) throws XregistryException {
+        FindResourceDocument document = FindResourceDocument.Factory.newInstance();
+        document.addNewFindResource().setResourceNameQuery(resourceNameQuery);
+        FindResourceResponseDocument responseDocument = proxy.findResource(document);
+        
+        ResourceData[] resourceData =  responseDocument.getFindResourceResponse().getResourceArray();
+        if(resourceData == null){
+            return null;
+        }
+        List<DocData> results = new ArrayList<DocData>();
+        for(int i = 0;i<resourceData.length;i++){
+            try {
+        	ResourceData host = resourceData[i];
+            DocData data = new DocData(host.getName(),host.getOwner());
+            data.allowedAction = host.getAllowedAction();
+            data.resourceID = host.getName();
+            data.resourcename = host.getResourceID();
+            results.add(data);
+            } catch (XmlValueOutOfRangeException e) {
+ 				log.severe("Problem with retrieving object : " + e.getLocalizedMessage(), e);
+ 			}   
+        }
+        return results.toArray(new DocData[0]);
+    }
+    
+    public DocData[]  findServiceDesc(String serviceName) throws XregistryException {
+        FindServiceDescDocument document = FindServiceDescDocument.Factory.newInstance();
+        document.addNewFindServiceDesc().setServiceQNameSearchStr(serviceName);
+        FindServiceDescResponseDocument responseDocument = proxy.findServiceDesc(document);
+        
+        ServiceDescData[] serviceDescData =  responseDocument.getFindServiceDescResponse().getServiceNameArray();
+        
+        if(serviceDescData == null){
+            return null;
+        }
+        List<DocData> results = new ArrayList<DocData>();
+        for(int i = 0;i<serviceDescData.length;i++){
+        	try {
+            DocData data = new DocData(serviceDescData[i].getName(),serviceDescData[i].getOwner());
+            data.allowedAction = serviceDescData[i].getAllowedAction();
+            data.resourceID = serviceDescData[i].getName();
+            results.add(data);
+        	} catch (XmlValueOutOfRangeException e) {
+   				log.severe("Problem with retrieving object : " + e.getLocalizedMessage(), e);
+   			}   
+        }
+        return results.toArray(new DocData[0]);
+    }
+    public DocData[]  findServiceInstance(String serviceName) throws XregistryException {
+        FindServiceInstanceDocument document = FindServiceInstanceDocument.Factory.newInstance();
+        document.addNewFindServiceInstance().setServiceQnameSearchStr(serviceName);
+        FindServiceInstanceResponseDocument responseDocument = proxy.findServiceInstance(document);
+       
+        WsdlData[] wsdlDescData =  responseDocument.getFindServiceInstanceResponse().getServiceInstanceArray();
+        if(wsdlDescData == null){
+            return null;
+        }
+        List<DocData> results = new ArrayList<DocData>();
+        for(int i = 0;i<wsdlDescData.length;i++){
+        	try {
+            DocData data = new DocData(wsdlDescData[i].getName(),wsdlDescData[i].getOwner());
+            data.allowedAction = wsdlDescData[i].getAllowedAction();
+            data.resourceID = wsdlDescData[i].getName();
+            results.add(data); 
+        	} catch (XmlValueOutOfRangeException e) {
+   				log.severe("Problem with retrieving object : " + e.getLocalizedMessage(), e);
+   			}               
+        }
+        return results.toArray(new DocData[0]);
+    }
+    public String getAbstractWsdl(QName wsdlQName) throws XregistryException {
+        GetAbstractWsdlDocument document = GetAbstractWsdlDocument.Factory.newInstance();
+        document.addNewGetAbstractWsdl().setWsdlQName(wsdlQName);
+        GetAbstractWsdlResponseDocument responseDocument = proxy.getAbstractWsdl(document);
+        return responseDocument.getGetAbstractWsdlResponse().getWsdlAsStr();
+    }
+    public String getAppDesc(String appName, String hostName) throws XregistryException {
+        GetAppDescDocument document = GetAppDescDocument.Factory.newInstance();
+        GetAppDesc getAppDesc = document.addNewGetAppDesc();
+        getAppDesc.setAppQName(appName);
+        getAppDesc.setHostName(hostName);
+        return proxy.getAppDesc(document).getGetAppDescResponse().getAppdescAsStr();
+    }
+    public String getConcreateWsdl(QName wsdlQName) throws XregistryException {
+        GetConcreateWsdlDocument document = GetConcreateWsdlDocument.Factory.newInstance();
+        document.addNewGetConcreateWsdl().setWsdlQname(wsdlQName);
+        return proxy.getConcreateWsdl(document).getGetConcreateWsdlResponse().getWsdlAsStr();
+    }
+    public String getHostDesc(String hostName) throws XregistryException {
+        GetHostDescDocument document = GetHostDescDocument.Factory.newInstance();
+        document.addNewGetHostDesc().setHostName(hostName);
+        return proxy.getHostDesc(document).getGetHostDescResponse().getHostDescAsStr();
+    }
+    
+    public String getResource(QName resourceName) throws XregistryException {
+        GetResourceDocument document = GetResourceDocument.Factory.newInstance();
+        document.addNewGetResource().setResourceName(resourceName);
+        return proxy.getResource(document).getGetResourceResponse().getResourceAsStr();
+    }
+    
+    public String getServiceDesc(QName serviceName) throws XregistryException {
+        GetServiceDescDocument input =  GetServiceDescDocument.Factory.newInstance();
+        input.addNewGetServiceDesc().setServiceQname(serviceName);
+        return proxy.getServiceDesc(input).getGetServiceDescResponse().getServiceDescAsStr();
+    }
+    public String registerAppDesc(String appDescAsStr) throws XregistryException {
+        RegisterAppDescDocument input =  RegisterAppDescDocument.Factory.newInstance();
+        input.addNewRegisterAppDesc().setAppDescAsStr(appDescAsStr);
+        return proxy.registerAppDesc(input).getRegisterAppDescResponse().getResourceID();
+    }
+    public String registerConcreteWsdl( String wsdlAsStr, int lifetimeAsSeconds) throws XregistryException {
+        RegisterConcreteWsdlDocument input =  RegisterConcreteWsdlDocument.Factory.newInstance();
+        RegisterConcreteWsdl concreteWsdl = input.addNewRegisterConcreteWsdl();
+        concreteWsdl.setWsdlAsStr(wsdlAsStr);
+        concreteWsdl.setLifetimeAsSeconds(lifetimeAsSeconds);
+        return proxy.registerConcreteWsdl(input).getRegisterConcreteWsdlResponse().getResourceID();
+    }
+    public String registerHostDesc( String hostDescAsStr) throws XregistryException {
+        RegisterHostDescDocument input =  RegisterHostDescDocument.Factory.newInstance();
+        input.addNewRegisterHostDesc().setHostDescAsStr(hostDescAsStr);
+        return proxy.registerHostDesc(input).getRegisterHostDescResponse().getResourceID();
+    }
+    
+    public void registerResource(QName resourceName, String resourceAsStr) throws XregistryException {
+        AddResourceDocument input = AddResourceDocument.Factory.newInstance();
+        AddResource resource = input.addNewAddResource();
+        resource.setResourceAsStr(resourceAsStr);
+        resource.setResourceName(resourceName);
+        proxy.addResource(input);
+    }
+    
+    public String registerServiceDesc( String serviceDescAsStr, String awsdlAsStr) throws XregistryException {
+        RegisterServiceDescDocument input =  RegisterServiceDescDocument.Factory.newInstance();
+        RegisterServiceDesc serviceDesc = input.addNewRegisterServiceDesc();
+        serviceDesc.setServiceDescAsStr(serviceDescAsStr);
+        serviceDesc.setAwsdlAdStr(awsdlAsStr);
+        return proxy.registerServiceDesc(input).getRegisterServiceDescResponse().getResourceID();
+    }
+    public void removeAppDesc(QName appName, String hostName) throws XregistryException {
+        RemoveAppDescDocument input =  RemoveAppDescDocument.Factory.newInstance();
+        RemoveAppDesc removeAppDesc = input.addNewRemoveAppDesc();
+        removeAppDesc.setAppName(appName);
+        removeAppDesc.setHostName(hostName);
+        proxy.removeAppDesc(input);
+        
+    }
+    public void removeConcreteWsdl(QName wsdlQName) throws XregistryException {
+        RemoveConcreteWsdlDocument input =  RemoveConcreteWsdlDocument.Factory.newInstance();
+        input.addNewRemoveConcreteWsdl().setWsdlQName(wsdlQName);
+        proxy.removeConcreteWsdl(input);
+    }
+    public void removeHostDesc(String hostName) throws XregistryException {
+        RemoveHostDescDocument input =  RemoveHostDescDocument.Factory.newInstance();
+        input.addNewRemoveHostDesc().setHostName(hostName);
+        proxy.removeHostDesc(input);        
+    }
+    public void removeServiceDesc(QName serviceName) throws XregistryException {
+        RemoveServiceDescDocument input =  RemoveServiceDescDocument.Factory.newInstance();
+        input.addNewRemoveServiceDesc().setServiceQname(serviceName);
+        proxy.removeServiceDesc(input);
+    }
+    
+    
+    public void removeResource(QName resourceName) throws XregistryException {
+        RemoveResourceDocument input =  RemoveResourceDocument.Factory.newInstance();
+        input.addNewRemoveResource().setResourceName(resourceName);
+        proxy.removeResource(input);
+    }
+    
+    /**
+     * Give a actor, and a resource, this decides does the actor have acess to the resource. The actor must be a user and not a group
+     * @param user
+     * @param resourceID
+     * @param actor
+     * @param action
+     * @return
+     * @throws XregistryException
+     */
+    
+    public boolean isAuthorizedToAcsses(String user, String resourceID, String actor, String action) throws XregistryException {
+        IsAuthorizedToAcssesDocument input = IsAuthorizedToAcssesDocument.Factory.newInstance();
+        IsAuthorizedToAcsses isAuthorizedToAcsses = input.addNewIsAuthorizedToAcsses();
+        isAuthorizedToAcsses.setActor(actor);
+        isAuthorizedToAcsses.setResourceID(resourceID);
+        isAuthorizedToAcsses.setAction(action);
+        IsAuthorizedToAcssesResponseDocument responseDocument =  proxy.isAuthorizedToAcsses(input);
+        return responseDocument.getIsAuthorizedToAcssesResponse().getDecision();
+    }
+    
+    /**
+     * 
+     * @param resourceName
+     * @param resourceType
+     * @param resourceDesc
+     * @throws XregistryException
+     */
+	public void registerOGCEResource(QName resourceID, String resourceName, String resourceType,
+			String resourceDesc, String resourceDocument,
+			String resourceParentTypedID, String owner)
+			throws XregistryException {
+		AddOGCEResourceDocument input = AddOGCEResourceDocument.Factory
+				.newInstance();
+		AddOGCEResource resource = input.addNewAddOGCEResource();
+		resource.setResourceType(resourceType);
+		resource.setResourceDesc(resourceDesc);
+		resource.setResourceDocument(resourceDocument);
+		resource.setResourceID(resourceID);
+		resource.setResourceName(resourceName);
+		if (owner != null && owner != "") {
+			resource.setOwner(owner);
+		}
+		resource.setParentTypedID(resourceParentTypedID);
+		proxy.addOGCEResource(input);
+	}
+    /**
+     * 
+     * @param resourceName
+     * @return
+     * @throws XregistryException
+     */
+    public String getOGCEResource(QName resourceID, String resourceType, String resourceParentTypedID) throws XregistryException {
+        GetOGCEResourceDocument input = GetOGCEResourceDocument.Factory.newInstance();
+        GetOGCEResource document = input.addNewGetOGCEResource();
+        document.setResourceID(resourceID);
+        document.setResourceType(resourceType);
+        document.setParentTypedID(resourceParentTypedID);
+        return proxy.getOGCEResource(input).getGetOGCEResourceResponse().getResourceAsStr();
+    }
+    
+    /**
+     * 
+     * @param resourceNameQuery
+     * @param resourceType
+     * @return
+     * @throws XregistryException
+     */
+    public DocData[]  findOGCEResource(String resourceNameQuery, String resourceType, String resourceParentTypedID) throws XregistryException {
+        FindOGCEResourceDocument document = FindOGCEResourceDocument.Factory.newInstance();
+        FindOGCEResource  findOGCEResource =  document.addNewFindOGCEResource();
+        findOGCEResource.setResourceNameQuery(resourceNameQuery);
+        findOGCEResource.setResourceType(resourceType);
+        findOGCEResource.setResourceName(resourceNameQuery);
+        findOGCEResource.setParentTypedID(resourceParentTypedID);
+        
+        FindOGCEResourceResponseDocument responseDocument = proxy.findOGCEResource(document);
+        
+        OGCEResourceData[] resourceData =  responseDocument.getFindOGCEResourceResponse().getResourceArray();
+        if(resourceData == null){
+            return null;
+        }
+        List<DocData> results = new ArrayList<DocData>();
+        for(int i = 0;i<resourceData.length;i++){
+        	try {
+            OGCEResourceData resource = resourceData[i];
+            DocData data = new DocData(resource.getName(),resource.getOwner());
+            data.allowedAction = resource.getAllowedAction();
+            data.resourceID = resource.getResourceID();
+            data.resourcename = resource.getResourceName();
+            data.created = resource.getCreated();
+            data.resourcedesc = resource.getResourceDesc();
+            data.resourcetype = resource.getResourceType();
+            results.add(data);
+        	} catch (XmlValueOutOfRangeException e) {
+   				log.severe("Problem with retrieving object : " + e.getLocalizedMessage(), e);
+   			}               
+        }
+        return results.toArray(new DocData[0]);
+    }
+    /**
+     * 
+     * @param resourceName
+     * @throws XregistryException
+     */
+    public void removeOGCEResource(QName resourceID, String resourceType) throws XregistryException {
+        RemoveOGCEResourceDocument input =  RemoveOGCEResourceDocument.Factory.newInstance();
+        RemoveOGCEResource removeOGCEResource = input.addNewRemoveOGCEResource();
+        removeOGCEResource.setResourceID(resourceID);
+        removeOGCEResource.setResourceType(resourceType);
+        proxy.removeOGCEResource(input);
+    }
+  
+    
+    
+}
+

Added: incubator/airavata/services/trunk/xregistry/src/main/java/org/apache/airavata/xregistry/client/DocumentRegistryShell.java
URL: http://svn.apache.org/viewvc/incubator/airavata/services/trunk/xregistry/src/main/java/org/apache/airavata/xregistry/client/DocumentRegistryShell.java?rev=1139850&view=auto
==============================================================================
--- incubator/airavata/services/trunk/xregistry/src/main/java/org/apache/airavata/xregistry/client/DocumentRegistryShell.java (added)
+++ incubator/airavata/services/trunk/xregistry/src/main/java/org/apache/airavata/xregistry/client/DocumentRegistryShell.java Sun Jun 26 17:50:29 2011
@@ -0,0 +1,277 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You 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.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.airavata.xregistry.client;
+
+import java.util.ArrayList;
+
+import javax.xml.namespace.QName;
+
+import org.apache.airavata.xregistry.XregistryConstants;
+import org.apache.airavata.xregistry.XregistryException;
+import org.apache.airavata.xregistry.auth.Authorizer;
+import org.apache.airavata.xregistry.context.GlobalContext;
+import org.apache.airavata.xregistry.doc.AppData;
+import org.apache.airavata.xregistry.doc.DocData;
+import org.apache.airavata.xregistry.doc.DocParser;
+import org.apache.airavata.xregistry.utils.Utils;
+
+
+public class DocumentRegistryShell extends AbstractShell {
+    private Command[] commands;
+
+    public Command[] getCommands() {
+        return commands;
+    }
+
+    public DocumentRegistryShell(String registryWsdlUrl) throws XregistryException {
+        super(new DocumentRegistryClient(new GlobalContext(true), registryWsdlUrl));
+        commands = new Command[] { new Command("app2Hosts", registryClient) {
+            public String[] handleCommand(ArrayList<String> args) throws XregistryException {
+                return ((DocumentRegistryClient) getClient()).app2Hosts(args.get(0));
+            }
+
+            public String getHelp() {
+                return getName() + " <appName>";
+            }
+        }, new Command("findApp", registryClient) {
+            public String[] handleCommand(ArrayList<String> args) throws XregistryException {
+                AppData[] results = ((DocumentRegistryClient) getClient()).findAppDesc(args.get(0));
+                ArrayList<String> formattedResult = new ArrayList<String>(results.length);
+
+                for (AppData result : results) {
+                    formattedResult.add(result.name + " " + result.secondryName);
+                }
+                return formattedResult.toArray(new String[0]);
+            }
+
+            public String getHelp() {
+                return getName() + " <appName>";
+            }
+        }, new Command("findHost", registryClient) {
+            public String[] handleCommand(ArrayList<String> args) throws XregistryException {
+                return Utils.docData2String(((DocumentRegistryClient) getClient()).findHosts(args
+                        .get(0)));
+            }
+
+            public String getHelp() {
+                return getName() + " <hostName>";
+            }
+        }, new Command("findSM", registryClient) {
+            public String[] handleCommand(ArrayList<String> args) throws XregistryException {
+                return Utils.docData2String(((DocumentRegistryClient) getClient())
+                        .findServiceDesc(args.get(0)));
+            }
+
+            public String getHelp() {
+                return getName() + " <serviceName>";
+            }
+        }, new Command("findCwsdl", registryClient) {
+            public String[] handleCommand(ArrayList<String> args) throws XregistryException {
+                return Utils.docData2String(((DocumentRegistryClient) getClient())
+                        .findServiceInstance(args.get(0)));
+            }
+
+            public String getHelp() {
+                return getName() + " <cwsdl-name>";
+            }
+        },
+
+        new Command("lsApp", registryClient) {
+            public String[] handleCommand(ArrayList<String> args) throws XregistryException {
+                return Utils.docData2String(((DocumentRegistryClient) getClient()).findAppDesc(""));
+            }
+
+            public String getHelp() {
+                return getName();
+            }
+        }
+        , new Command("lsHost", registryClient) {
+         public String[] handleCommand(ArrayList<String> args) throws XregistryException {
+             return Utils.docData2String(((DocumentRegistryClient) getClient()).findHosts(""));
+         }
+        }
+         , new Command("lsSm", registryClient) {
+             public String[] handleCommand(ArrayList<String> args) throws XregistryException {
+                 return Utils.docData2String(((DocumentRegistryClient) getClient()).findServiceDesc(""));
+             }
+         }
+         , new Command("lsCwsdl", registryClient) {
+             public String[] handleCommand(ArrayList<String> args) throws XregistryException {
+                 return Utils.docData2String(((DocumentRegistryClient) getClient()).findServiceInstance(""));
+             }
+         }
+
+        , new Command("getAwsdl", registryClient) {
+            public String[] handleCommand(ArrayList<String> args) throws XregistryException {
+                return new String[] { ((DocumentRegistryClient) getClient()).getAbstractWsdl(QName.valueOf(args.get(0))) };
+            }
+
+            public String getHelp() {
+                return getName() + " <awsdlName>";
+            }
+        }, new Command("getApp", registryClient) {
+            public String[] handleCommand(ArrayList<String> args) throws XregistryException {
+                return new String[] { ((DocumentRegistryClient) getClient()).getAppDesc(
+                        args.get(0), args.get(1)) };
+            }
+
+            public String getHelp() {
+                return getName() + " <appname hostname>";
+            }
+        }, new Command("getCwsdl", registryClient) {
+            public String[] handleCommand(ArrayList<String> args) throws XregistryException {
+                return new String[] { ((DocumentRegistryClient) getClient()).getConcreateWsdl(QName.valueOf(args.get(0))) };
+            }
+
+            public String getHelp() {
+                return getName() + " <cwsdlName>";
+            }
+        }, new Command("getHost", registryClient) {
+            public String[] handleCommand(ArrayList<String> args) throws XregistryException {
+                return new String[] { ((DocumentRegistryClient) getClient()).getHostDesc(args
+                        .get(0)) };
+            }
+
+            public String getHelp() {
+                return getName() + " <hostName>";
+            }
+        }, new Command("getSM", registryClient) {
+            public String[] handleCommand(ArrayList<String> args) throws XregistryException {
+                return new String[] { ((DocumentRegistryClient) getClient()).getServiceDesc(QName.valueOf(args
+                        .get(0))) };
+            }
+
+            public String getHelp() {
+                return getName() + " <serviceName>";
+            }
+        }, new Command("addApp", registryClient) {
+            public String[] handleCommand(ArrayList<String> args) throws XregistryException {
+                String appDescAsStr = Utils.readFile(args.get(0));
+                ((DocumentRegistryClient) getClient()).registerAppDesc(appDescAsStr);
+                return null;
+            }
+
+            public String getHelp() {
+
+                return getName() + " <service-desc-file,awsdl-file>";
+            }
+        }, new Command("addSM", registryClient) {
+            public String[] handleCommand(ArrayList<String> args) throws XregistryException {
+                String serviceDescAsStr = Utils.readFile(args.get(0));
+                String awsdlAsStr = DocParser.createWsdl(serviceDescAsStr,true);
+                ((DocumentRegistryClient) getClient()).registerServiceDesc(serviceDescAsStr,
+                        awsdlAsStr);
+                return null;
+            }
+
+            public String getHelp() {
+
+                return getName() + " <service-desc-file,awsdl-file>";
+            }
+        }, new Command("addCwsdl", registryClient) {
+            public String[] handleCommand(ArrayList<String> args) throws XregistryException {
+                String cwsdlAsStr = Utils.readFile(args.get(0));
+                int lifetime = Integer.parseInt(args.get(1));
+                ((DocumentRegistryClient) getClient()).registerConcreteWsdl(cwsdlAsStr, lifetime);
+                return null;
+            }
+
+            public String getHelp() {
+                return getName() + " <cwsdl-file lifetimeSeconds>";
+            }
+        }, new Command("addHost", registryClient) {
+            public String[] handleCommand(ArrayList<String> args) throws XregistryException {
+                String appdescAsStr = Utils.readFile(args.get(0));
+                ((DocumentRegistryClient) getClient()).registerHostDesc(appdescAsStr);
+                return null;
+            }
+
+            public String getHelp() {
+
+                return getName() + " <appDesc-file>";
+            }
+        }, new Command("rmApp", registryClient) {
+            public String[] handleCommand(ArrayList<String> args) throws XregistryException {
+                ((DocumentRegistryClient) getClient()).removeAppDesc(QName.valueOf(args.get(0)), args.get(1));
+                return null;
+            }
+
+            public String getHelp() {
+
+                return getName() + " <appName,hostName>";
+            }
+        }, new Command("rmCwsdl", registryClient) {
+            public String[] handleCommand(ArrayList<String> args) throws XregistryException {
+                ((DocumentRegistryClient) getClient()).removeConcreteWsdl(QName.valueOf(args.get(0)));
+                return null;
+            }
+
+            public String getHelp() {
+                return getName() + " <cwsdl-qname>";
+            }
+        }, new Command("rmHost", registryClient) {
+            public String[] handleCommand(ArrayList<String> args) throws XregistryException {
+                ((DocumentRegistryClient) getClient()).removeHostDesc(args.get(0));
+                return null;
+            }
+
+            public String getHelp() {
+                return getName() + " <cwsdl-qname>";
+            }
+        },new Command("share", registryClient) {
+            public String[] handleCommand(ArrayList<String> args) throws XregistryException {
+                String action = XregistryConstants.Action.Read.toString();
+                ((DocumentRegistryClient) getClient()).addCapability(args.get(0), args.get(1), false, action);
+                return null;
+            }
+
+            public String getHelp() {
+                return getName() + " <cwsdl-qname>";
+            }
+        }, new Command("rmSM", registryClient) {
+            public String[] handleCommand(ArrayList<String> args) throws XregistryException {
+                ((DocumentRegistryClient) getClient()).removeServiceDesc(QName.valueOf(args.get(0)));
+                return null;
+            }
+
+            public String getHelp() {
+                return getName() + " <cwsdl-qname>";
+            }
+        }, };
+
+        for (Command cmd : commands) {
+            commandMap.put(cmd.getName(), cmd);
+        }
+
+    }
+
+    public static void main(String[] args) {
+        try {
+            AbstractShell shell;
+            if (args.length > 0) {
+                shell = new DocumentRegistryShell(args[0]);
+                shell.runTheShell();
+            } else {
+                throw new XregistryException(
+                        "initialization Command DocumentRegistryShell <registry-shell-wsdl-url>");
+            }
+        } catch (XregistryException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+    }
+}

Added: incubator/airavata/services/trunk/xregistry/src/main/java/org/apache/airavata/xregistry/context/GlobalContext.java
URL: http://svn.apache.org/viewvc/incubator/airavata/services/trunk/xregistry/src/main/java/org/apache/airavata/xregistry/context/GlobalContext.java?rev=1139850&view=auto
==============================================================================
--- incubator/airavata/services/trunk/xregistry/src/main/java/org/apache/airavata/xregistry/context/GlobalContext.java (added)
+++ incubator/airavata/services/trunk/xregistry/src/main/java/org/apache/airavata/xregistry/context/GlobalContext.java Sun Jun 26 17:50:29 2011
@@ -0,0 +1,353 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You 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.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.airavata.xregistry.context;
+
+import static org.apache.airavata.xregistry.XregistryOptions.DBURL;
+import static org.apache.airavata.xregistry.XregistryOptions.MYPROXY_LIFETIME;
+import static org.apache.airavata.xregistry.XregistryOptions.MYPROXY_PASSWD;
+import static org.apache.airavata.xregistry.XregistryOptions.MYPROXY_SERVER;
+import static org.apache.airavata.xregistry.XregistryOptions.MYPROXY_USERNAME;
+import static org.apache.airavata.xregistry.XregistryOptions.SECURITY_ENABLED;
+import static org.apache.airavata.xregistry.XregistryOptions.SSL_HOST_KEY_FILE;
+import static org.apache.airavata.xregistry.XregistryOptions.SSL_TRUSTED_CERT_FILE;
+import static org.apache.airavata.xregistry.utils.Utils.createCredentials;
+import static org.apache.airavata.xregistry.utils.Utils.findBooleanProperty;
+import static org.apache.airavata.xregistry.utils.Utils.findIntegerProperty;
+import static org.apache.airavata.xregistry.utils.Utils.findStringProperty;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.cert.X509Certificate;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Properties;
+import java.util.StringTokenizer;
+import java.util.Timer;
+
+import org.apache.airavata.xregistry.XregistryConstants;
+import org.apache.airavata.xregistry.XregistryException;
+import org.apache.airavata.xregistry.XregistryOptions;
+import org.apache.airavata.xregistry.auth.Authorizer;
+import org.apache.airavata.xregistry.auth.AuthorizerImpl;
+import org.apache.airavata.xregistry.db.JdbcStorage;
+import org.apache.airavata.xregistry.group.GroupManager;
+import org.apache.airavata.xregistry.group.GroupManagerImpl;
+import org.apache.airavata.xregistry.utils.CWsdlUpdateTask;
+import org.apache.airavata.xregistry.utils.ProxyRenewer;
+import org.apache.airavata.xregistry.utils.Utils;
+import org.globus.myproxy.MyProxy;
+import org.ietf.jgss.GSSCredential;
+import org.ietf.jgss.GSSException;
+
+/**
+ * This is the central configuration Store for Xregistry
+ */
+
+public class GlobalContext {
+    private static final String MYSQL_DRIVER = "com.mysql.jdbc.Driver";
+
+    private Properties config;
+
+    private JdbcStorage storage;
+
+    private GroupManager groupManager;
+
+    private Authorizer authorizer;
+
+    private String trustedCertsFile;
+
+    private String hostcertsKeyFile;
+
+    private GSSCredential credential;
+
+    private final boolean isClientSide;
+
+    private String dbUrl;
+
+    private int port;
+    
+    private boolean securityEnabled;
+    
+    private String userDN;
+    
+    private X509Certificate[] trustedCertificates;
+    
+    
+    public GlobalContext(boolean clientSide) throws XregistryException{
+        this(clientSide,(String)null);
+    }
+    
+    
+    public GlobalContext(boolean clientSide,String propertiesFileName) throws XregistryException {
+        this(clientSide,loadPropertiesFromPorpertyFile(propertiesFileName));
+    }
+        
+    private static Properties loadPropertiesFromPorpertyFile(String propertiesFileName) throws XregistryException{    
+            try {
+                Properties properties = new Properties();
+                InputStream propertiesIn;
+                if(propertiesFileName != null){
+                    //try explicit parameter
+                    propertiesIn = new FileInputStream(propertiesFileName);
+                }else{
+                    // xregistry.properties file on current directory
+                    File propertiesFile = new File(XregistryConstants.X_REGISTRY_PROPERTY_FILE);
+                    if(propertiesFile.exists()){
+                        propertiesIn = new FileInputStream(propertiesFile);
+                    }else{
+                        //3) xregistry/xregistry.properties file on classpath
+                        propertiesIn = Thread.currentThread().getContextClassLoader()
+                        .getResourceAsStream(
+                                "xregistry/" + XregistryConstants.X_REGISTRY_PROPERTY_FILE);
+                    }
+                }
+                if(propertiesIn != null){
+                    properties.load(propertiesIn);
+                    propertiesIn.close();
+                }else{
+                    throw new XregistryException("Can not load configuration, the configuration order " +
+                       "1) explict parameter 2) xregistry.properties file on current directory 3) xregistry/xregistry.properties file on classpath");
+                }
+                return properties;
+            } catch (FileNotFoundException e) {
+                throw new XregistryException();
+            } catch (IOException e) {
+                throw new XregistryException();
+            }
+       }
+            
+       public GlobalContext(boolean clientSide,Properties properties) throws XregistryException {  
+           this.isClientSide = clientSide;
+           this.config = properties;
+           try{
+            if(clientSide){
+                String loginDataFile = System.getProperty("login.file");
+                if(loginDataFile == null){
+                    loginDataFile = System.getProperty("user.home")+"/.xregistry";
+                }
+                File loginPropertiesFile = new File(loginDataFile);
+                if(loginPropertiesFile.exists()){
+                    InputStream loginPropertiesIn = new FileInputStream(loginPropertiesFile); 
+                    config.load(loginPropertiesIn);
+                    loginPropertiesIn.close();
+                }    
+            }
+        } catch (FileNotFoundException e) {
+            throw new XregistryException();
+        } catch (IOException e) {
+            throw new XregistryException();
+        }
+                
+        if (!clientSide) {
+            loadConfiguration();
+            storage = new JdbcStorage(dbUrl, MYSQL_DRIVER);
+            //intialize databse
+            initDatabaseTables();
+
+            //start Xregistry support modules
+            groupManager = new GroupManagerImpl(this);
+            authorizer = new AuthorizerImpl(this, groupManager);
+            
+            startSheduledTasks();
+        }
+    }
+
+    public GSSCredential getCredential() throws XregistryException {
+        try {
+            if (credential == null) {
+                credential = createMyProxyCredentails();
+                if (credential == null) {
+                    if (isClientSide) {
+                        throw new XregistryException(
+                                "At the client side, myproxy credentails must present");
+                    } else {
+                        credential = createCredentials();
+                    }
+                }
+                userDN = credential.getName().toString();
+            }
+            return credential;
+        } catch (GSSException e) {
+            throw new XregistryException(e);
+        }
+    }
+
+    public String getHostcertsKeyFile() {
+        return hostcertsKeyFile;
+    }
+
+    public X509Certificate[] getTrustedCertificates() {
+        return trustedCertificates;
+    }
+
+
+    public void setTrustedCertificates(X509Certificate[] trustedCertificates) {
+        this.trustedCertificates = trustedCertificates;
+    }
+
+
+    public String getTrustedCertsFile() {
+        return trustedCertsFile;
+    }
+
+    public void setCredential(GSSCredential credential) throws XregistryException {
+        try {
+            this.credential = credential;
+            userDN = credential.getName().toString();
+        } catch (GSSException e) {
+            throw new XregistryException(e);
+        }
+    }
+
+    public void loadConfiguration() throws XregistryException {
+
+        this.hostcertsKeyFile = findStringProperty(config, SSL_HOST_KEY_FILE, hostcertsKeyFile);
+        this.trustedCertsFile = findStringProperty(config, SSL_TRUSTED_CERT_FILE, trustedCertsFile);
+        this.dbUrl = findStringProperty(config, DBURL, dbUrl);
+        if (dbUrl == null) {
+            throw new XregistryException("Database URL for underline database is not defined");
+        }
+        this.port = findIntegerProperty(config, XregistryOptions.PORT, 6666);
+        this.securityEnabled = findBooleanProperty(config, SECURITY_ENABLED, true);
+    }
+
+    public Connection createConnection() throws XregistryException {
+        return storage.connect();
+    }
+
+    public void closeConnection(Connection connection) throws XregistryException {
+        try {
+            storage.closeConnection(connection);
+        } catch (SQLException e) {
+            throw new XregistryException(e);
+        }
+    }
+
+    public GroupManager getGroupManager() {
+        return groupManager;
+    }
+
+    public Authorizer getAuthorizer() {
+        return authorizer;
+    }
+
+    public void setTrustedCertsFile(String trustedCertsFile) {
+        this.trustedCertsFile = trustedCertsFile;
+    }
+
+    public int getPort() {
+        return port;
+    }
+
+    public void setHostcertsKeyFile(String hostcertsKeyFile) {
+        this.hostcertsKeyFile = hostcertsKeyFile;
+    }
+
+    private GSSCredential createMyProxyCredentails() throws XregistryException {
+        String myproxyUserNameStr = config.getProperty(MYPROXY_USERNAME);
+        String myproxyPasswdStr = config.getProperty(MYPROXY_PASSWD);
+        String myproxyServerStr = config.getProperty(MYPROXY_SERVER);
+        String myproxyLifetimeStr = config.getProperty(MYPROXY_LIFETIME);
+
+        if (myproxyUserNameStr != null && myproxyPasswdStr != null && myproxyServerStr != null) {
+            int myproxyLifetime = 14400;
+            if (myproxyLifetimeStr != null) {
+                myproxyLifetime = Integer.parseInt(myproxyLifetimeStr.trim());
+            }
+            ProxyRenewer proxyRenewer = new ProxyRenewer(myproxyUserNameStr, myproxyPasswdStr,
+                    MyProxy.DEFAULT_PORT, myproxyLifetime, myproxyServerStr,trustedCertsFile);
+            return proxyRenewer.renewProxy();
+        } else {
+            System.out.println("Can not find sufficent information to load myproxy, server = "+ myproxyServerStr+" User Name=" 
+                    + myproxyUserNameStr + " passwd is "+ myproxyPasswdStr == null? "":"Not" + null);
+            return null;
+        }
+
+    }
+    
+
+    /**
+     * If data base tables are defined as SQL queries in file placed at 
+     * xregistry/tables.sql in the classpath, those SQL queries are execuated against the 
+     * data base. On the file, any line start # is igonred as a comment.
+     * @throws XregistryException
+     */
+    private void initDatabaseTables() throws XregistryException{
+        ClassLoader cl = Thread.currentThread().getContextClassLoader();
+        InputStream sqltablesAsStream = cl.getResourceAsStream(
+                "xregistry/" + XregistryConstants.XREGISTRY_SQL_FILE);
+        
+        if(sqltablesAsStream == null){
+            return;
+        }
+        
+        Connection connection = createConnection();
+        try{
+         Statement statement = connection.createStatement();
+         
+         
+         String docAsStr = Utils.readFromStream(sqltablesAsStream);
+         StringTokenizer t = new StringTokenizer(docAsStr,";");
+         
+         while(t.hasMoreTokens()){
+             String line = t.nextToken();
+             if(line.trim().length() > 0 && !line.startsWith("#")){
+                 System.out.println(line.trim());
+                 statement.executeUpdate(line.trim());
+             }
+         }
+        } catch (SQLException e) {
+            throw new XregistryException(e);
+        } finally{
+            closeConnection(connection);
+        }
+        
+    }
+    
+    
+    public void startSheduledTasks(){
+        Timer timer = new Timer();
+        int delay = 5000;   // delay for 5 sec.
+        int period = 1000*60*10; //every 10 minute 
+        timer.scheduleAtFixedRate(new CWsdlUpdateTask(this), delay, period);
+    }
+    
+
+    public void setUserDN(String userDN) {
+        this.userDN = userDN;
+    }
+
+
+    public boolean isSecurityEnabled() {
+        return securityEnabled;
+    }
+
+    public String getUserDN() {
+        return userDN;
+    }
+
+
+    public Properties getConfig() {
+        return config;
+    }
+    
+    
+}

Added: incubator/airavata/services/trunk/xregistry/src/main/java/org/apache/airavata/xregistry/context/SqlParam.java
URL: http://svn.apache.org/viewvc/incubator/airavata/services/trunk/xregistry/src/main/java/org/apache/airavata/xregistry/context/SqlParam.java?rev=1139850&view=auto
==============================================================================
--- incubator/airavata/services/trunk/xregistry/src/main/java/org/apache/airavata/xregistry/context/SqlParam.java (added)
+++ incubator/airavata/services/trunk/xregistry/src/main/java/org/apache/airavata/xregistry/context/SqlParam.java Sun Jun 26 17:50:29 2011
@@ -0,0 +1,66 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You 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.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.airavata.xregistry.context;
+import static org.apache.airavata.xregistry.XregistryConstants.*;
+public class SqlParam {
+//    public static final int SQL_STRING = 30067;
+//    public static final int SQL_INT = 30068;
+//    public static final int SQL_LONG = 30069;
+    
+    private String name;
+    private String value;
+    private SqlParmType type;
+    public SqlParam(String name, String value, SqlParmType type) {
+        super();
+        this.name = name;
+        this.value = value;
+        this.type = type;
+    }
+    public SqlParam(String value, SqlParmType type) {
+        super();
+        this.value = value;
+        this.type = type;
+    }
+    
+    public SqlParam(String value) {
+        this.type = SqlParmType.String;
+        this.value = value;
+    }
+    
+    public String getName() {
+        return name;
+    }
+    public void setName(String name) {
+        this.name = name;
+    }
+    public SqlParmType getType() {
+        return type;
+    }
+    public void setType(SqlParmType type) {
+        this.type = type;
+    }
+    public String getValue() {
+        return value;
+    }
+    public void setValue(String value) {
+        this.value = value;
+    }
+    
+    
+}
+

Added: incubator/airavata/services/trunk/xregistry/src/main/java/org/apache/airavata/xregistry/db/Configuration.java
URL: http://svn.apache.org/viewvc/incubator/airavata/services/trunk/xregistry/src/main/java/org/apache/airavata/xregistry/db/Configuration.java?rev=1139850&view=auto
==============================================================================
--- incubator/airavata/services/trunk/xregistry/src/main/java/org/apache/airavata/xregistry/db/Configuration.java (added)
+++ incubator/airavata/services/trunk/xregistry/src/main/java/org/apache/airavata/xregistry/db/Configuration.java Sun Jun 26 17:50:29 2011
@@ -0,0 +1,553 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You 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.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.airavata.xregistry.db;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.util.Properties;
+import java.util.Vector;
+
+/**
+ * Configuration interface.
+ * 
+ */
+
+public interface Configuration {
+
+	/**
+	 * Create an Configuration object that is a subset of this one. The new
+	 * Configuration object contains every key from the current Configuration
+	 * that starts with prefix. The prefix is removed from the keys in the
+	 * subset.
+	 * 
+	 * @param prefix
+	 *            The prefix used to select the properties.
+	 */
+	Configuration subset(String prefix);
+
+	/**
+	 * Check if the configuration is empty.
+	 * 
+	 * @return true is the configuration contains no key/value pair, false
+	 *         otherwise
+	 */
+	boolean isEmpty();
+
+	/**
+	 * Check if the configuration contains the key.
+	 * 
+	 * @return true is the configuration contains a value for this key, false
+	 *         otherwise
+	 */
+	boolean containsKey(String key);
+
+	/**
+	 * Add a property to the configuration. If it already exists then the value
+	 * stated here will be added to the configuration entry. For example, if
+	 * 
+	 * resource.loader = file
+	 * 
+	 * is already present in the configuration and you
+	 * 
+	 * addProperty("resource.loader", "classpath")
+	 * 
+	 * Then you will end up with a Vector like the following:
+	 * 
+	 * ["file", "classpath"]
+	 * 
+	 * @param key
+	 *            The Key to add the property to.
+	 * @param token
+	 *            The Value to add.
+	 */
+	void addProperty(String key, Object value);
+
+	/**
+	 * Set a property, this will replace any previously set values. Set values
+	 * is implicitly a call to clearProperty(key), addProperty(key,value).
+	 * 
+	 * @param key
+	 *            The key of the property to change
+	 * @param value
+	 *            The new value
+	 */
+	void setProperty(String key, Object value);
+
+	/**
+	 * Clear a property in the configuration.
+	 * 
+	 * @param key
+	 *            the key to remove along with corresponding value.
+	 */
+	void clearProperty(String key);
+
+	/**
+	 * Gets a property from the configuration.
+	 * 
+	 * @param key
+	 *            property to retrieve
+	 * @return value as object. Will return user value if exists, if not then
+	 *         default value if exists, otherwise null
+	 */
+	String getProperty(String key);
+
+	/**
+	 * Get the list of the keys contained in the configuration repository that
+	 * match the specified prefix.
+	 * 
+	 * @param prefix
+	 *            The prefix to test against.
+	 * @return An Iterator of keys that match the prefix.
+	 */
+	Iterator getKeys(String prefix);
+
+	/**
+	 * Get the list of the keys contained in the configuration repository.
+	 * 
+	 * @return An Iterator.
+	 */
+	Iterator getKeys();
+
+	/**
+	 * Get a list of properties associated with the given configuration key.
+	 * 
+	 * @param key
+	 *            The configuration key.
+	 * @return The associated properties if key is found.
+	 * @exception ClassCastException
+	 *                is thrown if the key maps to an object that is not a
+	 *                String/Vector.
+	 * @exception IllegalArgumentException
+	 *                if one of the tokens is malformed (does not contain an
+	 *                equals sign).
+	 */
+	Properties getProperties(String key);
+
+	/**
+	 * Get a boolean associated with the given configuration key.
+	 * 
+	 * @param key
+	 *            The configuration key.
+	 * @return The associated boolean.
+	 * @exception NoSuchElementException
+	 *                is thrown if the key doesn't map to an existing object.
+	 * @exception ClassCastException
+	 *                is thrown if the key maps to an object that is not a
+	 *                Boolean.
+	 */
+	boolean getBoolean(String key);
+
+	/**
+	 * Get a boolean associated with the given configuration key.
+	 * 
+	 * @param key
+	 *            The configuration key.
+	 * @param defaultValue
+	 *            The default value.
+	 * @return The associated boolean.
+	 * @exception ClassCastException
+	 *                is thrown if the key maps to an object that is not a
+	 *                Boolean.
+	 */
+	boolean getBoolean(String key, boolean defaultValue);
+
+	/**
+	 * Get a boolean associated with the given configuration key.
+	 * 
+	 * @param key
+	 *            The configuration key.
+	 * @param defaultValue
+	 *            The default value.
+	 * @return The associated boolean if key is found and has valid format,
+	 *         default value otherwise.
+	 * @exception ClassCastException
+	 *                is thrown if the key maps to an object that is not a
+	 *                Boolean.
+	 */
+	Boolean getBoolean(String key, Boolean defaultValue);
+
+	/**
+	 * Get a byte associated with the given configuration key.
+	 * 
+	 * @param key
+	 *            The configuration key.
+	 * @return The associated byte.
+	 * @exception NoSuchElementException
+	 *                is thrown if the key doesn't map to an existing object.
+	 * @exception ClassCastException
+	 *                is thrown if the key maps to an object that is not a Byte.
+	 * @exception NumberFormatException
+	 *                is thrown if the value mapped by the key has not a valid
+	 *                number format.
+	 */
+	byte getByte(String key);
+
+	/**
+	 * Get a byte associated with the given configuration key.
+	 * 
+	 * @param key
+	 *            The configuration key.
+	 * @param defaultValue
+	 *            The default value.
+	 * @return The associated byte.
+	 * @exception ClassCastException
+	 *                is thrown if the key maps to an object that is not a Byte.
+	 * @exception NumberFormatException
+	 *                is thrown if the value mapped by the key has not a valid
+	 *                number format.
+	 */
+	byte getByte(String key, byte defaultValue);
+
+	/**
+	 * Get a byte associated with the given configuration key.
+	 * 
+	 * @param key
+	 *            The configuration key.
+	 * @param defaultValue
+	 *            The default value.
+	 * @return The associated byte if key is found and has valid format, default
+	 *         value otherwise.
+	 * @exception ClassCastException
+	 *                is thrown if the key maps to an object that is not a Byte.
+	 * @exception NumberFormatException
+	 *                is thrown if the value mapped by the key has not a valid
+	 *                number format.
+	 */
+	Byte getByte(String key, Byte defaultValue);
+
+	/**
+	 * Get a double associated with the given configuration key.
+	 * 
+	 * @param key
+	 *            The configuration key.
+	 * @return The associated double.
+	 * @exception NoSuchElementException
+	 *                is thrown if the key doesn't map to an existing object.
+	 * @exception ClassCastException
+	 *                is thrown if the key maps to an object that is not a
+	 *                Double.
+	 * @exception NumberFormatException
+	 *                is thrown if the value mapped by the key has not a valid
+	 *                number format.
+	 */
+	double getDouble(String key);
+
+	/**
+	 * Get a double associated with the given configuration key.
+	 * 
+	 * @param key
+	 *            The configuration key.
+	 * @param defaultValue
+	 *            The default value.
+	 * @return The associated double.
+	 * @exception ClassCastException
+	 *                is thrown if the key maps to an object that is not a
+	 *                Double.
+	 * @exception NumberFormatException
+	 *                is thrown if the value mapped by the key has not a valid
+	 *                number format.
+	 */
+	double getDouble(String key, double defaultValue);
+
+	/**
+	 * Get a double associated with the given configuration key.
+	 * 
+	 * @param key
+	 *            The configuration key.
+	 * @param defaultValue
+	 *            The default value.
+	 * @return The associated double if key is found and has valid format,
+	 *         default value otherwise.
+	 * @exception ClassCastException
+	 *                is thrown if the key maps to an object that is not a
+	 *                Double.
+	 * @exception NumberFormatException
+	 *                is thrown if the value mapped by the key has not a valid
+	 *                number format.
+	 */
+	Double getDouble(String key, Double defaultValue);
+
+	/**
+	 * Get a float associated with the given configuration key.
+	 * 
+	 * @param key
+	 *            The configuration key.
+	 * @return The associated float.
+	 * @exception NoSuchElementException
+	 *                is thrown if the key doesn't map to an existing object.
+	 * @exception ClassCastException
+	 *                is thrown if the key maps to an object that is not a
+	 *                Float.
+	 * @exception NumberFormatException
+	 *                is thrown if the value mapped by the key has not a valid
+	 *                number format.
+	 */
+	float getFloat(String key);
+
+	/**
+	 * Get a float associated with the given configuration key.
+	 * 
+	 * @param key
+	 *            The configuration key.
+	 * @param defaultValue
+	 *            The default value.
+	 * @return The associated float.
+	 * @exception ClassCastException
+	 *                is thrown if the key maps to an object that is not a
+	 *                Float.
+	 * @exception NumberFormatException
+	 *                is thrown if the value mapped by the key has not a valid
+	 *                number format.
+	 */
+	float getFloat(String key, float defaultValue);
+
+	/**
+	 * Get a float associated with the given configuration key.
+	 * 
+	 * @param key
+	 *            The configuration key.
+	 * @param defaultValue
+	 *            The default value.
+	 * @return The associated float if key is found and has valid format,
+	 *         default value otherwise.
+	 * @exception ClassCastException
+	 *                is thrown if the key maps to an object that is not a
+	 *                Float.
+	 * @exception NumberFormatException
+	 *                is thrown if the value mapped by the key has not a valid
+	 *                number format.
+	 */
+	Float getFloat(String key, Float defaultValue);
+
+	/**
+	 * Get a int associated with the given configuration key.
+	 * 
+	 * @param key
+	 *            The configuration key.
+	 * @return The associated int.
+	 * @exception NoSuchElementException
+	 *                is thrown if the key doesn't map to an existing object.
+	 * @exception ClassCastException
+	 *                is thrown if the key maps to an object that is not a
+	 *                Integer.
+	 * @exception NumberFormatException
+	 *                is thrown if the value mapped by the key has not a valid
+	 *                number format.
+	 */
+	int getInt(String key);
+
+	/**
+	 * Get a int associated with the given configuration key.
+	 * 
+	 * @param key
+	 *            The configuration key.
+	 * @param defaultValue
+	 *            The default value.
+	 * @return The associated int.
+	 * @exception ClassCastException
+	 *                is thrown if the key maps to an object that is not a
+	 *                Integer.
+	 * @exception NumberFormatException
+	 *                is thrown if the value mapped by the key has not a valid
+	 *                number format.
+	 */
+	int getInt(String key, int defaultValue);
+
+	/**
+	 * Get a int associated with the given configuration key.
+	 * 
+	 * @param key
+	 *            The configuration key.
+	 * @param defaultValue
+	 *            The default value.
+	 * @return The associated int if key is found and has valid format, default
+	 *         value otherwise.
+	 * @exception ClassCastException
+	 *                is thrown if the key maps to an object that is not a
+	 *                Integer.
+	 * @exception NumberFormatException
+	 *                is thrown if the value mapped by the key has not a valid
+	 *                number format.
+	 */
+	Integer getInteger(String key, Integer defaultValue);
+
+	/**
+	 * Get a long associated with the given configuration key.
+	 * 
+	 * @param key
+	 *            The configuration key.
+	 * @return The associated long.
+	 * @exception NoSuchElementException
+	 *                is thrown if the key doesn't map to an existing object.
+	 * @exception ClassCastException
+	 *                is thrown if the key maps to an object that is not a Long.
+	 * @exception NumberFormatException
+	 *                is thrown if the value mapped by the key has not a valid
+	 *                number format.
+	 */
+	long getLong(String key);
+
+	/**
+	 * Get a long associated with the given configuration key.
+	 * 
+	 * @param key
+	 *            The configuration key.
+	 * @param defaultValue
+	 *            The default value.
+	 * @return The associated long.
+	 * @exception ClassCastException
+	 *                is thrown if the key maps to an object that is not a Long.
+	 * @exception NumberFormatException
+	 *                is thrown if the value mapped by the key has not a valid
+	 *                number format.
+	 */
+	long getLong(String key, long defaultValue);
+
+	/**
+	 * Get a long associated with the given configuration key.
+	 * 
+	 * @param key
+	 *            The configuration key.
+	 * @param defaultValue
+	 *            The default value.
+	 * @return The associated long if key is found and has valid format, default
+	 *         value otherwise.
+	 * @exception ClassCastException
+	 *                is thrown if the key maps to an object that is not a Long.
+	 * @exception NumberFormatException
+	 *                is thrown if the value mapped by the key has not a valid
+	 *                number format.
+	 */
+	Long getLong(String key, Long defaultValue);
+
+	/**
+	 * Get a short associated with the given configuration key.
+	 * 
+	 * @param key
+	 *            The configuration key.
+	 * @return The associated short.
+	 * @exception NoSuchElementException
+	 *                is thrown if the key doesn't map to an existing object.
+	 * @exception ClassCastException
+	 *                is thrown if the key maps to an object that is not a
+	 *                Short.
+	 * @exception NumberFormatException
+	 *                is thrown if the value mapped by the key has not a valid
+	 *                number format.
+	 */
+	short getShort(String key);
+
+	/**
+	 * Get a short associated with the given configuration key.
+	 * 
+	 * @param key
+	 *            The configuration key.
+	 * @param defaultValue
+	 *            The default value.
+	 * @return The associated short.
+	 * @exception ClassCastException
+	 *                is thrown if the key maps to an object that is not a
+	 *                Short.
+	 * @exception NumberFormatException
+	 *                is thrown if the value mapped by the key has not a valid
+	 *                number format.
+	 */
+	short getShort(String key, short defaultValue);
+
+	/**
+	 * Get a short associated with the given configuration key.
+	 * 
+	 * @param key
+	 *            The configuration key.
+	 * @param defaultValue
+	 *            The default value.
+	 * @return The associated short if key is found and has valid format,
+	 *         default value otherwise.
+	 * @exception ClassCastException
+	 *                is thrown if the key maps to an object that is not a
+	 *                Short.
+	 * @exception NumberFormatException
+	 *                is thrown if the value mapped by the key has not a valid
+	 *                number format.
+	 */
+	Short getShort(String key, Short defaultValue);
+
+	/**
+	 * Get a string associated with the given configuration key.
+	 * 
+	 * @param key
+	 *            The configuration key.
+	 * @return The associated string.
+	 * @exception ClassCastException
+	 *                is thrown if the key maps to an object that is not a
+	 *                String.
+	 */
+	String getString(String key);
+
+	/**
+	 * Get a string associated with the given configuration key.
+	 * 
+	 * @param key
+	 *            The configuration key.
+	 * @param defaultValue
+	 *            The default value.
+	 * @return The associated string if key is found and has valid format,
+	 *         default value otherwise.
+	 * @exception ClassCastException
+	 *                is thrown if the key maps to an object that is not a
+	 *                String.
+	 */
+	String getString(String key, String defaultValue);
+
+	/**
+	 * Get an array of strings associated with the given configuration key.
+	 * 
+	 * @param key
+	 *            The configuration key.
+	 * @return The associated string array if key is found.
+	 * @exception ClassCastException
+	 *                is thrown if the key maps to an object that is not a
+	 *                String/Vector of Strings.
+	 */
+	String[] getStringArray(String key);
+
+	/**
+	 * Get a Vector of strings associated with the given configuration key.
+	 * 
+	 * @param key
+	 *            The configuration key.
+	 * @return The associated Vector.
+	 * @exception ClassCastException
+	 *                is thrown if the key maps to an object that is not a
+	 *                Vector.
+	 */
+	Vector getVector(String key);
+
+	/**
+	 * Get a Vector of strings associated with the given configuration key.
+	 * 
+	 * @param key
+	 *            The configuration key.
+	 * @param defaultValue
+	 *            The default value.
+	 * @return The associated Vector.
+	 * @exception ClassCastException
+	 *                is thrown if the key maps to an object that is not a
+	 *                Vector.
+	 */
+	Vector getVector(String key, Vector defaultValue);
+}