From 727d39b38839ef11c7048c7c58ea54a9d1fa4c43 Mon Sep 17 00:00:00 2001 From: "luca.frosini" Date: Tue, 18 Apr 2017 07:44:58 +0000 Subject: [PATCH] throwing exception instead of ignoring it git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@146910 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../er/relation/RelationManagement.java | 48 ++++++++++++++++--- 1 file changed, 42 insertions(+), 6 deletions(-) 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 {}. "