airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject svn commit: r1181255 - in /incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api: Registry.java impl/JCRRegistry.java
Date Mon, 10 Oct 2011 21:47:14 GMT
Author: lahiru
Date: Mon Oct 10 21:47:14 2011
New Revision: 1181255

URL: http://svn.apache.org/viewvc?rev=1181255&view=rev
Log:
fixing https://issues.apache.org/jira/browse/AIRAVATA-133.

Modified:
    incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/Registry.java
    incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java

Modified: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/Registry.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/Registry.java?rev=1181255&r1=1181254&r2=1181255&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/Registry.java
(original)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/Registry.java
Mon Oct 10 21:47:14 2011
@@ -22,11 +22,15 @@
 package org.apache.airavata.registry.api;
 
 import java.util.List;
+import java.util.Map;
 
 import org.apache.airavata.commons.gfac.type.ApplicationDeploymentDescription;
 import org.apache.airavata.commons.gfac.type.HostDescription;
 import org.apache.airavata.commons.gfac.type.ServiceDescription;
 
+import javax.jcr.Node;
+import javax.xml.namespace.QName;
+
 public interface Registry {
 	/**
 	 * Find locations where the service is deployed
@@ -139,4 +143,10 @@ public interface Registry {
 
     public List<String> getGFacDescriptorList();
 
+    public boolean saveWorkflow(QName ResourceID, String workflowName, String resourceDesc,
String workflowAsaString, String owner, boolean isMakePublic);
+
+    public Map<QName,Node> getAvailableWorkflows(String userName);
+
+    public Node getWorkflow(QName templateID,String userName);
+
 }

Modified: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java?rev=1181255&r1=1181254&r2=1181255&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java
(original)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java
Mon Oct 10 21:47:14 2011
@@ -24,11 +24,7 @@ package org.apache.airavata.registry.api
 import java.lang.reflect.Constructor;
 import java.net.URI;
 import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.List;
-import java.util.Map;
-import java.util.TimeZone;
+import java.util.*;
 
 import javax.jcr.Credentials;
 import javax.jcr.Node;
@@ -42,6 +38,7 @@ import javax.jcr.RepositoryFactory;
 import javax.jcr.Session;
 import javax.jcr.SimpleCredentials;
 import javax.jcr.Value;
+import javax.xml.namespace.QName;
 
 import org.apache.airavata.commons.gfac.type.ApplicationDeploymentDescription;
 import org.apache.airavata.commons.gfac.type.HostDescription;
@@ -66,6 +63,9 @@ public class JCRRegistry implements Axis
 	private static final String WSDL_PROPERTY_NAME = "WSDL";
     private static final String GFAC_URL_PROPERTY_NAME = "GFAC_URL_LIST";
     private static final String LINK_NAME = "LINK";
+    public static final String WORKFLOWS = "WORKFLOWS";
+    public static final String PUBLIC = "PUBLIC";
+    public static final String REGISTRY_TYPE_WORKFLOW = "workflow";
     public static final int GFAC_URL_UPDATE_INTERVAL = 1000 * 60 * 60 * 3;
 
     private Repository repository;
@@ -575,4 +575,73 @@ public class JCRRegistry implements Axis
         }
         return result;
     }
+
+
+
+
+
+    public Map<QName, Node> getAvailableWorkflows(String userName) {
+        Session session = null;
+        Map<QName,Node> workflowList = new HashMap<QName, Node>();
+        try {
+            session = getSession();
+            Node workflowListNode = getOrAddNode(getOrAddNode(session.getRootNode(), WORKFLOWS),
PUBLIC);
+            NodeIterator iterator = workflowListNode.getNodes();
+            while (iterator.hasNext()) {
+                Node nextNode = iterator.nextNode();
+                workflowList.put(new QName(nextNode.getName()),nextNode);
+            }
+            workflowListNode = getOrAddNode(getOrAddNode(session.getRootNode(), WORKFLOWS),
userName);
+            iterator = workflowListNode.getNodes();
+            while (iterator.hasNext()) {
+                Node nextNode = iterator.nextNode();
+                workflowList.put(new QName(nextNode.getName()), nextNode);
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+            return workflowList;
+    }
+
+    public Node getWorkflow(QName templateID, String userName) {
+        Session session = null;
+        Node result = null;
+        try {
+            session = getSession();
+            Node workflowListNode = getOrAddNode(getOrAddNode(session.getRootNode(), WORKFLOWS),
userName);
+            result = getOrAddNode(workflowListNode, templateID.getLocalPart());
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+            return result;
+    }
+        public boolean saveWorkflow(QName ResourceID, String workflowName, String resourceDesc,
String workflowAsaString, String owner, boolean isMakePublic) {
+              Session session = null;
+              try {
+                  session = getSession();
+                  Node workflowListNode = getOrAddNode(session.getRootNode(), WORKFLOWS);
+                  Node workflowNode = null;
+                  if(isMakePublic){
+                       workflowNode = getOrAddNode(getOrAddNode(workflowListNode, PUBLIC),
workflowName);
+                  }else{
+                       workflowNode = getOrAddNode(getOrAddNode(workflowListNode, owner),workflowName);
+                  }
+                  workflowNode.setProperty("workflow",workflowAsaString);
+                  workflowNode.setProperty("Prefix",ResourceID.getPrefix());
+                  workflowNode.setProperty("LocalPart",ResourceID.getLocalPart());
+                  workflowNode.setProperty("NamespaceURI",ResourceID.getNamespaceURI());
+                  workflowNode.setProperty("public",isMakePublic);
+                  workflowNode.setProperty("Description",resourceDesc);
+                  workflowNode.setProperty("Type",REGISTRY_TYPE_WORKFLOW);
+                  session.save();
+              } catch (Exception e) {
+                  e.printStackTrace();
+              } finally {
+                  if (session != null && session.isLive()) {
+                      session.logout();
+                  }
+                  return true;
+              }
+          }
 }



Mime
View raw message