Improving code

This commit is contained in:
Luca Frosini 2021-02-19 19:32:23 +01:00
parent a0ffe74776
commit 44631557da
15 changed files with 372 additions and 336 deletions

View File

@ -4,7 +4,6 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.gcube.com.fasterxml.jackson.core.JsonProcessingException;
@ -49,19 +48,19 @@ import com.orientechnologies.orient.core.sql.executor.OResultSet;
* @author Luca Frosini (ISTI - CNR)
*/
public class ContextManagement extends EntityElementManagement<Context> {
private static Logger logger = LoggerFactory.getLogger(ContextManagement.class);
protected String name;
private void init() {
this.ignoreStartWithKeys.add(Context.PARENT_PROPERTY);
this.ignoreStartWithKeys.add(Context.CHILDREN_PROPERTY);
this.typeName = Context.NAME;
}
protected ContextCacheRenewal contextCacheRenewal = new ContextCacheRenewal() {
@Override
public List<Context> renew() throws ResourceRegistryException {
String contextsJsonString = allFromServer(false);
@ -73,25 +72,25 @@ public class ContextManagement extends EntityElementManagement<Context> {
}
return contexts;
}
};
};
public ContextManagement() {
super(AccessType.CONTEXT);
init();
ContextCache contextCache = ContextCache.getInstance();
contextCache.setContextCacheRenewal(contextCacheRenewal);
}
public ContextManagement(ODatabaseDocument oDatabaseDocument) throws ResourceRegistryException {
this();
this.oDatabaseDocument = oDatabaseDocument;
getWorkingContext();
}
public String getName() {
if(name == null) {
if(element == null) {
if(jsonNode != null) {
if (name == null) {
if (element == null) {
if (jsonNode != null) {
name = jsonNode.get(Context.NAME_PROPERTY).asText();
}
} else {
@ -100,160 +99,158 @@ public class ContextManagement extends EntityElementManagement<Context> {
}
return name;
}
@Override
protected SecurityContext getWorkingContext() throws ResourceRegistryException {
if(workingContext == null) {
if (workingContext == null) {
workingContext = ContextUtility.getInstance()
.getSecurityContextByUUID(DatabaseEnvironment.CONTEXT_SECURITY_CONTEXT_UUID);
}
return workingContext;
}
@Override
protected ContextNotFoundException getSpecificElementNotFoundException(NotFoundException e) {
return new ContextNotFoundException(e.getMessage(), e.getCause());
}
@Override
protected ContextAlreadyPresentException getSpecificERAlreadyPresentException(String message) {
return new ContextAlreadyPresentException(message);
}
protected void checkContext(ContextManagement parentContext)
throws ContextNotFoundException, ContextAlreadyPresentException, ResourceRegistryException {
if(parentContext != null) {
if (parentContext != null) {
String parentId = parentContext.getElement().getIdentity().toString();
String select = "SELECT FROM (TRAVERSE out(" + IsParentOf.NAME + ") FROM " + parentId
+ " MAXDEPTH 1) WHERE " + Context.NAME_PROPERTY + "=\"" + getName() + "\" AND "
+ Context.HEADER_PROPERTY + "." + Header.UUID_PROPERTY + "<>\"" + parentContext.uuid + "\"";
logger.trace(select);
StringBuilder message = new StringBuilder();
message.append("A context with name (");
message.append(getName());
message.append(") has been already created as child of ");
message.append(parentContext.getElement().toString());
logger.trace("Checking if {} -> {}", message, select);
OResultSet resultSet = oDatabaseDocument.command(select, new HashMap<>());
if(resultSet != null && resultSet.hasNext()) {
if (resultSet != null && resultSet.hasNext()) {
throw new ContextAlreadyPresentException(message.toString());
}
} else {
String select = "SELECT FROM " + Context.NAME + " WHERE "
+ Context.NAME_PROPERTY + " = \"" + getName() + "\"" + " AND in(\"" + IsParentOf.NAME
+ "\").size() = 0";
String select = "SELECT FROM " + Context.NAME + " WHERE " + Context.NAME_PROPERTY + " = \"" + getName()
+ "\"" + " AND in(\"" + IsParentOf.NAME + "\").size() = 0";
OResultSet resultSet = oDatabaseDocument.command(select, new HashMap<>());
if(resultSet != null && resultSet.hasNext()) {
if (resultSet != null && resultSet.hasNext()) {
throw new ContextAlreadyPresentException(
"A root context with the same name (" + this.getName() + ") already exist");
}
}
}
@Override
protected JsonNode createCompleteJsonNode() throws ResourceRegistryException {
JsonNode context = serializeSelfAsJsonNode();
int count = 0;
Iterable<OEdge> parents = getElement().getEdges(ODirection.IN);
for(OEdge edge : parents) {
if(++count > 1) {
for (OEdge edge : parents) {
if (++count > 1) {
throw new ContextException("A " + Context.NAME + " can not have more than one parent");
}
try {
IsParentOfManagement isParentOfManagement = new IsParentOfManagement(oDatabaseDocument);
isParentOfManagement.setElement(edge);
JsonNode isParentOf = isParentOfManagement.createCompleteJsonNode(true, false);
if(isParentOf!=null) {
if (isParentOf != null) {
((ObjectNode) context).replace(Context.PARENT_PROPERTY, isParentOf);
}
} catch(Exception e) {
} catch (Exception e) {
logger.error("Unable to correctly serialize {}. {}", edge, Utility.SHOULD_NOT_OCCUR_ERROR_MESSAGE);
throw new ContextException("");
}
}
Iterable<OEdge> childrenEdges = getElement().getEdges(ODirection.OUT);
for(OEdge edge : childrenEdges) {
for (OEdge edge : childrenEdges) {
IsParentOfManagement isParentOfManagement = new IsParentOfManagement(oDatabaseDocument);
isParentOfManagement.setElement(edge);
try {
JsonNode isParentOf = isParentOfManagement.serializeAsJsonNode();
context = addRelation(context, isParentOf, Context.CHILDREN_PROPERTY);
} catch(ResourceRegistryException e) {
} catch (ResourceRegistryException e) {
logger.error("Unable to correctly serialize {}. {}", edge, Utility.SHOULD_NOT_OCCUR_ERROR_MESSAGE);
throw e;
} catch(Exception e) {
} catch (Exception e) {
logger.error("Unable to correctly serialize {}. {}", edge, Utility.SHOULD_NOT_OCCUR_ERROR_MESSAGE);
throw new ResourceRegistryException(e);
}
}
return context;
}
@Override
protected OVertex reallyCreate() throws AlreadyPresentException, ResourceRegistryException {
SecurityContext securityContext = null;
SecurityContext parentSecurityContext = null;
try {
JsonNode isParentOfJsonNode = jsonNode.get(Context.PARENT_PROPERTY);
if(isParentOfJsonNode != null && !(isParentOfJsonNode instanceof NullNode)) {
if (isParentOfJsonNode != null && !(isParentOfJsonNode instanceof NullNode)) {
JsonNode parentJsonNode = isParentOfJsonNode.get(Relation.SOURCE_PROPERTY);
ContextManagement parentContextManagement = new ContextManagement(oDatabaseDocument);
parentContextManagement.setJsonNode(parentJsonNode);
UUID parentUUID = parentContextManagement.uuid;
parentSecurityContext = ContextUtility.getInstance().getSecurityContextByUUID(parentUUID);
checkContext(parentContextManagement);
if(uuid == null) {
if (uuid == null) {
uuid = UUID.randomUUID();
}
createVertex();
IsParentOfManagement isParentOfManagement = new IsParentOfManagement(oDatabaseDocument);
isParentOfManagement.setJsonNode(isParentOfJsonNode);
isParentOfManagement.setSourceEntityManagement(parentContextManagement);
isParentOfManagement.setTargetEntityManagement(this);
isParentOfManagement.internalCreate();
} else {
checkContext(null);
createVertex();
}
securityContext = new SecurityContext(uuid);
securityContext.setParentSecurityContext(parentSecurityContext);
securityContext.create(oDatabaseDocument);
ContextUtility.getInstance().addSecurityContext(securityContext);
return getElement();
} catch(Exception e) {
} catch (Exception e) {
oDatabaseDocument.rollback();
if(securityContext != null) {
if (securityContext != null) {
securityContext.delete(oDatabaseDocument);
if(parentSecurityContext!=null && securityContext!=null) {
if (parentSecurityContext != null && securityContext != null) {
parentSecurityContext.getChildren().remove(securityContext);
}
ContextCache.getInstance().cleanCache();
@ -261,19 +258,19 @@ public class ContextManagement extends EntityElementManagement<Context> {
throw e;
}
}
@Override
protected OVertex reallyUpdate() throws NotFoundException, ResourceRegistryException {
boolean parentChanged = false;
boolean nameChanged = false;
OVertex parent = null;
boolean found = false;
Iterable<OVertex> iterable = getElement().getVertices(ODirection.IN, IsParentOf.NAME);
for(OVertex p : iterable) {
if(found) {
for (OVertex p : iterable) {
if (found) {
String message = String.format("{} has more than one parent. {}", Context.NAME,
Utility.SHOULD_NOT_OCCUR_ERROR_MESSAGE);
throw new ResourceRegistryException(message.toString());
@ -281,142 +278,142 @@ public class ContextManagement extends EntityElementManagement<Context> {
parent = p;
found = true;
}
ContextManagement actualParentContextManagement = null;
if(parent != null) {
if (parent != null) {
actualParentContextManagement = new ContextManagement(oDatabaseDocument);
actualParentContextManagement.setElement(parent);
}
ContextManagement newParentContextManagement = actualParentContextManagement;
JsonNode isParentOfJsonNode = jsonNode.get(Context.PARENT_PROPERTY);
JsonNode parentContextJsonNode = null;
if(isParentOfJsonNode != null && !(isParentOfJsonNode instanceof NullNode)) {
if (isParentOfJsonNode != null && !(isParentOfJsonNode instanceof NullNode)) {
parentContextJsonNode = isParentOfJsonNode.get(Relation.SOURCE_PROPERTY);
}
if(parentContextJsonNode != null && !(parentContextJsonNode instanceof NullNode)) {
if (parentContextJsonNode != null && !(parentContextJsonNode instanceof NullNode)) {
UUID parentUUID = org.gcube.informationsystem.utils.Utility.getUUIDFromJsonNode(parentContextJsonNode);
if(actualParentContextManagement != null) {
if(parentUUID.compareTo(actualParentContextManagement.uuid) != 0) {
if (actualParentContextManagement != null) {
if (parentUUID.compareTo(actualParentContextManagement.uuid) != 0) {
parentChanged = true;
}
} else {
parentChanged = true;
}
if(parentChanged) {
if (parentChanged) {
newParentContextManagement = new ContextManagement(oDatabaseDocument);
newParentContextManagement.setJsonNode(parentContextJsonNode);
}
} else {
if(actualParentContextManagement != null) {
if (actualParentContextManagement != null) {
parentChanged = true;
newParentContextManagement = null;
}
}
String oldName = getElement().getProperty(Context.NAME_PROPERTY);
String newName = jsonNode.get(Context.NAME_PROPERTY).asText();
if(oldName.compareTo(newName) != 0) {
if (oldName.compareTo(newName) != 0) {
nameChanged = true;
name = newName;
}
if(parentChanged || nameChanged) {
if (parentChanged || nameChanged) {
checkContext(newParentContextManagement);
}
if(parentChanged) {
if (parentChanged) {
move(newParentContextManagement, false);
}
element = (OVertex) updateProperties(oClass, getElement(), jsonNode, ignoreKeys,
ignoreStartWithKeys);
element = (OVertex) updateProperties(oClass, getElement(), jsonNode, ignoreKeys, ignoreStartWithKeys);
ContextCache.getInstance().cleanCache();
return element;
}
private void move(ContextManagement newParentContextManagement, boolean check)
throws ContextNotFoundException, ContextAlreadyPresentException, ResourceRegistryException {
if(check) {
if (check) {
checkContext(newParentContextManagement);
}
SecurityContext newParentSecurityContext = null;
// Removing the old parent relationship if any
Iterable<OEdge> edges = getElement().getEdges(ODirection.IN, IsParentOf.NAME);
if(edges != null && edges.iterator().hasNext()) {
if (edges != null && edges.iterator().hasNext()) {
Iterator<OEdge> edgeIterator = edges.iterator();
OEdge edge = edgeIterator.next();
IsParentOfManagement isParentOfManagement = new IsParentOfManagement();
isParentOfManagement.setElement(edge);
isParentOfManagement.internalDelete();
if(edgeIterator.hasNext()) {
if (edgeIterator.hasNext()) {
throw new ContextException(
"Seems that the Context has more than one Parent. " + Utility.SHOULD_NOT_OCCUR_ERROR_MESSAGE);
}
}
if(newParentContextManagement != null) {
if (newParentContextManagement != null) {
JsonNode isParentOfJsonNode = jsonNode.get(Context.PARENT_PROPERTY);
IsParentOfManagement isParentOfManagement = new IsParentOfManagement(oDatabaseDocument);
isParentOfManagement.setJsonNode(isParentOfJsonNode);
isParentOfManagement.setSourceEntityManagement(newParentContextManagement);
isParentOfManagement.setTargetEntityManagement(this);
isParentOfManagement.internalCreate();
newParentSecurityContext = ContextUtility.getInstance().getSecurityContextByUUID(newParentContextManagement.uuid);
newParentSecurityContext = ContextUtility.getInstance()
.getSecurityContextByUUID(newParentContextManagement.uuid);
}
SecurityContext thisSecurityContext = ContextUtility.getInstance().getSecurityContextByUUID(uuid);
thisSecurityContext.changeParentSecurityContext(newParentSecurityContext, oDatabaseDocument);
}
@Override
protected boolean reallyDelete() throws NotFoundException, ResourceRegistryException {
Iterable<OEdge> iterable = getElement().getEdges(ODirection.OUT);
Iterator<OEdge> iterator = iterable.iterator();
while(iterator.hasNext()) {
while (iterator.hasNext()) {
throw new ContextException("Cannot remove a " + Context.NAME + " having children");
}
element.delete();
ContextUtility contextUtility = ContextUtility.getInstance();
SecurityContext securityContext = contextUtility.getSecurityContextByUUID(uuid);
securityContext.delete(oDatabaseDocument);
ContextCache.getInstance().cleanCache();
return true;
}
@Override
public String reallyGetAll(boolean polymorphic) throws ResourceRegistryException {
ObjectMapper objectMapper = new ObjectMapper();
ArrayNode arrayNode = objectMapper.createArrayNode();
Iterable<ODocument> iterable = oDatabaseDocument.browseClass(typeName, polymorphic);
for(ODocument vertex : iterable) {
for (ODocument vertex : iterable) {
ContextManagement contextManagement = new ContextManagement();
contextManagement.setElement((OVertex) vertex);
try {
JsonNode jsonObject = contextManagement.serializeAsJsonNode();
arrayNode.add(jsonObject);
} catch(ResourceRegistryException e) {
} catch (ResourceRegistryException e) {
logger.error("Unable to correctly serialize {}. It will be excluded from results. {}",
vertex.toString(), Utility.SHOULD_NOT_OCCUR_ERROR_MESSAGE);
}
}
try {
return objectMapper.writeValueAsString(arrayNode);
} catch(JsonProcessingException e) {
} catch (JsonProcessingException e) {
throw new ResourceRegistryException(e);
}
}
@ -424,7 +421,7 @@ public class ContextManagement extends EntityElementManagement<Context> {
public String allFromServer(boolean polymorphic) throws ResourceRegistryException {
return super.all(polymorphic);
}
@Override
public String all(boolean polymorphic) throws ResourceRegistryException {
try {
@ -434,12 +431,14 @@ public class ContextManagement extends EntityElementManagement<Context> {
return allFromServer(polymorphic);
}
}
public String readFromServer() throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
public String readFromServer()
throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
return super.read().toString();
}
public String readAsString() throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
public String readAsString()
throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
try {
ContextCache contextCache = ContextCache.getInstance();
return ElementMapper.marshal(contextCache.getContextByUUID(uuid));
@ -447,10 +446,9 @@ public class ContextManagement extends EntityElementManagement<Context> {
return readFromServer();
}
}
@Override
public void sanityCheck(Map<UUID, JsonNode> expectedInstances)
throws SchemaViolationException, ResourceRegistryException {
public void sanityCheck() throws SchemaViolationException, ResourceRegistryException {
// Nothing to do
}
}

View File

@ -1,8 +1,5 @@
package org.gcube.informationsystem.resourceregistry.contexts.relations;
import java.util.Map;
import java.util.UUID;
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
import org.gcube.com.fasterxml.jackson.databind.node.ObjectNode;
import org.gcube.informationsystem.base.reference.AccessType;
@ -27,77 +24,80 @@ import com.orientechnologies.orient.core.record.OVertex;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public class IsParentOfManagement extends RelationElementManagement<ContextManagement,ContextManagement> {
public class IsParentOfManagement extends RelationElementManagement<ContextManagement, ContextManagement> {
public IsParentOfManagement() {
super(AccessType.IS_PARENT_OF, Context.class, Context.class);
}
public IsParentOfManagement(ODatabaseDocument oDatabaseDocument) throws ResourceRegistryException {
this();
this.oDatabaseDocument = oDatabaseDocument;
getWorkingContext();
}
@Override
protected SecurityContext getWorkingContext() throws ResourceRegistryException {
if(workingContext == null) {
if (workingContext == null) {
workingContext = ContextUtility.getInstance()
.getSecurityContextByUUID(DatabaseEnvironment.CONTEXT_SECURITY_CONTEXT_UUID);
}
return workingContext;
}
@Override
protected IsParentOfNotFoundException getSpecificElementNotFoundException(NotFoundException e) {
return new IsParentOfNotFoundException(e.getMessage(), e.getCause());
}
@Override
protected IsParentOfAlreadyPresentException getSpecificERAlreadyPresentException(String message) {
return new IsParentOfAlreadyPresentException(message);
}
@Override
protected JsonNode createCompleteJsonNode() throws ResourceRegistryException {
return createCompleteJsonNode(false, true);
}
@Override
public JsonNode createCompleteJsonNode(boolean includeSource, boolean includeTarget) throws ResourceRegistryException {
public JsonNode createCompleteJsonNode(boolean includeSource, boolean includeTarget)
throws ResourceRegistryException {
JsonNode relation = serializeSelfAsJsonNode();
try {
OVertex source = element.getVertex(ODirection.OUT);
ContextManagement sourceContextManagement = new ContextManagement(oDatabaseDocument);
sourceContextManagement.setElement(source);
if(includeSource) {
((ObjectNode)relation).replace(Relation.SOURCE_PROPERTY, sourceContextManagement.serializeSelfAsJsonNode());
if (includeSource) {
((ObjectNode) relation).replace(Relation.SOURCE_PROPERTY,
sourceContextManagement.serializeSelfAsJsonNode());
}
OVertex target = element.getVertex(ODirection.IN);
ContextManagement targetContextManagement = new ContextManagement(oDatabaseDocument);
targetContextManagement.setElement(target);
if(includeTarget) {
((ObjectNode)relation).replace(Relation.TARGET_PROPERTY, targetContextManagement.serializeSelfAsJsonNode());
if (includeTarget) {
((ObjectNode) relation).replace(Relation.TARGET_PROPERTY,
targetContextManagement.serializeSelfAsJsonNode());
}
} catch(ResourceRegistryException e) {
} catch (ResourceRegistryException e) {
logger.error("Unable to correctly serialize {}. {}", element, Utility.SHOULD_NOT_OCCUR_ERROR_MESSAGE, e);
throw e;
} catch(Exception e) {
} catch (Exception e) {
logger.error("Unable to correctly serialize {}. {}", element, Utility.SHOULD_NOT_OCCUR_ERROR_MESSAGE, e);
throw new ResourceRegistryException(e);
}
return relation;
}
@Override
protected ContextManagement newSourceEntityManagement() throws ResourceRegistryException {
return new ContextManagement(oDatabaseDocument);
}
@Override
protected ContextManagement newTargetEntityManagement() throws ResourceRegistryException {
return new ContextManagement(oDatabaseDocument);
@ -109,9 +109,8 @@ public class IsParentOfManagement extends RelationElementManagement<ContextManag
}
@Override
public void sanityCheck(Map<UUID, JsonNode> expectedInstances)
throws SchemaViolationException, ResourceRegistryException {
public void sanityCheck() throws SchemaViolationException, ResourceRegistryException {
// Nothing to do
}
}

View File

@ -448,7 +448,9 @@ public abstract class ElementManagement<El extends OElement> {
public abstract String reallyGetAll(boolean polymorphic) throws ResourceRegistryException;
public abstract void sanityCheck(Map<UUID, JsonNode> expectedInstances) throws SchemaViolationException, ResourceRegistryException;
public abstract void sanityCheck() throws SchemaViolationException, ResourceRegistryException;
//public abstract void sanityCheck(Map<UUID, JsonNode> expectedInstances) throws SchemaViolationException, ResourceRegistryException;
public String all(boolean polymorphic) throws ResourceRegistryException {
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
@ -513,7 +515,7 @@ public abstract class ElementManagement<El extends OElement> {
element = internalCreate();
}
sanityCheck(null);
sanityCheck();
oDatabaseDocument.commit();
@ -556,7 +558,7 @@ public abstract class ElementManagement<El extends OElement> {
element = internalCreate();
sanityCheck(null);
sanityCheck();
oDatabaseDocument.commit();
@ -621,7 +623,7 @@ public abstract class ElementManagement<El extends OElement> {
element = internalUpdate();
sanityCheck(null);
sanityCheck();
oDatabaseDocument.commit();

View File

@ -33,7 +33,8 @@ public interface ERManagement {
public Map<UUID, JsonNode> removeFromContext(UUID contextUUID)
throws SchemaViolationException, NotFoundException, ContextException, ResourceRegistryException;
public void sanityCheck(Map<UUID, JsonNode> expectedInstances) throws SchemaViolationException, ResourceRegistryException;
public void sanityCheck() throws SchemaViolationException, ResourceRegistryException;
//public void sanityCheck(Map<UUID, JsonNode> expectedInstances) throws SchemaViolationException, ResourceRegistryException;
public AvailableInAnotherContextException getSpecificERAvailableInAnotherContextException(String message);

View File

@ -10,7 +10,6 @@ import org.gcube.informationsystem.base.reference.Element;
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextException;
import org.gcube.informationsystem.resourceregistry.api.rest.SharingPath.SharingOperation;
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
import org.gcube.informationsystem.resourceregistry.contexts.security.AdminSecurityContext;
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
@ -39,6 +38,7 @@ public class ERManagementUtility {
SecurityContext targetSecurityContext = ContextUtility.getInstance().getSecurityContextByUUID(contextUUID);
Map<UUID, ElementManagement<?>> instancesManagement = new HashMap<>();
for(UUID uuid : expectedInstances.keySet()) {
String type = expectedInstances.get(uuid).get(Element.CLASS_PROPERTY).asText();
ElementManagement<?> elementManagement = ElementManagementUtility.getERManagement(type);
@ -49,7 +49,13 @@ public class ERManagementUtility {
((ERManagement) elementManagement).setHonourPropagationConstraintsInContextSharing(false);
((ERManagement) elementManagement).setDryRunContextSharing(dryRun);
((ERManagement) elementManagement).internalAddToContext(targetSecurityContext);
((ERManagement) elementManagement).sanityCheck(expectedInstances);
instancesManagement.put(uuid, elementManagement);
}
for(UUID uuid : expectedInstances.keySet()) {
ElementManagement<?> elementManagement = instancesManagement.get(uuid);
// TODO
elementManagement.sanityCheck();
}
/*
@ -120,14 +126,16 @@ public class ERManagementUtility {
affectedInstances.putAll(((ERManagement) elementManagement).internalRemoveFromContext(targetSecurityContext));
((ERManagement) elementManagement).sanityCheck(expectedInstances);
((ERManagement) elementManagement).sanityCheck();
}
/*
SharingOperationValidator operationValidator = new SharingOperationValidator(expectedInstances, SharingOperation.REMOVE);
if(operationValidator.isValidOperation(affectedInstances)) {
oDatabaseDocument.commit();
}
*/
staticLogger.info("{} successfully removed from Context with UUID {} not following Propagation Constraints", instances, contextUUID);

View File

@ -1,8 +1,5 @@
package org.gcube.informationsystem.resourceregistry.instances.model.entities;
import java.util.Map;
import java.util.UUID;
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
import org.gcube.informationsystem.base.reference.AccessType;
import org.gcube.informationsystem.model.reference.entities.Facet;
@ -63,7 +60,7 @@ public class FacetManagement extends EntityManagement<Facet> {
}
@Override
public void sanityCheck(Map<UUID, JsonNode> expectedInstances) throws ResourceRegistryException {
public void sanityCheck() throws ResourceRegistryException {
// TODO Auto-generated method stub
}

View File

@ -12,11 +12,9 @@ import org.gcube.com.fasterxml.jackson.databind.JsonNode;
import org.gcube.com.fasterxml.jackson.databind.node.ArrayNode;
import org.gcube.informationsystem.base.reference.AccessType;
import org.gcube.informationsystem.base.reference.Element;
import org.gcube.informationsystem.base.reference.IdentifiableElement;
import org.gcube.informationsystem.context.reference.entities.Context;
import org.gcube.informationsystem.model.reference.entities.Facet;
import org.gcube.informationsystem.model.reference.entities.Resource;
import org.gcube.informationsystem.model.reference.properties.Header;
import org.gcube.informationsystem.model.reference.relations.ConsistsOf;
import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
import org.gcube.informationsystem.model.reference.relations.Relation;
@ -311,25 +309,6 @@ public class ResourceManagement extends EntityManagement<Resource> {
}
}
private String facetMustBePresentErrorMessage(String consistsOfType, UUID consistsOfUUID, String facetType, UUID facetUUID) {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("To avoid to have an incosistent graph, add to context no follows cannot add a ");
stringBuffer.append(ConsistsOf.NAME);
stringBuffer.append(" relation (i.e. ");
stringBuffer.append(consistsOfType);
stringBuffer.append(" with UUID ");
stringBuffer.append(consistsOfUUID.toString());
stringBuffer.append(") without indicating the target ");
stringBuffer.append(Facet.NAME);
stringBuffer.append(" (i.e. ");
stringBuffer.append(facetType);
stringBuffer.append(" with UUID ");
stringBuffer.append(facetUUID.toString());
stringBuffer.append(").");
return stringBuffer.toString();
}
protected Set<LinkedEntity> getResourceTypeConstraint() throws SchemaException, ResourceRegistryException{
Set<LinkedEntity> constraints = new HashSet<>();
@ -420,6 +399,76 @@ public class ResourceManagement extends EntityManagement<Resource> {
return true;
}
@Override
public void sanityCheck() throws SchemaViolationException, ResourceRegistryException {
JsonNode resourceInstance = createCompleteJsonNode();
TypesCache typesCache = TypesCache.getInstance();
Set<LinkedEntity> consistsOfFacetConstraints = getResourceTypeConstraint();
Map<LinkedEntity, Integer> satisfiedConsistsOfFacet = new HashMap<>();
ArrayNode consistsOfArrayNode = (ArrayNode) resourceInstance.get(Resource.CONSISTS_OF_PROPERTY);
for(JsonNode consistsOfJsonNode : consistsOfArrayNode) {
String consistsOfType = consistsOfJsonNode.get(Element.CLASS_PROPERTY).asText();
JsonNode facetJsonNode = consistsOfJsonNode.get(Relation.TARGET_PROPERTY);
String facetType = facetJsonNode.get(Element.CLASS_PROPERTY).asText();
for(LinkedEntity constraint : consistsOfFacetConstraints) {
if(constraintSatisfied(typesCache, constraint, consistsOfType, facetType)) {
Integer integer = satisfiedConsistsOfFacet.get(constraint);
if(integer==null) {
satisfiedConsistsOfFacet.put(constraint, 1);
}else {
satisfiedConsistsOfFacet.put(constraint, ++integer);
}
}
}
}
consistsOfFacetConstraints.removeAll(satisfiedConsistsOfFacet.keySet());
if(!consistsOfFacetConstraints.isEmpty()) {
String message = constraintNotSatisfiedErrorMessage(consistsOfFacetConstraints.iterator().next(), 0);
throw new SchemaViolationException(message);
}
for(LinkedEntity linkedEntity : satisfiedConsistsOfFacet.keySet()) {
Integer satisfiedTimes = satisfiedConsistsOfFacet.get(linkedEntity);
if(satisfiedTimes<linkedEntity.getMin()) {
String message = constraintNotSatisfiedErrorMessage(linkedEntity, satisfiedTimes);
throw new SchemaViolationException(message);
}
Integer max = linkedEntity.getMax();
if((max!=null && max>0) && satisfiedTimes>max) {
String message = constraintNotSatisfiedErrorMessage(linkedEntity, satisfiedTimes);
throw new SchemaViolationException(message);
}
}
}
/*
private String facetMustBePresentErrorMessage(String consistsOfType, UUID consistsOfUUID, String facetType, UUID facetUUID) {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("To avoid to have an incosistent graph, add to context no follows cannot add a ");
stringBuffer.append(ConsistsOf.NAME);
stringBuffer.append(" relation (i.e. ");
stringBuffer.append(consistsOfType);
stringBuffer.append(" with UUID ");
stringBuffer.append(consistsOfUUID.toString());
stringBuffer.append(") without indicating the target ");
stringBuffer.append(Facet.NAME);
stringBuffer.append(" (i.e. ");
stringBuffer.append(facetType);
stringBuffer.append(" with UUID ");
stringBuffer.append(facetUUID.toString());
stringBuffer.append(").");
return stringBuffer.toString();
}
@Override
public void sanityCheck(Map<UUID, JsonNode> expectedInstances) throws SchemaViolationException, ResourceRegistryException {
JsonNode resourceInstance = createCompleteJsonNode();
@ -519,7 +568,6 @@ public class ResourceManagement extends EntityManagement<Resource> {
throw new SchemaViolationException(stringBuffer.toString());
}
}
*/
}

View File

@ -1,9 +1,5 @@
package org.gcube.informationsystem.resourceregistry.instances.model.relations;
import java.util.Map;
import java.util.UUID;
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
import org.gcube.informationsystem.base.reference.AccessType;
import org.gcube.informationsystem.model.impl.properties.PropagationConstraintImpl;
import org.gcube.informationsystem.model.reference.entities.Facet;
@ -60,7 +56,7 @@ public class ConsistsOfManagement extends RelationManagement<FacetManagement> {
}
@Override
public void sanityCheck(Map<UUID, JsonNode> expectedInstances) throws SchemaViolationException, ResourceRegistryException {
public void sanityCheck() throws SchemaViolationException, ResourceRegistryException {
// TODO Auto-generated method stub
}

View File

@ -1,9 +1,5 @@
package org.gcube.informationsystem.resourceregistry.instances.model.relations;
import java.util.Map;
import java.util.UUID;
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
import org.gcube.informationsystem.base.reference.AccessType;
import org.gcube.informationsystem.model.impl.properties.PropagationConstraintImpl;
import org.gcube.informationsystem.model.reference.entities.Resource;
@ -60,7 +56,7 @@ public class IsRelatedToManagement extends RelationManagement<ResourceManagement
}
@Override
public void sanityCheck(Map<UUID, JsonNode> expectedInstances) throws SchemaViolationException, ResourceRegistryException {
public void sanityCheck() throws SchemaViolationException, ResourceRegistryException {
// TODO Auto-generated method stub
}

View File

@ -1,8 +1,6 @@
package org.gcube.informationsystem.resourceregistry.types.entities;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
import org.gcube.informationsystem.base.reference.AccessType;
@ -32,33 +30,33 @@ import com.orientechnologies.orient.core.sql.executor.OResultSet;
* @author Luca Frosini (ISTI - CNR)
*/
public abstract class EntityTypeDefinitionManagement<E extends EntityType> extends EntityElementManagement<E> {
private static Logger logger = LoggerFactory.getLogger(EntityTypeDefinitionManagement.class);
protected String name;
protected EntityTypeDefinitionManagement(Class<E> clz) {
super(AccessType.ENTITY_TYPE);
this.typeName = TypeMapper.getType(clz);
}
@Override
protected SecurityContext getWorkingContext() throws ResourceRegistryException {
if(workingContext == null) {
if (workingContext == null) {
workingContext = ContextUtility.getInstance()
.getSecurityContextByUUID(DatabaseEnvironment.SCHEMA_SECURITY_CONTEXT_UUID);
}
return workingContext;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
if(name == null) {
if(element == null) {
if(jsonNode != null) {
if (name == null) {
if (element == null) {
if (jsonNode != null) {
name = jsonNode.get(EntityType.NAME_PROPERTY).asText();
}
} else {
@ -67,136 +65,135 @@ public abstract class EntityTypeDefinitionManagement<E extends EntityType> exten
}
return name;
}
@Override
protected JsonNode createCompleteJsonNode() throws ResourceRegistryException {
return serializeSelfAsJsonNode();
}
@Override
protected OVertex reallyCreate() throws AlreadyPresentException, ResourceRegistryException {
logger.debug("Going to create {} for {}", this.typeName, getName());
return createVertex();
}
@Override
protected OVertex reallyUpdate() throws NotFoundException, ResourceRegistryException {
logger.debug("Going to update {} for {}", this.typeName, getName());
OVertex entityTypeDefinition = getElement();
entityTypeDefinition = (OVertex) updateProperties(oClass, entityTypeDefinition, jsonNode,
ignoreKeys, ignoreStartWithKeys);
entityTypeDefinition = (OVertex) updateProperties(oClass, entityTypeDefinition, jsonNode, ignoreKeys,
ignoreStartWithKeys);
return entityTypeDefinition;
}
@Override
protected boolean reallyDelete() throws NotFoundException, ResourceRegistryException {
logger.debug("Going to remove {} for {}", this.typeName, getName());
getElement().delete();
return true;
}
@Override
public OVertex getElement() throws NotFoundException, ResourceRegistryException {
if(element == null) {
if (element == null) {
try {
element = retrieveElement();
} catch(NotFoundException e) {
} catch (NotFoundException e) {
throw e;
} catch(ResourceRegistryException e) {
} catch (ResourceRegistryException e) {
throw e;
} catch(Exception e) {
} catch (Exception e) {
throw new ResourceRegistryException(e);
}
} else {
if(reload) {
if (reload) {
element.reload();
}
}
return element;
}
@Override
public OVertex retrieveElement() throws NotFoundException, ResourceRegistryException {
try {
if(getName() == null) {
if (getName() == null) {
throw new NotFoundException("null name does not allow to retrieve the Element");
}
String select = "SELECT FROM " + typeName + " WHERE " + EntityType.NAME_PROPERTY + " = \""
+ getName() + "\"";
String select = "SELECT FROM " + typeName + " WHERE " + EntityType.NAME_PROPERTY + " = \"" + getName()
+ "\"";
OResultSet resultSet = oDatabaseDocument.query(select, new HashMap<>());
if(resultSet == null || !resultSet.hasNext()) {
if (resultSet == null || !resultSet.hasNext()) {
String error = String.format("No %s with name %s was found", typeName, getName());
logger.info(error);
throw new NotFoundException(error);
}
OResult oResult = resultSet.next();
OVertex element = (OVertex) ElementManagementUtility.getElementFromOptional(oResult.getElement());
logger.trace("{} with id {} is : {}", typeName, getName(), Utility.toJsonString(element, true));
if(resultSet.hasNext()) {
if (resultSet.hasNext()) {
throw new ResourceRegistryException("Found more than one " + typeName + " with name " + getName()
+ ". This is a fatal error please contact Admnistrator");
}
return element;
} catch(NotFoundException e) {
} catch (NotFoundException e) {
throw getSpecificElementNotFoundException(e);
} catch(ResourceRegistryException e) {
} catch (ResourceRegistryException e) {
throw e;
} catch(Exception e) {
} catch (Exception e) {
throw new ResourceRegistryException(e);
}
}
@Override
protected OVertex createVertex() throws EntityAlreadyPresentException, ResourceRegistryException {
logger.trace("Going to create {} for {} ({}) using {}", OVertex.class.getSimpleName(), accessType.getName(),
typeName, jsonNode);
try {
this.element = oDatabaseDocument.newVertex(typeName);
updateProperties(oClass, element, jsonNode, ignoreKeys, ignoreStartWithKeys);
logger.info("Created {} is {}", OVertex.class.getSimpleName(), Utility.toJsonString(element, true));
return element;
} catch(ResourceRegistryException e) {
} catch (ResourceRegistryException e) {
throw e;
} catch(Exception e) {
} catch (Exception e) {
logger.trace("Error while creating {} for {} ({}) using {}", OVertex.class.getSimpleName(),
accessType.getName(), typeName, jsonNode, e);
throw new ResourceRegistryException("Error Creating " + typeName + " with " + jsonNode, e.getCause());
}
}
@Override
public String reallyGetAll(boolean polymorphic) throws ResourceRegistryException {
throw new UnsupportedOperationException();
}
@Override
protected NotFoundException getSpecificElementNotFoundException(NotFoundException e) {
return new SchemaNotFoundException(e.getMessage(), e.getCause());
}
@Override
protected AlreadyPresentException getSpecificERAlreadyPresentException(String message) {
return new SchemaAlreadyPresentException(message);
}
@Override
public void sanityCheck(Map<UUID, JsonNode> expectedInstances)
throws SchemaViolationException, ResourceRegistryException {
public void sanityCheck() throws SchemaViolationException, ResourceRegistryException {
// Nothing to do
}
}

View File

@ -1,9 +1,5 @@
package org.gcube.informationsystem.resourceregistry.types.entities;
import java.util.Map;
import java.util.UUID;
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaViolationException;
import org.gcube.informationsystem.types.reference.entities.ResourceType;
@ -18,8 +14,7 @@ public class ResourceTypeDefinitionManagement extends EntityTypeDefinitionManage
}
@Override
public void sanityCheck(Map<UUID, JsonNode> expectedInstances)
throws SchemaViolationException, ResourceRegistryException {
public void sanityCheck() throws SchemaViolationException, ResourceRegistryException {
// TODO
// We should check that a constraint defined here is not in contrast with the constraint of supertypes
}

View File

@ -1,8 +1,6 @@
package org.gcube.informationsystem.resourceregistry.types.properties;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
import org.gcube.informationsystem.base.reference.AccessType;
@ -195,8 +193,8 @@ public class PropertyTypeDefinitionManagement extends ElementManagement<OElement
}
@Override
public void sanityCheck(Map<UUID, JsonNode> expectedInstances)
throws SchemaViolationException, ResourceRegistryException {
public void sanityCheck() throws SchemaViolationException, ResourceRegistryException {
// Nothing to do
}
}

View File

@ -1,6 +1,7 @@
package org.gcube.informationsystem.resourceregistry.types.relations;
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaViolationException;
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
import org.gcube.informationsystem.resourceregistry.types.entities.FacetTypeDefinitionManagement;
import org.gcube.informationsystem.types.reference.entities.FacetType;
@ -33,4 +34,9 @@ public class ConsistsOfTypeDefinitionManagement
return ftdm;
}
@Override
public void sanityCheck() throws SchemaViolationException, ResourceRegistryException {
// Nothing to do
}
}

View File

@ -1,6 +1,7 @@
package org.gcube.informationsystem.resourceregistry.types.relations;
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaViolationException;
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
import org.gcube.informationsystem.resourceregistry.types.entities.ResourceTypeDefinitionManagement;
import org.gcube.informationsystem.types.reference.entities.ResourceType;
@ -33,4 +34,8 @@ public class IsRelatedToTypeDefinitionManagement
return rtdm;
}
@Override
public void sanityCheck() throws SchemaViolationException, ResourceRegistryException {
// Nothing to do
}
}

View File

@ -1,10 +1,7 @@
package org.gcube.informationsystem.resourceregistry.types.relations;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
import org.gcube.informationsystem.base.reference.AccessType;
import org.gcube.informationsystem.model.reference.relations.Relation;
import org.gcube.informationsystem.resourceregistry.api.exceptions.AlreadyPresentException;
@ -13,7 +10,6 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegis
import org.gcube.informationsystem.resourceregistry.api.exceptions.relation.RelationNotFoundException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaAlreadyPresentException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaViolationException;
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
import org.gcube.informationsystem.resourceregistry.dbinitialization.DatabaseEnvironment;
@ -37,37 +33,38 @@ import com.orientechnologies.orient.core.sql.executor.OResultSet;
*/
public abstract class RelationTypeDefinitionManagement<T extends EntityTypeDefinitionManagement<TT>, TT extends EntityType>
extends RelationElementManagement<ResourceTypeDefinitionManagement, T> {
protected String name;
public RelationTypeDefinitionManagement(Class<TT> clz) {
super(AccessType.RELATION_TYPE, ResourceType.class, clz);
this.typeName = RelationType.NAME;
}
public RelationTypeDefinitionManagement(SecurityContext securityContext, ODatabaseDocument oDatabaseDocument, Class<TT> clz) throws ResourceRegistryException {
public RelationTypeDefinitionManagement(SecurityContext securityContext, ODatabaseDocument oDatabaseDocument,
Class<TT> clz) throws ResourceRegistryException {
this(clz);
this.oDatabaseDocument = oDatabaseDocument;
setWorkingContext(securityContext);
}
@Override
protected SecurityContext getWorkingContext() throws ResourceRegistryException {
if(workingContext == null) {
if (workingContext == null) {
this.workingContext = ContextUtility.getInstance()
.getSecurityContextByUUID(DatabaseEnvironment.SCHEMA_SECURITY_CONTEXT_UUID);
}
return workingContext;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
if(name == null) {
if(element == null) {
if(jsonNode != null) {
if (name == null) {
if (element == null) {
if (jsonNode != null) {
name = jsonNode.get(RelationType.NAME_PROPERTY).asText();
}
} else {
@ -76,135 +73,134 @@ public abstract class RelationTypeDefinitionManagement<T extends EntityTypeDefin
}
return name;
}
@Override
protected OEdge reallyCreate() throws ResourceRegistryException {
logger.debug("Going to create {} for {}", RelationType.NAME, getName());
if(sourceEntityManagement == null) {
if(!jsonNode.has(Relation.SOURCE_PROPERTY)) {
if (sourceEntityManagement == null) {
if (!jsonNode.has(Relation.SOURCE_PROPERTY)) {
throw new ResourceRegistryException("Error while creating relation. No source definition found");
}
sourceEntityManagement = newSourceEntityManagement();
// sourceEntityManagement.setElementType(EntityTypeDefinition.NAME);
sourceEntityManagement.setJsonNode(jsonNode.get(Relation.SOURCE_PROPERTY));
}
if(targetEntityManagement == null) {
if(!jsonNode.has(Relation.TARGET_PROPERTY)) {
if (targetEntityManagement == null) {
if (!jsonNode.has(Relation.TARGET_PROPERTY)) {
throw new ResourceRegistryException(
"Error while creating " + typeName + ". No target definition found");
}
targetEntityManagement = newTargetEntityManagement();
// targetEntityManagement.setElementType(EntityTypeDefinition.NAME);
targetEntityManagement.setJsonNode(jsonNode.get(Relation.TARGET_PROPERTY));
}
OVertex source = (OVertex) getSourceEntityManagement().getElement();
OVertex target = (OVertex) getTargetEntityManagement().getElement();
logger.trace("Creating {} beetween {} -> {}", typeName, source.toString(),
target.toString());
logger.trace("Creating {} beetween {} -> {}", typeName, source.toString(), target.toString());
element = oDatabaseDocument.newEdge(source, target, typeName);
updateProperties(oClass, element, jsonNode, ignoreKeys, ignoreStartWithKeys);
return element;
}
@Override
protected OEdge reallyUpdate() throws NotFoundException, ResourceRegistryException {
logger.debug("Going to update {} for {}", RelationType.NAME, getName());
OEdge relationTypeDefinition = getElement();
relationTypeDefinition = (OEdge) updateProperties(oClass, relationTypeDefinition, jsonNode,
ignoreKeys, ignoreStartWithKeys);
relationTypeDefinition = (OEdge) updateProperties(oClass, relationTypeDefinition, jsonNode, ignoreKeys,
ignoreStartWithKeys);
return relationTypeDefinition;
}
@Override
protected boolean reallyDelete() throws RelationNotFoundException, ResourceRegistryException {
logger.debug("Going to remove {} for {}", RelationType.NAME, getName());
getElement().delete();
return true;
}
@Override
public OEdge getElement() throws NotFoundException, ResourceRegistryException {
if(element == null) {
if (element == null) {
try {
element = retrieveElement();
} catch(NotFoundException e) {
} catch (NotFoundException e) {
throw e;
} catch(ResourceRegistryException e) {
} catch (ResourceRegistryException e) {
throw e;
} catch(Exception e) {
} catch (Exception e) {
throw new ResourceRegistryException(e);
}
} else {
if(reload) {
if (reload) {
element.reload();
}
}
return element;
}
@Override
public OEdge retrieveElement() throws NotFoundException, ResourceRegistryException {
try {
if(getName() == null) {
if (getName() == null) {
throw new NotFoundException("null name does not allow to retrieve the Element");
}
String select = "SELECT FROM " + typeName + " WHERE " + RelationType.NAME_PROPERTY + " = \""
+ getName() + "\"";
String select = "SELECT FROM " + typeName + " WHERE " + RelationType.NAME_PROPERTY + " = \"" + getName()
+ "\"";
OResultSet resultSet = oDatabaseDocument.query(select, new HashMap<>());
if(resultSet == null || !resultSet.hasNext()) {
if (resultSet == null || !resultSet.hasNext()) {
String error = String.format("No %s with name %s was found", typeName, getName());
logger.info(error);
throw new NotFoundException(error);
}
OResult oResult = resultSet.next();
OEdge element = (OEdge) ElementManagementUtility.getElementFromOptional(oResult.getElement());
logger.trace("{} with id {} is : {}", typeName, getName(), Utility.toJsonString(element, true));
if(resultSet.hasNext()) {
if (resultSet.hasNext()) {
throw new ResourceRegistryException("Found more than one " + typeName + " with name " + getName()
+ ". This is a fatal error please contact Admnistrator");
}
return element;
} catch(NotFoundException e) {
} catch (NotFoundException e) {
throw getSpecificElementNotFoundException(e);
} catch(ResourceRegistryException e) {
} catch (ResourceRegistryException e) {
throw e;
} catch(Exception e) {
} catch (Exception e) {
throw new ResourceRegistryException(e);
}
}
@Override
public String reallyGetAll(boolean polymorphic) throws ResourceRegistryException {
throw new UnsupportedOperationException();
}
@Override
protected NotFoundException getSpecificElementNotFoundException(NotFoundException e) {
return new SchemaNotFoundException(e.getMessage(), e.getCause());
}
@Override
protected AlreadyPresentException getSpecificERAlreadyPresentException(String message) {
return new SchemaAlreadyPresentException(message);
}
@Override
protected ResourceTypeDefinitionManagement newSourceEntityManagement() throws ResourceRegistryException {
ResourceTypeDefinitionManagement rtdm = new ResourceTypeDefinitionManagement();
@ -212,11 +208,5 @@ public abstract class RelationTypeDefinitionManagement<T extends EntityTypeDefin
rtdm.setoDatabaseDocument(oDatabaseDocument);
return rtdm;
}
@Override
public void sanityCheck(Map<UUID, JsonNode> expectedInstances)
throws SchemaViolationException, ResourceRegistryException {
// Nothing to do
}
}