airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ami...@apache.org
Subject svn commit: r1425176 - in /airavata/trunk/modules: airavata-client/src/main/java/org/apache/airavata/client/ airavata-client/src/main/java/org/apache/airavata/client/api/ airavata-client/src/main/java/org/apache/airavata/client/api/builder/ airavata-cl...
Date Fri, 21 Dec 2012 23:04:24 GMT
Author: amilaj
Date: Fri Dec 21 23:04:23 2012
New Revision: 1425176

URL: http://svn.apache.org/viewvc?rev=1425176&view=rev
Log:
Fixing AIRAVATA-683

Added:
    airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/DescriptorRecordAlreadyExistsException.java
    airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/builder/
    airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/builder/DescriptorBuilder.java
Modified:
    airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataClient.java
    airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/AiravataAPI.java
    airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/ApplicationManager.java
    airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/ApplicationManagerImpl.java
    airavata/trunk/modules/integration-tests/src/test/java/org/apache/airavata/integration/BaseCaseIT.java

Modified: airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataClient.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataClient.java?rev=1425176&r1=1425175&r2=1425176&view=diff
==============================================================================
--- airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataClient.java
(original)
+++ airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/AiravataClient.java
Fri Dec 21 23:04:23 2012
@@ -56,6 +56,7 @@ import org.apache.airavata.client.api.Ex
 import org.apache.airavata.client.api.ProvenanceManager;
 import org.apache.airavata.client.api.UserManager;
 import org.apache.airavata.client.api.WorkflowManager;
+import org.apache.airavata.client.api.builder.DescriptorBuilder;
 import org.apache.airavata.client.impl.AiravataManagerImpl;
 import org.apache.airavata.client.impl.ApplicationManagerImpl;
 import org.apache.airavata.client.impl.ExecutionManagerImpl;
@@ -1014,7 +1015,12 @@ public class AiravataClient extends Obse
 		return API_VERSION;
 	}
 
-	public void setCurrentUser(String currentUser) {
+    @Override
+    public DescriptorBuilder getDescriptorBuilder() {
+        return new DescriptorBuilder();
+    }
+
+    public void setCurrentUser(String currentUser) {
 		this.currentUser = currentUser;
 	}
 

Modified: airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/AiravataAPI.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/AiravataAPI.java?rev=1425176&r1=1425175&r2=1425176&view=diff
==============================================================================
--- airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/AiravataAPI.java
(original)
+++ airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/AiravataAPI.java
Fri Dec 21 23:04:23 2012
@@ -21,6 +21,7 @@
 
 package org.apache.airavata.client.api;
 
+import org.apache.airavata.client.api.builder.DescriptorBuilder;
 import org.apache.airavata.common.utils.Version;
 
 
@@ -77,4 +78,11 @@ public interface AiravataAPI {
 	 */
 	public Version getVersion();
 
+    /**
+     * Gets the DescriptorBuilder. DescriptorBuilder is a helper class to create various
descriptors.
+     * E.g :- Build HostDescriptors, ServiceDescriptors etc ...
+     * @return DescriptorBuilder.
+     */
+    public DescriptorBuilder getDescriptorBuilder();
+
 }
\ No newline at end of file

Modified: airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/ApplicationManager.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/ApplicationManager.java?rev=1425176&r1=1425175&r2=1425176&view=diff
==============================================================================
--- airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/ApplicationManager.java
(original)
+++ airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/ApplicationManager.java
Fri Dec 21 23:04:23 2012
@@ -27,7 +27,6 @@ import java.util.Map;
 import org.apache.airavata.commons.gfac.type.ApplicationDeploymentDescription;
 import org.apache.airavata.commons.gfac.type.HostDescription;
 import org.apache.airavata.commons.gfac.type.ServiceDescription;
-import org.apache.airavata.registry.api.exception.RegistryException;
 
 public interface ApplicationManager {
 	//Service descriptors
@@ -49,13 +48,36 @@ public interface ApplicationManager {
 
     /**
      * Save service description on registry
-     * @param service
-     * @return
-     * @throws AiravataAPIInvocationException
+     * @param service Service description information to update.
+     * @return The service descriptor name.
+     * @deprecated Deprecated since 0.6 release. User {@see #addServiceDescription} and {@see
#updateServiceDescription}
+     *             methods instead.
+     * @throws AiravataAPIInvocationException If an error occurred while updating service
descriptor.
      */
+    @Deprecated
     public String saveServiceDescription(ServiceDescription service)throws AiravataAPIInvocationException;
 
     /**
+     * Adds a new Service descriptor to the system. If service descriptor already exists
in the system
+     * this will throw {@see DescriptorRecordAlreadyExistsException}. If you want to update
an existing
+     * service descriptor use {@see #updateServiceDescription}.
+     * @param serviceDescription The service descriptor.
+     * @throws AiravataAPIInvocationException If an error occurred while adding service description.
+     * @throws DescriptorRecordAlreadyExistsException If service descriptor already exists
in the system.
+     */
+    public void addServiceDescription(ServiceDescription serviceDescription)throws AiravataAPIInvocationException,
+            DescriptorRecordAlreadyExistsException;
+
+    /**
+     * Updates the service descriptor.
+     * @param serviceDescription Service description information to update.
+     * @throws AiravataAPIInvocationException If an error occurred while updating service
description.
+     */
+    public void updateServiceDescription(ServiceDescription serviceDescription)throws AiravataAPIInvocationException;
+
+
+
+    /**
      * Delete service description from the registry
      * @param serviceName
      * @throws AiravataAPIInvocationException
@@ -83,14 +105,44 @@ public interface ApplicationManager {
 
     /**
      * Save deployment description on registry for a given service for a host
-     * @param serviceId
-     * @param hostId
-     * @param app
-     * @return
-     * @throws AiravataAPIInvocationException
+     * @param serviceId The service descriptor id.
+     * @param hostId The host descriptor id.
+     * @param app The application deployment descriptor.
+     * @return The application deployment descriptor name.
+     * @deprecated Deprecated since 0.6 release. Please use {@see #addDeploymentDescription}
and
+     *              {@see #updateDeploymentDescription}.
+     * @throws AiravataAPIInvocationException If an error occurred while adding application
deployment descriptor.
      */
+    @Deprecated
     public String saveDeploymentDescription(String serviceId, String hostId, ApplicationDeploymentDescription
app)throws AiravataAPIInvocationException;
 
+
+    /**
+     * Adds a new deployment description associating with given service description and given
host description. If
+     * an association already exists this will throw {@see DescriptorRecordAlreadyExistsException}
exception. If you
+     * want to update an existing deployment descriptor use {@see #updateDeploymentDescription}.
+     * @param serviceDescription The service description to associate. Should be saved before
passing to this method.
+     * @param hostDescription The host description to associate, should have been saved before
calling this method.
+     * @param applicationDeploymentDescription The application descriptor to save.
+     * @throws AiravataAPIInvocationException If an error occurred while saving application
descriptor.
+     * @throws DescriptorRecordAlreadyExistsException If deployment descriptor already exists
in the system.
+     */
+    public void addDeploymentDescription(ServiceDescription serviceDescription, HostDescription
hostDescription,
+                                         ApplicationDeploymentDescription applicationDeploymentDescription)
+        throws AiravataAPIInvocationException, DescriptorRecordAlreadyExistsException;
+
+    /**
+     * Adds a new deployment description associating with given service description and given
host description. If
+     * an association already exists this will throw {@see DescriptorRecordAlreadyExistsException}
exception.
+     * @param serviceDescription The service description to associate. Should be saved before
passing to this method.
+     * @param hostDescription The host description to associate, should have been saved before
calling this method.
+     * @param applicationDeploymentDescription The application descriptor to save.
+     * @throws AiravataAPIInvocationException If an error occurred while saving application
descriptor.
+     */
+    public void updateDeploymentDescription(ServiceDescription serviceDescription, HostDescription
hostDescription,
+                                         ApplicationDeploymentDescription applicationDeploymentDescription)
+            throws AiravataAPIInvocationException;
+
     /**
      * Retrieve list of registered deployment descriptions of the given regex service name
& regex host name
      * @param serviceName
@@ -153,12 +205,35 @@ public interface ApplicationManager {
 
     /**
      * Save host description on registry
-     * @param host
-     * @return
-     * @throws AiravataAPIInvocationException
+     * @param host The host descriptor object to update in the database.
+     * @deprecated Deprecated since 0.6 release. Please use {@see #addHostDescription} and
{@see #updateHostDescription}
+     * @throws AiravataAPIInvocationException If an error occurred while saving the host
description.
      */
+    @Deprecated
     public String saveHostDescription(HostDescription host)throws AiravataAPIInvocationException;
 
+
+    /**
+     * Adds a new host descriptor object. If adding host descriptor already exists in the
system this will throw
+     * DescriptorRecordAlreadyExistsException. If user wants to update an existing host descriptor
use
+     * {@see #updateHostDescription(HostDescription host)} method.
+     * @param host The host descriptor object to save in the database.
+     * @throws AiravataAPIInvocationException If an error occurred while saving the host
description.
+     * @throws DescriptorRecordAlreadyExistsException If host descriptor object already exists
in the system.
+     */
+    public void addHostDescription (HostDescription host) throws AiravataAPIInvocationException,
+            DescriptorRecordAlreadyExistsException;
+
+
+    /**
+     * Updates an existing host descriptor. If you are not sure whether descriptor already
exists try using
+     * {@see #addHostDescription} and catch {@see DescriptorRecordAlreadyExistsException}.
If caught use this method
+     * to update the record.
+     * @param host The host descriptor object to update in the database.
+     * @throws AiravataAPIInvocationException If an error occurred while saving the host
description.
+     */
+    public void updateHostDescription(HostDescription host)throws AiravataAPIInvocationException;
+
     /**
      * Retrieve a list of registered hsot descriptions of the given regex host name
      * @param regExName

Added: airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/DescriptorRecordAlreadyExistsException.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/DescriptorRecordAlreadyExistsException.java?rev=1425176&view=auto
==============================================================================
--- airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/DescriptorRecordAlreadyExistsException.java
(added)
+++ airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/DescriptorRecordAlreadyExistsException.java
Fri Dec 21 23:04:23 2012
@@ -0,0 +1,21 @@
+package org.apache.airavata.client.api;
+
+/**
+ * If a saving descriptor already found in the system this exception will be thrown.
+ */
+public class DescriptorRecordAlreadyExistsException extends Exception {
+
+    private static final long serialVersionUID = 1231L;
+
+    public DescriptorRecordAlreadyExistsException(Throwable e) {
+        super(e);
+    }
+    public DescriptorRecordAlreadyExistsException(String message) {
+        super(message, null);
+    }
+
+    public DescriptorRecordAlreadyExistsException(String message, Throwable e) {
+        super(message, e);
+    }
+
+}

Added: airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/builder/DescriptorBuilder.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/builder/DescriptorBuilder.java?rev=1425176&view=auto
==============================================================================
--- airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/builder/DescriptorBuilder.java
(added)
+++ airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/api/builder/DescriptorBuilder.java
Fri Dec 21 23:04:23 2012
@@ -0,0 +1,187 @@
+package org.apache.airavata.client.api.builder;
+
+import org.apache.airavata.client.api.AiravataAPIInvocationException;
+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.schemas.gfac.*;
+import org.apache.xmlbeans.SchemaType;
+
+import java.util.List;
+
+/**
+ * This class provides set of utility methods to create descriptors. Following descriptors
are
+ * included.
+ * <ol>
+ *     <li>HostDescription - org.apache.airavata.commons.gfac.type.HostDescription</li>
+ * </ol>
+ */
+public class DescriptorBuilder {
+
+    private static final String IP_ADDRESS_VALIDATION_STRING
+            = "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$";
+
+    private static final String HOST_NAME_VALIDATION_STRING
+            = "^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9])$";
+
+
+    /**
+     * Builds a host descriptor object. Host descriptor gives information about application
+     * hosted machine.
+     * @param type The host type. Following types are available at the moment.
+     *             <ol>
+     *             <li>org.apache.airavata.schemas.gfac.GlobusHostType</li>
+     *             <li>org.apache.airavata.schemas.gfac.Ec2HostType</li>
+     *             <li>org.apache.airavata.schemas.gfac.GsisshHostType</li>
+     *             <li>org.apache.airavata.schemas.gfac.UnicoreHostType</li>
+     *             </ol>
+     * @param hostName An unique id given to hosted machine. This could be any name. But
should be unique across the
+     *                 workflow.
+     * @param hostAddress This is the IP address where application is running. This should
be a valid IP address or
+     *                    valid host name.
+     * @return The org.apache.airavata.commons.gfac.type.HostDescription object.
+     * @throws AiravataAPIInvocationException If provided host address does not comply with
IP address format or
+     *          host name format.
+     */
+    public HostDescription buildHostDescription (HostDescriptionType type, String hostName,
String hostAddress)
+            throws AiravataAPIInvocationException{
+
+        return buildHostDescription(type.schemaType(), hostName, hostAddress);
+
+    }
+
+    /**
+     * Builds a host descriptor object. Host descriptor gives information about application
+     * hosted machine.
+     * @param schemaType The host type as per the schema. All available schema types are
listed
+     *                   in org.apache.xmlbeans.SchemaType
+     * @param hostName An unique id given to hosted machine. This could be any name. But
should be unique across the
+     *                 workflow.
+     * @param hostAddress This is the IP address where application is running. This should
be a valid IP address or
+     *                    valid host name.
+     * @return The org.apache.airavata.commons.gfac.type.HostDescription object.
+     * @throws AiravataAPIInvocationException If provided host address does not comply with
IP address format or
+     *          host name format.
+     */
+    public HostDescription buildHostDescription (SchemaType schemaType, String hostName,
String hostAddress)
+            throws AiravataAPIInvocationException{
+
+        if (!validateHostAddress(hostAddress)) {
+            throw new AiravataAPIInvocationException("Invalid host address. Host address
should be " +
+                    "either an IP address or a valid host name.");
+        }
+
+        HostDescription hostDescription = new HostDescription(schemaType);
+        hostDescription.getType().setHostName(hostName);
+        hostDescription.getType().setHostAddress(hostAddress);
+
+        return hostDescription;
+
+    }
+
+    /**
+     * Create an input parameter.
+     * @param parameterName The input parameter name.
+     * @param parameterDescription A short description about the input parameter.
+     * @param parameterDataType Input parameter type. E.g :- String, Integer etc ..
+     *                          All possible types are define in DataType.Enum class.
+     *                          E.g :- DataType.String
+     * @see org.apache.airavata.schemas.gfac.DataType.Enum
+     * @return Encapsulating InputParameterType object.
+     */
+    public InputParameterType buildInputParameterType (String parameterName, String parameterDescription,
+                                                  DataType.Enum parameterDataType) {
+
+        InputParameterType parameter = InputParameterType.Factory.newInstance();
+        parameter.setParameterName(parameterName);
+        parameter.setParameterDescription(parameterDescription);
+
+        ParameterType parameterType = parameter.addNewParameterType();
+        parameterType.setType(parameterDataType);
+        parameterType.setName(parameterDataType.toString());
+
+        return parameter;
+
+    }
+
+    /**
+     * Create an input parameter.
+     * @param parameterName The input parameter name.
+     * @param parameterDescription A short description about the input parameter.
+     * @param parameterDataType Input parameter type. E.g :- String, Integer etc ..
+     *                          All possible types are define in DataType.Enum class.
+     *                          E.g :- DataType.String
+     * @see org.apache.airavata.schemas.gfac.DataType.Enum
+     * @return Encapsulating InputParameterType object.
+     */
+    public OutputParameterType buildOutputParameterType (String parameterName, String parameterDescription,
+                                                  DataType.Enum parameterDataType) {
+
+        OutputParameterType parameter = OutputParameterType.Factory.newInstance();
+        parameter.setParameterName(parameterName);
+        parameter.setParameterDescription(parameterDescription);
+
+        ParameterType parameterType = parameter.addNewParameterType();
+        parameterType.setType(parameterDataType);
+        parameterType.setName(parameterDataType.toString());
+
+        return parameter;
+
+    }
+
+    /**
+     * Creates a ServiceDescription object. This includes information about the service.
Mainly we
+     * are focusing on following details about the service.
+     * <ol>
+     *     <li>A name for service</li>
+     *     <li>A short description about the service</li>
+     *     <li>A what are input data types</li>
+     *     <li>A what are output data types</li>
+     * </ol>
+     * @param serviceName Name of the service.
+     * @param description A short description about the service.
+     * @param inputParameterTypes Input parameter types.
+     * @param outputParameterTypes Output parameter types.
+     * @return A ServiceDescription object with above information encapsulated.
+     */
+    public ServiceDescription buildServiceDescription (String serviceName, String description,
+                                                       List<InputParameterType> inputParameterTypes,
+                                                       List<OutputParameterType> outputParameterTypes)
{
+
+        ServiceDescription serviceDescription = new ServiceDescription();
+        serviceDescription.getType().setName(serviceName);
+        serviceDescription.getType().setDescription(description);
+
+
+        serviceDescription.getType().
+                setInputParametersArray(inputParameterTypes.toArray(
+                        new InputParameterType[inputParameterTypes.size()]));
+        serviceDescription.getType().
+                setOutputParametersArray(outputParameterTypes.toArray(
+                        new OutputParameterType[outputParameterTypes.size()]));
+
+        return serviceDescription;
+
+    }
+
+    public ApplicationDeploymentDescription buildApplicationDeploymentDescription (String
applicationName,
+                                                                                   String
executablePath,
+                                                                                   String
workingDirectory) {
+
+        ApplicationDeploymentDescription applicationDeploymentDescription = new ApplicationDeploymentDescription();
+        ApplicationDeploymentDescriptionType applicationDeploymentDescriptionType
+                = applicationDeploymentDescription.getType();
+        applicationDeploymentDescriptionType.addNewApplicationName().setStringValue(applicationName);
+        applicationDeploymentDescriptionType.setExecutableLocation(executablePath);
+        applicationDeploymentDescriptionType.setScratchWorkingDirectory(workingDirectory);
+
+        return applicationDeploymentDescription;
+
+    }
+
+
+
+    private boolean validateHostAddress(String hostAddress) {
+        return hostAddress.matches(IP_ADDRESS_VALIDATION_STRING) || hostAddress.matches(HOST_NAME_VALIDATION_STRING);
+    }
+}

Modified: airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/ApplicationManagerImpl.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/ApplicationManagerImpl.java?rev=1425176&r1=1425175&r2=1425176&view=diff
==============================================================================
--- airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/ApplicationManagerImpl.java
(original)
+++ airavata/trunk/modules/airavata-client/src/main/java/org/apache/airavata/client/impl/ApplicationManagerImpl.java
Fri Dec 21 23:04:23 2012
@@ -29,10 +29,14 @@ import java.util.Map;
 import org.apache.airavata.client.AiravataClient;
 import org.apache.airavata.client.api.AiravataAPIInvocationException;
 import org.apache.airavata.client.api.ApplicationManager;
+import org.apache.airavata.client.api.DescriptorRecordAlreadyExistsException;
+import org.apache.airavata.common.exception.AiravataConfigurationException;
 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.registry.api.exception.RegistryException;
 import org.apache.airavata.registry.api.exception.UnimplementedRegistryOperationException;
+import org.apache.airavata.registry.api.exception.gateway.DescriptorAlreadyExistsException;
 
 public class ApplicationManagerImpl implements ApplicationManager {
 	private AiravataClient client;
@@ -81,7 +85,43 @@ public class ApplicationManagerImpl impl
 		}
 	}
 
-	@Override
+    @Override
+    public void addServiceDescription(ServiceDescription serviceDescription) throws AiravataAPIInvocationException,
+            DescriptorRecordAlreadyExistsException {
+        try {
+            getClient().getRegistryClient().addServiceDescriptor(serviceDescription);
+        } catch (DescriptorAlreadyExistsException e) {
+            throw new DescriptorRecordAlreadyExistsException("Service descriptor "
+                    + serviceDescription.getType().getName()
+                    + " already exists.", e);
+        } catch (RegistryException e) {
+            throw new AiravataAPIInvocationException("An internal error occurred while trying
to add service descriptor"
+                    + serviceDescription.getType().getName(),
+                    e);
+        } catch (AiravataConfigurationException e) {
+            throw new AiravataAPIInvocationException("Error retrieving registry controller.
" +
+                    "An error occurred while trying to " +
+                    "add service descriptor" + serviceDescription.getType().getName(), e);
+        }
+    }
+
+    @Override
+    public void updateServiceDescription(ServiceDescription serviceDescription) throws AiravataAPIInvocationException
{
+        try {
+            getClient().getRegistryClient().updateServiceDescriptor(serviceDescription);
+        } catch (RegistryException e) {
+            throw new AiravataAPIInvocationException("An internal error occurred while trying
to add service descriptor"
+                    + serviceDescription.getType().getName(),
+                    e);
+        } catch (AiravataConfigurationException e) {
+            throw new AiravataAPIInvocationException("Error retrieving registry controller.
" +
+                    "An error occurred while trying to " +
+                    "add service descriptor" + serviceDescription.getType().getName(), e);
+        }
+    }
+
+
+    @Override
 	public void deleteServiceDescription(String serviceId)
 			throws AiravataAPIInvocationException {
 		try {
@@ -125,7 +165,66 @@ public class ApplicationManagerImpl impl
 		}
 	}
 
-	@Override
+
+    @Override
+    public void addDeploymentDescription(ServiceDescription serviceDescription, HostDescription
hostDescription,
+                                         ApplicationDeploymentDescription applicationDeploymentDescription)
+            throws AiravataAPIInvocationException, DescriptorRecordAlreadyExistsException
{
+
+        try {
+            getClient().getRegistryClient().addApplicationDescriptor(serviceDescription.getType().getName(),
+                    hostDescription.getType().getHostName(), applicationDeploymentDescription);
+        } catch (DescriptorAlreadyExistsException e) {
+            throw new DescriptorRecordAlreadyExistsException("Application descriptor " +
+                    applicationDeploymentDescription.getType().getApplicationName().getStringValue()
+                    + " already associated to host " + hostDescription.getType().getHostName()
+                    + " and service " + serviceDescription.getType().getName(), e);
+        } catch (RegistryException e) {
+
+            throw new AiravataAPIInvocationException("An internal error occurred while trying
to add " +
+                    "application descriptor " +
+                    applicationDeploymentDescription.getType().getApplicationName().getStringValue()
+                    + " associated to host " + hostDescription.getType().getHostName()
+                    + " and service " + serviceDescription.getType().getName(), e);
+
+        } catch (AiravataConfigurationException e) {
+
+            throw new AiravataAPIInvocationException("Error retrieving registry controller.
" +
+                    "An error occurred while trying to add application descriptor " +
+                    applicationDeploymentDescription.getType().getApplicationName().getStringValue()
+                    + " associated to host " + hostDescription.getType().getHostName()
+                    + " and service " + serviceDescription.getType().getName(), e);
+        }
+
+    }
+
+    @Override
+    public void updateDeploymentDescription(ServiceDescription serviceDescription, HostDescription
hostDescription,
+                                            ApplicationDeploymentDescription applicationDeploymentDescription)
+            throws AiravataAPIInvocationException {
+        try {
+            getClient().getRegistryClient().updateApplicationDescriptor(serviceDescription.getType().getName(),
+                    hostDescription.getType().getHostName(), applicationDeploymentDescription);
+        } catch (RegistryException e) {
+
+            throw new AiravataAPIInvocationException("An internal error occurred while trying
to add " +
+                    "application descriptor " +
+                    applicationDeploymentDescription.getType().getApplicationName().getStringValue()
+                    + " associated to host " + hostDescription.getType().getHostName()
+                    + " and service " + serviceDescription.getType().getName(), e);
+
+        } catch (AiravataConfigurationException e) {
+
+            throw new AiravataAPIInvocationException("Error retrieving registry controller.
" +
+                    "An error occurred while trying to add application descriptor " +
+                    applicationDeploymentDescription.getType().getApplicationName().getStringValue()
+                    + " associated to host " + hostDescription.getType().getHostName()
+                    + " and service " + serviceDescription.getType().getName(), e);
+        }
+    }
+
+
+    @Override
 	public List<ApplicationDeploymentDescription> searchDeploymentDescription(
 			String serviceName, String hostName)
 			throws AiravataAPIInvocationException {
@@ -212,7 +311,44 @@ public class ApplicationManagerImpl impl
 		}
 	}
 
-	@Override
+    @Override
+    public void addHostDescription(HostDescription host) throws AiravataAPIInvocationException,
+            DescriptorRecordAlreadyExistsException {
+
+        try {
+            getClient().getRegistryClient().addHostDescriptor(host);
+        } catch (DescriptorAlreadyExistsException e) {
+            throw new DescriptorRecordAlreadyExistsException("Host descriptor " + host.getType().getHostName()
+                    + " already exists.", e);
+        } catch (RegistryException e) {
+            throw new AiravataAPIInvocationException("An internal error occurred while trying
to add host descriptor"
+                    + host.getType().getHostName(),
+                    e);
+        } catch (AiravataConfigurationException e) {
+            throw new AiravataAPIInvocationException("Error retrieving registry controller.
" +
+                    "An error occurred while trying to " +
+                    "add host descriptor" + host.getType().getHostName(), e);
+        }
+
+    }
+
+    @Override
+    public void updateHostDescription(HostDescription host) throws AiravataAPIInvocationException
{
+        try {
+            getClient().getRegistryClient().updateHostDescriptor(host);
+        } catch (RegistryException e) {
+            throw new AiravataAPIInvocationException("An internal error occurred while trying
to add host descriptor"
+                    + host.getType().getHostName(),
+                    e);
+        } catch (AiravataConfigurationException e) {
+            throw new AiravataAPIInvocationException("Error retrieving registry controller.
" +
+                    "An error occurred while trying to " +
+                    "add host descriptor" + host.getType().getHostName(), e);
+        }
+    }
+
+
+    @Override
 	public List<HostDescription> searchHostDescription(String regExName)
 			throws AiravataAPIInvocationException {
 		throw new AiravataAPIInvocationException(new UnimplementedRegistryOperationException());

Modified: airavata/trunk/modules/integration-tests/src/test/java/org/apache/airavata/integration/BaseCaseIT.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/integration-tests/src/test/java/org/apache/airavata/integration/BaseCaseIT.java?rev=1425176&r1=1425175&r2=1425176&view=diff
==============================================================================
--- airavata/trunk/modules/integration-tests/src/test/java/org/apache/airavata/integration/BaseCaseIT.java
(original)
+++ airavata/trunk/modules/integration-tests/src/test/java/org/apache/airavata/integration/BaseCaseIT.java
Fri Dec 21 23:04:23 2012
@@ -14,17 +14,13 @@ import junit.framework.Assert;
 import org.apache.airavata.client.AiravataAPIFactory;
 import org.apache.airavata.client.api.AiravataAPI;
 import org.apache.airavata.client.api.AiravataAPIInvocationException;
+import org.apache.airavata.client.api.builder.DescriptorBuilder;
 import org.apache.airavata.common.utils.Version;
 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.registry.api.PasswordCallback;
-import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
-import org.apache.airavata.schemas.gfac.DataType;
-import org.apache.airavata.schemas.gfac.GlobusHostType;
-import org.apache.airavata.schemas.gfac.InputParameterType;
-import org.apache.airavata.schemas.gfac.OutputParameterType;
-import org.apache.airavata.schemas.gfac.ParameterType;
+import org.apache.airavata.schemas.gfac.*;
 import org.apache.airavata.workflow.model.wf.Workflow;
 import org.apache.airavata.workflow.model.wf.WorkflowInput;
 import org.apache.airavata.ws.monitor.Monitor;
@@ -219,56 +215,41 @@ public class BaseCaseIT {
 
     @Test
     public void testEchoService() throws Exception {
-        HostDescription hostDescription = new HostDescription(GlobusHostType.type);
-        hostDescription.getType().setHostName("localhost");
-        hostDescription.getType().setHostAddress("127.0.0.1");
 
-        log("Saving host description ....");
-        airavataAPI.getApplicationManager().saveHostDescription(hostDescription);
+        DescriptorBuilder descriptorBuilder = airavataAPI.getDescriptorBuilder();
+
+        HostDescription hostDescription
+                = descriptorBuilder.buildHostDescription(HostDescriptionType.type, "localhost",
"127.0.0.1");
+
+        log("Adding host description ....");
+        airavataAPI.getApplicationManager().addHostDescription(hostDescription);
 
         Assert.assertTrue(airavataAPI.getApplicationManager().isHostDescriptorExists(hostDescription.getType()
                 .getHostName()));
 
-        ServiceDescription serviceDescription = new ServiceDescription();
+
         List<InputParameterType> inputParameters = new ArrayList<InputParameterType>();
+        inputParameters.add(descriptorBuilder.buildInputParameterType("echo_input", "echo
input", DataType.STRING));
+
         List<OutputParameterType> outputParameters = new ArrayList<OutputParameterType>();
-        serviceDescription.getType().setName("Echo");
-        serviceDescription.getType().setDescription("Echo service");
-        InputParameterType parameter = InputParameterType.Factory.newInstance();
-        parameter.setParameterName("echo_input");
-        parameter.setParameterDescription("echo input");
-        ParameterType parameterType = parameter.addNewParameterType();
-        parameterType.setType(DataType.STRING);
-        parameterType.setName("String");
-        inputParameters.add(parameter);
-
-        OutputParameterType outputParameter = OutputParameterType.Factory.newInstance();
-        outputParameter.setParameterName("echo_output");
-        outputParameter.setParameterDescription("Echo output");
-        ParameterType outputParaType = outputParameter.addNewParameterType();
-        outputParaType.setType(DataType.STRING);
-        outputParaType.setName("String");
-        outputParameters.add(outputParameter);
+        outputParameters.add(descriptorBuilder.buildOutputParameterType("echo_output", "Echo
output", DataType.STRING));
 
-        serviceDescription.getType().setInputParametersArray(inputParameters.toArray(new
InputParameterType[]{}));
-        serviceDescription.getType().setOutputParametersArray(outputParameters.toArray(new
OutputParameterType[]{}));
+        ServiceDescription serviceDescription = descriptorBuilder.buildServiceDescription("Echo",
"Echo service",
+                inputParameters, outputParameters);
 
-        log("Saving service description ...");
-        airavataAPI.getApplicationManager().saveServiceDescription(serviceDescription);
+        log("Adding service description ...");
+        airavataAPI.getApplicationManager().addServiceDescription(serviceDescription);
         Assert.assertTrue(airavataAPI.getApplicationManager().isServiceDescriptorExists(serviceDescription.
                 getType().getName()));
 
         // Deployment descriptor
-        ApplicationDeploymentDescription applicationDeploymentDescription = new ApplicationDeploymentDescription();
-        ApplicationDeploymentDescriptionType applicationDeploymentDescriptionType
-                = applicationDeploymentDescription.getType();
-        applicationDeploymentDescriptionType.addNewApplicationName().setStringValue("EchoApplication");
-        applicationDeploymentDescriptionType.setExecutableLocation("/bin/echo");
-        applicationDeploymentDescriptionType.setScratchWorkingDirectory("/tmp");
-
-        log("Saving deployment description ...");
-        airavataAPI.getApplicationManager().saveDeploymentDescription(serviceDescription.getType().getName(),
-                hostDescription.getType().getHostName(), applicationDeploymentDescription);
+        ApplicationDeploymentDescription applicationDeploymentDescription
+                = descriptorBuilder.buildApplicationDeploymentDescription("EchoApplication",
"/bin/echo", "/tmp");
+
+        log("Adding deployment description ...");
+        airavataAPI.getApplicationManager().addDeploymentDescription(serviceDescription,
+                hostDescription, applicationDeploymentDescription);
+
         Assert.assertTrue(airavataAPI.getApplicationManager().isDeploymentDescriptorExists(serviceDescription.getType().
                 getName(), hostDescription.getType().getHostName(),
                 applicationDeploymentDescription.getType().getApplicationName().getStringValue()));



Mime
View raw message