diff --git a/.classpath b/.classpath
index e43402f..fae1a2b 100644
--- a/.classpath
+++ b/.classpath
@@ -22,7 +22,7 @@
-
+
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
index 443e085..4ede96d 100644
--- a/.settings/org.eclipse.jdt.core.prefs
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -1,8 +1,2 @@
eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
-org.eclipse.jdt.core.compiler.compliance=1.7
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
-org.eclipse.jdt.core.compiler.source=1.7
diff --git a/pom.xml b/pom.xml
index 7d4bcd8..4737055 100644
--- a/pom.xml
+++ b/pom.xml
@@ -180,7 +180,6 @@
org.apache.maven.plugins
maven-war-plugin
- 2.6
resource-registry
false
diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/er/ERManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/er/ERManagement.java
index d67397b..80ccd06 100644
--- a/src/main/java/org/gcube/informationsystem/resourceregistry/er/ERManagement.java
+++ b/src/main/java/org/gcube/informationsystem/resourceregistry/er/ERManagement.java
@@ -838,8 +838,8 @@ public abstract class ERManagement {
} catch (Exception e) {
String error = String.format(
- "Error while setting property %s : %s", key, properties
- .get(key).toString());
+ "Error while setting property %s : %s (%s)", key, properties
+ .get(key).toString(), e.getMessage());
logger.error(error);
throw new ResourceRegistryException(error, e);
}
diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/Access.java b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/Access.java
index 75e0665..5f08f35 100644
--- a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/Access.java
+++ b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/Access.java
@@ -3,6 +3,7 @@ package org.gcube.informationsystem.resourceregistry.rest;
import java.util.Arrays;
import java.util.UUID;
+import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.HEAD;
import javax.ws.rs.Path;
@@ -149,9 +150,9 @@ public class Access {
@Path(AccessPath.INSTANCES_PATH_PART + "/" + "{" + TYPE_PATH_PARAM + "}")
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
public String getInstances(@PathParam(TYPE_PATH_PARAM) String type,
- @QueryParam(AccessPath.POLYMORPHIC_PARAM) Boolean polymorphic,
+ @QueryParam(AccessPath.POLYMORPHIC_PARAM) @DefaultValue("false") Boolean polymorphic,
@QueryParam(AccessPath.REFERENCE) String reference,
- @QueryParam(AccessPath.DIRECTION) String direction)
+ @QueryParam(AccessPath.DIRECTION) @DefaultValue("both") String direction)
throws ResourceRegistryException {
logger.info("Requested {} ({}={}) instances", type,
AccessPath.POLYMORPHIC_PARAM, polymorphic);
@@ -209,7 +210,7 @@ public class Access {
@Path(AccessPath.SCHEMA_PATH_PART + "/{" + TYPE_PATH_PARAM + "}")
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
public String getSchema(@PathParam(TYPE_PATH_PARAM) String type,
- @QueryParam(AccessPath.POLYMORPHIC_PARAM) Boolean polymorphic)
+ @QueryParam(AccessPath.POLYMORPHIC_PARAM) @DefaultValue("false") Boolean polymorphic)
throws SchemaNotFoundException, ResourceRegistryException {
logger.info("Requested Schema for type {}", type);
diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/ContextManager.java b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/ContextManager.java
index c4bacc2..b9a8824 100644
--- a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/ContextManager.java
+++ b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/ContextManager.java
@@ -6,6 +6,7 @@ package org.gcube.informationsystem.resourceregistry.rest;
import java.util.UUID;
import javax.ws.rs.DELETE;
+import javax.ws.rs.DefaultValue;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
@@ -53,11 +54,15 @@ public class ContextManager {
@PUT
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
public Response create(
- @QueryParam(ContextPath.PARENT_CONTEXT_ID_PARAM) String parentUUID,
+ @QueryParam(ContextPath.PARENT_CONTEXT_ID_PARAM) @DefaultValue("") String parentUUID,
@QueryParam(ContextPath.NAME_PARAM) String name)
throws ContextCreationException, ResourceRegistryException {
logger.trace("requested to create context with name : {} ", name);
- String ret = contextManager.create(UUID.fromString(parentUUID), name);
+ UUID parent = null;
+ if(parentUUID!=null && parentUUID.compareTo("")!=0){
+ parent = UUID.fromString(parentUUID);
+ }
+ String ret = contextManager.create(parent, name);
return Response.status(Status.CREATED).entity(ret).type(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8).build();
}
diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/ERManager.java b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/ERManager.java
index 039c717..392b35f 100644
--- a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/ERManager.java
+++ b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/ERManager.java
@@ -40,7 +40,7 @@ import org.slf4j.LoggerFactory;
@Path(ERPath.ER_PATH_PART)
public class ERManager {
- private static Logger logger = LoggerFactory.getLogger(SchemaManager.class);
+ private static Logger logger = LoggerFactory.getLogger(ERManager.class);
public static final String ID_PATH_PARAM = "id";
public static final String TYPE_PATH_PARAM = "type";
diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/utils/HeaderOrient.java b/src/main/java/org/gcube/informationsystem/resourceregistry/utils/HeaderOrient.java
index a01df24..9d4f8ee 100644
--- a/src/main/java/org/gcube/informationsystem/resourceregistry/utils/HeaderOrient.java
+++ b/src/main/java/org/gcube/informationsystem/resourceregistry/utils/HeaderOrient.java
@@ -28,6 +28,7 @@ public class HeaderOrient extends ODocument implements org.gcube.informationsyst
return UUID.fromString((String) this.field(Header.UUID_PROPERTY));
}
+ @Override
public void setUUID(UUID uuid){
this.field(Header.UUID_PROPERTY, uuid.toString());
}
diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/er/ERManagementTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/er/ERManagementTest.java
index 4413617..bc9ea36 100644
--- a/src/test/java/org/gcube/informationsystem/resourceregistry/er/ERManagementTest.java
+++ b/src/test/java/org/gcube/informationsystem/resourceregistry/er/ERManagementTest.java
@@ -3,6 +3,9 @@
*/
package org.gcube.informationsystem.resourceregistry.er;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
@@ -42,6 +45,7 @@ import org.gcube.informationsystem.model.entity.facet.ServiceStateFacet;
import org.gcube.informationsystem.model.entity.facet.SimpleFacet;
import org.gcube.informationsystem.model.entity.facet.SoftwareFacet;
import org.gcube.informationsystem.model.entity.facet.StateFacet;
+import org.gcube.informationsystem.model.entity.resource.Configuration;
import org.gcube.informationsystem.model.entity.resource.EService;
import org.gcube.informationsystem.model.entity.resource.HostingNode;
import org.gcube.informationsystem.model.relation.ConsistsOf;
@@ -61,6 +65,8 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
import com.tinkerpop.blueprints.Direction;
/**
@@ -702,4 +708,43 @@ public class ERManagementTest extends ScopedTest {
}
+ public static final String TEST_RESOURCE = "test-resource.json";
+
+ //@Test
+ public void testUpdateResourceFromFile() throws JsonParseException, JsonMappingException, IOException, ResourceRegistryException{
+ File file = new File("src/test/resources/" + TEST_RESOURCE);
+
+ logger.debug("{}", file.getAbsolutePath());
+
+ FileInputStream fileInputStream = new FileInputStream(file);
+ EService eService = ISMapper.unmarshal(EService.class, fileInputStream);
+
+ ResourceManagement resourceManagement = new ResourceManagement();
+ resourceManagement.setUUID(eService.getHeader().getUUID());
+ resourceManagement.setJSON(ISMapper.marshal(eService));
+
+ resourceManagement.update();
+
+ }
+
+ // @Test
+ public void readSingleResource() throws ResourceRegistryException, JsonParseException, JsonMappingException, IOException{
+ UUID uuid = UUID.fromString("");
+
+ ResourceManagement resourceManagement = new ResourceManagement();
+ resourceManagement.setUUID(uuid);
+ String res = resourceManagement.read();
+ logger.debug(res);
+
+ Configuration configuration = ISMapper.unmarshal(Configuration.class, res);
+
+
+ resourceManagement = new ResourceManagement();
+ resourceManagement.setUUID(configuration.getHeader().getUUID());
+ resourceManagement.setJSON(ISMapper.marshal(configuration));
+
+ resourceManagement.update();
+
+ }
+
}
diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/er/SmartgearResourcesTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/er/SmartgearResourcesTest.java
index e5c5fc0..8e23f9a 100644
--- a/src/test/java/org/gcube/informationsystem/resourceregistry/er/SmartgearResourcesTest.java
+++ b/src/test/java/org/gcube/informationsystem/resourceregistry/er/SmartgearResourcesTest.java
@@ -241,15 +241,15 @@ public class SmartgearResourcesTest extends ScopedTest {
/* Testing convenient methods */
@SuppressWarnings("unchecked")
- List> hasVolatileMemoryList = hostingNodeToUpdate.getConsistsOf(HasVolatileMemory.class);
+ List extends ConsistsOf extends Resource, ? extends Facet>> hasVolatileMemoryList = hostingNodeToUpdate.getConsistsOf(HasVolatileMemory.class);
Assert.assertTrue(hasVolatileMemoryList.size()==2);
@SuppressWarnings("unchecked")
- List> hasPeristentMemoryList = hostingNodeToUpdate.getConsistsOf(HasPersistentMemory.class);
+ List extends ConsistsOf extends Resource, ? extends Facet>> hasPeristentMemoryList = hostingNodeToUpdate.getConsistsOf(HasPersistentMemory.class);
Assert.assertTrue(hasPeristentMemoryList.size()==1);
@SuppressWarnings("unchecked")
- List> memoryList = hostingNodeToUpdate.getConsistsOf(ConsistsOf.class, MemoryFacet.class);
+ List extends ConsistsOf extends Resource, MemoryFacet>> memoryList = hostingNodeToUpdate.getConsistsOf(ConsistsOf.class, MemoryFacet.class);
Assert.assertTrue(memoryList.size()==3);
List csfList = hostingNodeToUpdate.getFacets(ContainerStateFacet.class);
@@ -267,8 +267,8 @@ public class SmartgearResourcesTest extends ScopedTest {
List nfList = hostingNodeToUpdate.getFacets(NetworkingFacet.class);
Assert.assertTrue(nfList.size()==1);
- @SuppressWarnings("unchecked")
- List> isbnfList = hostingNodeToUpdate.getConsistsOf(IsIdentifiedBy.class, NetworkingFacet.class);
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ List isbnfList = hostingNodeToUpdate.getConsistsOf(IsIdentifiedBy.class, NetworkingFacet.class);
Assert.assertTrue(isbnfList.size()==1);
/* Testing convenient methods */
diff --git a/src/test/resources/curl_test.sh b/src/test/resources/curl_test.sh
deleted file mode 100755
index 824cc73..0000000
--- a/src/test/resources/curl_test.sh
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/bin/bash
-# Creating ROOT
-ROOT_NAME="myRoot"
-URL="http://localhost:8080/resource-registry/context?name=${ROOT_NAME}"
-echo "Going to create ROOT Context with name ${ROOT_NAME} by invoking URL ${URL}"
-ROOT_UUID=$(curl -H gcube-scope:/gcube/devNext -X PUT ${URL})
-echo "Created Context (${ROOT_NAME}) has UUID ${ROOT_UUID}"
-echo ""
-echo ""
-
-
-# Creating VO
-VO_NAME="myVO"
-URL="http://localhost:8080/resource-registry/context?name=${VO_NAME}&parentContextId=${ROOT_UUID}"
-echo "Going to create Context with name ${VO_NAME} as child of ${ROOT_UUID} (${ROOT_NAME}) by invoking URL ${URL}"
-VO_UUID=$(curl -H gcube-scope:/gcube/devNext -X PUT ${URL})
-echo "Created Context ${VO_NAME} has UUID ${VO_UUID} as child of ${ROOT_UUID} (${ROOT_NAME})"
-echo ""
-echo ""
-
-
-# Renaming VO
-VO_NEW_NAME="myVONewName"
-URL="http://localhost:8080/resource-registry/context/rename/${VO_UUID}?name=${VO_NEW_NAME}"
-echo "Going to rename VO Context from name ${VO_NAME} to ${VO_NEW_NAME} by invoking URL ${URL}"
-RENAMED_VO_UUID=$(curl -H gcube-scope:/gcube/devNext -X POST ${URL})
-
-if [ "${VO_UUID}" = "${RENAMED_VO_UUID}" ]; then
- echo "VO Context ${VO_UUID} has been renamed from name ${VO_NAME} to ${VO_NEW_NAME}"
-else
- echo "VO Context ${VO_UUID} has NOT been renamed from name ${VO_NAME} to ${VO_NEW_NAME}"
- exit 1
-fi
-
-echo ""
-echo ""
-
-
-# Moving VO as ROOT
-URL="http://localhost:8080/resource-registry/context/move/${VO_UUID}"
-echo "Going to move VO Context ${VO_NEW_NAME} as ROOT by invoking URL ${URL}"
-MOVED_VO_UUID=$(curl -H gcube-scope:/gcube/devNext -X POST ${URL})
-
-if [ "${VO_UUID}" = "${MOVED_VO_UUID}" ]; then
- echo "VO Context ${VO_UUID} (${VO_NEW_NAME}) has been moved as ROOT"
-else
- echo "VO Context ${VO_UUID} (${VO_NEW_NAME}) has NOT been moved as ROOT"
- exit 1
-fi
-
-echo ""
-echo ""
-
-
-# Moving VO under myRoot
-URL="http://localhost:8080/resource-registry/context/move/${VO_UUID}?parentContextId=${ROOT_UUID}"
-echo "Going to move VO Context ${VO_NEW_NAME} under ${ROOT_UUID} (${ROOT_NAME}) by invoking URL ${URL}"
-MOVED_AGAIN_VO_UUID=$(curl -H gcube-scope:/gcube/devNext -X POST ${URL})
-
-if [ "${VO_UUID}" = "${MOVED_AGAIN_VO_UUID}" ]; then
- echo "VO Context ${VO_UUID} (${VO_NEW_NAME}) has been moved under ${ROOT_UUID} (${ROOT_NAME})"
-else
- echo "VO Context ${VO_UUID} (${VO_NEW_NAME}) has NOT been moved under ${ROOT_UUID} (${ROOT_NAME})"
- exit 1
-fi
-
-echo ""
-echo ""
-
-
-# Deleting VO
-URL="http://localhost:8080/resource-registry/context/${VO_UUID}"
-echo "Going to delete VO Context ${VO_UUID} (${VO_NEW_NAME}) by invoking URL ${URL}"
-DELETED_VO_UUID=$(curl -H gcube-scope:/gcube/devNext -X DELETE ${URL})
-
-if [ "${VO_UUID}" = "${DELETED_VO_UUID}" ]; then
- echo "VO Context ${VO_UUID} (${VO_NEW_NAME}) has been removed"
-else
- echo "VO Context ${VO_UUID} (${VO_NEW_NAME}) has NOT been moved removed"
- exit 1
-fi
-
-echo ""
-echo ""
-
-
-# Deleting ROOT
-URL="http://localhost:8080/resource-registry/context/${ROOT_UUID}"
-echo "Going to delete ROOT Context ${ROOT_UUID} (${ROOT_NAME}) by invoking URL ${URL}"
-DELETED_ROOT_UUID=$(curl -H gcube-scope:/gcube/devNext -X DELETE ${URL})
-
-if [ "${ROOT_UUID}" = "${DELETED_ROOT_UUID}" ]; then
- echo "VO Context ${ROOT_UUID} (${ROOT_NAME}) has been removed"
-else
- echo "VO Context ${ROOT_UUID} (${ROOT_NAME}) has NOT been moved removed"
- exit 1
-fi
-
-echo ""
-echo ""
-
diff --git a/src/test/resources/enunciate.xml b/src/test/resources/enunciate.xml
deleted file mode 100644
index bada26d..0000000
--- a/src/test/resources/enunciate.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
\ No newline at end of file