diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/er/relation/RelationManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/er/relation/RelationManagement.java index 2124e47..1315f7a 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/er/relation/RelationManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/er/relation/RelationManagement.java @@ -301,13 +301,24 @@ public abstract class RelationManagement extends Relation.PROPAGATION_CONSTRAINT); if (propagationConstraint.getAddConstraint() != null) { addConstraint = propagationConstraint.getAddConstraint(); + }else { + String error = String.format("%s in %s is null" + + "This is really strange and should not occur. " + + "Please Investigate it.", + Relation.ADD_CONSTRAINT, + Relation.PROPAGATION_CONSTRAINT, + Utility.toJsonString(element, true)); + logger.error(error); + throw new ResourceRegistryException(error); } } catch (Exception e) { - logger.warn("Error while getting {} from {}. Assuming {}. " + String error = String.format("Error while getting %s from %s while performing AddToContext." + "This is really strange and should not occur. " + "Please Investigate it.", Relation.PROPAGATION_CONSTRAINT, - Utility.toJsonString(element, true), addConstraint); + Utility.toJsonString(element, true)); + logger.warn(error); + throw new ResourceRegistryException(error, e); } Vertex target = element.getVertex(Direction.IN); @@ -319,10 +330,11 @@ public abstract class RelationManagement extends * must be added. Otherwise we have a relation which point to an * entity outside of the context. */ - ContextUtility.addToActualContext(orientGraph, getElement()); EntityManagement entityManagement = EntityManagement .getEntityManagement(orientGraph, target); entityManagement.reallyAddToContext(); + ContextUtility.addToActualContext(orientGraph, getElement()); + break; case unpropagate: @@ -382,13 +394,25 @@ public abstract class RelationManagement extends Relation.PROPAGATION_CONSTRAINT); if (propagationConstraint.getRemoveConstraint() != null) { removeConstraint = propagationConstraint.getRemoveConstraint(); + }else{ + String error = String.format("%s in %s is null" + + "This is really strange and should not occur. " + + "Please Investigate it.", + Relation.REMOVE_CONSTRAINT, + Relation.PROPAGATION_CONSTRAINT, + Utility.toJsonString(element, true)); + logger.error(error); + throw new ResourceRegistryException(error); } } catch (Exception e) { - logger.warn("Error while getting {} from {}. Assuming {}. " + String error = String.format("Error while getting %s from %s while performing RemoveFromContext." + "This is really strange and should not occur. " + "Please Investigate it.", Relation.PROPAGATION_CONSTRAINT, - Utility.toJsonString(element, true), removeConstraint); + Utility.toJsonString(element, true)); + logger.error(error); + throw new ResourceRegistryException(error, e); + } Vertex target = element.getVertex(Direction.IN); @@ -416,9 +440,12 @@ public abstract class RelationManagement extends if(thisOrientEdge.getOutVertex().compareTo(edge.getOutVertex())!=0){ count++; break; - }else{ + } + /* + else{ ContextUtility.removeFromActualContext(orientGraph, edge); } + */ } } @@ -522,6 +549,15 @@ public abstract class RelationManagement extends Relation.PROPAGATION_CONSTRAINT); if (propagationConstraint.getRemoveConstraint() != null) { removeConstraint = propagationConstraint.getRemoveConstraint(); + }else{ + String error = String.format("%s in %s is null" + + "This is really strange and should not occur. " + + "Please Investigate it.", + Relation.REMOVE_CONSTRAINT, + Relation.PROPAGATION_CONSTRAINT, + Utility.toJsonString(element, true)); + logger.error(error); + throw new ResourceRegistryException(error); } } catch (Exception e) { logger.warn("Error while getting {} from {}. Assuming {}. "