airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject airavata git commit: handling URI_COLLECTION type when creating process input model
Date Tue, 05 Jul 2016 22:50:33 GMT
Repository: airavata
Updated Branches:
  refs/heads/develop c382ae2ab -> d20f77e4b


handling URI_COLLECTION type when creating process input model


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/d20f77e4
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/d20f77e4
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/d20f77e4

Branch: refs/heads/develop
Commit: d20f77e4b5d3545fe01facbb9b2a3b0f9f6ce16c
Parents: c382ae2
Author: scnakandala <supun.nakandala@gmail.com>
Authored: Tue Jul 5 18:50:29 2016 -0400
Committer: scnakandala <supun.nakandala@gmail.com>
Committed: Tue Jul 5 18:50:29 2016 -0400

----------------------------------------------------------------------
 .../server/OrchestratorServerHandler.java       | 40 +++++++++++++++++---
 1 file changed, 35 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/d20f77e4/modules/orchestrator/orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java
b/modules/orchestrator/orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java
index 1367e44..60cb7a0 100644
--- a/modules/orchestrator/orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java
+++ b/modules/orchestrator/orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java
@@ -38,6 +38,7 @@ import org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePrefer
 import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile;
 import org.apache.airavata.model.application.io.DataType;
 import org.apache.airavata.model.data.replica.DataProductModel;
+import org.apache.airavata.model.data.replica.DataReplicaLocationModel;
 import org.apache.airavata.model.data.replica.ReplicaLocationCategory;
 import org.apache.airavata.model.error.LaunchValidationException;
 import org.apache.airavata.model.experiment.ExperimentModel;
@@ -59,6 +60,7 @@ import org.apache.airavata.registry.core.app.catalog.resources.AppCatAbstractRes
 import org.apache.airavata.registry.core.experiment.catalog.impl.RegistryFactory;
 import org.apache.airavata.registry.core.experiment.catalog.resources.AbstractExpCatResource;
 import org.apache.airavata.registry.cpi.*;
+import org.apache.commons.lang.StringUtils;
 import org.apache.curator.RetryPolicy;
 import org.apache.curator.framework.CuratorFramework;
 import org.apache.curator.framework.CuratorFrameworkFactory;
@@ -168,11 +170,39 @@ public class OrchestratorServerHandler implements OrchestratorService.Iface
{
 						if (pi.getType().equals(DataType.URI) && pi.getValue().startsWith("airavata-dp://"))
{
 							try {
 								DataProductModel dataProductModel = replicaCatalog.getDataProduct(pi.getValue());
-								dataProductModel.getReplicaLocations().stream().filter(rpModel -> rpModel.getReplicaLocationCategory()
-										.equals(ReplicaLocationCategory.GATEWAY_DATA_STORE)).forEach(rpModel -> {
-									pi.setValue(rpModel.getFilePath());
-									pi.setStorageResourceId(rpModel.getStorageResourceId());
-								});
+								Optional<DataReplicaLocationModel> rpLocation = dataProductModel.getReplicaLocations()
+										.stream().filter(rpModel -> rpModel.getReplicaLocationCategory().
+												equals(ReplicaLocationCategory.GATEWAY_DATA_STORE)).findFirst();
+								if (rpLocation.isPresent()) {
+									pi.setValue(rpLocation.get().getFilePath());
+									pi.setStorageResourceId(rpLocation.get().getStorageResourceId());
+								} else {
+									log.error("Could not find a replica for the URI " + pi.getValue());
+								}
+							} catch (ReplicaCatalogException e) {
+								log.error(e.getMessage(), e);
+							}
+						} else if (pi.getType().equals(DataType.URI_COLLECTION) && pi.getValue().contains("airavata-dp://"))
{
+							try {
+								String[] uriList = pi.getValue().split(",");
+								final ArrayList<String> filePathList = new ArrayList<>();
+								for (String uri : uriList) {
+									if (uri.startsWith("airavata-dp://")) {
+										DataProductModel dataProductModel = replicaCatalog.getDataProduct(uri);
+										Optional<DataReplicaLocationModel> rpLocation = dataProductModel.getReplicaLocations()
+												.stream().filter(rpModel -> rpModel.getReplicaLocationCategory().
+														equals(ReplicaLocationCategory.GATEWAY_DATA_STORE)).findFirst();
+										if (rpLocation.isPresent()) {
+											filePathList.add(rpLocation.get().getFilePath());
+										} else {
+											log.error("Could not find a replica for the URI " + pi.getValue());
+										}
+									} else {
+										// uri is in file path format
+										filePathList.add(uri);
+									}
+								}
+								pi.setValue(StringUtils.join(filePathList, ','));
 							} catch (ReplicaCatalogException e) {
 								log.error(e.getMessage(), e);
 							}


Mime
View raw message