airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chath...@apache.org
Subject svn commit: r1406321 [2/2] - /airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/
Date Tue, 06 Nov 2012 20:53:44 GMT
Added: airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/ProvenanceRegistryResource.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/ProvenanceRegistryResource.java?rev=1406321&view=auto
==============================================================================
--- airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/ProvenanceRegistryResource.java (added)
+++ airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/ProvenanceRegistryResource.java Tue Nov  6 20:53:43 2012
@@ -0,0 +1,840 @@
+/*
+ *
+ * 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.services.registry.rest.resources;
+
+import org.apache.airavata.registry.api.AiravataRegistry2;
+import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.impl.ExperimentDataImpl;
+import org.apache.airavata.registry.api.workflow.*;
+import org.apache.airavata.services.registry.rest.resourcemappings.ExperimentDataList;
+import org.apache.airavata.services.registry.rest.resourcemappings.ExperimentIDList;
+import org.apache.airavata.services.registry.rest.resourcemappings.WorkflowInstancesList;
+import org.apache.airavata.services.registry.rest.utils.RestServicesConstants;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+@Path("/registry/api/provenanceregistry")
+public class ProvenanceRegistryResource {
+    private AiravataRegistry2 airavataRegistry;
+
+    @Context
+    ServletContext context;
+
+    /**
+     * --------------------------------- Provenance Registry ----------------------------------*
+     */
+
+    @POST
+    @Path("update/experiment")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response updateExperimentExecutionUser(@FormParam("experimentId") String experimentId,
+                                                  @FormParam("user") String user) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try {
+            airavataRegistry.updateExperimentExecutionUser(experimentId, user);
+            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
+            return builder.build();
+        }
+    }
+
+    @GET
+    @Path("get/experiment/executionuser")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response getExperimentExecutionUser(@QueryParam("experimentId") String experimentId) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try {
+            String user = airavataRegistry.getExperimentExecutionUser(experimentId);
+            if (user != null) {
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity(user);
+                return builder.build();
+            } else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NOT_MODIFIED);
+                return builder.build();
+            }
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
+    }
+
+    @GET
+    @Path("get/experiment/name")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response getExperimentName(@QueryParam("experimentId") String experimentId) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try {
+            String result = airavataRegistry.getExperimentName(experimentId);
+            if (result != null) {
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity(result);
+                return builder.build();
+            } else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NOT_MODIFIED);
+                return builder.build();
+            }
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
+    }
+
+    @POST
+    @Path("update/experimentname")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response updateExperimentName(@FormParam("experimentId") String experimentId,
+                                         @FormParam("experimentName") String experimentName) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try {
+            airavataRegistry.updateExperimentName(experimentId, experimentName);
+            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
+            return builder.build();
+        }
+    }
+
+
+    @GET
+    @Path("get/experimentmetadata")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response getExperimentMetadata(@QueryParam("experimentId") String experimentId) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try {
+            String result = airavataRegistry.getExperimentMetadata(experimentId);
+            if (result != null) {
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity(result);
+                return builder.build();
+            } else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NOT_MODIFIED);
+                return builder.build();
+            }
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
+    }
+
+    @POST
+    @Path("update/experimentmetadata")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response updateExperimentMetadata(@FormParam("experimentId") String experimentId,
+                                             @FormParam("metadata") String metadata) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try {
+            airavataRegistry.updateExperimentMetadata(experimentId, metadata);
+            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
+            return builder.build();
+        }
+    }
+
+
+
+    @GET
+    @Path("get/workflowtemplatename")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response getWorkflowExecutionTemplateName(@QueryParam("workflowInstanceId") String workflowInstanceId) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try {
+            String result = airavataRegistry.getWorkflowExecutionTemplateName(workflowInstanceId);
+            if (result != null) {
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity(result);
+                return builder.build();
+            } else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NOT_MODIFIED);
+                return builder.build();
+            }
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
+    }
+
+    @POST
+    @Path("update/workflowinstancetemplatename")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response setWorkflowInstanceTemplateName(@FormParam("workflowInstanceId") String workflowInstanceId,
+                                                    @FormParam("templateName") String templateName) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try {
+            airavataRegistry.setWorkflowInstanceTemplateName(workflowInstanceId, templateName);
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
+            return builder.build();
+        }
+    }
+
+    @GET
+    @Path("get/experimentworkflowinstances")
+    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+    public Response getExperimentWorkflowInstances(@QueryParam("experimentId") String experimentId) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try {
+            List<WorkflowInstance> experimentWorkflowInstances = airavataRegistry.getExperimentWorkflowInstances(experimentId);
+            WorkflowInstancesList workflowInstancesList = new WorkflowInstancesList();
+            WorkflowInstance[] workflowInstanceMappings = new WorkflowInstance[experimentWorkflowInstances.size()];
+            for (int i = 0; i < experimentWorkflowInstances.size(); i++) {
+                workflowInstanceMappings[i] = experimentWorkflowInstances.get(i);
+            }
+            workflowInstancesList.setWorkflowInstances(workflowInstanceMappings);
+            if (experimentWorkflowInstances.size() != 0) {
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity(workflowInstancesList);
+                return builder.build();
+            } else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+                return builder.build();
+            }
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
+    }
+
+    @GET
+    @Path("workflowinstance/exist/check")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response isWorkflowInstanceExists(@QueryParam("instanceId") String instanceId) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try {
+            Boolean result = airavataRegistry.isWorkflowInstanceExists(instanceId);
+            if (result) {
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity("True");
+                return builder.build();
+            } else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
+                builder.entity("False");
+                return builder.build();
+            }
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
+            return builder.build();
+        }
+
+    }
+
+    @GET
+    @Path("workflowinstance/exist/create")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response isWorkflowInstanceExistsThenCreate(@QueryParam("instanceId") String instanceId,
+                                                       @QueryParam("createIfNotPresent") boolean createIfNotPresent) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try {
+            Boolean result = airavataRegistry.isWorkflowInstanceExists(instanceId, createIfNotPresent);
+            if (result) {
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity("True");
+                return builder.build();
+            } else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
+                return builder.build();
+            }
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
+            return builder.build();
+        }
+    }
+
+    @POST
+    @Path("update/workflowinstancestatus/instanceid")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response updateWorkflowInstanceStatusByInstance(@FormParam("instanceId") String instanceId,
+                                                           @FormParam("executionStatus") String executionStatus) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try {
+            WorkflowInstanceStatus.ExecutionStatus status = WorkflowInstanceStatus.ExecutionStatus.valueOf(executionStatus);
+            airavataRegistry.updateWorkflowInstanceStatus(instanceId, status);
+            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
+            return builder.build();
+        }
+    }
+
+    @POST
+    @Path("update/workflowinstancestatus")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response updateWorkflowInstanceStatus(@FormParam("workflowInstanceId") String workflowInstanceId,
+                                                 @FormParam("executionStatus") String executionStatus,
+                                                 @FormParam("statusUpdateTime") String statusUpdateTime) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try {
+            DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            Date formattedDate = dateFormat.parse(statusUpdateTime);
+            WorkflowInstance workflowInstance = airavataRegistry.getWorkflowInstanceData(workflowInstanceId).getWorkflowInstance();
+            WorkflowInstanceStatus.ExecutionStatus status = WorkflowInstanceStatus.ExecutionStatus.valueOf(executionStatus);
+            WorkflowInstanceStatus workflowInstanceStatus = new WorkflowInstanceStatus(workflowInstance, status, formattedDate);
+            airavataRegistry.updateWorkflowInstanceStatus(workflowInstanceStatus);
+            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
+            return builder.build();
+        } catch (ParseException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
+            return builder.build();
+        }
+    }
+
+    @GET
+    @Path("get/workflowinstancestatus")
+    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+    public Response getWorkflowInstanceStatus(@QueryParam("instanceId") String instanceId) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try {
+            WorkflowInstanceStatus workflowInstanceStatus = airavataRegistry.getWorkflowInstanceStatus(instanceId);
+            if (workflowInstanceStatus != null) {
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity(workflowInstanceStatus);
+                return builder.build();
+            } else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+                return builder.build();
+            }
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
+    }
+
+    @POST
+    @Path("update/workflownodeinput")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response updateWorkflowNodeInput(@FormParam("nodeID") String nodeID,
+                                            @FormParam("workflowInstanceId") String workflowInstanceID,
+                                            @FormParam("data") String data) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try {
+            WorkflowInstanceData workflowInstanceData = airavataRegistry.getWorkflowInstanceData(workflowInstanceID);
+            WorkflowInstanceNode workflowInstanceNode = workflowInstanceData.getNodeData(nodeID).getWorkflowInstanceNode();
+            airavataRegistry.updateWorkflowNodeInput(workflowInstanceNode, data);
+            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
+            return builder.build();
+        }
+
+    }
+
+    @POST
+    @Path("update/workflownodeoutput")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response updateWorkflowNodeOutput(@FormParam("nodeID") String nodeID,
+                                             @FormParam("workflowInstanceId") String workflowInstanceID,
+                                             @FormParam("data") String data) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try {
+            WorkflowInstanceData workflowInstanceData = airavataRegistry.getWorkflowInstanceData(workflowInstanceID);
+            WorkflowInstanceNode workflowInstanceNode = workflowInstanceData.getNodeData(nodeID).getWorkflowInstanceNode();
+            airavataRegistry.updateWorkflowNodeOutput(workflowInstanceNode, data);
+            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.NOT_FOUND);
+            return builder.build();
+        }
+    }
+
+    /*
+    @GET
+    @Path("search/workflowinstancenodeinput")
+    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+    public Response searchWorkflowInstanceNodeInput(@QueryParam("experimentIdRegEx") String experimentIdRegEx,
+                                                    @QueryParam("workflowNameRegEx") String workflowNameRegEx,
+                                                    @QueryParam("nodeNameRegEx") String nodeNameRegEx) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try {
+            List<WorkflowNodeIOData> workflowNodeIODataList = airavataRegistry.searchWorkflowInstanceNodeInput(experimentIdRegEx, workflowNameRegEx, nodeNameRegEx);
+            WorkflowNodeIODataMapping[] workflowNodeIODataCollection = new WorkflowNodeIODataMapping[workflowNodeIODataList.size()];
+            WorkflowNodeIODataList workflowNodeIOData = new WorkflowNodeIODataList();
+            for (int i = 0; i < workflowNodeIODataList.size(); i++) {
+                WorkflowNodeIOData nodeIOData = workflowNodeIODataList.get(i);
+                WorkflowNodeIODataMapping workflowNodeIODataMapping = new WorkflowNodeIODataMapping();
+
+                workflowNodeIODataMapping.setExperimentId(nodeIOData.getExperimentId());
+                workflowNodeIODataMapping.setWorkflowId(nodeIOData.getWorkflowId());
+                workflowNodeIODataMapping.setWorkflowInstanceId(nodeIOData.getWorkflowInstanceId());
+                workflowNodeIODataMapping.setWorkflowName(nodeIOData.getWorkflowName());
+                workflowNodeIODataMapping.setWorkflowNodeType(nodeIOData.getNodeType().toString());
+                workflowNodeIODataCollection[i] = workflowNodeIODataMapping;
+            }
+            workflowNodeIOData.setWorkflowNodeIOData(workflowNodeIODataCollection);
+            if (workflowNodeIODataList.size() != 0) {
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity(workflowNodeIOData);
+                return builder.build();
+            } else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+                return builder.build();
+            }
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
+    }
+
+    @GET
+    @Path("search/workflowinstancenodeoutput")
+    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+    public Response searchWorkflowInstanceNodeOutput(@QueryParam("experimentIdRegEx") String experimentIdRegEx,
+                                                     @QueryParam("workflowNameRegEx") String workflowNameRegEx,
+                                                     @QueryParam("nodeNameRegEx") String nodeNameRegEx) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try {
+            List<WorkflowNodeIOData> workflowNodeIODataList = airavataRegistry.searchWorkflowInstanceNodeOutput(experimentIdRegEx, workflowNameRegEx, nodeNameRegEx);
+            WorkflowNodeIODataMapping[] workflowNodeIODataCollection = new WorkflowNodeIODataMapping[workflowNodeIODataList.size()];
+            WorkflowNodeIODataList workflowNodeIOData = new WorkflowNodeIODataList();
+            for (int i = 0; i < workflowNodeIODataList.size(); i++) {
+                WorkflowNodeIOData nodeIOData = workflowNodeIODataList.get(i);
+                WorkflowNodeIODataMapping workflowNodeIODataMapping = new WorkflowNodeIODataMapping();
+
+                workflowNodeIODataMapping.setExperimentId(nodeIOData.getExperimentId());
+                workflowNodeIODataMapping.setWorkflowId(nodeIOData.getWorkflowId());
+                workflowNodeIODataMapping.setWorkflowInstanceId(nodeIOData.getWorkflowInstanceId());
+                workflowNodeIODataMapping.setWorkflowName(nodeIOData.getWorkflowName());
+                workflowNodeIODataMapping.setWorkflowNodeType(nodeIOData.getNodeType().toString());
+                workflowNodeIODataCollection[i] = workflowNodeIODataMapping;
+            }
+            workflowNodeIOData.setWorkflowNodeIOData(workflowNodeIODataCollection);
+            if (workflowNodeIODataList.size() != 0) {
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity(workflowNodeIOData);
+                return builder.build();
+            } else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+                return builder.build();
+            }
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
+    }
+
+    @GET
+    @Path("get/workflowinstancenodeinput")
+    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+    public Response getWorkflowInstanceNodeInput(@QueryParam("workflowInstanceId") String workflowInstanceId,
+                                                 @QueryParam("nodeType") String nodeType) {
+        // Airavata JPA Registry method returns null at the moment
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try {
+            List<WorkflowNodeIOData> workflowNodeIODataList = airavataRegistry.getWorkflowInstanceNodeInput(workflowInstanceId, nodeType);
+            WorkflowNodeIODataMapping[] workflowNodeIODataCollection = new WorkflowNodeIODataMapping[workflowNodeIODataList.size()];
+            WorkflowNodeIODataList workflowNodeIOData = new WorkflowNodeIODataList();
+            for (int i = 0; i < workflowNodeIODataList.size(); i++) {
+                WorkflowNodeIOData nodeIOData = workflowNodeIODataList.get(i);
+                WorkflowNodeIODataMapping workflowNodeIODataMapping = new WorkflowNodeIODataMapping();
+
+                workflowNodeIODataMapping.setExperimentId(nodeIOData.getExperimentId());
+                workflowNodeIODataMapping.setWorkflowId(nodeIOData.getWorkflowId());
+                workflowNodeIODataMapping.setWorkflowInstanceId(nodeIOData.getWorkflowInstanceId());
+                workflowNodeIODataMapping.setWorkflowName(nodeIOData.getWorkflowName());
+                workflowNodeIODataMapping.setWorkflowNodeType(nodeIOData.getNodeType().toString());
+                workflowNodeIODataCollection[i] = workflowNodeIODataMapping;
+            }
+            workflowNodeIOData.setWorkflowNodeIOData(workflowNodeIODataCollection);
+            if (workflowNodeIODataList.size() != 0) {
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity(workflowNodeIOData);
+                return builder.build();
+            } else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+                return builder.build();
+            }
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
+    }
+
+    @GET
+    @Path("get/workflowinstancenodeoutput")
+    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+    public Response getWorkflowInstanceNodeOutput(@QueryParam("workflowInstanceId") String workflowInstanceId,
+                                                  @QueryParam("nodeType") String nodeType) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try {
+            List<WorkflowNodeIOData> workflowNodeIODataList = airavataRegistry.getWorkflowInstanceNodeOutput(workflowInstanceId, nodeType);
+            WorkflowNodeIODataMapping[] workflowNodeIODataCollection = new WorkflowNodeIODataMapping[workflowNodeIODataList.size()];
+            WorkflowNodeIODataList workflowNodeIOData = new WorkflowNodeIODataList();
+            for (int i = 0; i < workflowNodeIODataList.size(); i++) {
+                WorkflowNodeIOData nodeIOData = workflowNodeIODataList.get(i);
+                WorkflowNodeIODataMapping workflowNodeIODataMapping = new WorkflowNodeIODataMapping();
+
+                workflowNodeIODataMapping.setExperimentId(nodeIOData.getExperimentId());
+                workflowNodeIODataMapping.setWorkflowId(nodeIOData.getWorkflowId());
+                workflowNodeIODataMapping.setWorkflowInstanceId(nodeIOData.getWorkflowInstanceId());
+                workflowNodeIODataMapping.setWorkflowName(nodeIOData.getWorkflowName());
+                workflowNodeIODataMapping.setWorkflowNodeType(nodeIOData.getNodeType().toString());
+                workflowNodeIODataCollection[i] = workflowNodeIODataMapping;
+            }
+            workflowNodeIOData.setWorkflowNodeIOData(workflowNodeIODataCollection);
+            if (workflowNodeIODataList.size() != 0) {
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity(workflowNodeIOData);
+                return builder.build();
+            } else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+                return builder.build();
+            }
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
+    }
+    */
+
+    @GET
+    @Path("get/experiment")
+    @Produces(MediaType.APPLICATION_XML)
+    public Response getExperiment(@QueryParam("experimentId") String experimentId) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try{
+            ExperimentDataImpl experimentData = (ExperimentDataImpl)airavataRegistry.getExperiment(experimentId);
+            if (experimentData != null){
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity(experimentData);
+                return builder.build();
+            } else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+                return builder.build();
+            }
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
+    }
+
+    @GET
+    @Path("get/experimentId/user")
+    @Produces(MediaType.APPLICATION_XML)
+    public Response getExperimentIdByUser(@QueryParam("username") String username) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try{
+            ArrayList<String> experiments = (ArrayList)airavataRegistry.getExperimentIdByUser(username);
+            ExperimentIDList experimentIDList = new ExperimentIDList();
+            experimentIDList.setExperimentIDList(experiments);
+
+            if (experiments.size() != 0){
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity(experimentIDList);
+                return builder.build();
+            } else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+                return builder.build();
+            }
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
+    }
+
+    @GET
+    @Path("get/experiment/user")
+    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+    public Response getExperimentByUser(@QueryParam("username") String username) throws RegistryException {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try{
+            List<ExperimentData> experimentDataList = airavataRegistry.getExperimentByUser(username);
+            ExperimentDataList experimentData = new ExperimentDataList();
+            List<ExperimentDataImpl> experimentDatas = new ArrayList<ExperimentDataImpl>();
+            for (int i = 0; i < experimentDataList.size(); i ++){
+                experimentDatas.add((ExperimentDataImpl)experimentDataList.get(i));
+            }
+            experimentData.setExperimentDataList(experimentDatas);
+            if (experimentDataList.size() != 0) {
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity(experimentData);
+                return builder.build();
+            } else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+                return builder.build();
+            }
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
+    }
+
+    @POST
+    @Path("update/workflownode/status")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response updateWorkflowNodeStatus(@FormParam("workflowInstanceId") String workflowInstanceId,
+                                             @FormParam("nodeId") String nodeId,
+                                             @FormParam("executionStatus") String executionStatus) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try{
+            WorkflowInstanceStatus.ExecutionStatus status = WorkflowInstanceStatus.ExecutionStatus.valueOf(executionStatus);
+            airavataRegistry.updateWorkflowNodeStatus(workflowInstanceId, nodeId, status);
+            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
+    }
+
+
+    @GET
+    @Path("get/workflownode/status")
+    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+    public Response getWorkflowNodeStatus(@QueryParam("workflowInstanceId") String workflowInstanceId,
+                                          @QueryParam("nodeId") String nodeId){
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try{
+            WorkflowInstanceData workflowInstanceData = airavataRegistry.getWorkflowInstanceData(workflowInstanceId);
+            WorkflowInstanceNode workflowInstanceNode = workflowInstanceData.getNodeData(nodeId).getWorkflowInstanceNode();
+            WorkflowInstanceNodeStatus workflowNodeStatus = airavataRegistry.getWorkflowNodeStatus(workflowInstanceNode);
+            if(workflowNodeStatus != null){
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity(workflowNodeStatus);
+                return builder.build();
+            } else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+                return builder.build();
+            }
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
+    }
+
+    @GET
+    @Path("get/workflownode/starttime")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response getWorkflowNodeStartTime(@QueryParam("workflowInstanceId") String workflowInstanceId,
+                                             @QueryParam("nodeId") String nodeId) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try{
+            WorkflowInstanceData workflowInstanceData = airavataRegistry.getWorkflowInstanceData(workflowInstanceId);
+            WorkflowInstanceNode workflowInstanceNode = workflowInstanceData.getNodeData(nodeId).getWorkflowInstanceNode();
+            Date workflowNodeStartTime = airavataRegistry.getWorkflowNodeStartTime(workflowInstanceNode);
+            if(workflowNodeStartTime != null){
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity(workflowNodeStartTime.toString());
+                return builder.build();
+            } else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+                return builder.build();
+            }
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
+    }
+
+    @GET
+    @Path("get/workflow/starttime")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response getWorkflowStartTime(@QueryParam("workflowInstanceId") String workflowInstanceId) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try{
+            WorkflowInstanceData workflowInstanceData = airavataRegistry.getWorkflowInstanceData(workflowInstanceId);
+            WorkflowInstance workflowInstance = workflowInstanceData.getWorkflowInstance();
+            Date workflowStartTime = airavataRegistry.getWorkflowStartTime(workflowInstance);
+            if(workflowStartTime != null){
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity(workflowStartTime.toString());
+                return builder.build();
+            } else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+                return builder.build();
+            }
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
+    }
+
+    @GET
+    @Path("update/workflownode/gramdata")
+    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response updateWorkflowNodeGramData(WorkflowNodeGramData workflowNodeGramData) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try{
+            airavataRegistry.updateWorkflowNodeGramData(workflowNodeGramData);
+            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
+
+    }
+
+    @GET
+    @Path("get/workflowinstancedata")
+    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+    public Response getWorkflowInstanceData(@QueryParam("workflowInstanceId") String workflowInstanceId) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try{
+            WorkflowInstanceData workflowInstanceData = airavataRegistry.getWorkflowInstanceData(workflowInstanceId);
+            if (workflowInstanceData != null){
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity(workflowInstanceData);
+                return builder.build();
+            } else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+                return builder.build();
+            }
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            return builder.build();
+        }
+    }
+
+    @GET
+    @Path("workflowinstance/exist")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response isWorkflowInstanceNodePresent(@QueryParam("workflowInstanceId") String workflowInstanceId,
+                                                  @QueryParam("nodeId") String nodeId){
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try{
+            boolean workflowInstanceNodePresent = airavataRegistry.isWorkflowInstanceNodePresent(workflowInstanceId, nodeId);
+            if (workflowInstanceNodePresent){
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity("True");
+                return builder.build();
+            } else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+                builder.entity("False");
+                return builder.build();
+            }
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            builder.entity(e.getMessage());
+            return builder.build();
+        }
+
+    }
+
+    @GET
+    @Path("workflowinstance/nodeData")
+    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+    public Response getWorkflowInstanceNodeData(@QueryParam("workflowInstanceId") String workflowInstanceId,
+                                                @QueryParam("nodeId") String nodeId) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try{
+            WorkflowInstanceNodeData workflowInstanceNodeData = airavataRegistry.getWorkflowInstanceNodeData(workflowInstanceId, nodeId);
+            if (workflowInstanceNodeData != null){
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity(workflowInstanceNodeData);
+                return builder.build();
+            }  else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+                return builder.build();
+            }
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            builder.entity(e.getMessage());
+            return builder.build();
+        }
+
+    }
+
+    @POST
+    @Path("add/workflowinstance")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response addWorkflowInstance(@FormParam("experimentId") String experimentId,
+                                        @FormParam("workflowInstanceId") String workflowInstanceId,
+                                        @FormParam("templateName") String templateName) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try{
+            airavataRegistry.addWorkflowInstance(experimentId, workflowInstanceId, templateName);
+            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+            builder.entity(e.getMessage());
+            return builder.build();
+        }
+    }
+
+    @POST
+    @Path("update/workflownodetype")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response updateWorkflowNodeType(@FormParam("workflowInstanceId") String workflowInstanceId,
+                                           @FormParam("nodeId") String nodeId,
+                                           @FormParam("nodeType") String nodeType) throws RegistryException {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try{
+            WorkflowInstanceNodeData workflowInstanceNodeData = airavataRegistry.getWorkflowInstanceData(workflowInstanceId).getNodeData(nodeId);
+            WorkflowInstanceNode workflowInstanceNode = workflowInstanceNodeData.getWorkflowInstanceNode();
+            WorkflowNodeType workflowNodeType = new WorkflowNodeType();
+
+            //currently from API only service node is being used
+            workflowNodeType.setNodeType(WorkflowNodeType.WorkflowNode.SERVICENODE);
+//            workflowNodeType.setNodeType(nodeType);
+            airavataRegistry.updateWorkflowNodeType(workflowInstanceNode, workflowNodeType);
+            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            builder.entity(e.getMessage());
+            return builder.build();
+        }
+    }
+
+
+    @POST
+    @Path("add/workflowinstancenode")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response addWorkflowInstanceNode(@FormParam("workflowInstanceId") String workflowInstanceId,
+                                            @FormParam("nodeId") String nodeId) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try{
+            airavataRegistry.addWorkflowInstanceNode(workflowInstanceId, nodeId);
+            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            builder.entity(e.getMessage());
+            return builder.build();
+        }
+    }
+
+}

Added: airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/PublishWorkflowRegistryResource.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/PublishWorkflowRegistryResource.java?rev=1406321&view=auto
==============================================================================
--- airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/PublishWorkflowRegistryResource.java (added)
+++ airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/PublishWorkflowRegistryResource.java Tue Nov  6 20:53:43 2012
@@ -0,0 +1,225 @@
+/*
+ *
+ * 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.services.registry.rest.resources;
+
+import org.apache.airavata.registry.api.AiravataRegistry2;
+import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.gateway.PublishedWorkflowAlreadyExistsException;
+import org.apache.airavata.registry.api.exception.gateway.PublishedWorkflowDoesNotExistsException;
+import org.apache.airavata.registry.api.exception.worker.UserWorkflowDoesNotExistsException;
+import org.apache.airavata.services.registry.rest.resourcemappings.PublishWorkflowNamesList;
+import org.apache.airavata.services.registry.rest.resourcemappings.Workflow;
+import org.apache.airavata.services.registry.rest.resourcemappings.WorkflowList;
+import org.apache.airavata.services.registry.rest.utils.RestServicesConstants;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+@Path("/registry/api/publishwfregistry")
+public class PublishWorkflowRegistryResource {
+    private AiravataRegistry2 airavataRegistry;
+
+    @Context
+    ServletContext context;
+
+    /**---------------------------------Published Workflow Registry----------------------------------**/
+
+    @GET
+    @Path("publishwf/exist")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response isPublishedWorkflowExists(@QueryParam("workflowname") String workflowname) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try{
+            boolean workflowExists = airavataRegistry.isPublishedWorkflowExists(workflowname);
+            if (workflowExists){
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity("True");
+                return builder.build();
+            }else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+                builder.entity("False");
+                return builder.build();
+            }
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            builder.entity(e.getMessage());
+            return builder.build();
+        }
+    }
+
+    @POST
+    @Path("publish/workflow")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response publishWorkflow(@FormParam("workflowName") String workflowName,
+                                    @FormParam("publishWorkflowName") String publishWorkflowName)  {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try{
+            airavataRegistry.publishWorkflow(workflowName, publishWorkflowName);
+            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+            return builder.build();
+        } catch (UserWorkflowDoesNotExistsException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            builder.entity(e.getMessage());
+            return builder.build();
+        } catch (PublishedWorkflowAlreadyExistsException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            builder.entity(e.getMessage());
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            builder.entity(e.getMessage());
+            return builder.build();
+        }
+    }
+
+    @POST
+    @Path("publish/default/workflow")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response publishWorkflow(@FormParam("workflowName") String workflowName){
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try{
+            airavataRegistry.publishWorkflow(workflowName);
+            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+            return builder.build();
+        } catch (UserWorkflowDoesNotExistsException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            builder.entity(e.getMessage());
+            return builder.build();
+        } catch (PublishedWorkflowAlreadyExistsException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            builder.entity(e.getMessage());
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            builder.entity(e.getMessage());
+            return builder.build();
+        }
+    }
+
+    @GET
+    @Path("get/publishworkflowgraph")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response getPublishedWorkflowGraphXML(@QueryParam("workflowName") String workflowName) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try{
+            String publishedWorkflowGraphXML = airavataRegistry.getPublishedWorkflowGraphXML(workflowName);
+            if (publishedWorkflowGraphXML !=null){
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity(publishedWorkflowGraphXML);
+                return builder.build();
+            }else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+                return builder.build();
+            }
+        } catch (PublishedWorkflowDoesNotExistsException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            builder.entity(e.getMessage());
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            builder.entity(e.getMessage());
+            return builder.build();
+        }
+    }
+
+    @GET
+    @Path("get/publishworkflownames")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response getPublishedWorkflowNames() {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try{
+            List<String> publishedWorkflowNames = airavataRegistry.getPublishedWorkflowNames();
+            PublishWorkflowNamesList publishWorkflowNamesList = new PublishWorkflowNamesList();
+            publishWorkflowNamesList.setPublishWorkflowNames(publishedWorkflowNames);
+            if (publishedWorkflowNames.size() != 0){
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity(publishWorkflowNamesList);
+                return builder.build();
+            } else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+                return builder.build();
+            }
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            builder.entity(e.getMessage());
+            return builder.build();
+        }
+    }
+
+    @GET
+    @Path("get/publishworkflows")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response getPublishedWorkflows() {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try{
+            Map<String, String> publishedWorkflows = airavataRegistry.getPublishedWorkflows();
+            WorkflowList workflowList = new WorkflowList();
+            List<Workflow> workflowsModels = new ArrayList<Workflow>();
+            for (String workflowName : publishedWorkflows.keySet()){
+                Workflow workflow = new Workflow();
+                workflow.setWorkflowName(workflowName);
+                workflow.setWorkflowGraph(publishedWorkflows.get(workflowName));
+                workflowsModels.add(workflow);
+            }
+            workflowList.setWorkflowList(workflowsModels);
+            if(publishedWorkflows.size() != 0 ){
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity(workflowList);
+                return builder.build();
+            } else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+                return builder.build();
+            }
+
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            builder.entity(e.getMessage());
+            return builder.build();
+        }
+    }
+
+    @GET
+    @Path("remove/publishworkflow")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response removePublishedWorkflow(@QueryParam("workflowName") String workflowName) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try{
+            airavataRegistry.removePublishedWorkflow(workflowName);
+            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+            return builder.build();
+        } catch (PublishedWorkflowDoesNotExistsException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            builder.entity(e.getMessage());
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            builder.entity(e.getMessage());
+            return builder.build();
+        }
+    }
+}

Modified: airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/RegistryResource.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/RegistryResource.java?rev=1406321&r1=1406320&r2=1406321&view=diff
==============================================================================
--- airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/RegistryResource.java (original)
+++ airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/RegistryResource.java Tue Nov  6 20:53:43 2012
@@ -1520,6 +1520,10 @@ public class RegistryResource {
         }
     }
 
+    /**
+     * --------------------------------- Provenance Registry ----------------------------------*
+     */
+
     @POST
     @Path("update/experiment")
     @Produces(MediaType.TEXT_PLAIN)

Added: airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/UserWorkflowRegistryResource.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/UserWorkflowRegistryResource.java?rev=1406321&view=auto
==============================================================================
--- airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/UserWorkflowRegistryResource.java (added)
+++ airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/UserWorkflowRegistryResource.java Tue Nov  6 20:53:43 2012
@@ -0,0 +1,194 @@
+/*
+ *
+ * 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.services.registry.rest.resources;
+
+import org.apache.airavata.registry.api.AiravataRegistry2;
+import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.registry.api.exception.worker.UserWorkflowAlreadyExistsException;
+import org.apache.airavata.registry.api.exception.worker.UserWorkflowDoesNotExistsException;
+import org.apache.airavata.services.registry.rest.resourcemappings.Workflow;
+import org.apache.airavata.services.registry.rest.resourcemappings.WorkflowList;
+import org.apache.airavata.services.registry.rest.utils.RestServicesConstants;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+@Path("/registry/api/userwfregistry")
+public class UserWorkflowRegistryResource {
+    private AiravataRegistry2 airavataRegistry;
+
+    @Context
+    ServletContext context;
+
+    /**---------------------------------User Workflow Registry----------------------------------**/
+
+    @GET
+    @Path("workflow/exist")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response isWorkflowExists(@QueryParam("workflowName") String workflowName){
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try{
+            boolean workflowExists = airavataRegistry.isWorkflowExists(workflowName);
+            if (workflowExists){
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity("True");
+                return builder.build();
+            }else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+                builder.entity("False");
+                return builder.build();
+            }
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            builder.entity(e.getMessage());
+            return builder.build();
+        }
+    }
+
+
+    @POST
+    @Path("add/workflow")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response addWorkflow(@FormParam("workflowName") String workflowName,
+                                @FormParam("workflowGraphXml") String workflowGraphXml) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try{
+            airavataRegistry.addWorkflow(workflowName, workflowGraphXml);
+            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+            return builder.build();
+        } catch (UserWorkflowAlreadyExistsException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            builder.entity(e.getMessage());
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            builder.entity(e.getMessage());
+            return builder.build();
+        }
+    }
+
+    @POST
+    @Path("update/workflow")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response updateWorkflow(@FormParam("workflowName") String workflowName,
+                                   @FormParam("workflowGraphXml") String workflowGraphXml){
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try{
+            airavataRegistry.updateWorkflow(workflowName, workflowGraphXml);
+            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+            return builder.build();
+        } catch (UserWorkflowAlreadyExistsException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            builder.entity(e.getMessage());
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            builder.entity(e.getMessage());
+            return builder.build();
+        }
+    }
+
+    @GET
+    @Path("get/workflowgraph")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response getWorkflowGraphXML(@QueryParam("workflowName") String workflowName) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try{
+            String workflowGraphXML = airavataRegistry.getWorkflowGraphXML(workflowName);
+            if (workflowGraphXML != null){
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity(workflowGraphXML);
+                return builder.build();
+            }else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+                return builder.build();
+            }
+        } catch (UserWorkflowDoesNotExistsException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            builder.entity(e.getMessage());
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            builder.entity(e.getMessage());
+            return builder.build();
+        }
+    }
+
+    @GET
+    @Path("get/workflows")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response getWorkflows()  {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try{
+            Map<String, String> workflows = airavataRegistry.getWorkflows();
+            WorkflowList workflowList = new WorkflowList();
+            List<Workflow> workflowsModels = new ArrayList<Workflow>();
+            for (String workflowName : workflows.keySet()){
+                Workflow workflow = new Workflow();
+                workflow.setWorkflowName(workflowName);
+                workflow.setWorkflowGraph(workflows.get(workflowName));
+                workflowsModels.add(workflow);
+            }
+            workflowList.setWorkflowList(workflowsModels);
+            if(workflows.size() != 0 ){
+                Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+                builder.entity(workflowList);
+                return builder.build();
+            } else {
+                Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT);
+                return builder.build();
+            }
+
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            builder.entity(e.getMessage());
+            return builder.build();
+        }
+    }
+
+
+    @GET
+    @Path("remove/workflow")
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response removeWorkflow(@QueryParam("workflowName") String workflowName) {
+        airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY);
+        try{
+            airavataRegistry.removeWorkflow(workflowName);
+            Response.ResponseBuilder builder = Response.status(Response.Status.OK);
+            return builder.build();
+        } catch (UserWorkflowDoesNotExistsException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            builder.entity(e.getMessage());
+            return builder.build();
+        } catch (RegistryException e) {
+            Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+            builder.entity(e.getMessage());
+            return builder.build();
+        }
+    }
+}



Mime
View raw message