Merged changed made in branch for release.
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@150395 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
62489a97ad
commit
9b05ff260c
|
@ -22,7 +22,7 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
|
|
|
@ -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
|
||||
|
|
1
pom.xml
1
pom.xml
|
@ -180,7 +180,6 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<configuration>
|
||||
<warName>resource-registry</warName>
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
|
|
|
@ -838,8 +838,8 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
|||
|
||||
} 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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -241,15 +241,15 @@ public class SmartgearResourcesTest extends ScopedTest {
|
|||
|
||||
/* Testing convenient methods */
|
||||
@SuppressWarnings("unchecked")
|
||||
List<ConsistsOf<? extends Resource, ? extends Facet>> 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<ConsistsOf<? extends Resource, ? extends Facet>> 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<ConsistsOf<? extends Resource, MemoryFacet>> 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<ContainerStateFacet> csfList = hostingNodeToUpdate.getFacets(ContainerStateFacet.class);
|
||||
|
@ -267,8 +267,8 @@ public class SmartgearResourcesTest extends ScopedTest {
|
|||
List<NetworkingFacet> nfList = hostingNodeToUpdate.getFacets(NetworkingFacet.class);
|
||||
Assert.assertTrue(nfList.size()==1);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<IsIdentifiedBy<? extends Resource, MemoryFacet>> isbnfList = hostingNodeToUpdate.getConsistsOf(IsIdentifiedBy.class, NetworkingFacet.class);
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
List<IsIdentifiedBy> isbnfList = hostingNodeToUpdate.getConsistsOf(IsIdentifiedBy.class, NetworkingFacet.class);
|
||||
Assert.assertTrue(isbnfList.size()==1);
|
||||
|
||||
/* Testing convenient methods */
|
||||
|
|
|
@ -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 ""
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE xml>
|
||||
<!-- enunciate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://enunciate.webcohesion.com/schemas/enunciate-2.0.0-M.4.xsd">
|
||||
<application root="resource-registry" />
|
||||
</enunciate -->
|
Loading…
Reference in New Issue