Return-Path: X-Original-To: apmail-airavata-commits-archive@www.apache.org Delivered-To: apmail-airavata-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AD6B19566 for ; Tue, 6 Nov 2012 17:26:37 +0000 (UTC) Received: (qmail 45748 invoked by uid 500); 6 Nov 2012 17:26:37 -0000 Delivered-To: apmail-airavata-commits-archive@airavata.apache.org Received: (qmail 45701 invoked by uid 500); 6 Nov 2012 17:26:37 -0000 Mailing-List: contact commits-help@airavata.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@airavata.apache.org Delivered-To: mailing list commits@airavata.apache.org Received: (qmail 45692 invoked by uid 99); 6 Nov 2012 17:26:37 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Nov 2012 17:26:37 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Nov 2012 17:26:34 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 3556323889C5 for ; Tue, 6 Nov 2012 17:26:14 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1406232 - in /airavata/sandbox/airavata-registry-rest: ./ src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ src/main/java/org/apache/airavata/services/registry/rest/resources/ Date: Tue, 06 Nov 2012 17:26:13 -0000 To: commits@airavata.apache.org From: chathuri@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121106172614.3556323889C5@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: chathuri Date: Tue Nov 6 17:26:13 2012 New Revision: 1406232 URL: http://svn.apache.org/viewvc?rev=1406232&view=rev Log: adding workflow related methods to rest service Added: airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ExperimentDataList.java airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ExperimentDataMapping.java airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/PublishWorkflowNamesList.java airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/Workflow.java airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/WorkflowList.java Modified: airavata/sandbox/airavata-registry-rest/README.txt airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resources/RegistryResource.java Modified: airavata/sandbox/airavata-registry-rest/README.txt URL: http://svn.apache.org/viewvc/airavata/sandbox/airavata-registry-rest/README.txt?rev=1406232&r1=1406231&r2=1406232&view=diff ============================================================================== --- airavata/sandbox/airavata-registry-rest/README.txt (original) +++ airavata/sandbox/airavata-registry-rest/README.txt Tue Nov 6 17:26:13 2012 @@ -98,6 +98,16 @@ To test curl -H "Accept: text/plain" -X POST -d 'nodeID=TempConvertSoap_FahrenheitToCelsius&workflowInstanceId=ff7338c9-f9ad-4d86-b486-1e8e9c3a9cc4&data=testOutputdata' http://localhost:9080/airavata-services/registry/api/update/workflownodeoutput +****************** Experiment Data ************************************* + curl --request GET 'http://localhost:9080/airavata-services/registry/api/get/experiment?experimentId=ff7338c9-f9ad-4d86-b486-1e8e9c3a9cc4' + curl --request GET 'http://localhost:9080/airavata-services/registry/api/get/experimentId/user?username=admin' + curl --request GET 'http://localhost:9080/airavata-services/registry/api/get/experiment/user?username=admin' + curl -H "Accept: text/plain" -X POST -d 'workflowInstanceId=ff7338c9-f9ad-4d86-b486-1e8e9c3a9cc4&nodeId=TempConvertSoap_FahrenheitToCelsius&executionStatus=STARTED' http://localhost:9080/airavata-services/registry/api/update/workflownode/status + curl --request GET 'http://localhost:9080/airavata-services/registry/api/get/workflownode/status?workflowInstanceId=ff7338c9-f9ad-4d86-b486-1e8e9c3a9cc4&nodeId=TempConvertSoap_FahrenheitToCelsius' + curl --request GET 'http://localhost:9080/airavata-services/registry/api/get/workflownode/starttime?workflowInstanceId=ff7338c9-f9ad-4d86-b486-1e8e9c3a9cc4&nodeId=TempConvertSoap_FahrenheitToCelsius' + + + ********* Sample JSON message for Application and service ***************** { Added: airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ExperimentDataList.java URL: http://svn.apache.org/viewvc/airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ExperimentDataList.java?rev=1406232&view=auto ============================================================================== --- airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ExperimentDataList.java (added) +++ airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ExperimentDataList.java Tue Nov 6 17:26:13 2012 @@ -0,0 +1,44 @@ +/* + * + * 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.resourcemappings; + +import org.apache.airavata.registry.api.impl.ExperimentDataImpl; + +import javax.xml.bind.annotation.XmlRootElement; +import java.util.List; + +@XmlRootElement +public class ExperimentDataList { + private List experimentDataList; + + public ExperimentDataList() { + } + + public List getExperimentDataList() { + return experimentDataList; + } + + public void setExperimentDataList(List experimentDataList) { + this.experimentDataList = experimentDataList; + } +} + Added: airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ExperimentDataMapping.java URL: http://svn.apache.org/viewvc/airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ExperimentDataMapping.java?rev=1406232&view=auto ============================================================================== --- airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ExperimentDataMapping.java (added) +++ airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/ExperimentDataMapping.java Tue Nov 6 17:26:13 2012 @@ -0,0 +1,85 @@ +/* + * + * 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.resourcemappings; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class ExperimentDataMapping { + public String experimentID; + public String topicID; + public String user; + public String experimentMetadata; + public String experimentName; + public WorkflowInstanceMapping[] workflowInstanceMappings; + + public ExperimentDataMapping() { + } + + public void setExperimentID(String experimentID) { + this.experimentID = experimentID; + } + + public void setTopicID(String topicID) { + this.topicID = topicID; + } + + public void setUser(String user) { + this.user = user; + } + + public void setExperimentMetadata(String experimentMetadata) { + this.experimentMetadata = experimentMetadata; + } + + public void setExperimentName(String experimentName) { + this.experimentName = experimentName; + } + + public void setWorkflowInstanceMappings(WorkflowInstanceMapping[] workflowInstanceMappings) { + this.workflowInstanceMappings = workflowInstanceMappings; + } + + public String getExperimentID() { + return experimentID; + } + + public String getTopicID() { + return topicID; + } + + public String getUser() { + return user; + } + + public String getExperimentMetadata() { + return experimentMetadata; + } + + public String getExperimentName() { + return experimentName; + } + + public WorkflowInstanceMapping[] getWorkflowInstanceMappings() { + return workflowInstanceMappings; + } +} Added: airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/PublishWorkflowNamesList.java URL: http://svn.apache.org/viewvc/airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/PublishWorkflowNamesList.java?rev=1406232&view=auto ============================================================================== --- airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/PublishWorkflowNamesList.java (added) +++ airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/PublishWorkflowNamesList.java Tue Nov 6 17:26:13 2012 @@ -0,0 +1,39 @@ +/* + * + * 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.resourcemappings; + +import java.util.List; + +public class PublishWorkflowNamesList { + private List publishWorkflowNames; + + public PublishWorkflowNamesList() { + } + + public List getPublishWorkflowNames() { + return publishWorkflowNames; + } + + public void setPublishWorkflowNames(List publishWorkflowNames) { + this.publishWorkflowNames = publishWorkflowNames; + } +} Added: airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/Workflow.java URL: http://svn.apache.org/viewvc/airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/Workflow.java?rev=1406232&view=auto ============================================================================== --- airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/Workflow.java (added) +++ airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/Workflow.java Tue Nov 6 17:26:13 2012 @@ -0,0 +1,49 @@ +/* + * + * 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.resourcemappings; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class Workflow { + private String workflowName; + private String workflowGraph; + + public Workflow() { + } + + public String getWorkflowName() { + return workflowName; + } + + public String getWorkflowGraph() { + return workflowGraph; + } + + public void setWorkflowName(String workflowName) { + this.workflowName = workflowName; + } + + public void setWorkflowGraph(String workflowGraph) { + this.workflowGraph = workflowGraph; + } +} Added: airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/WorkflowList.java URL: http://svn.apache.org/viewvc/airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/WorkflowList.java?rev=1406232&view=auto ============================================================================== --- airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/WorkflowList.java (added) +++ airavata/sandbox/airavata-registry-rest/src/main/java/org/apache/airavata/services/registry/rest/resourcemappings/WorkflowList.java Tue Nov 6 17:26:13 2012 @@ -0,0 +1,41 @@ +/* + * + * 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.resourcemappings; + +import javax.xml.bind.annotation.XmlRootElement; +import java.util.List; + +@XmlRootElement +public class WorkflowList { + private List workflowList; + + public WorkflowList() { + } + + public List getWorkflowList() { + return workflowList; + } + + public void setWorkflowList(List workflowList) { + this.workflowList = workflowList; + } +} 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=1406232&r1=1406231&r2=1406232&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 17:26:13 2012 @@ -1,24 +1,17 @@ package org.apache.airavata.services.registry.rest.resources; -import org.apache.airavata.registry.api.exception.RegistryException; 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 org.apache.airavata.persistance.registry.jpa.JPAResourceAccessor; import org.apache.airavata.registry.api.*; +import org.apache.airavata.registry.api.exception.RegistryException; import org.apache.airavata.registry.api.exception.gateway.*; import org.apache.airavata.registry.api.exception.worker.*; import org.apache.airavata.registry.api.impl.ExperimentDataImpl; import org.apache.airavata.registry.api.workflow.*; -import org.apache.airavata.schemas.gfac.*; import org.apache.airavata.services.registry.rest.resourcemappings.*; -import org.apache.airavata.registry.api.AiravataExperiment; -import org.apache.airavata.services.registry.rest.resourcemappings.WorkflowInstanceMapping; -import org.apache.airavata.services.registry.rest.utils.ApplicationDescriptorTypes; import org.apache.airavata.services.registry.rest.utils.DescriptorUtil; import org.apache.airavata.services.registry.rest.utils.RestServicesConstants; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import javax.servlet.ServletContext; import javax.ws.rs.*; @@ -29,24 +22,21 @@ import java.net.URI; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.*; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; /** * RegistryResource for REST interface of Registry API - * Three objects will be retrieved from the servelet context as - * airavataRegistry, axis2Registry, dataRegistry which are - * analogues to main API interfaces of Airavata + * */ @Path("/registry/api") //public class RegistryResource implements ConfigurationRegistryService, // ProjectsRegistryService, ProvenanceRegistryService, UserWorkflowRegistryService, // PublishedWorkflowRegistryService, DescriptorRegistryService{ public class RegistryResource { - private final static Logger logger = LoggerFactory.getLogger(RegistryResource.class); - private JPAResourceAccessor jpa; - private boolean active = false; - private static final String DEFAULT_PROJECT_NAME = "default"; private AiravataRegistry2 airavataRegistry; @Context @@ -56,12 +46,6 @@ public class RegistryResource { return null; } - protected void initialize() { - airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY); - jpa = new JPAResourceAccessor(airavataRegistry); - active = true; - } - /** * ---------------------------------Configuration Registry----------------------------------* */ @@ -2091,175 +2075,635 @@ public class RegistryResource { @GET @Path("get/experiment") @Produces(MediaType.APPLICATION_XML) - public ExperimentDataImpl getExperiment(@QueryParam("experimentId") String experimentId) { + public Response getExperiment(@QueryParam("experimentId") String experimentId) { airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY); try{ ExperimentDataImpl experimentData = (ExperimentDataImpl)airavataRegistry.getExperiment(experimentId); - return experimentData; -// 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(); -// } + 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); - throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR); + Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR); + return builder.build(); } } @GET - @Path("get/experimentID/user") + @Path("get/experimentId/user") @Produces(MediaType.APPLICATION_XML) - public ExperimentIDList getExperimentIdByUser(@QueryParam("username") String username) { + public Response getExperimentIdByUser(@QueryParam("username") String username) { airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY); try{ ArrayList experiments = (ArrayList)airavataRegistry.getExperimentIdByUser(username); ExperimentIDList experimentIDList = new ExperimentIDList(); experimentIDList.setExperimentIDList(experiments); -// return experiments.toArray(new String[experiments.size()]); - return experimentIDList; -// if (experiments.size() != 0){ -// Response.ResponseBuilder builder = Response.status(Response.Status.OK); -// builder.entity(experiments); -// return builder.build(); -// } else { -// Response.ResponseBuilder builder = Response.status(Response.Status.NO_CONTENT); -// return builder.build(); -// } + + 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) { - throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR); + Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR); + return builder.build(); } } - public Response getExperimentByUser(String s) throws RegistryException { - return null; //To change body of implemented methods use File | Settings | File Templates. + @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 experimentDataList = airavataRegistry.getExperimentByUser(username); + ExperimentDataList experimentData = new ExperimentDataList(); + List experimentDatas = new ArrayList(); + 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(); + } } - public Response getExperimentByUser(String s, int i, int i1) throws RegistryException { - return null; //To change body of implemented methods use File | Settings | File Templates. + @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(); + } } - public Response updateWorkflowNodeStatus(WorkflowInstanceNodeStatus workflowInstanceNodeStatus) throws RegistryException { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - public Response updateWorkflowNodeStatus(String s, String s1, String s2) throws RegistryException { - return null; //To change body of implemented methods use File | Settings | File Templates. + @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(); + } } - public Response updateWorkflowNodeStatus(String s, String s1) throws RegistryException { - return null; //To change body of implemented methods use File | Settings | File Templates. + @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(); + } } - public Response getWorkflowNodeStatus(String s, String s1) throws RegistryException { - return null; //To change body of implemented methods use File | Settings | File Templates. + @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(); + } } - public Response getWorkflowNodeStartTime(String s, String s1) throws RegistryException { - return null; //To change body of implemented methods use File | Settings | File Templates. - } + @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(); + } - public Response getWorkflowStartTime(String s) throws RegistryException { - return null; //To change body of implemented methods use File | Settings | File Templates. } - public Response updateWorkflowNodeGramData(WorkflowNodeGramData workflowNodeGramData) throws RegistryException { - return null; //To change body of implemented methods use File | Settings | File Templates. + @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(); + } } - public Response getWorkflowInstanceData(String s) throws RegistryException { - return null; //To change body of implemented methods use File | Settings | File Templates. - } + @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(); + } - public Response isWorkflowInstanceNodePresent(String s, String s1) throws RegistryException { - return null; //To change body of implemented methods use File | Settings | File Templates. } - public Response isWorkflowInstanceNodePresent(String s, String s1, boolean b) throws RegistryException { - return null; //To change body of implemented methods use File | Settings | File Templates. - } + @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(); + } - public Response getWorkflowInstanceNodeData(String s, String s1) throws RegistryException { - return null; //To change body of implemented methods use File | Settings | File Templates. } - public Response addWorkflowInstance(String s, String s1, String s2) throws RegistryException { - return null; //To change body of implemented methods use File | Settings | File Templates. + @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(); + } } - public Response updateWorkflowNodeType(String s, String s1, String s2) throws RegistryException { - return null; //To change body of implemented methods use File | Settings | File Templates. + @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(); + } } - public Response addWorkflowInstanceNode(String s, String s1) throws RegistryException { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - public boolean isActive() { - return active; + @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(); + } } - public Response isWorkflowExists(String s) throws RegistryException { - return null; //To change body of implemented methods use File | Settings | File Templates. - } + /**---------------------------------User Workflow Registry----------------------------------**/ - public Response addWorkflow(String s, String s1) throws UserWorkflowAlreadyExistsException, RegistryException { - return null; //To change body of implemented methods use File | Settings | File Templates. + @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(); + } } - public Response updateWorkflow(String s, String s1) throws UserWorkflowDoesNotExistsException, RegistryException { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - public Response getWorkflowGraphXML(String s) throws UserWorkflowDoesNotExistsException, RegistryException { - return null; //To change body of implemented methods use File | Settings | File Templates. + @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(); + } } - public Response getWorkflows() throws RegistryException { - return null; //To change body of implemented methods use File | Settings | File Templates. + @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(); + } } - public Response getWorkflowMetadata(String s) throws RegistryException { - return null; //To change body of implemented methods use File | Settings | File Templates. + @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(); + } } - public Response removeWorkflow(String s) throws UserWorkflowDoesNotExistsException, RegistryException { - return null; //To change body of implemented methods use File | Settings | File Templates. + @GET + @Path("get/workflows") + @Produces(MediaType.TEXT_PLAIN) + public Response getWorkflows() { + airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY); + try{ + Map workflows = airavataRegistry.getWorkflows(); + WorkflowList workflowList = new WorkflowList(); + List workflowsModels = new ArrayList(); + 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(); + } } - public Response isPublishedWorkflowExists(String s) throws RegistryException { - return null; //To change body of implemented methods use File | Settings | File Templates. + + @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(); + } } - public Response publishWorkflow(String s, String s1) throws PublishedWorkflowAlreadyExistsException, UserWorkflowDoesNotExistsException, RegistryException { - return null; //To change body of implemented methods use File | Settings | File Templates. + /**---------------------------------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(); + } } - public Response publishWorkflow(String s) throws PublishedWorkflowAlreadyExistsException, UserWorkflowDoesNotExistsException, RegistryException { - return null; //To change body of implemented methods use File | Settings | File Templates. + @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(); + } } - public Response getPublishedWorkflowGraphXML(String s) throws PublishedWorkflowDoesNotExistsException, RegistryException { - return null; //To change body of implemented methods use File | Settings | File Templates. + @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(); + } } - public Response getPublishedWorkflowNames() throws RegistryException { - return null; //To change body of implemented methods use File | Settings | File Templates. + @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(); + } } - public Response getPublishedWorkflows() throws RegistryException { - return null; //To change body of implemented methods use File | Settings | File Templates. + @GET + @Path("get/publishworkflownames") + @Produces(MediaType.TEXT_PLAIN) + public Response getPublishedWorkflowNames() { + airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY); + try{ + List 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(); + } } - public Response getPublishedWorkflowMetadata(String s) throws RegistryException { - return null; //To change body of implemented methods use File | Settings | File Templates. + @GET + @Path("get/publishworkflows") + @Produces(MediaType.TEXT_PLAIN) + public Response getPublishedWorkflows() { + airavataRegistry = (AiravataRegistry2) context.getAttribute(RestServicesConstants.AIRAVATA_REGISTRY); + try{ + Map publishedWorkflows = airavataRegistry.getPublishedWorkflows(); + WorkflowList workflowList = new WorkflowList(); + List workflowsModels = new ArrayList(); + 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(); + } } - public Response removePublishedWorkflow(String s) throws PublishedWorkflowDoesNotExistsException, RegistryException { - return null; //To change body of implemented methods use File | Settings | File Templates. + @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(); + } } } +