airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject [02/51] [partial] airavata-php-gateway git commit: removing files from wrong merge
Date Tue, 13 Dec 2016 22:14:26 GMT
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/provider/impl/BESProvider.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/provider/impl/BESProvider.java b/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/provider/impl/BESProvider.java
deleted file mode 100644
index 8533abb..0000000
--- a/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/provider/impl/BESProvider.java
+++ /dev/null
@@ -1,453 +0,0 @@
-/*
- *
- * 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.gfac.bes.provider.impl;
-
-import java.util.Calendar;
-import java.util.Map;
-
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.gfac.core.GFacException;
-import org.apache.airavata.gfac.bes.security.UNICORESecurityContext;
-import org.apache.airavata.gfac.bes.security.X509SecurityContext;
-import org.apache.airavata.gfac.bes.utils.BESConstants;
-import org.apache.airavata.gfac.bes.utils.DataTransferrer;
-import org.apache.airavata.gfac.bes.utils.JSDLGenerator;
-import org.apache.airavata.gfac.bes.utils.SecurityUtils;
-import org.apache.airavata.gfac.bes.utils.StorageCreator;
-import org.apache.airavata.gfac.core.context.JobExecutionContext;
-import org.apache.airavata.gfac.core.provider.AbstractProvider;
-import org.apache.airavata.gfac.core.provider.GFacProvider;
-import org.apache.airavata.gfac.core.provider.GFacProviderException;
-import org.apache.airavata.gfac.core.GFacUtils;
-import org.apache.airavata.model.appcatalog.computeresource.JobSubmissionInterface;
-import org.apache.airavata.model.appcatalog.computeresource.JobSubmissionProtocol;
-import org.apache.airavata.model.appcatalog.computeresource.UnicoreJobSubmission;
-import org.apache.airavata.model.messaging.event.JobIdentifier;
-import org.apache.airavata.model.messaging.event.JobStatusChangeRequestEvent;
-import org.apache.airavata.model.experiment.JobDetails;
-import org.apache.airavata.model.experiment.JobState;
-import org.apache.xmlbeans.XmlCursor;
-import org.bouncycastle.asn1.x500.style.BCStyle;
-import org.ggf.schemas.bes.x2006.x08.besFactory.ActivityStateEnumeration;
-import org.ggf.schemas.bes.x2006.x08.besFactory.ActivityStateEnumeration.Enum;
-import org.ggf.schemas.bes.x2006.x08.besFactory.ActivityStatusType;
-import org.ggf.schemas.bes.x2006.x08.besFactory.CreateActivityDocument;
-import org.ggf.schemas.bes.x2006.x08.besFactory.CreateActivityResponseDocument;
-import org.ggf.schemas.bes.x2006.x08.besFactory.GetActivityStatusesDocument;
-import org.ggf.schemas.bes.x2006.x08.besFactory.GetActivityStatusesResponseDocument;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionDocument;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3.x2005.x08.addressing.EndpointReferenceType;
-
-import de.fzj.unicore.bes.client.ActivityClient;
-import de.fzj.unicore.bes.client.FactoryClient;
-import de.fzj.unicore.bes.faults.UnknownActivityIdentifierFault;
-import de.fzj.unicore.uas.client.StorageClient;
-import de.fzj.unicore.wsrflite.xmlbeans.WSUtilities;
-import eu.emi.security.authn.x509.impl.X500NameUtils;
-import eu.unicore.util.httpclient.DefaultClientConfiguration;
-
-public class BESProvider extends AbstractProvider implements GFacProvider,
-		BESConstants {
-	protected final Logger log = LoggerFactory.getLogger(this.getClass());
-
-	private DefaultClientConfiguration secProperties;
-
-	private String jobId;
-
-	public void initialize(JobExecutionContext jobExecutionContext)
-			throws GFacProviderException, GFacException {
-		log.info("Initializing UNICORE Provider..");
-		super.initialize(jobExecutionContext);
-		secProperties = (DefaultClientConfiguration) jobExecutionContext.getProperty(PROP_CLIENT_CONF);
-		if (secProperties != null) {
-			secProperties = secProperties.clone();
-			return;
-		}
-		SecurityUtils.addSecurityContext(jobExecutionContext);
-		UNICORESecurityContext unicoreContext = (UNICORESecurityContext) jobExecutionContext.getSecurityContext(X509SecurityContext.X509_SECURITY_CONTEXT);
-		try{
-			if (jobExecutionContext.getExperiment()
-					.getUserConfigurationData().isGenerateCert())  {
-				secProperties = unicoreContext
-						.getDefaultConfiguration(false, jobExecutionContext
-								.getExperiment().getUserConfigurationData());
-			}else {
-				secProperties = unicoreContext.getDefaultConfiguration(false);
-			}
-				
-		} catch (ApplicationSettingsException e) {
-			throw new GFacProviderException("Error initializing security of Unicore provider", e);
-		}
-		if (log.isDebugEnabled()) {
-			log.debug("Security properties initialized.");
-		}
-	}
-
-	public void execute(JobExecutionContext jobExecutionContext)
-			throws GFacProviderException, GFacException {
-
-        StorageClient sc = null;
-        try {
-            JobSubmissionInterface preferredJobSubmissionInterface = jobExecutionContext.getPreferredJobSubmissionInterface();
-            JobSubmissionProtocol protocol = preferredJobSubmissionInterface.getJobSubmissionProtocol();
-            String interfaceId = preferredJobSubmissionInterface.getJobSubmissionInterfaceId();
-            String factoryUrl = null;
-            if (protocol.equals(JobSubmissionProtocol.UNICORE)) {
-                UnicoreJobSubmission unicoreJobSubmission = GFacUtils.getUnicoreJobSubmission(interfaceId);
-                factoryUrl = unicoreJobSubmission.getUnicoreEndPointURL();
-            }
-            EndpointReferenceType eprt = EndpointReferenceType.Factory.newInstance();
-            eprt.addNewAddress().setStringValue(factoryUrl);
-            String userDN = getUserName(jobExecutionContext);
-
-            // TODO: to be removed
-            if (userDN == null || userDN.equalsIgnoreCase("admin")) {
-                userDN = "CN=zdv575, O=Ultrascan Gateway, C=DE";
-            }
-            CreateActivityDocument cad = CreateActivityDocument.Factory.newInstance();
-            JobDefinitionDocument jobDefDoc = JobDefinitionDocument.Factory.newInstance();
-
-            // create storage
-            StorageCreator storageCreator = new StorageCreator(secProperties, factoryUrl, 5, null);
-            sc = storageCreator.createStorage();
-
-            JobDefinitionType jobDefinition = JSDLGenerator.buildJSDLInstance(jobExecutionContext, sc.getUrl()).getJobDefinition();
-            cad.addNewCreateActivity().addNewActivityDocument().setJobDefinition(jobDefinition);
-            log.info("JSDL" + jobDefDoc.toString());
-
-            // upload files if any
-            DataTransferrer dt = new DataTransferrer(jobExecutionContext, sc);
-            dt.uploadLocalFiles();
-
-            JobDetails jobDetails = new JobDetails();
-            FactoryClient factory = new FactoryClient(eprt, secProperties);
-
-            log.info("Activity Submitting to {} ... \n", factoryUrl));
-            CreateActivityResponseDocument response = factory.createActivity(cad);
-            log.info("Activity Submitted to {} \n", factoryUrl);
-
-            EndpointReferenceType activityEpr = response.getCreateActivityResponse().getActivityIdentifier();
-
-            log.info("Activity : " + activityEpr.getAddress().getStringValue() + " Submitted.");
-
-            // factory.waitWhileActivityIsDone(activityEpr, 1000);
-            jobId = WSUtilities.extractResourceID(activityEpr);
-            if (jobId == null) {
-                jobId = new Long(Calendar.getInstance().getTimeInMillis())
-                        .toString();
-            }
-            log.info("JobID: " + jobId);
-            jobDetails.setJobID(jobId);
-            jobDetails.setJobDescription(activityEpr.toString());
-
-            jobExecutionContext.setJobDetails(jobDetails);
-            GFacUtils.saveJobStatus(jobExecutionContext, jobDetails, JobState.SUBMITTED);
-            log.info(formatStatusMessage(activityEpr.getAddress()
-                    .getStringValue(), factory.getActivityStatus(activityEpr)
-                    .toString()));
-            
-            waitUntilDone(eprt, activityEpr, jobDetails, secProperties);
-
-            ActivityStatusType activityStatus = null;
-            activityStatus = getStatus(factory, activityEpr);
-            log.info(formatStatusMessage(activityEpr.getAddress().getStringValue(), activityStatus.getState().toString()));
-            ActivityClient activityClient;
-            activityClient = new ActivityClient(activityEpr, secProperties);
-            dt.setStorageClient(activityClient.getUspaceClient());
-
-            if ((activityStatus.getState() == ActivityStateEnumeration.FAILED)) {
-                String error = activityStatus.getFault().getFaultcode()
-                        .getLocalPart()
-                        + "\n"
-                        + activityStatus.getFault().getFaultstring()
-                        + "\n EXITCODE: " + activityStatus.getExitCode();
-                log.info(error);
-  
-                JobState applicationJobStatus = JobState.FAILED;
-                sendNotification(jobExecutionContext,applicationJobStatus);
-                GFacUtils.updateJobStatus(jobExecutionContext, jobDetails, applicationJobStatus);
-                try {Thread.sleep(5000);} catch (InterruptedException e) {}
-                
-                //What if job is failed before execution and there are not stdouts generated yet?
-                log.debug("Downloading any standard output and error files, if they were produced.");
-                dt.downloadStdOuts();
-                
-            } else if (activityStatus.getState() == ActivityStateEnumeration.CANCELLED) {
-                JobState applicationJobStatus = JobState.CANCELED;
-                sendNotification(jobExecutionContext,applicationJobStatus);
-                GFacUtils.updateJobStatus(jobExecutionContext, jobDetails, applicationJobStatus);
-                throw new GFacProviderException(
-                        jobExecutionContext.getExperimentID() + "Job Canceled");
-            } else if (activityStatus.getState() == ActivityStateEnumeration.FINISHED) {
-                try {
-                    Thread.sleep(5000);
-                    JobState applicationJobStatus = JobState.COMPLETE;
-                    sendNotification(jobExecutionContext,applicationJobStatus);
-                    
-                } catch (InterruptedException e) {
-                }
-                if (activityStatus.getExitCode() == 0) {
-                    dt.downloadRemoteFiles();
-                } else {
-                    dt.downloadStdOuts();
-                }
-            }
-        } catch (AppCatalogException e) {
-            log.error("Error while retrieving UNICORE job submission..");
-            throw new GFacProviderException("Error while retrieving UNICORE job submission..", e);
-        } catch (Exception e) {
-            log.error("Cannot create storage..");
-            throw new GFacProviderException("Cannot create storage..", e);
-        } finally {
-            // destroy sms instance
-            try {
-                if (sc != null) {
-                    sc.destroy();
-                }
-            } catch (Exception e) {
-                log.warn(
-                        "Cannot destroy temporary SMS instance:" + sc.getUrl(),
-                        e);
-            }
-        }
-
-    }
-	
-
-	private JobState getApplicationJobStatus(ActivityStatusType activityStatus) {
-		if (activityStatus == null) {
-			return JobState.UNKNOWN;
-		}
-		Enum state = activityStatus.getState();
-		String status = null;
-		XmlCursor acursor = activityStatus.newCursor();
-		try {
-			if (acursor.toFirstChild()) {
-				if (acursor.getName().getNamespaceURI()
-						.equals("http://schemas.ogf.org/hpcp/2007/01/fs")) {
-					status = acursor.getName().getLocalPart();
-				}
-			}
-			if (status != null) {
-				if (status.equalsIgnoreCase("Queued")
-						|| status.equalsIgnoreCase("Starting")
-						|| status.equalsIgnoreCase("Ready")) {
-					return JobState.QUEUED;
-				} else if (status.equalsIgnoreCase("Staging-In")) {
-					return JobState.SUBMITTED;
-				} else if (status.equalsIgnoreCase("FINISHED")) {
-					return JobState.COMPLETE;
-				}else if(status.equalsIgnoreCase("Staging-Out")){
-					return JobState.ACTIVE;
-				} 
-				else if (status.equalsIgnoreCase("Executing")) {
-					return JobState.ACTIVE;
-				} else if (status.equalsIgnoreCase("FAILED")) {
-					return JobState.FAILED;
-				} else if (status.equalsIgnoreCase("CANCELLED")) {
-					return JobState.CANCELED;
-				}
-			} else {
-				if (ActivityStateEnumeration.CANCELLED.equals(state)) {
-					return JobState.CANCELED;
-				} else if (ActivityStateEnumeration.FAILED.equals(state)) {
-					return JobState.FAILED;
-				} else if (ActivityStateEnumeration.FINISHED.equals(state)) {
-					return JobState.COMPLETE;
-				} else if (ActivityStateEnumeration.RUNNING.equals(state)) {
-					return JobState.ACTIVE;
-				}
-			}
-		} finally {
-			if (acursor != null)
-				acursor.dispose();
-		}
-		return JobState.UNKNOWN;
-	}
-
-	/**
-	 * EndpointReference need to be saved to make cancel work.
-	 * 
-	 * @param activityEpr
-	 * @param jobExecutionContext
-	 * @throws GFacProviderException
-	 */
-	public boolean cancelJob(
-			JobExecutionContext jobExecutionContext)
-			throws GFacProviderException {
-		try {
-			String activityEpr = jobExecutionContext.getJobDetails().getJobDescription();
-			// initSecurityProperties(jobExecutionContext);
-			EndpointReferenceType eprt = EndpointReferenceType.Factory
-					.parse(activityEpr);
-            JobSubmissionInterface preferredJobSubmissionInterface = jobExecutionContext.getPreferredJobSubmissionInterface();
-            JobSubmissionProtocol protocol = preferredJobSubmissionInterface.getJobSubmissionProtocol();
-            String interfaceId = preferredJobSubmissionInterface.getJobSubmissionInterfaceId();
-            String factoryUrl = null;
-            if (protocol.equals(JobSubmissionProtocol.UNICORE)) {
-                UnicoreJobSubmission unicoreJobSubmission = GFacUtils.getUnicoreJobSubmission(interfaceId);
-                factoryUrl = unicoreJobSubmission.getUnicoreEndPointURL();
-            }
-			EndpointReferenceType epr = EndpointReferenceType.Factory
-					.newInstance();
-			epr.addNewAddress().setStringValue(factoryUrl);
-
-			FactoryClient factory = new FactoryClient(epr, secProperties);
-			factory.terminateActivity(eprt);
-			return true;
-		} catch (Exception e) {
-			throw new GFacProviderException(e.getLocalizedMessage(), e);
-		}
-
-	}
-
-	// FIXME: Get user details
-	private String getUserName(JobExecutionContext context) {
-		// if (context.getConfigurationData()!= null) {
-		// return
-		// context.getConfigurationData().getBasicMetadata().getUserName();
-		// } else {
-		return "";
-		// }
-	}
-
-	protected ActivityStatusType getStatus(FactoryClient fc, EndpointReferenceType activityEpr)
-			throws UnknownActivityIdentifierFault {
-
-		GetActivityStatusesDocument stats = GetActivityStatusesDocument.Factory
-				.newInstance();
-
-		stats.addNewGetActivityStatuses().setActivityIdentifierArray(
-				new EndpointReferenceType[] { activityEpr });
-
-		GetActivityStatusesResponseDocument resDoc = fc
-				.getActivityStatuses(stats);
-
-		ActivityStatusType activityStatus = resDoc
-				.getGetActivityStatusesResponse().getResponseArray()[0]
-				.getActivityStatus();
-		return activityStatus;
-	}
-
-	protected String formatStatusMessage(String activityUrl, String status) {
-		return String.format("Activity %s is %s.\n", activityUrl, status);
-	}
-
-	protected String subStatusAsString(ActivityStatusType statusType) {
-
-		StringBuffer sb = new StringBuffer();
-
-		sb.append(statusType.getState().toString());
-
-		XmlCursor acursor = statusType.newCursor();
-		if (acursor.toFirstChild()) {
-			do {
-				if (acursor.getName().getNamespaceURI()
-						.equals("http://schemas.ogf.org/hpcp/2007/01/fs")) {
-					sb.append(":");
-					sb.append(acursor.getName().getLocalPart());
-				}
-			} while (acursor.toNextSibling());
-			acursor.dispose();
-			return sb.toString();
-		} else {
-			acursor.dispose();
-			return sb.toString();
-		}
-
-	}
-
-	private String getCNFromUserDN(String userDN) {
-		return X500NameUtils.getAttributeValues(userDN, BCStyle.CN)[0];
-
-	}
-
-	@Override
-	public void initProperties(Map<String, String> properties)
-			throws GFacProviderException, GFacException {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void dispose(JobExecutionContext jobExecutionContext)
-			throws GFacProviderException, GFacException {
-		secProperties = null;
-
-	}
-
-    @Override
-    public void recover(JobExecutionContext jobExecutionContext) throws GFacProviderException, GFacException {
-        // TODO: Auto generated method body.
-    }
-
-    @Override
-    public void monitor(JobExecutionContext jobExecutionContext) throws GFacProviderException, GFacException {
-        // TODO: Auto generated method body.
-    }
-
-    protected void waitUntilDone(EndpointReferenceType factoryEpr, EndpointReferenceType activityEpr, JobDetails jobDetails, DefaultClientConfiguration secProperties) throws Exception {
-		
-		try {
-			FactoryClient factoryClient = new FactoryClient(factoryEpr, secProperties);
-			JobState applicationJobStatus = null;
-			
-			while ((factoryClient.getActivityStatus(activityEpr) != ActivityStateEnumeration.FINISHED)
-	                && (factoryClient.getActivityStatus(activityEpr) != ActivityStateEnumeration.FAILED)
-	                && (factoryClient.getActivityStatus(activityEpr) != ActivityStateEnumeration.CANCELLED) 
-	                && (applicationJobStatus != JobState.COMPLETE)) {
-	
-	            ActivityStatusType activityStatus = getStatus(factoryClient, activityEpr);
-	            applicationJobStatus = getApplicationJobStatus(activityStatus);
-	         
-	            sendNotification(jobExecutionContext,applicationJobStatus);
-	
-	            // GFacUtils.updateApplicationJobStatus(jobExecutionContext,jobId,
-	            // applicationJobStatus);
-	            try {
-	                Thread.sleep(5000);
-	            } catch (InterruptedException e) {}
-	            continue;
-	        }
-		} catch(Exception e) {
-			log.error("Error monitoring job status..");
-			throw e;
-		}
-	}
-    private void sendNotification(JobExecutionContext jobExecutionContext,  JobState status) {
-        JobStatusChangeRequestEvent jobStatus = new JobStatusChangeRequestEvent();
-        JobIdentifier jobIdentity = new JobIdentifier(jobExecutionContext.getJobDetails().getJobID(),
-        		jobExecutionContext.getTaskData().getTaskID(),
-        		jobExecutionContext.getWorkflowNodeDetails().getNodeInstanceId(),
-        		jobExecutionContext.getExperimentID(),
-        		jobExecutionContext.getGatewayID());
-        jobStatus.setJobIdentity(jobIdentity);
-        jobStatus.setState(status);
-        log.debug(jobStatus.getJobIdentity().getJobId(), "Published job status change request, " +
-                "experiment {} , task {}", jobStatus.getJobIdentity().getExperimentId(),
-        jobStatus.getJobIdentity().getTaskId());
-        jobExecutionContext.getLocalEventPublisher().publish(jobStatus);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/security/UNICORESecurityContext.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/security/UNICORESecurityContext.java b/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/security/UNICORESecurityContext.java
deleted file mode 100644
index b25d2ee..0000000
--- a/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/security/UNICORESecurityContext.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
-*
-* 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.gfac.bes.security;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Properties;
-import java.util.Set;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.credential.store.store.CredentialReader;
-import org.apache.airavata.gfac.core.GFacException;
-import org.apache.airavata.gfac.core.RequestData;
-import org.apache.airavata.gfac.bes.utils.BESConstants;
-import org.apache.airavata.gfac.bes.utils.SecurityUtils;
-import org.apache.airavata.gfac.core.provider.GFacProviderException;
-import org.apache.airavata.model.experiment.UserConfigurationData;
-import org.bouncycastle.asn1.x500.style.BCStyle;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import eu.emi.security.authn.x509.X509Credential;
-import eu.emi.security.authn.x509.impl.KeyAndCertCredential;
-import eu.emi.security.authn.x509.impl.X500NameUtils;
-import eu.unicore.util.httpclient.DefaultClientConfiguration;
-
-public class UNICORESecurityContext extends X509SecurityContext {
-
-	private static final long serialVersionUID = 1L;
-	protected static final Logger log = LoggerFactory.getLogger(UNICORESecurityContext.class);
-	private DefaultClientConfiguration secProperties;
-	
-	
-	public UNICORESecurityContext(CredentialReader credentialReader, RequestData requestData) {
-		super(credentialReader, requestData);
-	}
-	
-	
-	/**
-	 * Get client configuration from MyProxy credentials. 
-	 * 
-	 * @return an instance of the default client configuration
-	 * @throws GFacException
-	 * @throws ApplicationSettingsException 
-	 * @throws GFacException, ApplicationSettingsException
-	 */
-	public DefaultClientConfiguration getDefaultConfiguration(Boolean enableMessageLogging) throws GFacException, ApplicationSettingsException {
-		try{
-			X509Credential cred = getX509Credentials();
-			secProperties = new DefaultClientConfiguration(dcValidator, cred);
-			setExtraSettings();
-		}
-		catch (Exception e) {
-			throw new GFacException(e.getMessage(), e); 
-		} 
-		secProperties.getETDSettings().setExtendTrustDelegation(true);
-		if(enableMessageLogging) secProperties.setMessageLogging(true);
-//		secProperties.setMessageLogging(true);
-//		secProperties.setDoSignMessage(true);
-		secProperties.getETDSettings().setIssuerCertificateChain(secProperties.getCredential().getCertificateChain());
-		
-		return secProperties;
-	}
-
-	public DefaultClientConfiguration getDefaultConfiguration(Boolean enableMessageLogging, UserConfigurationData userData) throws GFacException, ApplicationSettingsException {
-		X509Credential cred = null;
-		
-		try{
-			boolean genCert = userData.isGenerateCert();
-				if(genCert) {
-					String userDN = userData.getUserDN();
-					if (userDN == null && "".equals(userDN)){
-						log.warn("Cannot generate cert, falling back to container configured MyProxy credentials");
-						return getDefaultConfiguration(enableMessageLogging);
-					}
-					else {
-						log.info("Generating X.509 certificate for: "+userDN);
-						try {
-							
-							String caCertPath = ServerSettings.getSetting(BESConstants.PROP_CA_CERT_PATH, "");
-							String caKeyPath = ServerSettings.getSetting(BESConstants.PROP_CA_KEY_PATH, "");
-							String caKeyPass = ServerSettings.getSetting(BESConstants.PROP_CA_KEY_PASS, "");
-							
-							if(caCertPath.equals("") || caKeyPath.equals("")) {
-								throw new Exception("CA certificate or key file path missing in the properties file. "
-										            + "Please make sure "+BESConstants.PROP_CA_CERT_PATH+ " or "+BESConstants.PROP_CA_KEY_PATH+" are not empty.");
-							}
-							
-							if("".equals(caKeyPass)) {
-								log.warn("Caution: CA key has no password. For security reasons it is highly recommended to set a CA key password");
-							}
-							cred = generateShortLivedCredential(userDN, caCertPath, caKeyPath, caKeyPass);
-						}catch (Exception e){
-							throw new GFacProviderException("Error occured while generating a short lived credential for user:"+userDN, e);
-						}
-						
-					}
-				}else  {
-					return getDefaultConfiguration(enableMessageLogging);
-				}
-				
-			secProperties = new DefaultClientConfiguration(dcValidator, cred);
-			setExtraSettings();
-		}
-		catch (Exception e) {
-			throw new GFacException(e.getMessage(), e); 
-		} 
-		secProperties.getETDSettings().setExtendTrustDelegation(true);
-		if(enableMessageLogging) secProperties.setMessageLogging(true);
-//		secProperties.setDoSignMessage(true);
-		secProperties.getETDSettings().setIssuerCertificateChain(secProperties.getCredential().getCertificateChain());
-		
-		return secProperties;
-	}
-
-	
-	/**
-	 * Get server signed credentials. Each time it is invoked new certificate 
-	 * is returned.
-	 * 
-	 * @param userID
-	 * @param userDN
-	 * @param caCertPath
-	 * @param caKeyPath
-	 * @param caKeyPwd
-	 * @return
-	 * @throws GFacException
-	 */
-	public DefaultClientConfiguration getServerSignedConfiguration(String userID, String userDN, String caCertPath, String caKeyPath, String caKeyPwd) throws GFacException {
-		try {
-			KeyAndCertCredential cred = SecurityUtils.generateShortLivedCertificate(userDN,caCertPath,caKeyPath,caKeyPwd);
-			secProperties = new DefaultClientConfiguration(dcValidator, cred);
-			setExtraSettings();
-		} catch (Exception e) {
-			throw new GFacException(e.getMessage(), e);
-		}
-
-		return secProperties;
-	}
-
-	
-	
-
-	
-	private void setExtraSettings(){
-		secProperties.getETDSettings().setExtendTrustDelegation(true);
-
-		secProperties.setDoSignMessage(true);
-
-		String[] outHandlers = secProperties.getOutHandlerClassNames();
-		
-		Set<String> outHandlerLst = null;
-
-		// timeout in milliseconds
-		Properties p = secProperties.getExtraSettings();
-		
-		if(p == null) {
-			p = new Properties();
-		}
-		
-		p.setProperty("http.connection.timeout", "5000");
-		p.setProperty("http.socket.timeout", "5000");
-		
-		secProperties.setExtraSettings(p);
-
-		if (outHandlers == null) {
-			outHandlerLst = new HashSet<String>();
-		} else {
-			outHandlerLst = new HashSet<String>(Arrays.asList(outHandlers));
-		}
-
-		outHandlerLst.add("de.fzj.unicore.uas.security.ProxyCertOutHandler");
-
-		secProperties.setOutHandlerClassNames(outHandlerLst
-				.toArray(new String[outHandlerLst.size()]));
-	}
-
-
-    private String getCNFromUserDN(String userDN) {
-        return X500NameUtils.getAttributeValues(userDN, BCStyle.CN)[0];
-
-    }
-
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/security/X509SecurityContext.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/security/X509SecurityContext.java b/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/security/X509SecurityContext.java
deleted file mode 100644
index d9b183f..0000000
--- a/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/security/X509SecurityContext.java
+++ /dev/null
@@ -1,344 +0,0 @@
-/*
- *
- * 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.gfac.bes.security;
-
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.credential.store.credential.Credential;
-import org.apache.airavata.credential.store.credential.impl.certificate.CertificateCredential;
-import org.apache.airavata.credential.store.store.CredentialReader;
-import org.apache.airavata.gfac.core.GFacConstants;
-import org.apache.airavata.gfac.core.context.AbstractSecurityContext;
-import org.apache.airavata.gfac.core.GFacException;
-import org.apache.airavata.gfac.core.RequestData;
-import org.apache.airavata.gfac.bes.utils.MyProxyLogon;
-import org.bouncycastle.asn1.ASN1InputStream;
-import org.bouncycastle.asn1.x500.X500Name;
-import org.bouncycastle.asn1.x500.style.BCStyle;
-import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
-import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import eu.emi.security.authn.x509.X509Credential;
-import eu.emi.security.authn.x509.helpers.CertificateHelpers;
-import eu.emi.security.authn.x509.helpers.proxy.X509v3CertificateBuilder;
-import eu.emi.security.authn.x509.impl.CertificateUtils;
-import eu.emi.security.authn.x509.impl.DirectoryCertChainValidator;
-import eu.emi.security.authn.x509.impl.KeyAndCertCredential;
-import eu.emi.security.authn.x509.impl.CertificateUtils.Encoding;
-import eu.emi.security.authn.x509.impl.X500NameUtils;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.math.BigInteger;
-import java.security.InvalidKeyException;
-import java.security.KeyPair;
-import java.security.KeyPairGenerator;
-import java.security.PrivateKey;
-import java.security.cert.X509Certificate;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Random;
-
-import javax.security.auth.x500.X500Principal;
-
-/**
- * Handles X509 Certificate based security.
- */
-public class X509SecurityContext extends AbstractSecurityContext {
-
-	private static final long serialVersionUID = 1L;
-
-	protected static final Logger log = LoggerFactory.getLogger(X509SecurityContext.class);
-    
-    /*
-     * context name
-     */
-    public static final String X509_SECURITY_CONTEXT = "x509.security.context";
-    
-    public static final int CREDENTIAL_RENEWING_THRESH_HOLD = 10 * 90;
-    
-    protected static DirectoryCertChainValidator dcValidator;
-    
-    private X509Credential x509Credentials= null;
-
-    static {
-        try {
-			setUpTrustedCertificatePath();
-			// set up directory based trust validator
-			dcValidator = getTrustedCerts();
-		} catch (Exception e) {
-			log.error(e.getLocalizedMessage(), e);
-		}
-    }
-    
-
-    public static void setUpTrustedCertificatePath(String trustedCertificatePath) {
-
-        File file = new File(trustedCertificatePath);
-
-        if (!file.exists() || !file.canRead()) {
-            File f = new File(".");
-            log.info("Current directory " + f.getAbsolutePath());
-            throw new RuntimeException("Cannot read trusted certificate path " + trustedCertificatePath);
-        } else {
-            System.setProperty(GFacConstants.TRUSTED_CERTIFICATE_SYSTEM_PROPERTY, file.getAbsolutePath());
-        }
-    }
-
-    private static void setUpTrustedCertificatePath() throws ApplicationSettingsException {
-
-        String trustedCertificatePath  = ServerSettings.getSetting(GFacConstants.TRUSTED_CERT_LOCATION);
-
-        setUpTrustedCertificatePath(trustedCertificatePath);
-    }
-
-    /**
-     * Gets the trusted certificate path. Trusted certificate path is stored in "X509_CERT_DIR"
-     * system property.
-     * @return The trusted certificate path as a string.
-     */
-    public static String getTrustedCertificatePath() {
-        return System.getProperty(GFacConstants.TRUSTED_CERTIFICATE_SYSTEM_PROPERTY);
-    }
-
-
-    public X509SecurityContext(CredentialReader credentialReader, RequestData requestData) {
-        super(credentialReader, requestData);
-    }
-
-
-    /**
-     * Gets X509Credentials. The process is as follows;
-     * If credentials were queried for the first time create credentials.
-     *   1. Try creating credentials using certificates stored in the credential store
-     *   2. If 1 fails use user name and password to create credentials
-     * @return x509credentials (from CANL security API)
-     * @throws GFacException If an error occurred while creating credentials.
-     * @throws org.apache.airavata.common.exception.ApplicationSettingsException
-     */
-    public X509Credential getX509Credentials() throws GFacException, ApplicationSettingsException {
-    	
-    	if(getCredentialReader() == null) {
-    		return getDefaultCredentials();
-    	}
-    	
-        if (x509Credentials == null) {
-
-            try {
-                x509Credentials = getCredentialsFromStore();
-            } catch (Exception e) {
-                log.error("An exception occurred while retrieving credentials from the credential store. " +
-                        "Will continue with my proxy user name and password.", e);
-            }
-
-            // If store does not have credentials try to get from user name and password
-            if (x509Credentials == null) {
-                x509Credentials = getDefaultCredentials();
-            }
-
-            // if still null, throw an exception
-            if (x509Credentials == null) {
-                throw new GFacException("Unable to retrieve my proxy credentials to continue operation.");
-            }
-        } else {
-            try {
-            	
-            	final long remainingTime = x509Credentials.getCertificate().getNotAfter().getTime() - new Date().getTime();
-            	
-                if (remainingTime < CREDENTIAL_RENEWING_THRESH_HOLD) {
-                	//                    return renewCredentials();
-                	log.warn("Do not support credentials renewal");
-                }
-                
-                log.info("Fall back to get new default credentials");
-                
-                try {
-                	x509Credentials.getCertificate().checkValidity();
-                }catch(Exception e){
-                	x509Credentials = getDefaultCredentials();
-                }
-                
-            } catch (Exception e) {
-                throw new GFacException("Unable to retrieve remaining life time from credentials.", e);
-            }
-        }
-
-        return x509Credentials;
-    }
-
-        /**
-     * Reads the credentials from credential store.
-     * @return If token is found in the credential store, will return a valid credential. Else returns null.
-     * @throws Exception If an error occurred while retrieving credentials.
-     */
-    public  X509Credential getCredentialsFromStore() throws Exception {
-
-        if (getCredentialReader() == null) {
-            return null;
-        }
-
-        Credential credential = getCredentialReader().getCredential(getRequestData().getGatewayId(),
-                getRequestData().getTokenId());
-
-        if (credential != null) {
-            if (credential instanceof CertificateCredential) {
-
-                log.info("Successfully found credentials for token id - " + getRequestData().getTokenId() +
-                        " gateway id - " + getRequestData().getGatewayId());
-
-                CertificateCredential certificateCredential = (CertificateCredential) credential;
-
-                X509Certificate[] certificates = certificateCredential.getCertificates();
-
-                KeyAndCertCredential keyAndCert = new KeyAndCertCredential(certificateCredential.getPrivateKey(), certificates); 
-                
-                return keyAndCert;
-                //return new GlobusGSSCredentialImpl(newCredential,
-                //        GSSCredential.INITIATE_AND_ACCEPT);
-            } else {
-                log.info("Credential type is not CertificateCredential. Cannot create mapping globus credentials. " +
-                        "Credential type - " + credential.getClass().getName());
-            }
-        } else {
-            log.info("Could not find credentials for token - " + getRequestData().getTokenId() + " and "
-                    + "gateway id - " + getRequestData().getGatewayId());
-        }
-
-        return null;
-    }
-
-    /**
-     * Gets the default proxy certificate.
-     * @return Default my proxy credentials.
-     * @throws GFacException If an error occurred while retrieving credentials.
-     * @throws org.apache.airavata.common.exception.ApplicationSettingsException
-     */
-    public X509Credential getDefaultCredentials() throws GFacException, ApplicationSettingsException{
-    	MyProxyLogon logon = new MyProxyLogon();
-    	logon.setValidator(dcValidator);
-    	logon.setHost(getRequestData().getMyProxyServerUrl());
-    	logon.setPort(getRequestData().getMyProxyPort());
-    	logon.setUsername(getRequestData().getMyProxyUserName());
-    	logon.setPassphrase(getRequestData().getMyProxyPassword().toCharArray());
-    	logon.setLifetime(getRequestData().getMyProxyLifeTime());
-    	
-        	try {
-				logon.connect();
-				logon.logon();
-				logon.getCredentials();
-				logon.disconnect();
-				PrivateKey pk=logon.getPrivateKey();
-				return new KeyAndCertCredential(pk, new X509Certificate[]{logon.getCertificate()});
-			}  catch (Exception e) {
-				throw new GFacException("An error occurred while retrieving default security credentials.", e);
-			}
-    }
-
-	private static  DirectoryCertChainValidator getTrustedCerts() throws Exception{
-		String certLocation = getTrustedCertificatePath();
-		List<String> trustedCert = new ArrayList<String>();
-		trustedCert.add(certLocation + "/*.0");
-		trustedCert.add(certLocation + "/*.pem");
-		DirectoryCertChainValidator dcValidator = new DirectoryCertChainValidator(trustedCert, Encoding.PEM, -1, 60000, null);
-		return dcValidator;
-	}
-	
-	private String getCNFromUserDN(String userDN) {
-		return X500NameUtils.getAttributeValues(userDN, BCStyle.CN)[0];
-	}
-	
-	public KeyAndCertCredential generateShortLivedCredential(String userDN, String caCertPath, String caKeyPath,
-			String caPwd) throws Exception {
-		final long CredentialGoodFromOffset = 1000L * 60L * 15L; // 15 minutes
-																	// ago
-
-		final long startTime = System.currentTimeMillis() - CredentialGoodFromOffset;
-		final long endTime = startTime + 30 * 3600 * 1000;
-
-		String keyLengthProp = "1024";
-		int keyLength = Integer.parseInt(keyLengthProp);
-		String signatureAlgorithm = "SHA1withRSA";
-
-		KeyAndCertCredential caCred = getCACredential(caCertPath, caKeyPath, caPwd);
-
-		KeyPairGenerator kpg = KeyPairGenerator.getInstance(caCred.getKey().getAlgorithm());
-		kpg.initialize(keyLength);
-		KeyPair pair = kpg.generateKeyPair();
-
-		X500Principal subjectDN = new X500Principal(userDN);
-		Random rand = new Random();
-
-		SubjectPublicKeyInfo publicKeyInfo;
-		try {
-			publicKeyInfo = SubjectPublicKeyInfo.getInstance(new ASN1InputStream(pair.getPublic().getEncoded())
-					.readObject());
-		} catch (IOException e) {
-			throw new InvalidKeyException("Can not parse the public key"
-					+ "being included in the short lived certificate", e);
-		}
-
-		X500Name issuerX500Name = CertificateHelpers.toX500Name(caCred.getCertificate().getSubjectX500Principal());
-
-		X500Name subjectX500Name = CertificateHelpers.toX500Name(subjectDN);
-
-		X509v3CertificateBuilder certBuilder = new X509v3CertificateBuilder(issuerX500Name, new BigInteger(20, rand),
-				new Date(startTime), new Date(endTime), subjectX500Name, publicKeyInfo);
-
-		AlgorithmIdentifier sigAlgId = X509v3CertificateBuilder.extractAlgorithmId(caCred.getCertificate());
-
-		X509Certificate certificate = certBuilder.build(caCred.getKey(), sigAlgId, signatureAlgorithm, null, null);
-
-		certificate.checkValidity(new Date());
-		certificate.verify(caCred.getCertificate().getPublicKey());
-		KeyAndCertCredential result = new KeyAndCertCredential(pair.getPrivate(), new X509Certificate[] { certificate,
-				caCred.getCertificate() });
-
-		return result;
-	}
-	
-	private KeyAndCertCredential getCACredential(String caCertPath, String caKeyPath, String password) throws Exception {
-		InputStream isKey, isCert;
-		isKey = isCert = null;
-		try {
-		isKey = new FileInputStream(caKeyPath);
-		PrivateKey pk = CertificateUtils.loadPrivateKey(isKey, Encoding.PEM, password.toCharArray());
-
-		isCert = new FileInputStream(caCertPath);
-		X509Certificate caCert = CertificateUtils.loadCertificate(isCert, Encoding.PEM);
-		return new KeyAndCertCredential(pk, new X509Certificate[] { caCert });
-		} finally {
-			if (isKey != null){
-				isKey.close();
-			}
-			if (isCert != null) {
-				isCert.close();
-			}
-		}
-	}
-	 
-    
-}

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/ActivityInfo.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/ActivityInfo.java b/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/ActivityInfo.java
deleted file mode 100644
index 3625513..0000000
--- a/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/ActivityInfo.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-*
-* 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.gfac.bes.utils;
-
-import java.io.Serializable;
-
-import org.ggf.schemas.bes.x2006.x08.besFactory.ActivityStatusType;
-import org.w3.x2005.x08.addressing.EndpointReferenceType;
-
-public class ActivityInfo implements Serializable{
-	
-	private static final long serialVersionUID = 1L;
-
-	private EndpointReferenceType activityEPR;
-	
-	private ActivityStatusType activityStatusDoc;
-	
-
-	public EndpointReferenceType getActivityEPR() {
-		return activityEPR;
-	}
-	public void setActivityEPR(EndpointReferenceType activityEPR) {
-		this.activityEPR = activityEPR;
-	}
-	public ActivityStatusType getActivityStatus() {
-		return activityStatusDoc;
-	}
-	public void setActivityStatusDoc(ActivityStatusType activityStatusDoc) {
-		this.activityStatusDoc = activityStatusDoc;
-	}
-	
-}

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/ApplicationProcessor.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/ApplicationProcessor.java b/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/ApplicationProcessor.java
deleted file mode 100644
index bc91e49..0000000
--- a/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/ApplicationProcessor.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- *
- * 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.gfac.bes.utils;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.airavata.gfac.core.context.JobExecutionContext;
-import org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription;
-import org.apache.airavata.model.appcatalog.appdeployment.ApplicationParallelismType;
-import org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.ApplicationType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.FileNameType;
-import org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.UserNameType;
-import org.ogf.schemas.jsdl.x2007.x02.jsdlSpmd.NumberOfProcessesType;
-import org.ogf.schemas.jsdl.x2007.x02.jsdlSpmd.ProcessesPerHostType;
-import org.ogf.schemas.jsdl.x2007.x02.jsdlSpmd.ThreadsPerProcessType;
-
-
-public class ApplicationProcessor {
-	
-	public static void generateJobSpecificAppElements(JobDefinitionType value, JobExecutionContext context){
-		
-		String userName = getUserNameFromContext(context);
-//		if (userName.equalsIgnoreCase("admin")){
-//			userName = "CN=zdv575, O=Ultrascan Gateway, C=DE";
-//		}
-		
-		ApplicationDeploymentDescription appDep= context.getApplicationContext().getApplicationDeploymentDescription();
-        String appname = context.getApplicationContext().getApplicationInterfaceDescription().getApplicationName();
-        ApplicationParallelismType parallelism = appDep.getParallelism();
-        ApplicationType appType = JSDLUtils.getOrCreateApplication(value);
-        appType.setApplicationName(appname);
-        
-
-//		if (appDep.getSetEnvironment().size() > 0) {
-//            createApplicationEnvironment(value, appDep.getSetEnvironment(), parallelism);
-//		}
-//
-        
-		String stdout = context.getStandardOutput();
-		String stderr = context.getStandardError();
-		if(stdout != null) {
-			stdout = stdout.substring(stdout.lastIndexOf('/')+1);
-		}
-		
-		if(stderr != null) {
-			stderr = stderr.substring(stderr.lastIndexOf('/')+1);
-		}
-		
-		stdout = (stdout == null || stdout.equals("")) ? "stdout":stdout;
-		stderr = (stdout == null || stderr.equals("")) ? "stderr":stderr;
-
-        if (appDep.getExecutablePath() != null) {
-			FileNameType fNameType = FileNameType.Factory.newInstance();
-			fNameType.setStringValue(appDep.getExecutablePath());
-			if(isParallelJob(context)) {
-				JSDLUtils.getOrCreateSPMDApplication(value).setExecutable(fNameType);
-                if (parallelism.equals(ApplicationParallelismType.OPENMP_MPI)){
-                    JSDLUtils.getSPMDApplication(value).setSPMDVariation(SPMDVariations.OpenMPI.value());
-                }else if (parallelism.equals(ApplicationParallelismType.MPI)){
-                    JSDLUtils.getSPMDApplication(value).setSPMDVariation(SPMDVariations.MPI.value());
-                }
-                
-                // setting number of processes
-                try { 
-	                String np = getInputAsString(context, BESConstants.NUMBER_OF_PROCESSES);
-	                if((np != null)  && (Integer.parseInt(np) > 0)){
-						NumberOfProcessesType num = NumberOfProcessesType.Factory.newInstance();
-	                    num.setStringValue(np);
-						JSDLUtils.getSPMDApplication(value).setNumberOfProcesses(num);
-					}
-	
-                }catch(RuntimeException np) {
-                	// do nothing
-                }
-
-
-                try { 
-	                // setting processes per host
-	                String pphost = getInputAsString(context, BESConstants.PROCESSES_PER_HOST);
-	                if((pphost != null)  && (Integer.parseInt(pphost) > 0)){
-	                    ProcessesPerHostType pph = ProcessesPerHostType.Factory.newInstance();
-	                    pph.setStringValue(String.valueOf(pphost));
-	                    JSDLUtils.getSPMDApplication(value).setProcessesPerHost(pph);
-	                }
-                }catch(RuntimeException np) {
-                	// do nothing
-                }
-                
-                int totalThreadCount = context.getTaskData().getTaskScheduling().getNumberOfThreads();
-                // we take it as threads per processes
-                if(totalThreadCount > 0){
-					ThreadsPerProcessType tpp = ThreadsPerProcessType.Factory.newInstance();
-					tpp.setStringValue(String.valueOf(totalThreadCount));
-					JSDLUtils.getSPMDApplication(value).setThreadsPerProcess(tpp);
-				}
-				
-				if(userName != null) {
-					UserNameType userNameType = UserNameType.Factory.newInstance();
-					userNameType.setStringValue(userName);
-					JSDLUtils.getSPMDApplication(value).setUserName(userNameType);
-				}
-                if (stdout != null){
-                    FileNameType fName = FileNameType.Factory.newInstance();
-                    fName.setStringValue(stdout);
-                    JSDLUtils.getOrCreateSPMDApplication(value).setOutput(fName);
-                }
-                if (stderr != null){
-                    FileNameType fName = FileNameType.Factory.newInstance();
-                    fName.setStringValue(stderr);
-                    JSDLUtils.getOrCreateSPMDApplication(value).setError(fName);
-                }
-
-
-			}
-			else {
-				JSDLUtils.getOrCreatePOSIXApplication(value).setExecutable(fNameType);
-				if(userName != null) {
-					UserNameType userNameType = UserNameType.Factory.newInstance();
-					userNameType.setStringValue(userName);
-					JSDLUtils.getOrCreatePOSIXApplication(value).setUserName(userNameType);
-				}
-                if (stdout != null){
-                    FileNameType fName = FileNameType.Factory.newInstance();
-                    fName.setStringValue(stdout);
-                    JSDLUtils.getOrCreatePOSIXApplication(value).setOutput(fName);
-                }
-                if (stderr != null){
-                    FileNameType fName = FileNameType.Factory.newInstance();
-                    fName.setStringValue(stderr);
-                    JSDLUtils.getOrCreatePOSIXApplication(value).setError(fName);
-                }
-			}
-		}
-	}
-	
-	public static String getUserNameFromContext(JobExecutionContext jobContext) {
-		if(jobContext.getTaskData() == null)
-			return null;
-		//TODO: Extend unicore model to specify optional unix user id (allocation account) 
-		return "admin";
-	}
-
-	public static void addApplicationArgument(JobDefinitionType value, JobExecutionContext context, String stringPrm) {
-		if(isParallelJob(context)){ 		
-			JSDLUtils.getOrCreateSPMDApplication(value).addNewArgument().setStringValue(stringPrm);
-		}
-		else { 
-		    JSDLUtils.getOrCreatePOSIXApplication(value).addNewArgument().setStringValue(stringPrm);
-		}
-	}
-	
-	public static String getApplicationStdOut(JobDefinitionType value, JobExecutionContext context) throws RuntimeException {
-		if (isParallelJob(context)) return JSDLUtils.getOrCreateSPMDApplication(value).getOutput().getStringValue();
-		else return JSDLUtils.getOrCreatePOSIXApplication(value).getOutput().getStringValue();
-	}
-	
-	public static String getApplicationStdErr(JobDefinitionType value, JobExecutionContext context) throws RuntimeException {
-		if (isParallelJob(context)) return JSDLUtils.getOrCreateSPMDApplication(value).getError().getStringValue();
-		else return JSDLUtils.getOrCreatePOSIXApplication(value).getError().getStringValue();
-	}
-	
-	public static void createGenericApplication(JobDefinitionType value, String appName) {
-        ApplicationType appType = JSDLUtils.getOrCreateApplication(value);
-        appType.setApplicationName(appName);
-    }
-	
-	public static boolean isParallelJob(JobExecutionContext context) {
-		
-		ApplicationDeploymentDescription appDep = context.getApplicationContext().getApplicationDeploymentDescription();
-		ApplicationParallelismType parallelism = appDep.getParallelism();
-		
-		boolean isParallel = false;
-		
-		if(parallelism.equals(ApplicationParallelismType.MPI) || 
-		   parallelism.equals(ApplicationParallelismType.OPENMP_MPI) || 
-		   parallelism.equals(ApplicationParallelismType.OPENMP	)) {
-			isParallel = true;
-		}
-		
-		return isParallel;
-	}
-	
-	private static String getInputAsString(JobExecutionContext context, String name) {
-		List<InputDataObjectType> inputList = context.getTaskData().getApplicationInputs();
-		String value = null;
-		for (Iterator<InputDataObjectType> iterator = inputList.iterator(); iterator.hasNext();) {
-			InputDataObjectType inputDataObjectType = iterator
-					.next();
-			if (inputDataObjectType.getName().equals(name)) {
-				value = inputDataObjectType.getValue();
-				break;
-			}
-		}
-		return value;
-	}
-	
-	
-
-}

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/BESConstants.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/BESConstants.java b/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/BESConstants.java
deleted file mode 100644
index 6e87e28..0000000
--- a/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/BESConstants.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-*
-* 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.gfac.bes.utils;
-
-public interface BESConstants {
-	
-	public static final String PROP_SMS_EPR = "unicore.sms.epr";
-	
-	public static final String PROP_BES_URL = "bes.factory.url";
-
-	public static final String PROP_ACTIVITY_INFO = "bes.activity.info";
-	
-	public static final String PROP_CLIENT_CONF = "bes.client.config";
-	
-	public static final String PROP_CA_CERT_PATH = "bes.ca.cert.path";
-	
-	public static final String PROP_CA_KEY_PATH = "bes.ca.key.path";
-	
-	public static final String PROP_CA_KEY_PASS = "bes.ca.key.pass";
-	
-	public static final String NUMBER_OF_PROCESSES = "NumberOfProcesses";
-	
-	public static final String PROCESSES_PER_HOST = "ProcessesPerHost";
-
-	
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/DataTransferrer.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/DataTransferrer.java b/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/DataTransferrer.java
deleted file mode 100644
index ad8ca2f..0000000
--- a/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/DataTransferrer.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- *
- * 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.gfac.bes.utils;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.airavata.gfac.core.GFacConstants;
-import org.apache.airavata.gfac.core.context.JobExecutionContext;
-import org.apache.airavata.gfac.core.provider.GFacProviderException;
-import org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription;
-import org.apache.airavata.model.appcatalog.appinterface.DataType;
-import org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType;
-import org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType;
-import org.apache.airavata.model.experiment.TaskDetails;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import de.fzj.unicore.uas.client.StorageClient;
-
-
-public class DataTransferrer {
-    protected final Logger log = LoggerFactory.getLogger(this.getClass());
-
-	private JobExecutionContext jobContext;
-	
-	private StorageClient storageClient;
-	
-	public DataTransferrer(JobExecutionContext jobContext, StorageClient storageClient) {
-		this.jobContext = jobContext;
-		this.storageClient = storageClient;
-	}
-	
-	
-	public void uploadLocalFiles() throws GFacProviderException {
-		List<String> inFilePrms = extractInFileParams();
-		for (String uri : inFilePrms) {
-			String fileName = new File(uri).getName();
-				if (uri.startsWith("file")) {
-					try {
-						String uriWithoutProtocol = uri.substring(uri.lastIndexOf("://") + 1, uri.length());
-						FileUploader fileUploader = new FileUploader(uriWithoutProtocol,fileName,Mode.overwrite);
-						fileUploader.perform(storageClient);
-					} catch (FileNotFoundException e3) {
-						throw new GFacProviderException(
-								"Error while staging-in, local file "+fileName+" not found", e3);
-					} catch (Exception e) {
-						throw new GFacProviderException("Cannot upload files", e);
-
-					}
-
-				}
-		}
-		
-	}
-	
-	/**
-	 * This method will download all the remote files specified in the output 
-	 * context of a job.  
-	 * */
-	public void downloadRemoteFiles() throws GFacProviderException {
-		
-		String downloadLocation = getDownloadLocation();
-		
-		File file = new File(downloadLocation);
-		if(!file.exists()){
-			file.mkdirs();	
-		}
-
-		Map<String, Object> output = jobContext.getOutMessageContext().getParameters();
-        Set<String> keys = output.keySet();
-        
-		for (String outPrm : keys) {
-			OutputDataObjectType actualParameter = (OutputDataObjectType) output.get(outPrm);
-				if (DataType.STDERR == actualParameter.getType()) continue;
-				if (DataType.STDOUT == actualParameter.getType()) continue;
-				
-				String value = actualParameter.getValue();
-				FileDownloader fileDownloader = new FileDownloader(value,downloadLocation, Mode.overwrite);
-				try {
-					fileDownloader.perform(storageClient);
-					String outputPath = downloadLocation + File.separator + value.substring(value.lastIndexOf('/')+1);
-					actualParameter.setValue(outputPath);
-					actualParameter.setType(DataType.URI);
-					jobContext.addOutputFile(outputPath);
-				} catch (Exception e) {
-					throw new GFacProviderException(e.getLocalizedMessage(),e);
-				}
-		}
-		downloadStdOuts();
-	}
-	
-	
-	public void downloadStdOuts()  throws GFacProviderException{
-		String downloadLocation = getDownloadLocation();
-		File file = new File(downloadLocation);
-		if(!file.exists()){
-			file.mkdirs();	
-		}
-		
-		String stdout = jobContext.getStandardOutput();
-		String stderr = jobContext.getStandardError();
-		if(stdout != null) {
-			stdout = stdout.substring(stdout.lastIndexOf('/')+1);
-		}
-		
-		if(stderr != null) {
-			stderr = stderr.substring(stderr.lastIndexOf('/')+1);
-		}
-		
-		String stdoutFileName = (stdout == null || stdout.equals("")) ? "stdout"
-				: stdout;
-		String stderrFileName = (stdout == null || stderr.equals("")) ? "stderr"
-				: stderr;
-		
-		ApplicationDeploymentDescription application = jobContext.getApplicationContext().getApplicationDeploymentDescription();
-		
-		String stdoutLocation = downloadLocation+File.separator+stdoutFileName;
-		FileDownloader f1 = new FileDownloader(stdoutFileName,stdoutLocation, Mode.overwrite);
-		try {
-			f1.perform(storageClient);
-			log.info("Downloading stdout and stderr..");
-			String stdoutput = readFile(stdoutLocation);
-			jobContext.addOutputFile(stdoutLocation);
-			jobContext.setStandardOutput(stdoutLocation);
-			log.info("Stdout downloaded to -> "+stdoutLocation);
-			if(UASDataStagingProcessor.isUnicoreEndpoint(jobContext)) {
-				String scriptExitCodeFName = "UNICORE_SCRIPT_EXIT_CODE";
-				String scriptCodeLocation = downloadLocation+File.separator+scriptExitCodeFName;
-				f1.setFrom(scriptExitCodeFName);
-				f1.setTo(scriptCodeLocation);
-				f1.perform(storageClient);
-				log.info("UNICORE_SCRIPT_EXIT_CODE downloaded to "+scriptCodeLocation);
-			}
-			String stderrLocation = downloadLocation+File.separator+stderrFileName;
-			f1.setFrom(stderrFileName);
-			f1.setTo(stderrLocation);
-			f1.perform(storageClient);
-			String stderror = readFile(stderrLocation);
-			jobContext.addOutputFile(stderrLocation);
-			jobContext.setStandardError(stderrLocation);
-			log.info("Stderr downloaded to -> "+stderrLocation);
-		} catch (Exception e) {
-			throw new GFacProviderException(e.getLocalizedMessage(),e);
-		}
-		
-	}
-	
-	public List<String> extractOutParams(JobExecutionContext context) {
-		List<String> outPrmsList = new ArrayList<String>();
-		List<OutputDataObjectType> applicationOutputs = jobContext.getTaskData().getApplicationOutputs();
-		 if (applicationOutputs != null && !applicationOutputs.isEmpty()){
-           for (OutputDataObjectType output : applicationOutputs){
-          	 if(output.getType().equals(DataType.STRING)) {
-          		outPrmsList.add(output.getValue());
-          	 }
-          	 else if(output.getType().equals(DataType.FLOAT) || output.getType().equals(DataType.INTEGER)) {
-          		outPrmsList.add(String.valueOf(output.getValue()));
-          		 
-          	 }
-           }
-		 }
-		return outPrmsList;
-	}
-	
-	public List<String> extractInFileParams() {
-		List<String> filePrmsList = new ArrayList<String>();
-		List<InputDataObjectType> applicationInputs = jobContext.getTaskData().getApplicationInputs();
-		 if (applicationInputs != null && !applicationInputs.isEmpty()){
-           for (InputDataObjectType output : applicationInputs){
-          	 if(output.getType().equals(DataType.URI)) {
-          		filePrmsList.add(output.getValue());
-          	 }
-           }
-		 }
-		return filePrmsList;
-	}
-
-	
-	private String readFile(String localFile) throws IOException {
-		BufferedReader instream = new BufferedReader(new FileReader(localFile));
-		StringBuffer buff = new StringBuffer();
-		String temp = null;
-		while ((temp = instream.readLine()) != null) {
-			buff.append(temp);
-			buff.append(GFacConstants.NEWLINE);
-		}
-
-		log.info("finish read file:" + localFile);
-
-		return buff.toString();
-	}
-	
-	public void setStorageClient(StorageClient sc){
-		storageClient = sc;
-	}
-	
-	private String getDownloadLocation() {
-		TaskDetails taskData = jobContext.getTaskData();
-		//In case of third party transfer this will not work.
-//		if (taskData != null && taskData.getAdvancedOutputDataHandling() != null) {
-//			String outputDataDirectory = taskData.getAdvancedOutputDataHandling().getOutputDataDir();
-//			return outputDataDirectory;
-//		}
-		String outputDataDir = File.separator + "tmp";
-        outputDataDir = outputDataDir + File.separator + jobContext.getExperimentID();
-        (new File(outputDataDir)).mkdirs();
-		return outputDataDir;
-	}
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/FileDownloader.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/FileDownloader.java b/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/FileDownloader.java
deleted file mode 100644
index 680aa51..0000000
--- a/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/FileDownloader.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- *
- * 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.gfac.bes.utils;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Map;
-
-import org.unigrids.services.atomic.types.GridFileType;
-import org.unigrids.services.atomic.types.ProtocolType;
-
-import de.fzj.unicore.uas.client.FileTransferClient;
-import de.fzj.unicore.uas.client.StorageClient;
-import de.fzj.unicore.uas.client.UFTPConstants;
-import de.fzj.unicore.uas.client.UFTPFileTransferClient;
-import de.fzj.unicore.uas.fts.FiletransferOptions.IMonitorable;
-import de.fzj.unicore.uas.fts.FiletransferOptions.SupportsPartialRead;
-
-/**
- * helper that exports remote files from a UNICORE Storage 
- * to the local client machine.<br/>
- * Simple wildcards ("*" and "?") and download of 
- * directories are supported.
- * 
- * TODO this should be refactored so the single-file download logic 
- * is separated from the wildcard/directory/provided outputStream logic
- * 
- * @author schuller
- */
-public class FileDownloader extends FileTransferBase{
-
-	private boolean showProgress=true;
-
-	private boolean forceFileOnly=false;
-	
-	private OutputStream targetStream=null;
-	
-	public FileDownloader(String from, String to, Mode mode){
-		this(from,to,mode,true);
-	}
-	
-	public FileDownloader(String from, String to, Mode mode, boolean failOnError){
-		this.to=to;
-		this.from=from;
-		this.mode=mode;
-		this.failOnError=failOnError;
-	}
-	
-	public void perform(StorageClient sms)throws Exception{
-		boolean isWildcard=hasWildCards(from);
-		boolean isDirectory=false;
-		GridFileType gridSource=null;
-		if(isWildcard){
-			performWildCardExport(sms);
-		}
-		else {
-			//check if source is a directory
-			gridSource=sms.listProperties(from);
-			isDirectory=gridSource.getIsDirectory();
-			if(isDirectory){
-				if(forceFileOnly){
-					throw new IOException("Source is a directory");
-				}
-				performDirectoryExport(gridSource, new File(to), sms);
-			}
-			else{
-				download(gridSource,new File(to),sms);
-			}
-		}	
-	}
-	
-	protected void performDirectoryExport(GridFileType directory, File targetDirectory, StorageClient sms)throws Exception{
-		if(!targetDirectory.exists()|| !targetDirectory.canWrite()){
-			throw new IOException("Target directory <"+to+"> does not exist or is not writable!");
-		}
-		if(!targetDirectory.isDirectory()){
-			throw new IOException("Target <"+to+"> is not a directory!");
-		}
-		GridFileType[]gridFiles=sms.listDirectory(directory.getPath());
-		for(GridFileType file: gridFiles){
-			if(file.getIsDirectory()){
-				if(!recurse) {
-					System.out.println("Skipping directory "+file.getPath());
-					continue;
-				}
-				else{
-					File newTargetDirectory=new File(targetDirectory,getName(file.getPath()));
-					boolean success=newTargetDirectory.mkdirs();
-					if(!success)throw new IOException("Can create directory: "+newTargetDirectory.getAbsolutePath());
-					performDirectoryExport(file, newTargetDirectory, sms);
-					continue;
-				}
-			}
-			download(file, new File(targetDirectory,getName(file.getPath())), sms);
-		}
-	}
-	
-	protected void performWildCardExport(StorageClient sms)throws Exception{
-		String dir=getDir(from);
-		if(dir==null)dir="/";
-		GridFileType[] files=sms.find(dir, false, from, false, null, null);
-		File targetDir=targetStream==null?new File(to):null;
-		if(targetStream==null){
-			if(!targetDir.isDirectory())throw new IOException("Target is not a directory.");
-		}
-		for(GridFileType f: files){
-			download(f, targetDir, sms);
-		}
-	}	
-	
-	private String getDir(String path){
-		return new File(path).getParent();
-	}
-	
-	private String getName(String path){
-		return new File(path).getName();
-	}
-	
-	/**
-	 * download a single regular file
-	 * 
-	 * @param source - grid file descriptor
-	 * @param localFile - local file or directory to write to
-	 * @param sms
-	 * @throws Exception
-	 */
-	private void download(GridFileType source, File localFile, StorageClient sms)throws Exception{
-		if(source==null || source.getIsDirectory()){
-			throw new IllegalStateException("Source="+source); 
-		}
-		
-		OutputStream os=targetStream!=null?targetStream:null;
-		FileTransferClient ftc=null;
-		try{
-			String path=source.getPath();
-			if(targetStream==null){
-				if(localFile.isDirectory()){
-					localFile=new File(localFile,getName(source.getPath()));
-				}
-				if(mode.equals(Mode.nooverwrite) && localFile.exists()){
-					System.out.println("File exists and creation mode was set to 'nooverwrite'.");
-					return; 
-				}
-				System.out.println("Downloading remote file '"+sms.getUrl()+"#/"+path+"' -> "+localFile.getAbsolutePath());
-				os=new FileOutputStream(localFile.getAbsolutePath(), mode.equals(Mode.append));
-			}
-			
-			chosenProtocol=sms.findSupportedProtocol(preferredProtocols.toArray(new ProtocolType.Enum[preferredProtocols.size()]));
-			Map<String,String>extraParameters=makeExtraParameters(chosenProtocol);
-			ftc=sms.getExport(path,extraParameters,chosenProtocol);
-			configure(ftc, extraParameters);
-			System.out.println("DEB:File transfer URL : "+ftc.getUrl());
-//			ProgressBar p=null;
-			if(ftc instanceof IMonitorable  && showProgress){
-				long size=ftc.getSourceFileSize();
-				if(isRange()){
-					size=getRangeSize();
-				}
-//				p=new ProgressBar(localFile.getName(),size,msg);
-//				((IMonitorable) ftc).setProgressListener(p);
-			}
-			long startTime=System.currentTimeMillis();
-			if(isRange()){
-				if(!(ftc instanceof SupportsPartialRead)){
-					throw new Exception("Byte range is defined but protocol does not allow " +
-							"partial read! Please choose a different protocol!");
-				}
-				System.out.println("Byte range: "+startByte+" - "+(getRangeSize()>0?endByte:""));
-				SupportsPartialRead pReader=(SupportsPartialRead)ftc;
-				pReader.readPartial(startByte, endByte-startByte+1, os);
-			}
-			else{
-				ftc.readAllData(os);
-			}
-//			if(p!=null){
-//				p.finish();
-//			}
-			if(timing){
-				long duration=System.currentTimeMillis()-startTime;
-				double rate=(double)localFile.length()/(double)duration;
-				System.out.println("Rate: " +rate+ " kB/sec.");
-			}
-			if(targetStream==null)copyProperties(source, localFile);
-		}
-		finally{
-			try{ 
-				if(targetStream==null && os!=null){
-					os.close();
-				}
-			}catch(Exception ignored){}
-			if(ftc!=null){
-				try{
-					ftc.destroy();
-				}catch(Exception e1){
-//					System.out.println("Could not destroy the filetransfer client",e1);
-				}
-			}
-		}
-	}
-
-	/**
-	 * if possible, copy the remote executable flag to the local file
-	 * @throws Exception
-	 */
-	private void copyProperties(GridFileType source, File localFile)throws Exception{
-		try{
-			localFile.setExecutable(source.getPermissions().getExecutable());
-		}
-		catch(Exception ex){
-			//TODO: logging
-//			("Can't set 'executable' flag for "+localFile.getName(), ex);
-		}
-	}
-	
-	private void configure(FileTransferClient ftc, Map<String,String>params){
-		if(ftc instanceof UFTPFileTransferClient){
-			UFTPFileTransferClient u=(UFTPFileTransferClient)ftc;
-			String secret=params.get(UFTPConstants.PARAM_SECRET);
-			u.setSecret(secret);
-		}
-	}
-
-	public void setShowProgress(boolean showProgress) {
-		this.showProgress = showProgress;
-	}
-
-	public void setForceFileOnly(boolean forceFileOnly) {
-		this.forceFileOnly = forceFileOnly;
-	}
-
-	public void setTargetStream(OutputStream targetStream) {
-		this.targetStream = targetStream;
-	}
-	
-}

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/FileTransferBase.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/FileTransferBase.java b/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/FileTransferBase.java
deleted file mode 100644
index ef46feb..0000000
--- a/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/bes/utils/FileTransferBase.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- *
- * 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.gfac.bes.utils;
-
-import java.io.File;
-import java.io.FilenameFilter;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.regex.Pattern;
-
-import org.unigrids.services.atomic.types.GridFileType;
-import org.unigrids.services.atomic.types.ProtocolType;
-
-import de.fzj.unicore.uas.client.StorageClient;
-import de.fzj.unicore.uas.util.PropertyHelper;
-public class FileTransferBase {
-
-	protected Properties extraParameterSource;
-
-	protected boolean timing=false;
-
-	protected boolean recurse=false;
-
-	protected String from;
-
-	protected String to;
-
-	//index of first byte to download
-	protected Long startByte;
-	
-	//index of last byte to download
-	protected Long endByte;
-	
-	/**
-	 * the creation mode
-	 */
-	protected Mode mode;
-
-	/**
-	 * whether the job processing should fail if an error occurs
-	 */
-	protected boolean failOnError;
-
-	protected List<ProtocolType.Enum> preferredProtocols=new ArrayList<ProtocolType.Enum>();
-
-	public FileTransferBase(){
-		preferredProtocols.add(ProtocolType.BFT);
-	}
-
-	protected Map<String,String>makeExtraParameters(ProtocolType.Enum protocol){
-		Map<String, String> res;
-		if(extraParameterSource==null){
-			res=new HashMap<String, String>();
-		}
-		else{
-			String p=String.valueOf(protocol);
-			PropertyHelper ph=new PropertyHelper(extraParameterSource, new String[]{p,p.toLowerCase()});
-			res= ph.getFilteredMap();
-		}
-		if(res.size()>0){
-			// TODO: change it to logger 
-			System.out.println("Have "+res.size()+" extra parameters for protocol "+protocol);
-		}
-		return res;
-	}
-	
-	
-	public String getTo() {
-		return to;
-	}
-
-	public String getFrom() {
-		return from;
-	}
-
-	public void setTo(String to) {
-		this.to = to;
-	}
-
-	public void setFrom(String from) {
-		this.from = from;
-	}
-
-	public Mode getMode() {
-		return mode;
-	}
-
-	public boolean isFailOnError() {
-		return failOnError;
-	}
-
-	public boolean isTiming() {
-		return timing;
-	}
-
-	public void setTiming(boolean timing) {
-		this.timing = timing;
-	}
-
-	public void setFailOnError(boolean failOnError) {
-		this.failOnError = failOnError;
-	}
-
-	public List<ProtocolType.Enum> getPreferredProtocols() {
-		return preferredProtocols;
-	}
-
-	public void setPreferredProtocols(List<ProtocolType.Enum> preferredProtocols) {
-		this.preferredProtocols = preferredProtocols;
-	}
-
-	public void setExtraParameterSource(Properties properties){
-		this.extraParameterSource=properties;
-	}
-
-	public void setRecurse(boolean recurse) {
-		this.recurse = recurse;
-	}
-	/**
-	 * check if the given path denotes a valid remote directory
-	 * @param remotePath - the path
-	 * @param sms - the storage
-	 * @return <code>true</code> if the remote directory exists and is a directory
-	 */
-	protected boolean isValidDirectory(String remotePath, StorageClient sms){
-		boolean result=false;
-		if(! ("/".equals(remotePath) || ".".equals(remotePath)) ){
-			try{
-				GridFileType gft=sms.listProperties(remotePath);
-				result=gft.getIsDirectory();
-			}catch(Exception ex){
-				result=false;
-			}
-		}
-		else result=true;
-		
-		return result;
-	}
-	
-	public File[] resolveWildCards(File original){
-		final String name=original.getName();
-		if(!hasWildCards(original))return new File[]{original};
-		File parent=original.getParentFile();
-		if(parent==null)parent=new File(".");
-		FilenameFilter filter=new FilenameFilter(){
-			Pattern p=createPattern(name);
-			public boolean accept(File file, String name){
-				return p.matcher(name).matches();
-			}
-		};
-		return parent.listFiles(filter);
-	}
-
-	protected boolean hasWildCards(File file){
-		return hasWildCards(file.getName());
-	}
-
-	public boolean hasWildCards(String name){
-		return name.contains("*") || name.contains("?");
-	}
-
-	private Pattern createPattern(String nameWithWildcards){
-		String regex=nameWithWildcards.replace("?",".").replace("*", ".*");
-		return Pattern.compile(regex);
-	}
-	
-	protected ProtocolType.Enum chosenProtocol=null;
-	
-	public ProtocolType.Enum getChosenProtocol(){
-		return chosenProtocol;
-	}
-
-	public Long getStartByte() {
-		return startByte;
-	}
-
-	public void setStartByte(Long startByte) {
-		this.startByte = startByte;
-	}
-
-	public Long getEndByte() {
-		return endByte;
-	}
-
-	public void setEndByte(Long endByte) {
-		this.endByte = endByte;
-	}
-	
-	/**
-	 * checks if a byte range is defined
-	 * @return <code>true</code> iff both startByte and endByte are defined
-	 */
-	protected boolean isRange(){
-		return startByte!=null && endByte!=null;
-	}
-	
-	/**
-	 * get the number of bytes in the byte range, or "-1" if the range is open-ended
-	 * @return
-	 */
-	protected long getRangeSize(){
-		if(Long.MAX_VALUE==endByte)return -1;
-		return endByte-startByte;
-	}
-}


Mime
View raw message