airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chath...@apache.org
Subject svn commit: r1410008 [2/4] - in /airavata/trunk/modules/airavata-rest-client: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/airavata/ src/main/java/org/apache/airavata/rest/ src/main/java/org/apa...
Date Thu, 15 Nov 2012 21:00:43 GMT
Added: airavata/trunk/modules/airavata-rest-client/src/main/java/org/apache/airavata/rest/client/DescriptorResourceClient.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-rest-client/src/main/java/org/apache/airavata/rest/client/DescriptorResourceClient.java?rev=1410008&view=auto
==============================================================================
--- airavata/trunk/modules/airavata-rest-client/src/main/java/org/apache/airavata/rest/client/DescriptorResourceClient.java (added)
+++ airavata/trunk/modules/airavata-rest-client/src/main/java/org/apache/airavata/rest/client/DescriptorResourceClient.java Thu Nov 15 21:00:39 2012
@@ -0,0 +1,501 @@
+/*
+ *
+ * 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.rest.client;
+
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.ClientResponse;
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.api.client.config.ClientConfig;
+import com.sun.jersey.api.client.config.DefaultClientConfig;
+import com.sun.jersey.api.json.JSONConfiguration;
+import com.sun.jersey.core.util.MultivaluedMapImpl;
+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.rest.resourcemappings.*;
+import org.apache.airavata.rest.utils.DescriptorUtil;
+import org.apache.airavata.rest.utils.ResourcePathConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.UriBuilder;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class DescriptorResourceClient {
+    private WebResource webResource;
+    private final static Logger logger = LoggerFactory.getLogger(DescriptorResourceClient.class);
+
+    private URI getBaseURI() {
+        logger.info("Creating Base URI");
+        return UriBuilder.fromUri("http://localhost:9080/airavata-services/").build();
+    }
+
+    private WebResource getDescriptorRegistryBaseResource (){
+        ClientConfig config = new DefaultClientConfig();
+        config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING,
+                Boolean.TRUE);
+        Client client = Client.create(config);
+        WebResource baseWebResource = client.resource(getBaseURI());
+        webResource = baseWebResource.path(ResourcePathConstants.DecResourcePathConstants.DESC_RESOURCE_PATH);
+        return webResource;
+    }
+
+    public boolean isHostDescriptorExists(String hostDescriptorName){
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.HOST_DESC_EXISTS);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("hostDescriptorName", hostDescriptorName);
+        ClientResponse response = webResource.queryParams(queryParams).get(ClientResponse.class);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        } else {
+            return true;
+        }
+    }
+
+    public void addHostDescriptor (HostDescription hostDescription){
+        HostDescriptor hostDescriptor = DescriptorUtil.createHostDescriptor(hostDescription);
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.HOST_DESC_SAVE);
+        ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).post(ClientResponse.class, hostDescriptor);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public void updateHostDescriptor (HostDescription hostDescription){
+        HostDescriptor hostDescriptor = DescriptorUtil.createHostDescriptor(hostDescription);
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.HOST_DESC_UPDATE);
+        ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).post(ClientResponse.class, hostDescriptor);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public HostDescription getHostDescriptor (String hostName){
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.HOST_DESC);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("hostName", hostName);
+        ClientResponse response = webResource.queryParams(queryParams).accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        HostDescriptor hostDescriptor = response.getEntity(HostDescriptor.class);
+        HostDescription hostDescription = DescriptorUtil.createHostDescription(hostDescriptor);
+        return hostDescription;
+    }
+
+    public void removeHostDescriptor(String hostName){
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.HOST_DESC_DELETE);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("hostName", hostName);
+        ClientResponse response = webResource.queryParams(queryParams).delete(ClientResponse.class);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public List<HostDescription> getHostDescriptors() {
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.GET_HOST_DESCS);
+        ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        HostDescriptionList hostDescriptionList = response.getEntity(HostDescriptionList.class);
+        HostDescriptor[] hostDescriptors = hostDescriptionList.getHostDescriptions();
+        List<HostDescription> hostDescriptions = new ArrayList<HostDescription>();
+        for (HostDescriptor hostDescriptor : hostDescriptors){
+           HostDescription hostDescription = DescriptorUtil.createHostDescription(hostDescriptor);
+            hostDescriptions.add(hostDescription);
+        }
+
+        return hostDescriptions;
+    }
+
+    public List<String> getHostDescriptorNames(){
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.GET_HOST_DESCS_NAMES);
+        ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        DescriptorNameList descriptorNameList = response.getEntity(DescriptorNameList.class);
+        return descriptorNameList.getDescriptorNames();
+    }
+
+    public boolean isServiceDescriptorExists(String serviceDescriptorName){
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.SERVICE_DESC_EXISTS);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("serviceDescriptorName", serviceDescriptorName);
+        ClientResponse response = webResource.queryParams(queryParams).get(ClientResponse.class);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        } else {
+            return true;
+        }
+    }
+
+    public void addServiceDescriptor (ServiceDescription serviceDescription){
+        ServiceDescriptor serviceDescriptor = DescriptorUtil.createServiceDescriptor(serviceDescription);
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.SERVICE_DESC_SAVE);
+        ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).post(ClientResponse.class, serviceDescriptor);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public void updateServiceDescriptor(ServiceDescription serviceDescription){
+        ServiceDescriptor serviceDescriptor = DescriptorUtil.createServiceDescriptor(serviceDescription);
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.SERVICE_DESC_UPDATE);
+        ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).post(ClientResponse.class, serviceDescriptor);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public ServiceDescription getServiceDescriptor (String serviceName){
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.SERVICE_DESC);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("serviceName", serviceName);
+        ClientResponse response = webResource.queryParams(queryParams).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        ServiceDescriptor serviceDescriptor = response.getEntity(ServiceDescriptor.class);
+        ServiceDescription serviceDescription = DescriptorUtil.createServiceDescription(serviceDescriptor);
+        return serviceDescription;
+    }
+
+    public void removeServiceDescriptor(String serviceName){
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.SERVICE_DESC_DELETE);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("serviceName", serviceName);
+        ClientResponse response = webResource.queryParams(queryParams).delete(ClientResponse.class);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public List<ServiceDescription> getServiceDescriptors (){
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.GET_SERVICE_DESCS);
+        ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        ServiceDescriptionList serviceDescriptionList = response.getEntity(ServiceDescriptionList.class);
+        ServiceDescriptor[] serviceDescriptors = serviceDescriptionList.getServiceDescriptions();
+        List<ServiceDescription> serviceDescriptions = new ArrayList<ServiceDescription>();
+        for (ServiceDescriptor serviceDescriptor : serviceDescriptors){
+            ServiceDescription serviceDescription = DescriptorUtil.createServiceDescription(serviceDescriptor);
+            serviceDescriptions.add(serviceDescription);
+        }
+        return serviceDescriptions;
+    }
+
+    public boolean isApplicationDescriptorExists (String serviceName, String hostName, String appDescriptorName){
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.APPL_DESC_EXIST);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("serviceName", serviceName);
+        queryParams.add("hostName", hostName);
+        queryParams.add("appDescName", appDescriptorName);
+        ClientResponse response = webResource.queryParams(queryParams).get(ClientResponse.class);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        } else {
+            return true;
+        }
+    }
+
+    public void addApplicationDescriptor(ServiceDescription serviceDescription,
+                                         HostDescription hostDescriptor,
+                                         ApplicationDeploymentDescription descriptor){
+        ApplicationDescriptor applicationDescriptor = DescriptorUtil.createApplicationDescriptor(descriptor);
+        applicationDescriptor.setHostdescName(hostDescriptor.getType().getHostName());
+        ServiceDescriptor serviceDescriptor = DescriptorUtil.createServiceDescriptor(serviceDescription);
+        applicationDescriptor.setServiceDescriptor(serviceDescriptor);
+
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_BUILD_SAVE);
+        ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).post(ClientResponse.class, applicationDescriptor);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public void addApplicationDescriptor(String serviceName, String hostName, ApplicationDeploymentDescription descriptor){
+        ServiceDescription serviceDescription = getServiceDescriptor(serviceName);
+        ApplicationDescriptor applicationDescriptor = DescriptorUtil.createApplicationDescriptor(descriptor);
+        applicationDescriptor.setHostdescName(hostName);
+        ServiceDescriptor serviceDescriptor = DescriptorUtil.createServiceDescriptor(serviceDescription);
+        applicationDescriptor.setServiceDescriptor(serviceDescriptor);
+
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_BUILD_SAVE);
+        ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).post(ClientResponse.class, applicationDescriptor);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public void udpateApplicationDescriptor(ServiceDescription serviceDescription,
+                                            HostDescription hostDescriptor,
+                                            ApplicationDeploymentDescription descriptor){
+        ApplicationDescriptor applicationDescriptor = DescriptorUtil.createApplicationDescriptor(descriptor);
+        applicationDescriptor.setHostdescName(hostDescriptor.getType().getHostName());
+        ServiceDescriptor serviceDescriptor = DescriptorUtil.createServiceDescriptor(serviceDescription);
+        applicationDescriptor.setServiceDescriptor(serviceDescriptor);
+
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_UPDATE);
+        ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).post(ClientResponse.class, applicationDescriptor);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public void updateApplicationDescriptor(String serviceName, String hostName, ApplicationDeploymentDescription descriptor){
+        ServiceDescription serviceDescription = getServiceDescriptor(serviceName);
+        ApplicationDescriptor applicationDescriptor = DescriptorUtil.createApplicationDescriptor(descriptor);
+        applicationDescriptor.setHostdescName(hostName);
+        ServiceDescriptor serviceDescriptor = DescriptorUtil.createServiceDescriptor(serviceDescription);
+        applicationDescriptor.setServiceDescriptor(serviceDescriptor);
+
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_UPDATE);
+        ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).post(ClientResponse.class, applicationDescriptor);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public ApplicationDeploymentDescription getApplicationDescriptor(String serviceName,
+                                                                     String hostname,
+                                                                     String applicationName){
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_DESCRIPTION);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("serviceName", serviceName);
+        queryParams.add("hostName", hostname);
+        queryParams.add("applicationName", applicationName);
+
+        ClientResponse response = webResource.queryParams(queryParams).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        ApplicationDescriptor applicationDescriptor = response.getEntity(ApplicationDescriptor.class);
+        ApplicationDeploymentDescription applicationDeploymentDescription = DescriptorUtil.createApplicationDescription(applicationDescriptor);
+        return applicationDeploymentDescription;
+    }
+
+    public ApplicationDeploymentDescription getApplicationDescriptors(String serviceName, String hostname){
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_PER_HOST_SERVICE);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("serviceName", serviceName);
+        queryParams.add("hostName", hostname);
+
+        ClientResponse response = webResource.queryParams(queryParams).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        ApplicationDescriptor applicationDescriptor = response.getEntity(ApplicationDescriptor.class);
+        ApplicationDeploymentDescription applicationDeploymentDescription = DescriptorUtil.createApplicationDescription(applicationDescriptor);
+        return applicationDeploymentDescription;
+    }
+
+    public Map<String, ApplicationDeploymentDescription> getApplicationDescriptors(String serviceName){
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_ALL_DESCS_SERVICE);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("serviceName", serviceName);
+        ClientResponse response = webResource.queryParams(queryParams).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        ApplicationDescriptorList applicationDescriptorList = response.getEntity(ApplicationDescriptorList.class);
+        ApplicationDescriptor[] applicationDescriptors = applicationDescriptorList.getApplicationDescriptors();
+        Map<String, ApplicationDeploymentDescription> applicationDeploymentDescriptionMap = new HashMap<String, ApplicationDeploymentDescription>();
+        for (ApplicationDescriptor applicationDescriptor : applicationDescriptors){
+            ApplicationDeploymentDescription applicationDeploymentDescription = DescriptorUtil.createApplicationDescription(applicationDescriptor);
+            applicationDeploymentDescriptionMap.put(applicationDescriptor.getHostdescName(), applicationDeploymentDescription);
+        }
+        return applicationDeploymentDescriptionMap;
+    }
+
+    public Map<String[], ApplicationDeploymentDescription> getApplicationDescriptors(){
+        Map<String[], ApplicationDeploymentDescription> applicationDeploymentDescriptionMap = new HashMap<String[], ApplicationDeploymentDescription>();
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_ALL_DESCRIPTORS);
+        ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        ApplicationDescriptorList applicationDescriptorList = response.getEntity(ApplicationDescriptorList.class);
+        ApplicationDescriptor[] applicationDescriptors = applicationDescriptorList.getApplicationDescriptors();
+        for (ApplicationDescriptor applicationDescriptor : applicationDescriptors){
+            ApplicationDeploymentDescription applicationDeploymentDescription = DescriptorUtil.createApplicationDescription(applicationDescriptor);
+            String[] descriptors = {applicationDescriptor.getServiceDescriptor().getServiceName(), applicationDescriptor.getHostdescName()};
+            applicationDeploymentDescriptionMap.put(descriptors, applicationDeploymentDescription);
+        }
+        return applicationDeploymentDescriptionMap;
+    }
+
+    public List<String> getApplicationDescriptorNames (){
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_NAMES);
+        ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        DescriptorNameList descriptorNameList = response.getEntity(DescriptorNameList.class);
+        return descriptorNameList.getDescriptorNames();
+    }
+
+    public void removeApplicationDescriptor (String serviceName, String hostName, String applicationName){
+        webResource = getDescriptorRegistryBaseResource().path(ResourcePathConstants.DecResourcePathConstants.APP_DESC_DELETE);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("serviceName", serviceName);
+        queryParams.add("hostName", hostName);
+        queryParams.add("appName", applicationName);
+        ClientResponse response = webResource.queryParams(queryParams).accept(MediaType.TEXT_PLAIN).delete(ClientResponse.class);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+}

Added: airavata/trunk/modules/airavata-rest-client/src/main/java/org/apache/airavata/rest/client/ExperimentResourceClient.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-rest-client/src/main/java/org/apache/airavata/rest/client/ExperimentResourceClient.java?rev=1410008&view=auto
==============================================================================
--- airavata/trunk/modules/airavata-rest-client/src/main/java/org/apache/airavata/rest/client/ExperimentResourceClient.java (added)
+++ airavata/trunk/modules/airavata-rest-client/src/main/java/org/apache/airavata/rest/client/ExperimentResourceClient.java Thu Nov 15 21:00:39 2012
@@ -0,0 +1,241 @@
+/*
+ *
+ * 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.rest.client;
+
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.ClientResponse;
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.api.client.config.ClientConfig;
+import com.sun.jersey.api.client.config.DefaultClientConfig;
+import com.sun.jersey.api.json.JSONConfiguration;
+import com.sun.jersey.core.util.MultivaluedMapImpl;
+import org.apache.airavata.registry.api.AiravataExperiment;
+import org.apache.airavata.rest.resourcemappings.ExperimentList;
+import org.apache.airavata.rest.utils.ResourcePathConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.UriBuilder;
+import java.net.URI;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+public class ExperimentResourceClient {
+    private WebResource webResource;
+    private final static Logger logger = LoggerFactory.getLogger(ExperimentResourceClient.class);
+
+    private URI getBaseURI() {
+        logger.info("Creating Base URI");
+        return UriBuilder.fromUri("http://localhost:9080/airavata-services/").build();
+    }
+
+    private WebResource getExperimentRegistryBaseResource (){
+        ClientConfig config = new DefaultClientConfig();
+        config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING,
+                Boolean.TRUE);
+        Client client = Client.create(config);
+        WebResource baseWebResource = client.resource(getBaseURI());
+        webResource = baseWebResource.path(ResourcePathConstants.ExperimentResourcePathConstants.EXP_RESOURCE_PATH);
+        return webResource;
+    }
+
+    public void addExperiment(String projectName, AiravataExperiment experiment){
+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String date = dateFormat.format(experiment.getSubmittedDate());
+        webResource = getExperimentRegistryBaseResource().path(ResourcePathConstants.ExperimentResourcePathConstants.ADD_EXP);
+        MultivaluedMap formParams = new MultivaluedMapImpl();
+        formParams.add("projectName", projectName);
+        formParams.add("experimentID", experiment.getExperimentId());
+        formParams.add("submittedDate", date);
+
+        ClientResponse response = webResource.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formParams);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            String errorMsg = response.getEntity(String.class);
+            logger.error(errorMsg);
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public void removeExperiment(String experimentId){
+        webResource = getExperimentRegistryBaseResource().path(ResourcePathConstants.ExperimentResourcePathConstants.DELETE_EXP);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("experimentId", experimentId);
+        ClientResponse response = webResource.queryParams(queryParams).delete(ClientResponse.class);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public List<AiravataExperiment> getExperiments(){
+        webResource = getExperimentRegistryBaseResource().path(ResourcePathConstants.ExperimentResourcePathConstants.GET_ALL_EXPS);
+        ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            String errorMsg = response.getEntity(String.class);
+            System.out.println(errorMsg);
+            logger.error(errorMsg);
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        ExperimentList experimentList = response.getEntity(ExperimentList.class);
+        AiravataExperiment[] experiments = experimentList.getExperiments();
+        List<AiravataExperiment>  airavataExperiments = new ArrayList<AiravataExperiment>();
+        for (AiravataExperiment airavataExperiment : experiments){
+            airavataExperiments.add(airavataExperiment);
+        }
+        return airavataExperiments;
+    }
+
+    public List<AiravataExperiment> getExperiments(String projectName){
+        webResource = getExperimentRegistryBaseResource().path(ResourcePathConstants.ExperimentResourcePathConstants.GET_EXPS_BY_PROJECT);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("projectName", projectName);
+
+        ClientResponse response = webResource.queryParams(queryParams).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        ExperimentList experimentList = response.getEntity(ExperimentList.class);
+        AiravataExperiment[] experiments = experimentList.getExperiments();
+
+        List<AiravataExperiment>  airavataExperiments = new ArrayList<AiravataExperiment>();
+        for (AiravataExperiment airavataExperiment : experiments){
+            airavataExperiments.add(airavataExperiment);
+        }
+        return airavataExperiments;
+    }
+
+    public List<AiravataExperiment> getExperiments(Date from, Date to){
+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String fromDate = dateFormat.format(from);
+        String toDate = dateFormat.format(to);
+        webResource = getExperimentRegistryBaseResource().path(ResourcePathConstants.ExperimentResourcePathConstants.GET_EXPS_BY_DATE);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("fromDate", fromDate);
+        queryParams.add("toDate", toDate);
+
+        ClientResponse response = webResource.queryParams(queryParams).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        ExperimentList experimentList = response.getEntity(ExperimentList.class);
+        AiravataExperiment[] experiments = experimentList.getExperiments();
+
+        List<AiravataExperiment>  airavataExperiments = new ArrayList<AiravataExperiment>();
+        for (AiravataExperiment airavataExperiment : experiments){
+            airavataExperiments.add(airavataExperiment);
+        }
+        return airavataExperiments;
+    }
+
+    public List<AiravataExperiment> getExperiments(String projectName, Date from, Date to){
+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String fromDate = dateFormat.format(from);
+        String toDate = dateFormat.format(to);
+        webResource = getExperimentRegistryBaseResource().path(ResourcePathConstants.ExperimentResourcePathConstants.GET_EXPS_PER_PROJECT_BY_DATE);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("projectName", projectName);
+        queryParams.add("fromDate", fromDate);
+        queryParams.add("toDate", toDate);
+
+        ClientResponse response = webResource.queryParams(queryParams).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        ExperimentList experimentList = response.getEntity(ExperimentList.class);
+        AiravataExperiment[] experiments = experimentList.getExperiments();
+
+        List<AiravataExperiment>  airavataExperiments = new ArrayList<AiravataExperiment>();
+        for (AiravataExperiment airavataExperiment : experiments){
+            airavataExperiments.add(airavataExperiment);
+        }
+        return airavataExperiments;
+    }
+
+    public boolean isExperimentExists(String experimentId){
+        webResource = getExperimentRegistryBaseResource().path(ResourcePathConstants.ExperimentResourcePathConstants.EXP_EXISTS);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("experimentId", experimentId);
+        ClientResponse response = webResource.queryParams(queryParams).get(ClientResponse.class);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }else {
+            return true;
+        }
+    }
+
+    public boolean isExperimentExists(String experimentId, boolean createIfNotPresent){
+        String createStatus = "false";
+        webResource = getExperimentRegistryBaseResource().path(ResourcePathConstants.ExperimentResourcePathConstants.EXP_EXISTS_CREATE);
+        if (createIfNotPresent){
+            createStatus = "true";
+        }
+        MultivaluedMap formParams = new MultivaluedMapImpl();
+        formParams.add("experimentId", experimentId );
+        formParams.add("createIfNotPresent", createStatus );
+
+        ClientResponse response = webResource.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formParams);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }else {
+            return true;
+        }
+    }
+
+}

Added: airavata/trunk/modules/airavata-rest-client/src/main/java/org/apache/airavata/rest/client/ProjectResourceClient.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-rest-client/src/main/java/org/apache/airavata/rest/client/ProjectResourceClient.java?rev=1410008&view=auto
==============================================================================
--- airavata/trunk/modules/airavata-rest-client/src/main/java/org/apache/airavata/rest/client/ProjectResourceClient.java (added)
+++ airavata/trunk/modules/airavata-rest-client/src/main/java/org/apache/airavata/rest/client/ProjectResourceClient.java Thu Nov 15 21:00:39 2012
@@ -0,0 +1,182 @@
+/*
+ *
+ * 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.rest.client;
+
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.ClientResponse;
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.api.client.config.ClientConfig;
+import com.sun.jersey.api.client.config.DefaultClientConfig;
+import com.sun.jersey.api.json.JSONConfiguration;
+import com.sun.jersey.core.util.MultivaluedMapImpl;
+import org.apache.airavata.registry.api.WorkspaceProject;
+import org.apache.airavata.rest.resourcemappings.WorkspaceProjectList;
+import org.apache.airavata.rest.utils.ResourcePathConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.UriBuilder;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+public class ProjectResourceClient {
+    private WebResource webResource;
+    private final static Logger logger = LoggerFactory.getLogger(ProjectResourceClient.class);
+
+    private URI getBaseURI() {
+        logger.info("Creating Base URI");
+        return UriBuilder.fromUri("http://localhost:9080/airavata-services/").build();
+    }
+
+    private WebResource getProjectRegistryBaseResource (){
+        ClientConfig config = new DefaultClientConfig();
+        config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING,
+                Boolean.TRUE);
+        Client client = Client.create(config);
+        WebResource baseWebResource = client.resource(getBaseURI());
+        webResource = baseWebResource.path(ResourcePathConstants.ProjectResourcePathConstants.REGISTRY_API_PROJECTREGISTRY);
+        return webResource;
+    }
+
+    public boolean isWorkspaceProjectExists(String projectName){
+        webResource = getProjectRegistryBaseResource().path(ResourcePathConstants.ProjectResourcePathConstants.PROJECT_EXIST);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("projectName", projectName);
+        ClientResponse response = webResource.queryParams(queryParams).get(ClientResponse.class);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        } else {
+            return true;
+        }
+    }
+
+    public boolean isWorkspaceProjectExists(String projectName, boolean createIfNotExists){
+        String createStatus = "false";
+        webResource = getProjectRegistryBaseResource().path(ResourcePathConstants.ProjectResourcePathConstants.PROJECT_EXIST);
+        if (createIfNotExists){
+            createStatus = "true";
+        }
+        MultivaluedMap formParams = new MultivaluedMapImpl();
+        formParams.add("projectName", projectName );
+        formParams.add("createIfNotExists", createStatus );
+
+        ClientResponse response = webResource.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formParams);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }else {
+            return true;
+        }
+    }
+
+    public void addWorkspaceProject(String projectName){
+        webResource = getProjectRegistryBaseResource().path(ResourcePathConstants.ProjectResourcePathConstants.ADD_PROJECT);
+        MultivaluedMap formParams = new MultivaluedMapImpl();
+        formParams.add("projectName", projectName );
+
+        ClientResponse response = webResource.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formParams);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public void updateWorkspaceProject(String projectName){
+        webResource = getProjectRegistryBaseResource().path(ResourcePathConstants.ProjectResourcePathConstants.UPDATE_PROJECT);
+        MultivaluedMap formParams = new MultivaluedMapImpl();
+        formParams.add("projectName", projectName );
+
+        ClientResponse response = webResource.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formParams);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public void  deleteWorkspaceProject(String projectName){
+        webResource = getProjectRegistryBaseResource().path(ResourcePathConstants.ProjectResourcePathConstants.DELETE_PROJECT);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("projectName", projectName);
+        ClientResponse response = webResource.queryParams(queryParams).delete(ClientResponse.class);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public WorkspaceProject getWorkspaceProject(String projectName) {
+        webResource = getProjectRegistryBaseResource().path(ResourcePathConstants.ProjectResourcePathConstants.GET_PROJECT);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("projectName", projectName);
+        ClientResponse response = webResource.queryParams(queryParams).get(ClientResponse.class);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        WorkspaceProject workspaceProject = response.getEntity(WorkspaceProject.class);
+        return workspaceProject;
+    }
+
+    public List<WorkspaceProject> getWorkspaceProjects(){
+        webResource = getProjectRegistryBaseResource().path(ResourcePathConstants.ProjectResourcePathConstants.GET_PROJECTS);
+        ClientResponse response = webResource.get(ClientResponse.class);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        WorkspaceProjectList workspaceProjectList = response.getEntity(WorkspaceProjectList.class);
+        WorkspaceProject[] workspaceProjects = workspaceProjectList.getWorkspaceProjects();
+        List<WorkspaceProject> workspaceProjectsList = new ArrayList<WorkspaceProject>();
+        for (WorkspaceProject workspaceProject : workspaceProjects){
+            workspaceProjectsList.add(workspaceProject);
+        }
+        return workspaceProjectsList;
+    }
+
+}

Added: airavata/trunk/modules/airavata-rest-client/src/main/java/org/apache/airavata/rest/client/ProvenanceResourceClient.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-rest-client/src/main/java/org/apache/airavata/rest/client/ProvenanceResourceClient.java?rev=1410008&view=auto
==============================================================================
--- airavata/trunk/modules/airavata-rest-client/src/main/java/org/apache/airavata/rest/client/ProvenanceResourceClient.java (added)
+++ airavata/trunk/modules/airavata-rest-client/src/main/java/org/apache/airavata/rest/client/ProvenanceResourceClient.java Thu Nov 15 21:00:39 2012
@@ -0,0 +1,707 @@
+/*
+ *
+ * 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.rest.client;
+
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.ClientResponse;
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.api.client.config.ClientConfig;
+import com.sun.jersey.api.client.config.DefaultClientConfig;
+import com.sun.jersey.api.json.JSONConfiguration;
+import com.sun.jersey.core.util.MultivaluedMapImpl;
+import org.apache.airavata.registry.api.impl.ExperimentDataImpl;
+import org.apache.airavata.registry.api.workflow.*;
+import org.apache.airavata.rest.resourcemappings.ExperimentDataList;
+import org.apache.airavata.rest.resourcemappings.ExperimentIDList;
+import org.apache.airavata.rest.resourcemappings.WorkflowInstancesList;
+import org.apache.airavata.rest.utils.ResourcePathConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.UriBuilder;
+import java.net.URI;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+public class ProvenanceResourceClient {
+    private WebResource webResource;
+    private final static Logger logger = LoggerFactory.getLogger(ProvenanceResourceClient.class);
+
+    private URI getBaseURI() {
+        logger.info("Creating Base URI");
+        return UriBuilder.fromUri("http://localhost:9080/airavata-services/").build();
+    }
+
+    private WebResource getProvenanceRegistryBaseResource (){
+        ClientConfig config = new DefaultClientConfig();
+        config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING,
+                Boolean.TRUE);
+        Client client = Client.create(config);
+        WebResource baseWebResource = client.resource(getBaseURI());
+        webResource = baseWebResource.path(ResourcePathConstants.ProvenanceResourcePathConstants.REGISTRY_API_PROVENANCEREGISTRY);
+        return webResource;
+    }
+
+    public void updateExperimentExecutionUser(String experimentId, String user){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.UPDATE_EXPERIMENT_EXECUTIONUSER);
+        MultivaluedMap formParams = new MultivaluedMapImpl();
+        formParams.add("experimentId", experimentId);
+        formParams.add("user", user);
+        ClientResponse response = webResource.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formParams);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public String getExperimentExecutionUser(String experimentId){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.GET_EXPERIMENT_EXECUTIONUSER);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("experimentId", experimentId);
+        ClientResponse response = webResource.queryParams(queryParams).accept(MediaType.TEXT_PLAIN).get(ClientResponse.class);
+        int status = response.getStatus();
+
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        String executionUser = response.getEntity(String.class);
+        return executionUser;
+    }
+
+    public boolean isExperimentNameExist(String experimentName){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.EXPERIMENTNAME_EXISTS);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("experimentName", experimentName);
+        ClientResponse response = webResource.queryParams(queryParams).accept(MediaType.TEXT_PLAIN).get(ClientResponse.class);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+        return true;
+    }
+
+    public String getExperimentName(String experimentId){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.GET_EXPERIMENT_NAME);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("experimentId", experimentId);
+        ClientResponse response = webResource.queryParams(queryParams).accept(MediaType.TEXT_PLAIN).get(ClientResponse.class);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        String experimentName = response.getEntity(String.class);
+        return experimentName;
+    }
+
+    public void updateExperimentName(String experimentId, String experimentName){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.UPDATE_EXPERIMENTNAME);
+        MultivaluedMap formParams = new MultivaluedMapImpl();
+        formParams.add("experimentId", experimentId);
+        formParams.add("experimentName", experimentName);
+
+        ClientResponse response = webResource.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formParams);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+    }
+
+    public String getExperimentMetadata(String experimentId){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.GET_EXPERIMENTMETADATA);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("experimentId", experimentId);
+        ClientResponse response = webResource.queryParams(queryParams).accept(MediaType.TEXT_PLAIN).get(ClientResponse.class);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        String experimentMetadata = response.getEntity(String.class);
+        return experimentMetadata;
+    }
+
+    public void updateExperimentMetadata(String experimentId, String metadata){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.UPDATE_EXPERIMENTMETADATA);
+        MultivaluedMap formParams = new MultivaluedMapImpl();
+        formParams.add("experimentId", experimentId);
+        formParams.add("metadata", metadata);
+
+        ClientResponse response = webResource.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formParams);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public String getWorkflowExecutionTemplateName(String workflowInstanceId){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.GET_WORKFLOWTEMPLATENAME);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("workflowInstanceId", workflowInstanceId);
+        ClientResponse response = webResource.queryParams(queryParams).accept(MediaType.TEXT_PLAIN).get(ClientResponse.class);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        String workflowTemplateName = response.getEntity(String.class);
+        return workflowTemplateName;
+    }
+
+    public void setWorkflowInstanceTemplateName(String workflowInstanceId, String templateName){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.UPDATE_WORKFLOWINSTANCETEMPLATENAME);
+        MultivaluedMap formParams = new MultivaluedMapImpl();
+        formParams.add("workflowInstanceId", workflowInstanceId);
+        formParams.add("templateName", templateName);
+
+        ClientResponse response = webResource.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formParams);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public List<WorkflowInstance> getExperimentWorkflowInstances(String experimentId){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.GET_EXPERIMENTWORKFLOWINSTANCES);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("experimentId", experimentId);
+        ClientResponse response = webResource.queryParams(queryParams).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        WorkflowInstancesList workflowInstancesList = response.getEntity(WorkflowInstancesList.class);
+        WorkflowInstance[] workflowInstances = workflowInstancesList.getWorkflowInstances();
+        List<WorkflowInstance> workflowInstanceList = new ArrayList<WorkflowInstance>();
+
+        for (WorkflowInstance workflowInstance : workflowInstances){
+            workflowInstanceList.add(workflowInstance);
+        }
+
+        return workflowInstanceList;
+    }
+
+    public boolean isWorkflowInstanceExists(String instanceId){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.WORKFLOWINSTANCE_EXIST_CHECK);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("instanceId", instanceId);
+        ClientResponse response = webResource.queryParams(queryParams).accept(MediaType.TEXT_PLAIN).get(ClientResponse.class);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+        return true;
+    }
+
+    public boolean isWorkflowInstanceExists(String instanceId, boolean createIfNotPresent){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.WORKFLOWINSTANCE_EXIST_CREATE);
+        MultivaluedMap formParams = new MultivaluedMapImpl();
+        formParams.add("instanceId", instanceId);
+        formParams.add("createIfNotPresent", String.valueOf(createIfNotPresent));
+
+        ClientResponse response = webResource.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formParams);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+        return true;
+    }
+
+    public void updateWorkflowInstanceStatus(String instanceId, WorkflowInstanceStatus.ExecutionStatus executionStatus){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.UPDATE_WORKFLOWINSTANCESTATUS_INSTANCEID);
+        MultivaluedMap formParams = new MultivaluedMapImpl();
+        formParams.add("instanceId", instanceId);
+        formParams.add("executionStatus", executionStatus.name());
+
+        ClientResponse response = webResource.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formParams);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public void updateWorkflowInstanceStatus(WorkflowInstanceStatus workflowInstanceStatus){
+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String statusUpdateDate = dateFormat.format(workflowInstanceStatus.getStatusUpdateTime());
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.UPDATE_WORKFLOWINSTANCESTATUS);
+        MultivaluedMap formParams = new MultivaluedMapImpl();
+        formParams.add("workflowInstanceId", workflowInstanceStatus.getWorkflowInstance().getWorkflowInstanceId());
+        formParams.add("executionStatus", workflowInstanceStatus.getExecutionStatus().name());
+        formParams.add("statusUpdateTime", statusUpdateDate);
+
+        ClientResponse response = webResource.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formParams);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public WorkflowInstanceStatus getWorkflowInstanceStatus(String instanceId){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.GET_WORKFLOWINSTANCESTATUS);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("instanceId", instanceId);
+        ClientResponse response = webResource.queryParams(queryParams).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        WorkflowInstanceStatus workflowInstanceStatus = response.getEntity(WorkflowInstanceStatus.class);
+        return workflowInstanceStatus;
+    }
+
+    public void updateWorkflowNodeInput(WorkflowInstanceNode node, String data){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.UPDATE_WORKFLOWNODEINPUT);
+        MultivaluedMap formParams = new MultivaluedMapImpl();
+        formParams.add("nodeID", node.getNodeId());
+        formParams.add("workflowInstanceId", node.getWorkflowInstance().getWorkflowInstanceId());
+        formParams.add("data", data);
+
+        ClientResponse response = webResource.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formParams);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public void updateWorkflowNodeOutput(WorkflowInstanceNode node, String data){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.UPDATE_WORKFLOWNODEOUTPUT);
+        MultivaluedMap formParams = new MultivaluedMapImpl();
+        formParams.add("nodeID", node.getNodeId());
+        formParams.add("workflowInstanceId", node.getWorkflowInstance().getWorkflowInstanceId());
+        formParams.add("data", data);
+
+        ClientResponse response = webResource.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formParams);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public ExperimentData getExperiment(String experimentId){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.GET_EXPERIMENT);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("experimentId", experimentId);
+        ClientResponse response = webResource.queryParams(queryParams).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        ExperimentDataImpl experimentData = response.getEntity(ExperimentDataImpl.class);
+        return experimentData;
+    }
+
+    public ExperimentData getExperimentMetaInformation(String experimentId){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.GET_EXPERIMENT_METAINFORMATION);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("experimentId", experimentId);
+        ClientResponse response = webResource.queryParams(queryParams).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        ExperimentDataImpl experimentData = response.getEntity(ExperimentDataImpl.class);
+        return experimentData;
+    }
+
+    public List<ExperimentData> getAllExperimentMetaInformation(String user){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.GET_ALL_EXPERIMENT_METAINFORMATION);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("user", user);
+        ClientResponse response = webResource.queryParams(queryParams).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        ExperimentDataList experimentDataList = response.getEntity(ExperimentDataList.class);
+        List<ExperimentDataImpl> dataList = experimentDataList.getExperimentDataList();
+        List<ExperimentData> experimentDatas = new ArrayList<ExperimentData>();
+        for (ExperimentDataImpl experimentData : dataList){
+            experimentDatas.add(experimentData);
+        }
+        return experimentDatas;
+    }
+
+    public List<ExperimentData> searchExperiments(String user, String experimentNameRegex){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.SEARCH_EXPERIMENTS);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("user", user);
+        queryParams.add("experimentNameRegex", experimentNameRegex);
+        ClientResponse response = webResource.queryParams(queryParams).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        ExperimentDataList experimentDataList = response.getEntity(ExperimentDataList.class);
+        List<ExperimentDataImpl> dataList = experimentDataList.getExperimentDataList();
+        List<ExperimentData> experimentDatas = new ArrayList<ExperimentData>();
+        for (ExperimentDataImpl experimentData : dataList){
+            experimentDatas.add(experimentData);
+        }
+        return experimentDatas;
+    }
+
+    public List<String> getExperimentIdByUser(String user){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.GET_EXPERIMENT_ID_USER);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("username", user);
+        ClientResponse response = webResource.queryParams(queryParams).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        ExperimentIDList experimentIDList = response.getEntity(ExperimentIDList.class);
+        List<String> experimentIDs = experimentIDList.getExperimentIDList();
+        return experimentIDs;
+    }
+
+    public List<ExperimentData> getExperimentByUser(String user){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.GET_EXPERIMENT_USER);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("username", user);
+        ClientResponse response = webResource.queryParams(queryParams).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+        ExperimentDataList experimentDataList = response.getEntity(ExperimentDataList.class);
+        List<ExperimentDataImpl> dataList = experimentDataList.getExperimentDataList();
+        List<ExperimentData> experimentDatas = new ArrayList<ExperimentData>();
+        for (ExperimentDataImpl experimentData : dataList){
+            experimentDatas.add(experimentData);
+        }
+        return experimentDatas;
+    }
+
+    public void updateWorkflowNodeStatus(WorkflowInstanceNodeStatus workflowStatusNode){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.UPDATE_WORKFLOWNODE_STATUS);
+        MultivaluedMap formParams = new MultivaluedMapImpl();
+        formParams.add("workflowInstanceId", workflowStatusNode.getWorkflowInstanceNode().getWorkflowInstance().getWorkflowInstanceId());
+        formParams.add("nodeId", workflowStatusNode.getWorkflowInstanceNode().getNodeId());
+        formParams.add("executionStatus", workflowStatusNode.getExecutionStatus().name());
+
+        ClientResponse response = webResource.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formParams);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public void updateWorkflowNodeStatus(String workflowInstanceId, String nodeId, WorkflowInstanceStatus.ExecutionStatus executionStatus){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.UPDATE_WORKFLOWNODE_STATUS);
+        MultivaluedMap formParams = new MultivaluedMapImpl();
+        formParams.add("workflowInstanceId", workflowInstanceId);
+        formParams.add("nodeId", nodeId);
+        formParams.add("executionStatus", executionStatus.name());
+
+        ClientResponse response = webResource.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formParams);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public void updateWorkflowNodeStatus(WorkflowInstanceNode workflowNode, WorkflowInstanceStatus.ExecutionStatus executionStatus){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.UPDATE_WORKFLOWNODE_STATUS);
+        MultivaluedMap formParams = new MultivaluedMapImpl();
+        formParams.add("workflowInstanceId", workflowNode.getWorkflowInstance().getWorkflowInstanceId());
+        formParams.add("nodeId", workflowNode.getNodeId());
+        formParams.add("executionStatus", executionStatus.name());
+
+        ClientResponse response = webResource.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formParams);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public WorkflowInstanceNodeStatus getWorkflowNodeStatus(WorkflowInstanceNode workflowNode){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.GET_WORKFLOWNODE_STATUS);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("workflowInstanceId", workflowNode.getWorkflowInstance().getWorkflowInstanceId());
+        queryParams.add("nodeId", workflowNode.getNodeId());
+        ClientResponse response = webResource.queryParams(queryParams).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        WorkflowInstanceNodeStatus workflowInstanceNodeStatus = response.getEntity(WorkflowInstanceNodeStatus.class);
+        return workflowInstanceNodeStatus;
+    }
+
+    public Date getWorkflowNodeStartTime(WorkflowInstanceNode workflowNode){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.GET_WORKFLOWNODE_STARTTIME);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("workflowInstanceId", workflowNode.getWorkflowInstance().getWorkflowInstanceId());
+        queryParams.add("nodeId", workflowNode.getNodeId());
+        ClientResponse response = webResource.queryParams(queryParams).accept(MediaType.TEXT_PLAIN).get(ClientResponse.class);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        String wfNodeStartTime = response.getEntity(String.class);
+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        try {
+            Date formattedDate = dateFormat.parse(wfNodeStartTime);
+            return formattedDate;
+        } catch (ParseException e) {
+            logger.error("Error in date format...", e);
+            return null;
+        }
+    }
+
+    public Date getWorkflowStartTime(WorkflowInstance workflowInstance){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.GET_WORKFLOW_STARTTIME);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("workflowInstanceId", workflowInstance.getWorkflowInstanceId());
+        ClientResponse response = webResource.queryParams(queryParams).accept(MediaType.TEXT_PLAIN).get(ClientResponse.class);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        String wfStartTime = response.getEntity(String.class);
+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        try {
+            Date formattedDate = dateFormat.parse(wfStartTime);
+            return formattedDate;
+        } catch (ParseException e) {
+            logger.error("Error in date format...", e);
+            return null;
+        }
+    }
+
+    public void updateWorkflowNodeGramData(WorkflowNodeGramData workflowNodeGramData){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.UPDATE_WORKFLOWNODE_GRAMDATA);
+        ClientResponse response = webResource.accept(MediaType.TEXT_PLAIN).type(MediaType.APPLICATION_JSON).post(ClientResponse.class, workflowNodeGramData);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public WorkflowInstanceData getWorkflowInstanceData(String workflowInstanceId){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.GET_WORKFLOWINSTANCEDATA);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("workflowInstanceId", workflowInstanceId);
+        ClientResponse response = webResource.queryParams(queryParams).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        WorkflowInstanceData workflowInstanceData = response.getEntity(WorkflowInstanceData.class);
+        return workflowInstanceData;
+    }
+
+    public boolean isWorkflowInstanceNodePresent(String workflowInstanceId, String nodeId){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.WORKFLOWINSTANCE_NODE_EXIST);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("workflowInstanceId", workflowInstanceId);
+        queryParams.add("nodeId", nodeId);
+        ClientResponse response = webResource.queryParams(queryParams).accept(MediaType.TEXT_PLAIN).get(ClientResponse.class);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+        return true;
+    }
+
+    public boolean isWorkflowInstanceNodePresent(String workflowInstanceId, String nodeId, boolean createIfNotPresent){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.WORKFLOWINSTANCE_NODE_EXIST_CREATE);
+        MultivaluedMap formParams = new MultivaluedMapImpl();
+        formParams.add("workflowInstanceId", workflowInstanceId);
+        formParams.add("nodeId", nodeId);
+        formParams.add("createIfNotPresent", String.valueOf(createIfNotPresent));
+        ClientResponse response = webResource.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formParams);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+        return true;
+    }
+
+    public WorkflowInstanceNodeData getWorkflowInstanceNodeData(String workflowInstanceId, String nodeId){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.WORKFLOWINSTANCE_NODE_DATA);
+        MultivaluedMap queryParams = new MultivaluedMapImpl();
+        queryParams.add("workflowInstanceId", workflowInstanceId);
+        queryParams.add("nodeId", nodeId);
+        ClientResponse response = webResource.queryParams(queryParams).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+
+        WorkflowInstanceNodeData workflowInstanceNodeData = response.getEntity(WorkflowInstanceNodeData.class);
+        return workflowInstanceNodeData;
+    }
+
+    public void addWorkflowInstance(String experimentId, String workflowInstanceId, String templateName){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.ADD_WORKFLOWINSTANCE);
+        MultivaluedMap formParams = new MultivaluedMapImpl();
+        formParams.add("experimentId", experimentId);
+        formParams.add("workflowInstanceId", workflowInstanceId);
+        formParams.add("templateName", templateName);
+
+        ClientResponse response = webResource.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formParams);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public void updateWorkflowNodeType(WorkflowInstanceNode node, WorkflowNodeType type){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.UPDATE_WORKFLOWNODETYPE);
+        MultivaluedMap formParams = new MultivaluedMapImpl();
+        formParams.add("workflowInstanceId", node.getWorkflowInstance().getWorkflowInstanceId());
+        formParams.add("nodeId", node.getNodeId());
+        formParams.add("nodeType", type.getNodeType().name());
+
+        ClientResponse response = webResource.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formParams);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public void addWorkflowInstanceNode(String workflowInstance, String nodeId){
+        webResource = getProvenanceRegistryBaseResource().path(ResourcePathConstants.ProvenanceResourcePathConstants.ADD_WORKFLOWINSTANCENODE);
+        MultivaluedMap formParams = new MultivaluedMapImpl();
+        formParams.add("workflowInstanceId", workflowInstance);
+        formParams.add("nodeId", nodeId);
+
+        ClientResponse response = webResource.accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, formParams);
+        int status = response.getStatus();
+        if (status != 200) {
+            logger.error(response.getEntity(String.class));
+            throw new RuntimeException("Failed : HTTP error code : "
+                    + status);
+        }
+    }
+
+    public List<WorkflowNodeIOData> searchWorkflowInstanceNodeInput(String experimentIdRegEx, String workflowNameRegEx, String nodeNameRegEx)  {
+        //not implemented in Registry API
+        return null;
+    }
+
+    public List<WorkflowNodeIOData> searchWorkflowInstanceNodeOutput(String experimentIdRegEx, String workflowNameRegEx, String nodeNameRegEx)  {
+        //not implemented in Registry API
+        return null;
+    }
+
+    public List<ExperimentData> getExperimentByUser(String user, int pageSize, int pageNo) {
+        //not implemented in Registry API
+        return null;
+    }
+
+
+
+}



Mime
View raw message