Fixed Rest API

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@131064 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2016-09-01 10:54:05 +00:00
parent 27feec58ac
commit 8891ab4fe4
2 changed files with 34 additions and 11 deletions

View File

@ -31,9 +31,9 @@ public class ContextManager {
protected ContextManagement contextManager = new ContextManagementImpl();
@PUT
@Path("create/{parentContextId}")
public String create(@PathParam("parentContextId") String parentContextId, @QueryParam("name") String name) throws Exception {
logger.trace("requested create context with json : {} ", name);
@Path("create")
public String create(@QueryParam("parentContextId") String parentContextId, @QueryParam("name") String name) throws Exception {
logger.trace("requested to create context with name : {} ", name);
return contextManager.create(parentContextId, name);
}
@ -41,7 +41,7 @@ public class ContextManager {
@Path("rename/{contextId}")
public String rename(@PathParam("contextId") String uuid, @QueryParam("name") String name)
throws ContextNotFoundException, ContextException{
logger.trace("requested rename context id {} with {} ", uuid, name);
logger.trace("requested to rename context id {} with {} ", uuid, name);
return contextManager.rename(uuid, name);
}
@ -49,15 +49,15 @@ public class ContextManager {
@Path("move/{contextId}")
public String move(@PathParam("contextId") String uuid, @QueryParam("newParentId") String newParentId)
throws ContextNotFoundException , ContextException{
logger.trace("requested move context id {} with new parend id {} ", uuid, newParentId);
logger.trace("requested to move context id {} with new parend id {} ", uuid, newParentId);
return contextManager.move(newParentId, uuid);
}
@DELETE
@Path("delete/{id}")
public String delete(@PathParam("id") String uuid) throws ContextNotFoundException {
logger.trace("requested delete context with id {} ",uuid);
return uuid;
@Path("delete/{contextId}")
public String delete(@PathParam("contextId") String uuid) throws ContextException {
logger.trace("requested to delete context with id {} ",uuid);
return contextManager.delete(uuid);
}
}

View File

@ -9,6 +9,7 @@ import org.codehaus.jettison.json.JSONObject;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.informationsystem.impl.entity.facet.CPUFacetImpl;
import org.gcube.informationsystem.impl.entity.facet.ContactFacetImpl;
import org.gcube.informationsystem.impl.entity.resource.HostingNodeImpl;
import org.gcube.informationsystem.impl.utils.Entities;
import org.gcube.informationsystem.impl.utils.Utility;
import org.gcube.informationsystem.model.embedded.Header;
@ -168,7 +169,7 @@ public class EntityManagementImplTest {
@Test
public void testCreateContactFacet() throws Exception {
ScopeProvider.instance.set("/gcube/devsec");
ScopeProvider.instance.set("/gcube/devNext");
ContactFacet contactFacet = new ContactFacetImpl();
contactFacet.setName("Luca");
@ -188,7 +189,7 @@ public class EntityManagementImplTest {
@Test
public void testCreateCPUFacet() throws Exception {
ScopeProvider.instance.set("/gcube/devsec/devVRE");
ScopeProvider.instance.set("/gcube/devNext");
CPUFacetImpl cpuFacetImpl = new CPUFacetImpl();
cpuFacetImpl.setClockSpeed("1 GHz");
@ -201,6 +202,28 @@ public class EntityManagementImplTest {
CPUFacet.class.getSimpleName(), stringWriter.toString());
logger.debug("Created : {}", json);
}
@Test
public void testCreateHostingNode() throws Exception {
ScopeProvider.instance.set("/gcube/devNext");
HostingNode hostingNode = new HostingNodeImpl();
CPUFacetImpl cpuFacetImpl = new CPUFacetImpl();
cpuFacetImpl.setClockSpeed("1 GHz");
cpuFacetImpl.setModel("Opteron");
cpuFacetImpl.setVendor("AMD");
hostingNode.addFacet(cpuFacetImpl);
StringWriter stringWriter = new StringWriter();
Entities.marshal(hostingNode, stringWriter);
String json = entityManagementImpl.createResource(HostingNode.NAME, stringWriter.toString());
logger.debug("Created : {}", json);
}
/*
* @Test public void testReadFacet() throws Exception{