You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by he...@apache.org on 2013/03/27 19:34:39 UTC
svn commit: r1461772 - in
/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider:
impl/LocalProvider.java utils/ProviderUtils.java
Author: heshan
Date: Wed Mar 27 18:34:39 2013
New Revision: 1461772
URL: http://svn.apache.org/r1461772
Log:
Extracting a method and putting it into a Utils class, so that other Providers will be able to reuse the same logic.
Added:
airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/ProviderUtils.java
Modified:
airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/LocalProvider.java
Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/LocalProvider.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/LocalProvider.java?rev=1461772&r1=1461771&r2=1461772&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/LocalProvider.java (original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/LocalProvider.java Wed Mar 27 18:34:39 2013
@@ -20,20 +20,17 @@
*/
package org.apache.airavata.gfac.provider.impl;
-import org.apache.airavata.commons.gfac.type.ActualParameter;
-import org.apache.airavata.commons.gfac.type.MappingFactory;
import org.apache.airavata.gfac.Constants;
import org.apache.airavata.gfac.context.JobExecutionContext;
-import org.apache.airavata.gfac.context.MessageContext;
import org.apache.airavata.gfac.notification.events.StartExecutionEvent;
import org.apache.airavata.gfac.provider.GFacProvider;
import org.apache.airavata.gfac.provider.GFacProviderException;
+import org.apache.airavata.gfac.provider.utils.ProviderUtils;
import org.apache.airavata.gfac.utils.GFacUtils;
import org.apache.airavata.gfac.utils.InputStreamToFileWriter;
import org.apache.airavata.gfac.utils.InputUtils;
import org.apache.airavata.gfac.utils.OutputUtils;
import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
-import org.apache.airavata.schemas.gfac.InputParameterType;
import org.apache.airavata.schemas.gfac.NameValuePairType;
import org.apache.xmlbeans.XmlException;
import org.slf4j.Logger;
@@ -41,7 +38,9 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
public class LocalProvider implements GFacProvider {
private static final Logger log = LoggerFactory.getLogger(LocalProvider.class);
@@ -56,7 +55,7 @@ public class LocalProvider implements GF
ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext().
getApplicationDeploymentDescription().getType();
- buildCommand(app.getExecutableLocation(), getInputParameters(jobExecutionContext));
+ buildCommand(app.getExecutableLocation(), ProviderUtils.getInputParameters(jobExecutionContext));
initProcessBuilder(app);
// extra environment variables
@@ -140,25 +139,6 @@ public class LocalProvider implements GF
}
}
- // TODO: Move to right class based on future requirements.
- private List<String> getInputParameters(JobExecutionContext jobExecutionContext) throws GFacProviderException {
- List<String> parameters = new ArrayList<String>();
- MessageContext inMessageContext = jobExecutionContext.getInMessageContext();
- InputParameterType[] inputParamDefinitionArray = jobExecutionContext.getApplicationContext().
- getServiceDescription().getType().getInputParametersArray();
- for (InputParameterType inputParam : inputParamDefinitionArray) {
- String parameterName = inputParam.getParameterName();
- ActualParameter parameter = (ActualParameter)inMessageContext.getParameter(parameterName);
- if(parameter == null){
- throw new GFacProviderException("Cannot find required input parameter " + parameterName + ".");
- }
-
- parameters.add(MappingFactory.toString(parameter));
- }
-
- return parameters;
- }
-
private void buildCommand(String executable, List<String> inputParameterList){
cmdList.add(executable);
cmdList.addAll(inputParameterList);
Added: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/ProviderUtils.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/ProviderUtils.java?rev=1461772&view=auto
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/ProviderUtils.java (added)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/utils/ProviderUtils.java Wed Mar 27 18:34:39 2013
@@ -0,0 +1,33 @@
+package org.apache.airavata.gfac.provider.utils;
+
+import org.apache.airavata.commons.gfac.type.ActualParameter;
+import org.apache.airavata.commons.gfac.type.MappingFactory;
+import org.apache.airavata.gfac.context.JobExecutionContext;
+import org.apache.airavata.gfac.context.MessageContext;
+import org.apache.airavata.gfac.provider.GFacProviderException;
+import org.apache.airavata.schemas.gfac.InputParameterType;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ProviderUtils {
+
+ public static List<String> getInputParameters(JobExecutionContext jobExecutionContext) throws GFacProviderException {
+ List<String> parameters = new ArrayList<String>();
+ MessageContext inMessageContext = jobExecutionContext.getInMessageContext();
+ InputParameterType[] inputParamDefinitionArray = jobExecutionContext.getApplicationContext().
+ getServiceDescription().getType().getInputParametersArray();
+ for (InputParameterType inputParam : inputParamDefinitionArray) {
+ String parameterName = inputParam.getParameterName();
+ ActualParameter parameter = (ActualParameter)inMessageContext.getParameter(parameterName);
+ if(parameter == null){
+ throw new GFacProviderException("Cannot find required input parameter " + parameterName + ".");
+ }
+
+ parameters.add(MappingFactory.toString(parameter));
+ }
+
+ return parameters;
+ }
+
+}