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:
parent
27feec58ac
commit
8891ab4fe4
|
@ -31,9 +31,9 @@ public class ContextManager {
|
||||||
protected ContextManagement contextManager = new ContextManagementImpl();
|
protected ContextManagement contextManager = new ContextManagementImpl();
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Path("create/{parentContextId}")
|
@Path("create")
|
||||||
public String create(@PathParam("parentContextId") String parentContextId, @QueryParam("name") String name) throws Exception {
|
public String create(@QueryParam("parentContextId") String parentContextId, @QueryParam("name") String name) throws Exception {
|
||||||
logger.trace("requested create context with json : {} ", name);
|
logger.trace("requested to create context with name : {} ", name);
|
||||||
return contextManager.create(parentContextId, name);
|
return contextManager.create(parentContextId, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ public class ContextManager {
|
||||||
@Path("rename/{contextId}")
|
@Path("rename/{contextId}")
|
||||||
public String rename(@PathParam("contextId") String uuid, @QueryParam("name") String name)
|
public String rename(@PathParam("contextId") String uuid, @QueryParam("name") String name)
|
||||||
throws ContextNotFoundException, ContextException{
|
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);
|
return contextManager.rename(uuid, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,15 +49,15 @@ public class ContextManager {
|
||||||
@Path("move/{contextId}")
|
@Path("move/{contextId}")
|
||||||
public String move(@PathParam("contextId") String uuid, @QueryParam("newParentId") String newParentId)
|
public String move(@PathParam("contextId") String uuid, @QueryParam("newParentId") String newParentId)
|
||||||
throws ContextNotFoundException , ContextException{
|
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);
|
return contextManager.move(newParentId, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("delete/{id}")
|
@Path("delete/{contextId}")
|
||||||
public String delete(@PathParam("id") String uuid) throws ContextNotFoundException {
|
public String delete(@PathParam("contextId") String uuid) throws ContextException {
|
||||||
logger.trace("requested delete context with id {} ",uuid);
|
logger.trace("requested to delete context with id {} ",uuid);
|
||||||
return uuid;
|
return contextManager.delete(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.codehaus.jettison.json.JSONObject;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.informationsystem.impl.entity.facet.CPUFacetImpl;
|
import org.gcube.informationsystem.impl.entity.facet.CPUFacetImpl;
|
||||||
import org.gcube.informationsystem.impl.entity.facet.ContactFacetImpl;
|
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.Entities;
|
||||||
import org.gcube.informationsystem.impl.utils.Utility;
|
import org.gcube.informationsystem.impl.utils.Utility;
|
||||||
import org.gcube.informationsystem.model.embedded.Header;
|
import org.gcube.informationsystem.model.embedded.Header;
|
||||||
|
@ -168,7 +169,7 @@ public class EntityManagementImplTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateContactFacet() throws Exception {
|
public void testCreateContactFacet() throws Exception {
|
||||||
ScopeProvider.instance.set("/gcube/devsec");
|
ScopeProvider.instance.set("/gcube/devNext");
|
||||||
|
|
||||||
ContactFacet contactFacet = new ContactFacetImpl();
|
ContactFacet contactFacet = new ContactFacetImpl();
|
||||||
contactFacet.setName("Luca");
|
contactFacet.setName("Luca");
|
||||||
|
@ -188,7 +189,7 @@ public class EntityManagementImplTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateCPUFacet() throws Exception {
|
public void testCreateCPUFacet() throws Exception {
|
||||||
ScopeProvider.instance.set("/gcube/devsec/devVRE");
|
ScopeProvider.instance.set("/gcube/devNext");
|
||||||
|
|
||||||
CPUFacetImpl cpuFacetImpl = new CPUFacetImpl();
|
CPUFacetImpl cpuFacetImpl = new CPUFacetImpl();
|
||||||
cpuFacetImpl.setClockSpeed("1 GHz");
|
cpuFacetImpl.setClockSpeed("1 GHz");
|
||||||
|
@ -201,6 +202,28 @@ public class EntityManagementImplTest {
|
||||||
CPUFacet.class.getSimpleName(), stringWriter.toString());
|
CPUFacet.class.getSimpleName(), stringWriter.toString());
|
||||||
logger.debug("Created : {}", json);
|
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{
|
* @Test public void testReadFacet() throws Exception{
|
||||||
|
|
Loading…
Reference in New Issue