diff --git a/pom.xml b/pom.xml
index 589d45b..e580a6b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,7 +11,7 @@
org.gcube.portlets.admin
rmp-common-library
- 2.8.1-SNAPSHOT
+ 2.8.2-SNAPSHOT
Resource Management Library
gCube Resource Management Library is a common library containing shared code for Information System Operations
diff --git a/src/main/java/org/gcube/resourcemanagement/support/server/managers/context/ContextManager.java b/src/main/java/org/gcube/resourcemanagement/support/server/managers/context/ContextManager.java
index 07aef43..65788bc 100644
--- a/src/main/java/org/gcube/resourcemanagement/support/server/managers/context/ContextManager.java
+++ b/src/main/java/org/gcube/resourcemanagement/support/server/managers/context/ContextManager.java
@@ -42,6 +42,7 @@ import org.gcube.common.resources.gcore.GenericResource;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.scope.impl.ScopeBean;
import org.gcube.resourcemanagement.support.server.utils.ServerConsole;
+import org.gcube.resourcemanagement.support.shared.types.datamodel.D4SEnvironment;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.w3c.dom.Document;
@@ -103,10 +104,10 @@ public class ContextManager {
public static LinkedHashMap readContexts() throws Exception {
LinkedHashMap toReturn = new LinkedHashMap();
String scopeXML = readInfraVoFromIS();
-
+ System.out.println("**** readContexts()");
Document scopeDocument = getDocumentGivenXML(scopeXML);
NodeList voElements = scopeDocument.getElementsByTagName("vo");
- System.out.println("voElements="+ voElements.getLength());
+ ServerConsole.debug("voElements="+ voElements.getLength());
for (int i = 0; i < voElements.getLength(); i++) {
NodeList voDetails = voElements.item(i).getChildNodes();
String voString = voDetails.item(2).getFirstChild().getNodeValue();
@@ -124,6 +125,41 @@ public class ContextManager {
}
return toReturn;
+ }
+
+ /**
+ *
+ * @param confFile
+ * @return
+ * @throws Exception
+ */
+ public static LinkedHashMap readContextsWithUUIDs() throws Exception {
+ LinkedHashMap toReturn = new LinkedHashMap();
+ String scopeXML = readInfraVoFromIS();
+ System.out.println("**** readContexts()");
+ Document scopeDocument = getDocumentGivenXML(scopeXML);
+ NodeList voElements = scopeDocument.getElementsByTagName("vo");
+ ServerConsole.debug("voElements="+ voElements.getLength());
+ for (int i = 0; i < voElements.getLength(); i++) {
+ NodeList voDetails = voElements.item(i).getChildNodes();
+ String voString = voDetails.item(2).getFirstChild().getNodeValue();
+ ScopeBean vo = new ScopeBean(voString);
+ D4SEnvironment voWrapper = new D4SEnvironment(vo, "uuid-not-exisiting-for-vos");
+ toReturn.put(vo.toString(), voWrapper);
+ try {
+ for (GenericResource resVRE : getVREResourcesFromVO(vo)) {
+ String name = resVRE.profile().name();
+ String uuid = resVRE.id();
+ D4SEnvironment vreWrapper = new D4SEnvironment(new ScopeBean(vo.toString()+"/"+name), uuid);
+ // This operation overrides the vo map
+ toReturn.put(name, vreWrapper);
+ }
+ } catch (Exception e) {
+ ServerConsole.error("Exception raised while loading VREs for VO : " + vo, e);
+ }
+ }
+ return toReturn;
+
}
/**
* query the IS to get the VRE list given a VO
@@ -149,6 +185,28 @@ public class ContextManager {
}
return toReturn;
}
+
+ /**
+ * query the IS to get the VRE list given a VO
+ * @param vo
+ * @return
+ * @throws Exception
+ */
+ protected static List getVREResourcesFromVO(final ScopeBean vo) throws Exception {
+ ServerConsole.info(LOG_PREFIX, "Starting Retrieving VREs for VO : " + vo);
+
+ ScopeProvider.instance.set(vo.toString());
+ SimpleQuery query = queryFor(GenericResource.class);
+ query.addCondition("$resource/Profile/SecondaryType/text() eq 'VRE'");
+
+ DiscoveryClient client = clientFor(GenericResource.class);
+
+ List gRes = client.submit(query);
+ for (GenericResource res : gRes) {
+ ServerConsole.info(LOG_PREFIX, "Found: " + res.profile().name());
+ }
+ return gRes;
+ }
/**
* Given a context, if it is a VO or an infrastructure, the corresponding
@@ -181,14 +239,6 @@ public class ContextManager {
return null;
}
- // private static ServiceMap loadServiceMap(final VO vo, final String fileName) throws Exception {
- // ServiceMap map = new ServiceMap();
- // String filePath = System.getenv("GLOBUS_LOCATION") + File.separator + "config" + File.separator + fileName;
- // ServerConsole.info(LOG_PREFIX, "--- Loading " + vo.getName() + " from: " + filePath);
- // map.load(new FileReader(filePath));
- // return map;
- // }
-
private static String readInfraVoFromIS() throws Exception {
String context = "";
String token = SecurityTokenProvider.instance.get();
diff --git a/src/main/java/org/gcube/resourcemanagement/support/shared/types/datamodel/D4SEnvironment.java b/src/main/java/org/gcube/resourcemanagement/support/shared/types/datamodel/D4SEnvironment.java
new file mode 100644
index 0000000..0366aa4
--- /dev/null
+++ b/src/main/java/org/gcube/resourcemanagement/support/shared/types/datamodel/D4SEnvironment.java
@@ -0,0 +1,46 @@
+package org.gcube.resourcemanagement.support.shared.types.datamodel;
+
+import java.io.Serializable;
+
+import org.gcube.common.scope.impl.ScopeBean;
+
+@SuppressWarnings("serial")
+public class D4SEnvironment implements Serializable{
+ private ScopeBean context;
+ private String uuid;
+
+ public D4SEnvironment() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+ public D4SEnvironment(ScopeBean context, String uuid) {
+ super();
+ this.context = context;
+ this.uuid = uuid;
+ }
+ public ScopeBean getContext() {
+ return context;
+ }
+ public void setContext(ScopeBean context) {
+ this.context = context;
+ }
+ public String getUuid() {
+ return uuid;
+ }
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("D4SEnvironment [context=");
+ builder.append(context);
+ builder.append(", uuid=");
+ builder.append(uuid);
+ builder.append("]");
+ return builder.toString();
+ }
+
+
+
+}