Removed catch in resource marshalling
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@134820 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
e4cbaf19d4
commit
1c9f4cec10
|
@ -89,15 +89,18 @@ public class EntityManagementImpl implements EntityManagement {
|
|||
RELATION_IGNORE_START_WITH_KEYS.add(AT);
|
||||
RELATION_IGNORE_START_WITH_KEYS.add(UNDERSCORE);
|
||||
|
||||
|
||||
ENTITY_IGNORE_KEYS = new HashSet<String>();
|
||||
ENTITY_IGNORE_KEYS.add(Entity.HEADER_PROPERTY);
|
||||
|
||||
ENTITY_IGNORE_START_WITH_KEYS = new HashSet<String>();
|
||||
ENTITY_IGNORE_START_WITH_KEYS.add(OrientVertex.CONNECTION_IN_PREFIX.toLowerCase());
|
||||
ENTITY_IGNORE_START_WITH_KEYS.add(OrientVertex.CONNECTION_OUT_PREFIX.toLowerCase());
|
||||
ENTITY_IGNORE_START_WITH_KEYS.add(OrientVertex.CONNECTION_IN_PREFIX.toUpperCase());
|
||||
ENTITY_IGNORE_START_WITH_KEYS.add(OrientVertex.CONNECTION_OUT_PREFIX.toUpperCase());
|
||||
ENTITY_IGNORE_START_WITH_KEYS.add(OrientVertex.CONNECTION_IN_PREFIX
|
||||
.toLowerCase());
|
||||
ENTITY_IGNORE_START_WITH_KEYS.add(OrientVertex.CONNECTION_OUT_PREFIX
|
||||
.toLowerCase());
|
||||
ENTITY_IGNORE_START_WITH_KEYS.add(OrientVertex.CONNECTION_IN_PREFIX
|
||||
.toUpperCase());
|
||||
ENTITY_IGNORE_START_WITH_KEYS.add(OrientVertex.CONNECTION_OUT_PREFIX
|
||||
.toUpperCase());
|
||||
ENTITY_IGNORE_START_WITH_KEYS.add(AT);
|
||||
ENTITY_IGNORE_START_WITH_KEYS.add(UNDERSCORE);
|
||||
|
||||
|
@ -148,7 +151,8 @@ public class EntityManagementImpl implements EntityManagement {
|
|||
String classProperty = getClassProperty(jsonNode);
|
||||
|
||||
try {
|
||||
SchemaManagementImpl.getTypeSchema(orientGraph, classProperty, classProperty);
|
||||
SchemaManagementImpl.getTypeSchema(orientGraph, classProperty,
|
||||
classProperty);
|
||||
} catch (SchemaNotFoundException e) {
|
||||
throw e;
|
||||
}
|
||||
|
@ -204,7 +208,8 @@ public class EntityManagementImpl implements EntityManagement {
|
|||
String classProperty = getClassProperty(jsonNode);
|
||||
if (relationType.compareTo(classProperty) != 0) {
|
||||
try {
|
||||
SchemaManagementImpl.getTypeSchema(orientGraph, relationType, classProperty);
|
||||
SchemaManagementImpl.getTypeSchema(orientGraph, relationType,
|
||||
classProperty);
|
||||
} catch (SchemaNotFoundException e) {
|
||||
throw e;
|
||||
}
|
||||
|
@ -324,7 +329,8 @@ public class EntityManagementImpl implements EntityManagement {
|
|||
}
|
||||
|
||||
public static Map<String, Object> getPropertyMap(JsonNode jsonNode,
|
||||
Set<String> ignoreKeys, Set<String> ignoreStartWith) throws JsonProcessingException, IOException {
|
||||
Set<String> ignoreKeys, Set<String> ignoreStartWith)
|
||||
throws JsonProcessingException, IOException {
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
||||
|
@ -338,8 +344,7 @@ public class EntityManagementImpl implements EntityManagement {
|
|||
|
||||
Iterator<Entry<String, JsonNode>> fields = jsonNode.fields();
|
||||
|
||||
OUTER_WHILE:
|
||||
while (fields.hasNext()) {
|
||||
OUTER_WHILE: while (fields.hasNext()) {
|
||||
Entry<String, JsonNode> entry = fields.next();
|
||||
|
||||
String key = entry.getKey();
|
||||
|
@ -348,8 +353,8 @@ public class EntityManagementImpl implements EntityManagement {
|
|||
continue;
|
||||
}
|
||||
|
||||
for(String prefix : ignoreStartWith){
|
||||
if(key.startsWith(prefix)){
|
||||
for (String prefix : ignoreStartWith) {
|
||||
if (key.startsWith(prefix)) {
|
||||
break OUTER_WHILE;
|
||||
}
|
||||
}
|
||||
|
@ -374,7 +379,8 @@ public class EntityManagementImpl implements EntityManagement {
|
|||
throws ResourceRegistryException {
|
||||
Map<String, Object> vertexProperties = null;
|
||||
try {
|
||||
vertexProperties = getPropertyMap(node, ENTITY_IGNORE_KEYS, ENTITY_IGNORE_START_WITH_KEYS);
|
||||
vertexProperties = getPropertyMap(node, ENTITY_IGNORE_KEYS,
|
||||
ENTITY_IGNORE_START_WITH_KEYS);
|
||||
} catch (Exception e) {
|
||||
String error = "Error while parsing json to get Relation properties";
|
||||
logger.error(error, e);
|
||||
|
@ -387,7 +393,8 @@ public class EntityManagementImpl implements EntityManagement {
|
|||
throws ResourceRegistryException {
|
||||
Map<String, Object> edgeProperties = null;
|
||||
try {
|
||||
edgeProperties = getPropertyMap(node, RELATION_IGNORE_KEYS, RELATION_IGNORE_START_WITH_KEYS);
|
||||
edgeProperties = getPropertyMap(node, RELATION_IGNORE_KEYS,
|
||||
RELATION_IGNORE_START_WITH_KEYS);
|
||||
} catch (Exception e) {
|
||||
String error = "Error while parsing json to get Relation properties";
|
||||
logger.error(error, e);
|
||||
|
@ -396,7 +403,6 @@ public class EntityManagementImpl implements EntityManagement {
|
|||
return edgeProperties;
|
||||
}
|
||||
|
||||
|
||||
private Element updateProperties(Element element, JsonNode jsonNode)
|
||||
throws ResourceRegistryException {
|
||||
Set<String> ignoreKeys = null;
|
||||
|
@ -433,15 +439,14 @@ public class EntityManagementImpl implements EntityManagement {
|
|||
}
|
||||
}
|
||||
|
||||
OUTER_FOR:
|
||||
for (String key : oldKeys) {
|
||||
OUTER_FOR: for (String key : oldKeys) {
|
||||
|
||||
if (ignoreKeys.contains(key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for(String prefix : ignoreStartWithKeys){
|
||||
if(key.startsWith(prefix)){
|
||||
for (String prefix : ignoreStartWithKeys) {
|
||||
if (key.startsWith(prefix)) {
|
||||
break OUTER_FOR;
|
||||
}
|
||||
}
|
||||
|
@ -727,7 +732,8 @@ public class EntityManagementImpl implements EntityManagement {
|
|||
private Edge updateRelation(
|
||||
OrientGraph orientGraph,
|
||||
JsonNode jsonNode,
|
||||
@SuppressWarnings("rawtypes") Class<? extends Relation> relationClass) throws ResourceRegistryException {
|
||||
@SuppressWarnings("rawtypes") Class<? extends Relation> relationClass)
|
||||
throws ResourceRegistryException {
|
||||
|
||||
logger.debug("Trying to update {} : {}", relationClass.getSimpleName(),
|
||||
jsonNode);
|
||||
|
@ -1113,7 +1119,8 @@ public class EntityManagementImpl implements EntityManagement {
|
|||
return true;
|
||||
}
|
||||
|
||||
private static String marshallResource(OrientGraph orientGraph, Vertex vertex) throws JSONException {
|
||||
private static String marshallResource(OrientGraph orientGraph,
|
||||
Vertex vertex) throws JSONException {
|
||||
JSONObject jsonObject = Utility.toJsonObject((OrientVertex) vertex,
|
||||
true);
|
||||
|
||||
|
@ -1121,30 +1128,25 @@ public class EntityManagementImpl implements EntityManagement {
|
|||
|
||||
Iterable<Edge> edges = vertex.getEdges(Direction.OUT);
|
||||
|
||||
for(Edge edge : edges) {
|
||||
for (Edge edge : edges) {
|
||||
|
||||
String edgeType = edge.getLabel();
|
||||
|
||||
try {
|
||||
SchemaManagementImpl.getTypeSchema(orientGraph, edgeType, ConsistsOf.NAME);
|
||||
}catch (SchemaNotFoundException e) {
|
||||
SchemaManagementImpl.getTypeSchema(orientGraph, edgeType,
|
||||
ConsistsOf.NAME);
|
||||
} catch (SchemaNotFoundException e) {
|
||||
// This not an ConsistsOf Edge. it will be skipped
|
||||
continue;
|
||||
}
|
||||
|
||||
try{
|
||||
JSONObject jsonObjectEdge = Utility.toJsonObject(
|
||||
(OrientEdge) edge, true);
|
||||
Vertex facetVertex = edge.getVertex(Direction.IN);
|
||||
JSONObject jsonObjectEdge = Utility.toJsonObject((OrientEdge) edge,
|
||||
true);
|
||||
Vertex facetVertex = edge.getVertex(Direction.IN);
|
||||
|
||||
jsonObjectEdge.put(Relation.TARGET_PROPERTY,
|
||||
Utility.toJsonObject((OrientVertex) facetVertex, true));
|
||||
consistsOfArray.put(jsonObjectEdge);
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Unable to add a Relation to serilization", e);
|
||||
continue;
|
||||
}
|
||||
jsonObjectEdge.put(Relation.TARGET_PROPERTY,
|
||||
Utility.toJsonObject((OrientVertex) facetVertex, true));
|
||||
consistsOfArray.put(jsonObjectEdge);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1279,7 +1281,8 @@ public class EntityManagementImpl implements EntityManagement {
|
|||
if (jsonNode.has(property)) {
|
||||
JsonNode jsonNodeArray = jsonNode.get(property);
|
||||
for (JsonNode relationJsonNode : jsonNodeArray) {
|
||||
updateRelation(orientGraph, relationJsonNode, ConsistsOf.class);
|
||||
updateRelation(orientGraph, relationJsonNode,
|
||||
ConsistsOf.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue