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
This commit is contained in:
Luca Frosini 2017-04-18 07:44:58 +00:00
parent b559d2f546
commit 727d39b388
1 changed files with 42 additions and 6 deletions

View File

@ -301,13 +301,24 @@ public abstract class RelationManagement<R extends Relation> 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<R extends Relation> 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<R extends Relation> 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<R extends Relation> extends
if(thisOrientEdge.getOutVertex().compareTo(edge.getOutVertex())!=0){
count++;
break;
}else{
}
/*
else{
ContextUtility.removeFromActualContext(orientGraph, edge);
}
*/
}
}
@ -522,6 +549,15 @@ public abstract class RelationManagement<R extends Relation> 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 {}. "