Refs #11288: Made resource-registry more RESTful
Task-Url: https://support.d4science.org/issues/11288 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@167900 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
9e609c1acf
commit
5590c79548
|
@ -143,7 +143,7 @@ public class ContextUtility {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SecurityContext getSecurityContextByUUID(UUID uuid) throws ResourceRegistryException {
|
public SecurityContext getSecurityContextByUUID(UUID uuid) throws ResourceRegistryException {
|
||||||
return getSecurityContextByUUID(uuid, null);
|
return getSecurityContextByUUID(uuid, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.gcube.informationsystem.resourceregistry.context;
|
package org.gcube.informationsystem.resourceregistry.context;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.codehaus.jettison.json.JSONObject;
|
import org.codehaus.jettison.json.JSONObject;
|
||||||
import org.gcube.informationsystem.model.AccessType;
|
import org.gcube.informationsystem.model.AccessType;
|
||||||
import org.gcube.informationsystem.model.embedded.PropagationConstraint;
|
import org.gcube.informationsystem.model.embedded.PropagationConstraint;
|
||||||
|
@ -140,12 +142,12 @@ public class IsParentOfManagement extends RelationManagement<IsParentOf,ContextM
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addToContext() throws NotFoundException, ContextException {
|
public boolean addToContext(UUID contexUUID) throws NotFoundException, ContextException {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeFromContext() throws NotFoundException, ContextException {
|
public boolean removeFromContext(UUID contexUUID) throws NotFoundException, ContextException {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -197,7 +197,7 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
||||||
if(jsonNode != null) {
|
if(jsonNode != null) {
|
||||||
String type = getClassProperty(jsonNode);
|
String type = getClassProperty(jsonNode);
|
||||||
if(type != null && type.compareTo(erType) != 0) {
|
if(type != null && type.compareTo(erType) != 0) {
|
||||||
String error = String.format("Declared resourceType does not match with json representation %s!=%s",
|
String error = String.format("Requested type does not match with json representation %s!=%s",
|
||||||
erType, type);
|
erType, type);
|
||||||
logger.trace(error);
|
logger.trace(error);
|
||||||
throw new ResourceRegistryException(error);
|
throw new ResourceRegistryException(error);
|
||||||
|
@ -296,33 +296,33 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
||||||
return reallyDelete();
|
return reallyDelete();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract boolean reallyAddToContext() throws ContextException, ResourceRegistryException;
|
protected abstract boolean reallyAddToContext(SecurityContext targetSecurityContext) throws ContextException, ResourceRegistryException;
|
||||||
|
|
||||||
public boolean internalAddToContext() throws ContextException, ResourceRegistryException {
|
public boolean internalAddToContext(SecurityContext targetSecurityContext) throws ContextException, ResourceRegistryException {
|
||||||
try {
|
try {
|
||||||
boolean ret = reallyAddToContext();
|
boolean ret = reallyAddToContext(targetSecurityContext);
|
||||||
HeaderUtility.updateModifiedByAndLastUpdate(element);
|
HeaderUtility.updateModifiedByAndLastUpdate(element);
|
||||||
((OrientElement) element).save();
|
((OrientElement) element).save();
|
||||||
return ret && true;
|
return ret && true;
|
||||||
} catch(ResourceRegistryException e) {
|
} catch(ResourceRegistryException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
throw new ResourceRegistryException("Error Adding " + erType + " to Current Context ", e.getCause());
|
throw new ResourceRegistryException("Error Adding " + erType + " to " + targetSecurityContext.toString(), e.getCause());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract boolean reallyRemoveFromContext() throws ContextException, ResourceRegistryException;
|
protected abstract boolean reallyRemoveFromContext(SecurityContext targetSecurityContext) throws ContextException, ResourceRegistryException;
|
||||||
|
|
||||||
public boolean internalRemoveFromContext() throws ContextException, ResourceRegistryException {
|
public boolean internalRemoveFromContext(SecurityContext targetSecurityContext) throws ContextException, ResourceRegistryException {
|
||||||
try {
|
try {
|
||||||
boolean ret = reallyRemoveFromContext();
|
boolean ret = reallyRemoveFromContext(targetSecurityContext);
|
||||||
HeaderUtility.updateModifiedByAndLastUpdate(element);
|
HeaderUtility.updateModifiedByAndLastUpdate(element);
|
||||||
((OrientElement) element).save();
|
((OrientElement) element).save();
|
||||||
return ret && true;
|
return ret && true;
|
||||||
} catch(ResourceRegistryException e) {
|
} catch(ResourceRegistryException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
throw new ResourceRegistryException("Error Removing " + erType + " from Current Context ", e.getCause());
|
throw new ResourceRegistryException("Error Removing " + erType + " from " + targetSecurityContext.toString(), e.getCause());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -568,29 +568,30 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addToContext() throws NotFoundException, ContextException, ResourceRegistryException {
|
public boolean addToContext(UUID contextUUID) throws NotFoundException, ContextException, ResourceRegistryException {
|
||||||
logger.info("Going to add {} with UUID {} to Context {}", accessType.getName(), uuid,
|
logger.info("Going to add {} with UUID {} to Context with UUID {}", accessType.getName(), uuid, contextUUID);
|
||||||
getWorkingContext().toString());
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
orientGraph = ContextUtility.getAdminSecurityContext().getGraph(PermissionMode.WRITER);
|
orientGraph = ContextUtility.getAdminSecurityContext().getGraph(PermissionMode.WRITER);
|
||||||
orientGraph.setAutoStartTx(false);
|
orientGraph.setAutoStartTx(false);
|
||||||
orientGraph.begin();
|
orientGraph.begin();
|
||||||
|
|
||||||
boolean added = internalAddToContext();
|
SecurityContext targetSecurityContext = ContextUtility.getInstance().getSecurityContextByUUID(contextUUID);
|
||||||
|
|
||||||
|
boolean added = internalAddToContext(targetSecurityContext);
|
||||||
|
|
||||||
orientGraph.commit();
|
orientGraph.commit();
|
||||||
logger.info("{} with UUID {} successfully added to actual Context", accessType.getName(), uuid);
|
logger.info("{} with UUID {} successfully added to Context with UUID {}", erType, uuid, contextUUID);
|
||||||
|
|
||||||
return added;
|
return added;
|
||||||
} catch(ResourceRegistryException e) {
|
} catch(ResourceRegistryException e) {
|
||||||
logger.error("Unable to add {} with UUID {} to actual Context", accessType.getName(), uuid);
|
logger.error("Unable to add {} with UUID {} to Context with UUID {}", erType, uuid, contextUUID);
|
||||||
if(orientGraph != null) {
|
if(orientGraph != null) {
|
||||||
orientGraph.rollback();
|
orientGraph.rollback();
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
logger.error("Unable to add {} with UUID {} to actual Context", accessType.getName(), uuid, e);
|
logger.error("Unable to add {} with UUID {} to Context with UUID {}", erType, uuid, contextUUID, e);
|
||||||
if(orientGraph != null) {
|
if(orientGraph != null) {
|
||||||
orientGraph.rollback();
|
orientGraph.rollback();
|
||||||
}
|
}
|
||||||
|
@ -602,8 +603,8 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeFromContext() throws NotFoundException, ContextException, ResourceRegistryException {
|
public boolean removeFromContext(UUID contextUUID) throws NotFoundException, ContextException, ResourceRegistryException {
|
||||||
logger.debug("Going to remove {} with UUID {} from actual Context", accessType.getName(), uuid);
|
logger.debug("Going to remove {} with UUID {} from Context with UUID {}", erType, uuid, contextUUID);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
@ -611,20 +612,22 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
||||||
orientGraph.setAutoStartTx(false);
|
orientGraph.setAutoStartTx(false);
|
||||||
orientGraph.begin();
|
orientGraph.begin();
|
||||||
|
|
||||||
boolean removed = internalRemoveFromContext();
|
SecurityContext targetSecurityContext = ContextUtility.getInstance().getSecurityContextByUUID(contextUUID);
|
||||||
|
|
||||||
|
boolean removed = internalRemoveFromContext(targetSecurityContext);
|
||||||
|
|
||||||
orientGraph.commit();
|
orientGraph.commit();
|
||||||
logger.info("{} with UUID {} successfully removed from actual Context", accessType.getName(), uuid);
|
logger.info("{} with UUID {} successfully removed from Context with UUID {}", erType, uuid, contextUUID);
|
||||||
|
|
||||||
return removed;
|
return removed;
|
||||||
} catch(ResourceRegistryException e) {
|
} catch(ResourceRegistryException e) {
|
||||||
logger.error("Unable to remove {} with UUID {} from actual Context", accessType.getName(), uuid);
|
logger.error("Unable to remove {} with UUID {} from Context with UUID {}", erType, uuid, contextUUID);
|
||||||
if(orientGraph != null) {
|
if(orientGraph != null) {
|
||||||
orientGraph.rollback();
|
orientGraph.rollback();
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
logger.error("Unable to remove {} with UUID {} from actual Context", accessType.getName(), uuid, e);
|
logger.error("Unable to remove {} with UUID {} from Context with UUID {}", erType, uuid, contextUUID, e);
|
||||||
if(orientGraph != null) {
|
if(orientGraph != null) {
|
||||||
orientGraph.rollback();
|
orientGraph.rollback();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ package org.gcube.informationsystem.resourceregistry.er;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.gcube.informationsystem.model.AccessType;
|
||||||
|
import org.gcube.informationsystem.model.embedded.Embedded;
|
||||||
import org.gcube.informationsystem.model.entity.Entity;
|
import org.gcube.informationsystem.model.entity.Entity;
|
||||||
import org.gcube.informationsystem.model.entity.Facet;
|
import org.gcube.informationsystem.model.entity.Facet;
|
||||||
import org.gcube.informationsystem.model.entity.Resource;
|
import org.gcube.informationsystem.model.entity.Resource;
|
||||||
|
@ -39,6 +41,26 @@ public class ERManagementUtility {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(EntityManagement.class);
|
private static Logger logger = LoggerFactory.getLogger(EntityManagement.class);
|
||||||
|
|
||||||
|
public static AccessType getBaseAccessType(String type) throws ResourceRegistryException {
|
||||||
|
OClass oClass = SchemaManagementImpl.getTypeSchema(type, null);
|
||||||
|
|
||||||
|
if(oClass.isSubClassOf(Resource.NAME)) {
|
||||||
|
return AccessType.RESOURCE;
|
||||||
|
} else if(oClass.isSubClassOf(Facet.NAME)) {
|
||||||
|
return AccessType.FACET;
|
||||||
|
} else if(oClass.isSubClassOf(ConsistsOf.NAME)) {
|
||||||
|
return AccessType.CONSISTS_OF;
|
||||||
|
} else if(oClass.isSubClassOf(IsRelatedTo.NAME)) {
|
||||||
|
return AccessType.IS_RELATED_TO;
|
||||||
|
} else if(oClass.isSubClassOf(Embedded.NAME)) {
|
||||||
|
return AccessType.EMBEDDED;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ResourceRegistryException(type + "is not a base type");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public static ERManagement getERManagement(String type) throws ResourceRegistryException {
|
public static ERManagement getERManagement(String type) throws ResourceRegistryException {
|
||||||
|
|
||||||
|
|
|
@ -171,33 +171,33 @@ public abstract class EntityManagement<E extends Entity> extends ERManagement<E,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean reallyAddToContext() throws ContextException, ResourceRegistryException {
|
protected boolean reallyAddToContext(SecurityContext targetSecurityContext) throws ContextException, ResourceRegistryException {
|
||||||
|
|
||||||
getWorkingContext().addElement(getElement(), orientGraph);
|
targetSecurityContext.addElement(getElement(), orientGraph);
|
||||||
|
|
||||||
Iterable<Edge> edges = getElement().getEdges(Direction.OUT);
|
Iterable<Edge> edges = getElement().getEdges(Direction.OUT);
|
||||||
|
|
||||||
for(Edge edge : edges) {
|
for(Edge edge : edges) {
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
RelationManagement relationManagement = getRelationManagement(edge);
|
RelationManagement relationManagement = getRelationManagement(edge);
|
||||||
relationManagement.internalAddToContext();
|
relationManagement.internalAddToContext(targetSecurityContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean reallyRemoveFromContext() throws ContextException, ResourceRegistryException {
|
protected boolean reallyRemoveFromContext(SecurityContext targetSecurityContext) throws ContextException, ResourceRegistryException {
|
||||||
|
|
||||||
Iterable<Edge> edges = getElement().getEdges(Direction.OUT);
|
Iterable<Edge> edges = getElement().getEdges(Direction.OUT);
|
||||||
|
|
||||||
for(Edge edge : edges) {
|
for(Edge edge : edges) {
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
RelationManagement relationManagement = getRelationManagement(edge);
|
RelationManagement relationManagement = getRelationManagement(edge);
|
||||||
relationManagement.internalRemoveFromContext();
|
relationManagement.internalRemoveFromContext(targetSecurityContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
getWorkingContext().removeElement(getElement(), orientGraph);
|
targetSecurityContext.removeElement(getElement(), orientGraph);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -290,7 +290,7 @@ public abstract class RelationManagement<R extends Relation, S extends EntityMan
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean reallyAddToContext() throws ContextException, ResourceRegistryException {
|
protected boolean reallyAddToContext(SecurityContext targetSecurityContext) throws ContextException, ResourceRegistryException {
|
||||||
getElement();
|
getElement();
|
||||||
|
|
||||||
AddConstraint addConstraint = AddConstraint.unpropagate;
|
AddConstraint addConstraint = AddConstraint.unpropagate;
|
||||||
|
@ -321,9 +321,9 @@ public abstract class RelationManagement<R extends Relation, S extends EntityMan
|
||||||
* The relation must be added only in the case the target vertex must be added.
|
* The relation must be added only in the case the target vertex must be added.
|
||||||
* Otherwise we have a relation which point to an entity outside of the context.
|
* Otherwise we have a relation which point to an entity outside of the context.
|
||||||
*/
|
*/
|
||||||
getTargetEntityManagement().internalAddToContext();
|
getTargetEntityManagement().internalAddToContext(targetSecurityContext);
|
||||||
|
|
||||||
getWorkingContext().addElement(getElement(), orientGraph);
|
targetSecurityContext.addElement(getElement(), orientGraph);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -337,23 +337,23 @@ public abstract class RelationManagement<R extends Relation, S extends EntityMan
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean forcedAddToContext() throws ContextException, ResourceRegistryException {
|
public boolean forcedAddToContext(SecurityContext targetSecurityContext) throws ContextException, ResourceRegistryException {
|
||||||
|
|
||||||
getElement();
|
getElement();
|
||||||
|
|
||||||
/* Adding source to Context */
|
/* Adding source to Context */
|
||||||
getSourceEntityManagement().internalAddToContext();
|
getSourceEntityManagement().internalAddToContext(targetSecurityContext);
|
||||||
|
|
||||||
/* Adding target to Context */
|
/* Adding target to Context */
|
||||||
getTargetEntityManagement().internalAddToContext();
|
getTargetEntityManagement().internalAddToContext(targetSecurityContext);
|
||||||
|
|
||||||
getWorkingContext().addElement(getElement(), orientGraph);
|
targetSecurityContext.addElement(getElement(), orientGraph);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean reallyRemoveFromContext() throws ContextException, ResourceRegistryException {
|
protected boolean reallyRemoveFromContext(SecurityContext targetSecurityContext) throws ContextException, ResourceRegistryException {
|
||||||
getElement();
|
getElement();
|
||||||
|
|
||||||
RemoveConstraint removeConstraint = RemoveConstraint.keep;
|
RemoveConstraint removeConstraint = RemoveConstraint.keep;
|
||||||
|
@ -383,11 +383,11 @@ public abstract class RelationManagement<R extends Relation, S extends EntityMan
|
||||||
* In any removeConstraint value the relation MUST be removed from context to
|
* In any removeConstraint value the relation MUST be removed from context to
|
||||||
* avoid to have edge having a source outside of the context.
|
* avoid to have edge having a source outside of the context.
|
||||||
*/
|
*/
|
||||||
getWorkingContext().removeElement(getElement(), orientGraph);
|
targetSecurityContext.removeElement(getElement(), orientGraph);
|
||||||
|
|
||||||
switch(removeConstraint) {
|
switch(removeConstraint) {
|
||||||
case cascade:
|
case cascade:
|
||||||
getTargetEntityManagement().internalRemoveFromContext();
|
getTargetEntityManagement().internalRemoveFromContext(targetSecurityContext);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case cascadeWhenOrphan:
|
case cascadeWhenOrphan:
|
||||||
|
@ -413,10 +413,10 @@ public abstract class RelationManagement<R extends Relation, S extends EntityMan
|
||||||
|
|
||||||
if(count > 0) {
|
if(count > 0) {
|
||||||
logger.trace(
|
logger.trace(
|
||||||
"{} point to {} which is not orphan ({} exists). Giving {} directive, it will be not remove from current context.",
|
"{} point to {} which is not orphan ({} exists). Giving {} directive, it will be not remove from .",
|
||||||
element, target, edge, removeConstraint);
|
element, target, edge, removeConstraint, targetSecurityContext);
|
||||||
} else {
|
} else {
|
||||||
getTargetEntityManagement().internalRemoveFromContext();
|
getTargetEntityManagement().internalRemoveFromContext(targetSecurityContext);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -552,20 +552,22 @@ public abstract class RelationManagement<R extends Relation, S extends EntityMan
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addToContext() throws NotFoundException, ContextException {
|
public boolean addToContext(UUID contextUUID) throws NotFoundException, ContextException {
|
||||||
logger.debug("Going to add {} with UUID {} to actual Context", accessType.getName(), uuid);
|
logger.debug("Going to add {} with UUID {} to Context with UUID {}", accessType.getName(), uuid, contextUUID);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
orientGraph = ContextUtility.getAdminSecurityContext().getGraph(PermissionMode.WRITER);
|
orientGraph = ContextUtility.getAdminSecurityContext().getGraph(PermissionMode.WRITER);
|
||||||
|
|
||||||
boolean added = forcedAddToContext();
|
SecurityContext targetSecurityContext = ContextUtility.getInstance().getSecurityContextByUUID(contextUUID);
|
||||||
|
|
||||||
|
boolean added = forcedAddToContext(targetSecurityContext);
|
||||||
|
|
||||||
orientGraph.commit();
|
orientGraph.commit();
|
||||||
logger.info("{} with UUID {} successfully added to actual Context", accessType.getName(), uuid);
|
logger.info("{} with UUID {} successfully added to Context with UUID {}", accessType.getName(), uuid, contextUUID);
|
||||||
|
|
||||||
return added;
|
return added;
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
logger.error("Unable to add {} with UUID {} to actual Context", accessType.getName(), uuid, e);
|
logger.error("Unable to add {} with UUID {} to Context with UUID {}", accessType.getName(), uuid, contextUUID, e);
|
||||||
if(orientGraph != null) {
|
if(orientGraph != null) {
|
||||||
orientGraph.rollback();
|
orientGraph.rollback();
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,47 +56,55 @@ public class Access {
|
||||||
public static final String ID_PATH_PARAM = "id";
|
public static final String ID_PATH_PARAM = "id";
|
||||||
public static final String TYPE_PATH_PARAM = "type";
|
public static final String TYPE_PATH_PARAM = "type";
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* It includeSubtypes to query Entities and Relations in the current Context.<br />
|
* e.g. GET /resource-registry/access/contexts
|
||||||
* It accepts idempotent query only.. <br />
|
|
||||||
* <br />
|
|
||||||
* For query syntax please refer to<br />
|
|
||||||
*
|
|
||||||
* <a href="https://orientdb.com/docs/last/SQL-Syntax.html" target="_blank">
|
|
||||||
* https://orientdb.com/docs/last/SQL-Syntax.html </a> <br />
|
|
||||||
* <br />
|
|
||||||
*
|
|
||||||
* e.g. GET /resource-registry/access?query=SELECT FROM V
|
|
||||||
*
|
|
||||||
* @param query
|
|
||||||
* Defines the query to send to the backend.
|
|
||||||
* @param limit
|
|
||||||
* Defines the number of results you want returned, defaults to includeSubtypes results.
|
|
||||||
* @param fetchPlan
|
|
||||||
* Defines the fetching strategy you want to use. See
|
|
||||||
* <a href="https://orientdb.com/docs/last/Fetching-Strategies.html" target="_blank">
|
|
||||||
* https://orientdb.com/docs/last/Fetching-Strategies.html
|
|
||||||
* </a>
|
|
||||||
* @return The JSON representation of the result
|
|
||||||
* @throws InvalidQueryException
|
|
||||||
* if the query is invalid or no idempotent
|
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
|
@Path(AccessPath.CONTEXTS_PATH_PART)
|
||||||
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
||||||
public String query(@QueryParam(AccessPath.QUERY_PARAM) String query,
|
public String getContexts()
|
||||||
@QueryParam(AccessPath.LIMIT_PARAM) Integer limit,
|
throws ContextNotFoundException, ResourceRegistryException {
|
||||||
@QueryParam(AccessPath.FETCH_PLAN_PARAM) String fetchPlan) throws InvalidQueryException {
|
ContextManagement contextManagement = new ContextManagement();
|
||||||
logger.info("Requested query (fetch plan {}, limit : {}):\n{}", fetchPlan, limit, query);
|
logger.info("Requested to read all {}s", org.gcube.informationsystem.model.entity.Context.NAME);
|
||||||
Query queryManager = new QueryImpl();
|
return contextManagement.all(false);
|
||||||
return queryManager.query(query, limit, fetchPlan);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* e.g. GET /resource-registry/access/contexts/c0f314e7-2807-4241-a792-2a6c79ed4fd0
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Path(AccessPath.CONTEXTS_PATH_PART + "{" + ID_PATH_PARAM + "}")
|
||||||
|
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
||||||
|
public String getContext(@PathParam(ID_PATH_PARAM) String uuid)
|
||||||
|
throws ContextNotFoundException, ResourceRegistryException {
|
||||||
|
ContextManagement contextManagement = new ContextManagement();
|
||||||
|
logger.info("Requested to read {} with id {} ", org.gcube.informationsystem.model.entity.Context.NAME, uuid);
|
||||||
|
contextManagement.setUUID(UUID.fromString(uuid));
|
||||||
|
return contextManagement.read();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* e.g. GET /resource-registry/access/types/ContactFacet?polymorphic=true
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Path(AccessPath.TYPES_PATH_PART + "/{" + TYPE_PATH_PARAM + "}")
|
||||||
|
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
||||||
|
public String getType(@PathParam(TYPE_PATH_PARAM) String type,
|
||||||
|
@QueryParam(AccessPath.POLYMORPHIC_PARAM) @DefaultValue("false") Boolean polymorphic)
|
||||||
|
throws SchemaNotFoundException, ResourceRegistryException {
|
||||||
|
logger.info("Requested Schema for type {}", type);
|
||||||
|
SchemaManagement schemaManagement = new SchemaManagementImpl();
|
||||||
|
return schemaManagement.read(type, polymorphic);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@HEAD
|
@HEAD
|
||||||
@Path(AccessPath.INSTANCE_PATH_PART + "/" + "{" + TYPE_PATH_PARAM + "}" + "/{" + ID_PATH_PARAM + "}")
|
@Path(AccessPath.INSTANCES_PATH_PART + "/" + "{" + TYPE_PATH_PARAM + "}" + "/{" + ID_PATH_PARAM + "}")
|
||||||
public Response exists(@PathParam(TYPE_PATH_PARAM) String type, @PathParam(ID_PATH_PARAM) String id)
|
public Response exists(@PathParam(TYPE_PATH_PARAM) String type, @PathParam(ID_PATH_PARAM) String id)
|
||||||
throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
|
throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
|
||||||
CalledMethodProvider.instance.set(HTTPMETHOD.HEAD.name() + " /" + AccessPath.ACCESS_PATH_PART + "/"
|
CalledMethodProvider.instance.set(HTTPMETHOD.HEAD.name() + " /" + AccessPath.ACCESS_PATH_PART + "/"
|
||||||
+ AccessPath.INSTANCE_PATH_PART + "/" + type + "/{" + ID_PATH_PARAM + "}");
|
+ AccessPath.INSTANCES_PATH_PART + "/" + type + "/{" + ID_PATH_PARAM + "}");
|
||||||
|
|
||||||
logger.info("Requested to check if {} with id {} exists", type, id);
|
logger.info("Requested to check if {} with id {} exists", type, id);
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
|
@ -126,18 +134,19 @@ public class Access {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* e.g. GET
|
* e.g. GET
|
||||||
* /resource-registry/access/instance/ContactFacet/4d28077b-566d-4132-b073-f4edaf61dcb9
|
* /resource-registry/access/instances/ContactFacet/4d28077b-566d-4132-b073-f4edaf61dcb9
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path(AccessPath.INSTANCE_PATH_PART + "/" + "{" + TYPE_PATH_PARAM + "}" + "/{" + ID_PATH_PARAM + "}")
|
@Path(AccessPath.INSTANCES_PATH_PART + "/" + "{" + TYPE_PATH_PARAM + "}" + "/{" + ID_PATH_PARAM + "}")
|
||||||
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
||||||
public String getInstance(@PathParam(TYPE_PATH_PARAM) String type, @PathParam(ID_PATH_PARAM) String id)
|
public String getInstance(@PathParam(TYPE_PATH_PARAM) String type, @PathParam(ID_PATH_PARAM) String id)
|
||||||
throws NotFoundException, ResourceRegistryException {
|
throws NotFoundException, ResourceRegistryException {
|
||||||
|
|
||||||
CalledMethodProvider.instance.set(HTTPMETHOD.GET.name() + " /" + AccessPath.ACCESS_PATH_PART + "/"
|
CalledMethodProvider.instance.set(HTTPMETHOD.GET.name() + " /" + AccessPath.ACCESS_PATH_PART + "/"
|
||||||
+ AccessPath.INSTANCE_PATH_PART + "/" + type + "/{" + ID_PATH_PARAM + "}");
|
+ AccessPath.INSTANCES_PATH_PART + "/" + type + "/{" + ID_PATH_PARAM + "}");
|
||||||
|
|
||||||
logger.info("Requested {} with id {}", type, id);
|
logger.info("Requested {} with id {}", type, id);
|
||||||
|
|
||||||
|
@ -153,6 +162,47 @@ public class Access {
|
||||||
return erManagement.read();
|
return erManagement.read();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It includeSubtypes to query Entities and Relations in the current Context.<br />
|
||||||
|
* It accepts idempotent query only.. <br />
|
||||||
|
* <br />
|
||||||
|
* For query syntax please refer to<br />
|
||||||
|
*
|
||||||
|
* <a href="https://orientdb.com/docs/last/SQL-Syntax.html" target="_blank">
|
||||||
|
* https://orientdb.com/docs/last/SQL-Syntax.html </a> <br />
|
||||||
|
* <br />
|
||||||
|
*
|
||||||
|
* e.g. GET /resource-registry/access?query=SELECT FROM V
|
||||||
|
*
|
||||||
|
* @param query
|
||||||
|
* Defines the query to send to the backend.
|
||||||
|
* @param limit
|
||||||
|
* Defines the number of results you want returned, defaults to includeSubtypes results.
|
||||||
|
* @param fetchPlan
|
||||||
|
* Defines the fetching strategy you want to use. See
|
||||||
|
* <a href="https://orientdb.com/docs/last/Fetching-Strategies.html" target="_blank">
|
||||||
|
* https://orientdb.com/docs/last/Fetching-Strategies.html
|
||||||
|
* </a>
|
||||||
|
* @return The JSON representation of the result
|
||||||
|
* @throws InvalidQueryException
|
||||||
|
* if the query is invalid or no idempotent
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Path(AccessPath.QUERY_PATH_PART)
|
||||||
|
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
||||||
|
public String query(@QueryParam(AccessPath.QUERY_PARAM) String query,
|
||||||
|
@QueryParam(AccessPath.LIMIT_PARAM) Integer limit,
|
||||||
|
@QueryParam(AccessPath.FETCH_PLAN_PARAM) String fetchPlan) throws InvalidQueryException {
|
||||||
|
logger.info("Requested query (fetch plan {}, limit : {}):\n{}", fetchPlan, limit, query);
|
||||||
|
Query queryManager = new QueryImpl();
|
||||||
|
return queryManager.query(query, limit, fetchPlan);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* e.g.
|
* e.g.
|
||||||
* GET /resource-registry/access/instances/EService?polymorphic=true
|
* GET /resource-registry/access/instances/EService?polymorphic=true
|
||||||
|
@ -251,46 +301,9 @@ public class Access {
|
||||||
throw new ResourceRegistryException("Invalid Request");
|
throw new ResourceRegistryException("Invalid Request");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* e.g. GET /resource-registry/access/schema/ContactFacet?polymorphic=true
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
@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) @DefaultValue("false") Boolean polymorphic)
|
|
||||||
throws SchemaNotFoundException, ResourceRegistryException {
|
|
||||||
logger.info("Requested Schema for type {}", type);
|
|
||||||
SchemaManagement schemaManagement = new SchemaManagementImpl();
|
|
||||||
return schemaManagement.read(type, polymorphic);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* e.g. GET /resource-registry/access/contexts/c0f314e7-2807-4241-a792-2a6c79ed4fd0
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
@Path(AccessPath.CONTEXTS_PATH_PART + "{" + ID_PATH_PARAM + "}")
|
|
||||||
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
|
||||||
public String getContext(@PathParam(ID_PATH_PARAM) String uuid)
|
|
||||||
throws ContextNotFoundException, ResourceRegistryException {
|
|
||||||
ContextManagement contextManagement = new ContextManagement();
|
|
||||||
logger.info("Requested to read {} with id {} ", org.gcube.informationsystem.model.entity.Context.NAME, uuid);
|
|
||||||
contextManagement.setUUID(UUID.fromString(uuid));
|
|
||||||
return contextManagement.read();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* e.g. GET /resource-registry/access/contexts/c0f314e7-2807-4241-a792-2a6c79ed4fd0
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
@Path(AccessPath.CONTEXTS_PATH_PART)
|
|
||||||
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
|
||||||
public String getContexts()
|
|
||||||
throws ContextNotFoundException, ResourceRegistryException {
|
|
||||||
ContextManagement contextManagement = new ContextManagement();
|
|
||||||
logger.info("Requested to read all {}s", org.gcube.informationsystem.model.entity.Context.NAME);
|
|
||||||
return contextManagement.all(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -2,26 +2,22 @@ package org.gcube.informationsystem.resourceregistry.rest;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.mail.Header;
|
|
||||||
import javax.ws.rs.DELETE;
|
import javax.ws.rs.DELETE;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.POST;
|
|
||||||
import javax.ws.rs.PUT;
|
import javax.ws.rs.PUT;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
import javax.ws.rs.core.Response.Status;
|
|
||||||
|
|
||||||
|
import org.gcube.common.authorization.library.provider.CalledMethodProvider;
|
||||||
import org.gcube.informationsystem.model.entity.Context;
|
import org.gcube.informationsystem.model.entity.Context;
|
||||||
import org.gcube.informationsystem.resourceregistry.ResourceInitializer;
|
import org.gcube.informationsystem.resourceregistry.ResourceInitializer;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextAlreadyPresentException;
|
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextCreationException;
|
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextNotFoundException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextNotFoundException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.rest.ContextPath;
|
import org.gcube.informationsystem.resourceregistry.api.rest.ContextPath;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.api.rest.httputils.HTTPCall.HTTPMETHOD;
|
||||||
import org.gcube.informationsystem.resourceregistry.context.ContextManagement;
|
import org.gcube.informationsystem.resourceregistry.context.ContextManagement;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -39,6 +35,11 @@ public class ContextManager {
|
||||||
|
|
||||||
public static final String ID_PATH_PARAM = "id";
|
public static final String ID_PATH_PARAM = "id";
|
||||||
|
|
||||||
|
protected void setCalledMethod(HTTPMETHOD httpMethod, String uuid) {
|
||||||
|
CalledMethodProvider.instance.set(httpMethod.name() + " /" + ContextPath.CONTEXTS_PATH_PART + "/" + uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
||||||
public String all() throws ContextNotFoundException, ResourceRegistryException {
|
public String all() throws ContextNotFoundException, ResourceRegistryException {
|
||||||
|
@ -47,30 +48,6 @@ public class ContextManager {
|
||||||
return contextManagement.all(false);
|
return contextManagement.all(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* e.g. POST /resource-registry/contexts
|
|
||||||
*
|
|
||||||
* BODY: {...}
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@POST
|
|
||||||
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
|
||||||
public Response create(String json)
|
|
||||||
throws ContextAlreadyPresentException, ResourceRegistryException {
|
|
||||||
logger.info("Requested to create {} with json {}", Context.NAME, json);
|
|
||||||
ContextManagement contextManagement = new ContextManagement();
|
|
||||||
contextManagement.setJSON(json);
|
|
||||||
UUID uuid = contextManagement.getUUID();
|
|
||||||
if(uuid!=null) {
|
|
||||||
String error = String.format("Could not specify an UUID in % to create a %s using POST. Please use PUT instead and specify the UUID as path argument.",
|
|
||||||
Header.class.getSimpleName(), Context.NAME);
|
|
||||||
logger.info(error);
|
|
||||||
throw new ContextCreationException(error);
|
|
||||||
}
|
|
||||||
String ret = contextManagement.create();
|
|
||||||
return Response.status(Status.CREATED).entity(ret).type(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* e.g. GET /resource-registry/contexts/c0f314e7-2807-4241-a792-2a6c79ed4fd0
|
* e.g. GET /resource-registry/contexts/c0f314e7-2807-4241-a792-2a6c79ed4fd0
|
||||||
* @param uuid
|
* @param uuid
|
||||||
|
@ -82,6 +59,9 @@ public class ContextManager {
|
||||||
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
||||||
public String read(@PathParam(ID_PATH_PARAM) String uuid)
|
public String read(@PathParam(ID_PATH_PARAM) String uuid)
|
||||||
throws ContextNotFoundException, ResourceRegistryException {
|
throws ContextNotFoundException, ResourceRegistryException {
|
||||||
|
|
||||||
|
setCalledMethod(HTTPMETHOD.GET, uuid);
|
||||||
|
|
||||||
ContextManagement contextManagement = new ContextManagement();
|
ContextManagement contextManagement = new ContextManagement();
|
||||||
logger.info("Requested to read {} with id {} ", Context.NAME, uuid);
|
logger.info("Requested to read {} with id {} ", Context.NAME, uuid);
|
||||||
contextManagement.setUUID(UUID.fromString(uuid));
|
contextManagement.setUUID(UUID.fromString(uuid));
|
||||||
|
@ -97,8 +77,11 @@ public class ContextManager {
|
||||||
@PUT
|
@PUT
|
||||||
@Path("{" + ID_PATH_PARAM + "}")
|
@Path("{" + ID_PATH_PARAM + "}")
|
||||||
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
||||||
public String update(@PathParam(ID_PATH_PARAM) String uuid, String json)
|
public String updateCreate(@PathParam(ID_PATH_PARAM) String uuid, String json)
|
||||||
throws ResourceRegistryException {
|
throws ResourceRegistryException {
|
||||||
|
|
||||||
|
setCalledMethod(HTTPMETHOD.PUT, uuid);
|
||||||
|
|
||||||
logger.info("Requested to update {} with json {} ", Context.NAME, json);
|
logger.info("Requested to update {} with json {} ", Context.NAME, json);
|
||||||
ContextManagement contextManagement = new ContextManagement();
|
ContextManagement contextManagement = new ContextManagement();
|
||||||
contextManagement.setUUID(UUID.fromString(uuid));
|
contextManagement.setUUID(UUID.fromString(uuid));
|
||||||
|
@ -127,6 +110,9 @@ public class ContextManager {
|
||||||
@Path("{" + ID_PATH_PARAM + "}")
|
@Path("{" + ID_PATH_PARAM + "}")
|
||||||
public boolean delete(@PathParam(ID_PATH_PARAM) String uuid)
|
public boolean delete(@PathParam(ID_PATH_PARAM) String uuid)
|
||||||
throws ContextNotFoundException, ResourceRegistryException {
|
throws ContextNotFoundException, ResourceRegistryException {
|
||||||
|
|
||||||
|
setCalledMethod(HTTPMETHOD.DELETE, uuid);
|
||||||
|
|
||||||
logger.info("Requested to delete {} with id {} ", Context.NAME, uuid);
|
logger.info("Requested to delete {} with id {} ", Context.NAME, uuid);
|
||||||
ContextManagement contextManagement = new ContextManagement();
|
ContextManagement contextManagement = new ContextManagement();
|
||||||
contextManagement.setUUID(UUID.fromString(uuid));
|
contextManagement.setUUID(UUID.fromString(uuid));
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.resour
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.resource.ResourceNotFoundException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.resource.ResourceNotFoundException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.rest.ERPath;
|
import org.gcube.informationsystem.resourceregistry.api.rest.ERPath;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.rest.httputils.HTTPCall.HTTPMETHOD;
|
import org.gcube.informationsystem.resourceregistry.api.rest.httputils.HTTPCall.HTTPMETHOD;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.context.ContextUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.er.entity.FacetManagement;
|
import org.gcube.informationsystem.resourceregistry.er.entity.FacetManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.er.entity.ResourceManagement;
|
import org.gcube.informationsystem.resourceregistry.er.entity.ResourceManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.er.relation.ConsistsOfManagement;
|
import org.gcube.informationsystem.resourceregistry.er.relation.ConsistsOfManagement;
|
||||||
|
@ -40,6 +41,7 @@ import org.slf4j.LoggerFactory;
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
@Path(ERPath.ER_PATH_PART)
|
@Path(ERPath.ER_PATH_PART)
|
||||||
public class ERManager {
|
public class ERManager {
|
||||||
|
|
||||||
|
@ -280,7 +282,7 @@ public class ERManager {
|
||||||
logger.info("Requested to add {} with UUID {} to current {}", Resource.NAME, uuid, Context.NAME);
|
logger.info("Requested to add {} with UUID {} to current {}", Resource.NAME, uuid, Context.NAME);
|
||||||
ResourceManagement resourceManagement = new ResourceManagement();
|
ResourceManagement resourceManagement = new ResourceManagement();
|
||||||
resourceManagement.setUUID(UUID.fromString(uuid));
|
resourceManagement.setUUID(UUID.fromString(uuid));
|
||||||
return resourceManagement.addToContext();
|
return resourceManagement.addToContext(ContextUtility.getCurrentSecurityContext().getUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -296,7 +298,7 @@ public class ERManager {
|
||||||
logger.info("Requested to add {} with UUID {} to current {}", Facet.NAME, uuid, Context.NAME);
|
logger.info("Requested to add {} with UUID {} to current {}", Facet.NAME, uuid, Context.NAME);
|
||||||
FacetManagement facetManagement = new FacetManagement();
|
FacetManagement facetManagement = new FacetManagement();
|
||||||
facetManagement.setUUID(UUID.fromString(uuid));
|
facetManagement.setUUID(UUID.fromString(uuid));
|
||||||
return facetManagement.addToContext();
|
return facetManagement.addToContext(ContextUtility.getCurrentSecurityContext().getUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -313,7 +315,7 @@ public class ERManager {
|
||||||
logger.info("Requested to remove {} with UUID {} from current {}", Resource.NAME, uuid, Context.NAME);
|
logger.info("Requested to remove {} with UUID {} from current {}", Resource.NAME, uuid, Context.NAME);
|
||||||
ResourceManagement resourceManagement = new ResourceManagement();
|
ResourceManagement resourceManagement = new ResourceManagement();
|
||||||
resourceManagement.setUUID(UUID.fromString(uuid));
|
resourceManagement.setUUID(UUID.fromString(uuid));
|
||||||
return resourceManagement.removeFromContext();
|
return resourceManagement.removeFromContext(ContextUtility.getCurrentSecurityContext().getUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -330,7 +332,7 @@ public class ERManager {
|
||||||
logger.info("Requested to remove {} with UUID {} from current {}", Facet.NAME, uuid, Context.NAME);
|
logger.info("Requested to remove {} with UUID {} from current {}", Facet.NAME, uuid, Context.NAME);
|
||||||
FacetManagement facetManagement = new FacetManagement();
|
FacetManagement facetManagement = new FacetManagement();
|
||||||
facetManagement.setUUID(UUID.fromString(uuid));
|
facetManagement.setUUID(UUID.fromString(uuid));
|
||||||
return facetManagement.removeFromContext();
|
return facetManagement.removeFromContext(ContextUtility.getCurrentSecurityContext().getUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,125 @@
|
||||||
|
package org.gcube.informationsystem.resourceregistry.rest;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.DELETE;
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.PUT;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.PathParam;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
|
import org.gcube.common.authorization.library.provider.CalledMethodProvider;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.ResourceInitializer;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.api.rest.InstancePath;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.api.rest.httputils.HTTPCall.HTTPMETHOD;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.er.ERManagement;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.er.ERManagementUtility;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
|
*/
|
||||||
|
@Path(InstancePath.INSTANCES_PATH_PART)
|
||||||
|
public class InstancesManager {
|
||||||
|
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(InstancesManager.class);
|
||||||
|
|
||||||
|
public static final String ID_PATH_PARAM = "id";
|
||||||
|
public static final String TYPE_PATH_PARAM = "type";
|
||||||
|
|
||||||
|
protected void setCalledMethod(HTTPMETHOD httpMethod, String type) {
|
||||||
|
CalledMethodProvider.instance.set(httpMethod.name() + " /" + InstancePath.INSTANCES_PATH_PART + "/"
|
||||||
|
+ type + "/{" + ID_PATH_PARAM + "}");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* e.g. GET /resource-registry/instances/{type}/4023d5b2-8601-47a5-83ef-49ffcbfc7d86
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Path("/{" + TYPE_PATH_PARAM + "}" + "/{" + ID_PATH_PARAM + "}")
|
||||||
|
@Consumes({MediaType.TEXT_PLAIN, ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8})
|
||||||
|
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
||||||
|
public String read(@PathParam(TYPE_PATH_PARAM) String type, @PathParam(ID_PATH_PARAM) String uuid, String json)
|
||||||
|
throws NotFoundException, ResourceRegistryException {
|
||||||
|
|
||||||
|
setCalledMethod(HTTPMETHOD.GET, type);
|
||||||
|
|
||||||
|
logger.info("Requested to read {} with id {}", type, uuid);
|
||||||
|
logger.trace("Requested to read {} with id {} with json {}", type, uuid, json);
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
ERManagement erManagement = ERManagementUtility.getERManagement(type);
|
||||||
|
|
||||||
|
erManagement.setElementType(type);
|
||||||
|
erManagement.setUUID(UUID.fromString(uuid));
|
||||||
|
return erManagement.read();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* e.g. PUT /resource-registry/instances/{type}/4023d5b2-8601-47a5-83ef-49ffcbfc7d86
|
||||||
|
*
|
||||||
|
* BODY: {...}
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@PUT
|
||||||
|
@Path("/{" + TYPE_PATH_PARAM + "}" + "/{" + ID_PATH_PARAM + "}")
|
||||||
|
@Consumes({MediaType.TEXT_PLAIN, ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8})
|
||||||
|
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
||||||
|
public String updateOrCreate(@PathParam(TYPE_PATH_PARAM) String type, @PathParam(ID_PATH_PARAM) String uuid, String json)
|
||||||
|
throws ResourceRegistryException {
|
||||||
|
|
||||||
|
setCalledMethod(HTTPMETHOD.PUT, type);
|
||||||
|
|
||||||
|
logger.info("Requested to update/create {} with id {}", type, uuid);
|
||||||
|
logger.trace("Requested to update/create {} with id {} with json {}", type, uuid, json);
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
ERManagement erManagement = ERManagementUtility.getERManagement(type);
|
||||||
|
|
||||||
|
erManagement.setUUID(UUID.fromString(uuid));
|
||||||
|
|
||||||
|
boolean create = false;
|
||||||
|
try {
|
||||||
|
erManagement.read();
|
||||||
|
} catch(NotFoundException e) {
|
||||||
|
create = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
erManagement.setElementType(type);
|
||||||
|
erManagement.setJSON(json);
|
||||||
|
if(create) {
|
||||||
|
return erManagement.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
return erManagement.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* e.g. DELETE /resource-registry/instances/{type}/4023d5b2-8601-47a5-83ef-49ffcbfc7d86
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@DELETE
|
||||||
|
@Path("/{" + TYPE_PATH_PARAM + "}" + "/{" + ID_PATH_PARAM + "}")
|
||||||
|
public boolean delete(@PathParam(TYPE_PATH_PARAM) String type, @PathParam(ID_PATH_PARAM) String uuid)
|
||||||
|
throws ResourceRegistryException {
|
||||||
|
|
||||||
|
setCalledMethod(HTTPMETHOD.DELETE, type);
|
||||||
|
|
||||||
|
logger.info("Requested to delete {} with id {}", type, uuid);
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
ERManagement erManagement = ERManagementUtility.getERManagement(type);
|
||||||
|
|
||||||
|
erManagement.setUUID(UUID.fromString(uuid));
|
||||||
|
return erManagement.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -17,7 +17,8 @@ import org.gcube.informationsystem.resourceregistry.ResourceInitializer;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.rest.SchemaPath;
|
import org.gcube.informationsystem.resourceregistry.api.rest.TypePath;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.er.ERManagementUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.schema.SchemaManagement;
|
import org.gcube.informationsystem.resourceregistry.schema.SchemaManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.schema.SchemaManagementImpl;
|
import org.gcube.informationsystem.resourceregistry.schema.SchemaManagementImpl;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -26,7 +27,7 @@ import org.slf4j.LoggerFactory;
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
@Path(SchemaPath.SCHEMAS_PATH_PART)
|
@Path(TypePath.TYPES_PATH_PART)
|
||||||
public class SchemaManager {
|
public class SchemaManager {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(SchemaManager.class);
|
private static Logger logger = LoggerFactory.getLogger(SchemaManager.class);
|
||||||
|
@ -34,48 +35,29 @@ public class SchemaManager {
|
||||||
public static final String TYPE_NAME_PATH_PARAM = "typeName";
|
public static final String TYPE_NAME_PATH_PARAM = "typeName";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* e.g. PUT /resource-registry/schemas/ContactFacet
|
* e.g. PUT /resource-registry/types/ContactFacet
|
||||||
*
|
*
|
||||||
* BODY: {...}
|
* BODY: {...}
|
||||||
*
|
*
|
||||||
* @param baseType
|
* @param typeName
|
||||||
* @param json
|
* @param json
|
||||||
* @return
|
* @return
|
||||||
* @throws SchemaException
|
* @throws SchemaException
|
||||||
|
* @throws ResourceRegistryException
|
||||||
*/
|
*/
|
||||||
@PUT
|
@PUT
|
||||||
@Path("{" + TYPE_NAME_PATH_PARAM + "}")
|
@Path("{" + TYPE_NAME_PATH_PARAM + "}")
|
||||||
@Consumes({MediaType.TEXT_PLAIN, ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8})
|
@Consumes({MediaType.TEXT_PLAIN, ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8})
|
||||||
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
||||||
public Response create(@PathParam(TYPE_NAME_PATH_PARAM) String typeName, @QueryParam(SchemaPath.BASE_TYPE_PATH_PARAM) String baseType, String json)
|
public Response create(@PathParam(TYPE_NAME_PATH_PARAM) String typeName, String json)
|
||||||
throws SchemaException, ResourceRegistryException {
|
throws SchemaException, ResourceRegistryException {
|
||||||
logger.info("Requested {} registration with schema {}", baseType, json);
|
logger.info("Requested {} registration with schema {}", typeName, json);
|
||||||
|
|
||||||
AccessType accessType = null;
|
AccessType accessType = null;
|
||||||
try {
|
try {
|
||||||
accessType = AccessType.valueOf(baseType.toUpperCase());
|
accessType = ERManagementUtility.getBaseAccessType(typeName);
|
||||||
switch(accessType) {
|
|
||||||
case EMBEDDED:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FACET:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RESOURCE:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IS_RELATED_TO:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CONSISTS_OF:
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new Exception();
|
|
||||||
|
|
||||||
}
|
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
String error = String.format("Cannot register %s schema", baseType);
|
String error = String.format("Cannot register %s schema", typeName);
|
||||||
throw new ResourceRegistryException(error);
|
throw new ResourceRegistryException(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,14 +68,21 @@ public class SchemaManager {
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* e.g. GET /resource-registry/schemas/ContactFacet?polymorphic=true
|
* e.g. GET /resource-registry/schemas/ContactFacet?polymorphic=true
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param typeName
|
||||||
|
* @param polymorphic
|
||||||
|
* @return
|
||||||
|
* @throws SchemaNotFoundException
|
||||||
|
* @throws ResourceRegistryException
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path("{" + TYPE_NAME_PATH_PARAM + "}")
|
@Path("{" + TYPE_NAME_PATH_PARAM + "}")
|
||||||
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
||||||
public String read(@PathParam(TYPE_NAME_PATH_PARAM) String typeName,
|
public String read(@PathParam(TYPE_NAME_PATH_PARAM) String typeName,
|
||||||
@QueryParam(SchemaPath.POLYMORPHIC_PARAM) @DefaultValue("false") Boolean polymorphic)
|
@QueryParam(TypePath.POLYMORPHIC_PARAM) @DefaultValue("false") Boolean polymorphic)
|
||||||
throws SchemaNotFoundException, ResourceRegistryException {
|
throws SchemaNotFoundException, ResourceRegistryException {
|
||||||
logger.info("Requested Schema for type {}", typeName);
|
logger.info("Requested Schema for type {}", typeName);
|
||||||
SchemaManagement schemaManagement = new SchemaManagementImpl();
|
SchemaManagement schemaManagement = new SchemaManagementImpl();
|
||||||
|
|
|
@ -0,0 +1,110 @@
|
||||||
|
package org.gcube.informationsystem.resourceregistry.rest;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import javax.ws.rs.DELETE;
|
||||||
|
import javax.ws.rs.PUT;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.PathParam;
|
||||||
|
|
||||||
|
import org.gcube.common.authorization.library.provider.CalledMethodProvider;
|
||||||
|
import org.gcube.informationsystem.model.entity.Context;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextNotFoundException;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.resource.ResourceNotFoundException;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.api.rest.SharingPath;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.er.ERManagement;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.er.ERManagementUtility;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@Path(SharingPath.SHARING_PATH_PART)
|
||||||
|
public class SharingManagement {
|
||||||
|
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(SharingManagement.class);
|
||||||
|
|
||||||
|
public static final String CONTEXT_ID_PATH_PARAM = "contextId";
|
||||||
|
public static final String TYPE_PATH_PARAM = "type";
|
||||||
|
public static final String ID_PATH_PARAM = "id";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* e.g PUT
|
||||||
|
* /resource-registry/sharing/67062c11-9c3a-4906-870d-7df6a43408b0/HostingNode/16032d09-3823-444e-a1ff-a67de4f350a8
|
||||||
|
* Where 67062c11-9c3a-4906-870d-7df6a43408b0/ is the context UUID
|
||||||
|
* and 16032d09-3823-444e-a1ff-a67de4f350a8 is the HostingNode UUID
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@PUT
|
||||||
|
@Path("/{" + CONTEXT_ID_PATH_PARAM + "}" + "/" + TYPE_PATH_PARAM + "/{" + ID_PATH_PARAM + "}")
|
||||||
|
public boolean add(
|
||||||
|
@PathParam(CONTEXT_ID_PATH_PARAM) String contextId,
|
||||||
|
@PathParam(TYPE_PATH_PARAM) String type,
|
||||||
|
@PathParam(ID_PATH_PARAM) String id)
|
||||||
|
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
|
||||||
|
|
||||||
|
CalledMethodProvider.instance.set("");
|
||||||
|
|
||||||
|
logger.info("Requested to add {} with UUID {} to {} with UUID {}", type, id, Context.NAME, contextId);
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
ERManagement erManagement = ERManagementUtility.getERManagement(type);
|
||||||
|
UUID uuid = null;
|
||||||
|
try {
|
||||||
|
uuid = UUID.fromString(id);
|
||||||
|
} catch(Exception e) {
|
||||||
|
throw new ResourceRegistryException(e);
|
||||||
|
}
|
||||||
|
erManagement.setUUID(uuid);
|
||||||
|
|
||||||
|
UUID contextUUID = null;
|
||||||
|
try {
|
||||||
|
contextUUID = UUID.fromString(contextId);
|
||||||
|
} catch(Exception e) {
|
||||||
|
throw new ResourceRegistryException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return erManagement.addToContext(contextUUID);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* e.g DELETE
|
||||||
|
* /resource-registry/sharing/67062c11-9c3a-4906-870d-7df6a43408b0/HostingNode/16032d09-3823-444e-a1ff-a67de4f350a8
|
||||||
|
* Where 67062c11-9c3a-4906-870d-7df6a43408b0/ is the context UUID
|
||||||
|
* and 16032d09-3823-444e-a1ff-a67de4f350a8 is the HostingNode UUID
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@DELETE
|
||||||
|
@Path("/{" + CONTEXT_ID_PATH_PARAM + "}" + "/" + TYPE_PATH_PARAM + "/{" + ID_PATH_PARAM + "}")
|
||||||
|
public boolean remove(
|
||||||
|
@PathParam(CONTEXT_ID_PATH_PARAM) String contextId,
|
||||||
|
@PathParam(TYPE_PATH_PARAM) String type,
|
||||||
|
@PathParam(ID_PATH_PARAM) String id)
|
||||||
|
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
|
||||||
|
|
||||||
|
CalledMethodProvider.instance.set("");
|
||||||
|
|
||||||
|
logger.info("Requested to remove {} with UUID {} to {} with UUID {}", type, id, Context.NAME, contextId);
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
ERManagement erManagement = ERManagementUtility.getERManagement(type);
|
||||||
|
UUID uuid = null;
|
||||||
|
try {
|
||||||
|
uuid = UUID.fromString(id);
|
||||||
|
} catch(Exception e) {
|
||||||
|
throw new ResourceRegistryException(e);
|
||||||
|
}
|
||||||
|
erManagement.setUUID(uuid);
|
||||||
|
|
||||||
|
UUID contextUUID = null;
|
||||||
|
try {
|
||||||
|
contextUUID = UUID.fromString(contextId);
|
||||||
|
} catch(Exception e) {
|
||||||
|
throw new ResourceRegistryException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return erManagement.removeFromContext(contextUUID);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -173,7 +173,7 @@ public class SchemaManagementImpl implements SchemaManagement {
|
||||||
TypeDefinition typeDefinition = mapper.readValue(jsonSchema, TypeDefinition.class);
|
TypeDefinition typeDefinition = mapper.readValue(jsonSchema, TypeDefinition.class);
|
||||||
|
|
||||||
if(typeName.compareTo(typeDefinition.getName())!=0) {
|
if(typeName.compareTo(typeDefinition.getName())!=0) {
|
||||||
String error = String.format("Provided typename path argument %s does not match with the type name in the definition %S. Please be coherent.", typeName, typeDefinition.getName());
|
String error = String.format("Provided type name path argument %s does not match with the type name in the definition %S. Please be coherent.", typeName, typeDefinition.getName());
|
||||||
throw new SchemaCreationException(error);
|
throw new SchemaCreationException(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -150,7 +150,7 @@ public class FacetManagementTest extends ScopedTest {
|
||||||
facetManagement.setElementType(facetType);
|
facetManagement.setElementType(facetType);
|
||||||
facetManagement.setUUID(facet.getHeader().getUUID());
|
facetManagement.setUUID(facet.getHeader().getUUID());
|
||||||
|
|
||||||
boolean added = facetManagement.addToContext();
|
boolean added = facetManagement.addToContext(ContextUtility.getCurrentSecurityContext().getUUID());
|
||||||
Assert.assertTrue(added);
|
Assert.assertTrue(added);
|
||||||
|
|
||||||
return added;
|
return added;
|
||||||
|
@ -162,7 +162,7 @@ public class FacetManagementTest extends ScopedTest {
|
||||||
facetManagement.setElementType(facetType);
|
facetManagement.setElementType(facetType);
|
||||||
facetManagement.setUUID(facet.getHeader().getUUID());
|
facetManagement.setUUID(facet.getHeader().getUUID());
|
||||||
|
|
||||||
boolean added = facetManagement.removeFromContext();
|
boolean added = facetManagement.removeFromContext(ContextUtility.getCurrentSecurityContext().getUUID());
|
||||||
Assert.assertTrue(added);
|
Assert.assertTrue(added);
|
||||||
|
|
||||||
return added;
|
return added;
|
||||||
|
|
|
@ -262,7 +262,7 @@ public class BasicTest extends ScopedTest {
|
||||||
resourceManagement = new ResourceManagement();
|
resourceManagement = new ResourceManagement();
|
||||||
resourceManagement.setUUID(uuid);
|
resourceManagement.setUUID(uuid);
|
||||||
|
|
||||||
boolean addedToContext = resourceManagement.addToContext();
|
boolean addedToContext = resourceManagement.addToContext(ContextUtility.getCurrentSecurityContext().getUUID());
|
||||||
Assert.assertTrue(addedToContext);
|
Assert.assertTrue(addedToContext);
|
||||||
|
|
||||||
resourceManagement = new ResourceManagement();
|
resourceManagement = new ResourceManagement();
|
||||||
|
@ -319,7 +319,7 @@ public class BasicTest extends ScopedTest {
|
||||||
ContextNotFoundException, ResourceRegistryException {
|
ContextNotFoundException, ResourceRegistryException {
|
||||||
ResourceManagement resourceManagement = new ResourceManagement();
|
ResourceManagement resourceManagement = new ResourceManagement();
|
||||||
resourceManagement.setUUID(UUID.fromString(""));
|
resourceManagement.setUUID(UUID.fromString(""));
|
||||||
resourceManagement.addToContext();
|
resourceManagement.addToContext(ContextUtility.getCurrentSecurityContext().getUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -400,7 +400,7 @@ public class BasicTest extends ScopedTest {
|
||||||
|
|
||||||
isRelatedToManagement = new IsRelatedToManagement();
|
isRelatedToManagement = new IsRelatedToManagement();
|
||||||
isRelatedToManagement.setUUID(hostsUUID);
|
isRelatedToManagement.setUUID(hostsUUID);
|
||||||
isRelatedToManagement.addToContext();
|
isRelatedToManagement.addToContext(ContextUtility.getCurrentSecurityContext().getUUID());
|
||||||
|
|
||||||
/* The addTocontext on the relation adds the source and target too.
|
/* The addTocontext on the relation adds the source and target too.
|
||||||
* So that I MUST be able to read HostinNode and EService
|
* So that I MUST be able to read HostinNode and EService
|
||||||
|
@ -420,7 +420,7 @@ public class BasicTest extends ScopedTest {
|
||||||
|
|
||||||
resourceManagement = new ResourceManagement();
|
resourceManagement = new ResourceManagement();
|
||||||
resourceManagement.setUUID(hnUUID);
|
resourceManagement.setUUID(hnUUID);
|
||||||
boolean removed = resourceManagement.removeFromContext();
|
boolean removed = resourceManagement.removeFromContext(ContextUtility.getCurrentSecurityContext().getUUID());
|
||||||
Assert.assertTrue(removed);
|
Assert.assertTrue(removed);
|
||||||
|
|
||||||
/* The cascading MUST remove the relation and the target so that
|
/* The cascading MUST remove the relation and the target so that
|
||||||
|
|
Loading…
Reference in New Issue