summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorsblimkie <steven.blimkie@amdocs.com>2018-01-22 19:29:18 -0500
committersblimkie <steven.blimkie@amdocs.com>2018-01-22 19:31:50 -0500
commitc8d962ad88da4403ae9186e7213a7ce28b82aaa1 (patch)
tree564a7482c69040e14b4c219f6904d02a2abb97d4 /src/main
parenta0e716dc093cd8a4a4ec8aaca7bc1635e518527a (diff)
Fix issue with patch requests
Fix issue where patch commands were failing for non-string vertex properties Change-Id: I1cf25565fc121745e817c8292c99d4cdc89c4a35 Issue-ID: AAI-685 Signed-off-by: sblimkie <steven.blimkie@amdocs.com>
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/crud/dao/GraphDao.java16
-rw-r--r--src/main/java/org/onap/crud/dao/champ/ChampDao.java56
-rw-r--r--src/main/java/org/onap/crud/entity/Vertex.java58
-rw-r--r--src/main/java/org/onap/crud/service/AbstractGraphDataService.java4
-rw-r--r--src/main/java/org/onap/crud/service/CrudAsyncGraphDataService.java2
-rw-r--r--src/main/java/org/onap/crud/service/CrudGraphDataService.java18
-rw-r--r--src/main/java/org/onap/schema/OxmModelValidator.java17
7 files changed, 113 insertions, 58 deletions
diff --git a/src/main/java/org/onap/crud/dao/GraphDao.java b/src/main/java/org/onap/crud/dao/GraphDao.java
index c62a788..7834bb2 100644
--- a/src/main/java/org/onap/crud/dao/GraphDao.java
+++ b/src/main/java/org/onap/crud/dao/GraphDao.java
@@ -34,9 +34,9 @@ import org.onap.crud.exception.CrudException;
public interface GraphDao {
- public Vertex getVertex(String id) throws CrudException;
+ public Vertex getVertex(String id, String version) throws CrudException;
- public Vertex getVertex(String id, String type) throws CrudException;
+ public Vertex getVertex(String id, String type, String version) throws CrudException;
/**
* Retrieve all of the edges which are incident to the vertex with the
@@ -111,7 +111,7 @@ public interface GraphDao {
* @return - The {@link Vertex} object that was created.
* @throws CrudException
*/
- public Vertex addVertex(String type, Map<String, Object> properties) throws CrudException;
+ public Vertex addVertex(String type, Map<String, Object> properties, String version) throws CrudException;
/**
* Updates an existing {@link Vertex}.
@@ -123,7 +123,7 @@ public interface GraphDao {
* @return - The udpated vertex.
* @throws CrudException
*/
- public Vertex updateVertex(String id, String type, Map<String, Object> properties) throws CrudException;
+ public Vertex updateVertex(String id, String type, Map<String, Object> properties, String version) throws CrudException;
/**
* Removes the specified vertex from the graph data base.
@@ -151,7 +151,7 @@ public interface GraphDao {
* @return - The {@link Edge} object that was created.
* @throws CrudException
*/
- public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties) throws CrudException;
+ public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version) throws CrudException;
/**
* Updates an existing {@link Edge}.
@@ -182,12 +182,12 @@ public interface GraphDao {
public boolean transactionExists(String id) throws CrudException;
- public Vertex addVertex(String type, Map<String, Object> properties, String txId) throws CrudException;
+ public Vertex addVertex(String type, Map<String, Object> properties, String version, String txId) throws CrudException;
- public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String txId)
+ public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version, String txId)
throws CrudException;
- public Vertex updateVertex(String id, String type, Map<String, Object> properties, String txId) throws CrudException;
+ public Vertex updateVertex(String id, String type, Map<String, Object> properties, String version, String txId) throws CrudException;
public Edge updateEdge(Edge edge, String txId) throws CrudException;
diff --git a/src/main/java/org/onap/crud/dao/champ/ChampDao.java b/src/main/java/org/onap/crud/dao/champ/ChampDao.java
index ecbac36..0bf8368 100644
--- a/src/main/java/org/onap/crud/dao/champ/ChampDao.java
+++ b/src/main/java/org/onap/crud/dao/champ/ChampDao.java
@@ -95,12 +95,12 @@ public class ChampDao implements GraphDao {
}
@Override
- public Vertex getVertex(String id) throws CrudException {
+ public Vertex getVertex(String id, String version) throws CrudException {
String url = baseObjectUrl + "/" + id;
OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
if (getResult.getResultCode() == 200) {
- return Vertex.fromJson(getResult.getResult());
+ return Vertex.fromJson(getResult.getResult(), version);
} else {
// We didn't find a vertex with the supplied id, so just throw an
// exception.
@@ -110,12 +110,12 @@ public class ChampDao implements GraphDao {
}
@Override
- public Vertex getVertex(String id, String type) throws CrudException {
+ public Vertex getVertex(String id, String type, String version) throws CrudException {
String url = baseObjectUrl + "/" + id;
OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
if (getResult.getResultCode() == 200) {
- Vertex vert = Vertex.fromJson(getResult.getResult());
+ Vertex vert = Vertex.fromJson(getResult.getResult(), version);
if (!vert.getType().equalsIgnoreCase(type)) {
// We didn't find a vertex with the supplied type, so just throw an
@@ -216,7 +216,7 @@ public class ChampDao implements GraphDao {
}
@Override
- public Vertex addVertex(String type, Map<String, Object> properties) throws CrudException {
+ public Vertex addVertex(String type, Map<String, Object> properties, String version) throws CrudException {
String url = baseObjectUrl;
// Add the aai_node_type so that AAI can read the data created by gizmo
@@ -231,7 +231,7 @@ public class ChampDao implements GraphDao {
MediaType.APPLICATION_JSON_TYPE);
if (getResult.getResultCode() == Response.Status.CREATED.getStatusCode()) {
- return Vertex.fromJson(getResult.getResult());
+ return Vertex.fromJson(getResult.getResult(), version);
} else {
// We didn't create a vertex with the supplied type, so just throw an
// exception.
@@ -240,7 +240,7 @@ public class ChampDao implements GraphDao {
}
@Override
- public Vertex updateVertex(String id, String type, Map<String, Object> properties) throws CrudException {
+ public Vertex updateVertex(String id, String type, Map<String, Object> properties, String version) throws CrudException {
String url = baseObjectUrl + "/" + id;
// Add the aai_node_type so that AAI can read the data created by gizmo
@@ -257,11 +257,11 @@ public class ChampDao implements GraphDao {
MediaType.APPLICATION_JSON_TYPE);
if (getResult.getResultCode() == Response.Status.OK.getStatusCode()) {
- return Vertex.fromJson(getResult.getResult());
+ return Vertex.fromJson(getResult.getResult(), version);
} else {
// We didn't create a vertex with the supplied type, so just throw an
// exception.
- throw new CrudException("Failed to update vertex", Response.Status.fromStatusCode(getResult.getResultCode()));
+ throw new CrudException("Failed to update vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
}
}
@@ -273,17 +273,17 @@ public class ChampDao implements GraphDao {
if (getResult.getResultCode() != Response.Status.OK.getStatusCode()) {
// We didn't delete a vertex with the supplied id, so just throw an
// exception.
- throw new CrudException("Failed to delete vertex", Response.Status.fromStatusCode(getResult.getResultCode()));
+ throw new CrudException("Failed to delete vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
}
}
@Override
- public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties) throws CrudException {
+ public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version) throws CrudException {
String url = baseRelationshipUrl;
// Try requests to ensure source and target exist in Champ
- Vertex dbSource = getVertex(source.getId().get(), source.getType());
- Vertex dbTarget = getVertex(target.getId().get(), target.getType());
+ Vertex dbSource = getVertex(source.getId().get(), source.getType(), version);
+ Vertex dbTarget = getVertex(target.getId().get(), target.getType(), version);
Edge.Builder insertEdgeBuilder = new Edge.Builder(type).source(dbSource).target(dbTarget);
properties.forEach(insertEdgeBuilder::property);
@@ -298,7 +298,7 @@ public class ChampDao implements GraphDao {
} else {
// We didn't create an edge with the supplied type, so just throw an
// exception.
- throw new CrudException("Failed to create edge", Response.Status.fromStatusCode(getResult.getResultCode()));
+ throw new CrudException("Failed to create edge: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
}
}
@@ -318,7 +318,7 @@ public class ChampDao implements GraphDao {
} else {
// We didn't create an edge with the supplied type, so just throw an
// exception.
- throw new CrudException("Failed to update edge", Response.Status.fromStatusCode(getResult.getResultCode()));
+ throw new CrudException("Failed to update edge: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
}
}
@@ -386,7 +386,7 @@ public class ChampDao implements GraphDao {
}
@Override
- public Vertex addVertex(String type, Map<String, Object> properties, String txId) throws CrudException {
+ public Vertex addVertex(String type, Map<String, Object> properties, String version, String txId) throws CrudException {
String url = baseObjectUrl + "?transactionId=" + txId;
// Add the aai_node_type so that AAI can read the data created by gizmo
@@ -401,22 +401,22 @@ public class ChampDao implements GraphDao {
MediaType.APPLICATION_JSON_TYPE);
if (getResult.getResultCode() == Response.Status.CREATED.getStatusCode()) {
- return Vertex.fromJson(getResult.getResult());
+ return Vertex.fromJson(getResult.getResult(), version);
} else {
// We didn't create a vertex with the supplied type, so just throw an
// exception.
- throw new CrudException("Failed to create vertex", Response.Status.fromStatusCode(getResult.getResultCode()));
+ throw new CrudException("Failed to create vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
}
}
@Override
- public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String txId)
+ public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version, String txId)
throws CrudException {
String url = baseRelationshipUrl + "?transactionId=" + txId;
// Try requests to ensure source and target exist in Champ
- Vertex dbSource = getVertex(source.getId().get(), source.getType(), txId);
- Vertex dbTarget = getVertex(target.getId().get(), target.getType(), txId);
+ Vertex dbSource = getVertex(source.getId().get(), source.getType(), version, txId);
+ Vertex dbTarget = getVertex(target.getId().get(), target.getType(), version, txId);
Edge.Builder insertEdgeBuilder = new Edge.Builder(type).source(dbSource).target(dbTarget);
properties.forEach(insertEdgeBuilder::property);
@@ -430,12 +430,12 @@ public class ChampDao implements GraphDao {
} else {
// We didn't create an edge with the supplied type, so just throw an
// exception.
- throw new CrudException("Failed to create edge", Response.Status.fromStatusCode(getResult.getResultCode()));
+ throw new CrudException("Failed to create edge: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
}
}
@Override
- public Vertex updateVertex(String id, String type, Map<String, Object> properties, String txId) throws CrudException {
+ public Vertex updateVertex(String id, String type, Map<String, Object> properties, String version, String txId) throws CrudException {
String url = baseObjectUrl + "/" + id + "?transactionId=" + txId;
// Add the aai_node_type so that AAI can read the data created by gizmo
@@ -452,11 +452,11 @@ public class ChampDao implements GraphDao {
MediaType.APPLICATION_JSON_TYPE);
if (getResult.getResultCode() == Response.Status.OK.getStatusCode()) {
- return Vertex.fromJson(getResult.getResult());
+ return Vertex.fromJson(getResult.getResult(), version);
} else {
// We didn't create a vertex with the supplied type, so just throw an
// exception.
- throw new CrudException("Failed to update vertex", Response.Status.fromStatusCode(getResult.getResultCode()));
+ throw new CrudException("Failed to update vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
}
}
@@ -468,7 +468,7 @@ public class ChampDao implements GraphDao {
if (getResult.getResultCode() != Response.Status.OK.getStatusCode()) {
// We didn't delete a vertex with the supplied id, so just throw an
// exception.
- throw new CrudException("Failed to delete vertex", Response.Status.fromStatusCode(getResult.getResultCode()));
+ throw new CrudException("Failed to delete vertex: " + getResult.getFailureCause(), Response.Status.fromStatusCode(getResult.getResultCode()));
}
}
@@ -525,12 +525,12 @@ public class ChampDao implements GraphDao {
}
}
- public Vertex getVertex(String id, String type, String txId) throws CrudException {
+ public Vertex getVertex(String id, String type, String version, String txId) throws CrudException {
String url = baseObjectUrl + "/" + id + "?transactionId=" + txId;
OperationResult getResult = client.get(url, createHeader(), MediaType.APPLICATION_JSON_TYPE);
if (getResult.getResultCode() == 200) {
- Vertex vert = Vertex.fromJson(getResult.getResult());
+ Vertex vert = Vertex.fromJson(getResult.getResult(), version);
if (!vert.getType().equalsIgnoreCase(type)) {
// We didn't find a vertex with the supplied type, so just throw an
diff --git a/src/main/java/org/onap/crud/entity/Vertex.java b/src/main/java/org/onap/crud/entity/Vertex.java
index 42d0eef..8fddaa3 100644
--- a/src/main/java/org/onap/crud/entity/Vertex.java
+++ b/src/main/java/org/onap/crud/entity/Vertex.java
@@ -25,6 +25,7 @@ package org.onap.crud.entity;
import net.dongliu.gson.GsonJava8TypeAdapterFactory;
+import com.google.common.base.CaseFormat;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.annotations.SerializedName;
@@ -32,6 +33,17 @@ import com.google.gson.annotations.SerializedName;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
+import java.util.Set;
+
+import org.eclipse.persistence.dynamic.DynamicType;
+import org.eclipse.persistence.internal.helper.DatabaseField;
+import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
+import org.eclipse.persistence.mappings.DatabaseMapping;
+import org.json.JSONObject;
+import org.onap.aaiutils.oxm.OxmModelLoader;
+import org.onap.crud.exception.CrudException;
+import org.onap.crud.util.CrudServiceUtil;
+import org.onap.schema.OxmModelValidator;
public class Vertex {
private static final Gson gson = new GsonBuilder().registerTypeAdapterFactory(new GsonJava8TypeAdapterFactory())
@@ -91,8 +103,50 @@ public class Vertex {
return customGson.toJson(this);
}
- public static Vertex fromJson(String jsonString) {
- return gson.fromJson(jsonString, Vertex.class);
+ public static Vertex fromJson(String jsonString, String version) throws CrudException {
+ Builder builder;
+
+ try {
+ JSONObject doc = new JSONObject(jsonString);
+ String type = doc.getString("type");
+ builder = new Builder(type).id(doc.getString("key"));
+
+ type = OxmModelValidator.resolveCollectionType(version, type);
+ DynamicJAXBContext jaxbContext = OxmModelLoader.getContextForVersion(version);
+ String modelObjectClass = CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, type));
+
+ final DynamicType modelObjectType = jaxbContext.getDynamicType(modelObjectClass);
+ final DynamicType reservedType = jaxbContext.getDynamicType("ReservedPropNames");
+
+
+ if (modelObjectType == null) {
+ throw new CrudException("Unable to load oxm version", javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR);
+ }
+
+ if (doc.has("properties")) {
+ JSONObject jsonProps = doc.getJSONObject("properties");
+ for (String key : (Set<String>)jsonProps.keySet()) {
+ String keyJavaName = CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL, key);
+ DatabaseMapping mapping = modelObjectType.getDescriptor().getMappingForAttributeName(keyJavaName);
+
+ if (mapping == null) {
+ // This might be one of the reserved properties
+ mapping = reservedType.getDescriptor().getMappingForAttributeName(keyJavaName);
+ }
+
+ if (mapping != null) {
+ DatabaseField field = mapping.getField();
+ Object value = CrudServiceUtil.validateFieldType(jsonProps.get(key).toString(), field.getType());
+ builder.property(key, value);
+ }
+ }
+ }
+ }
+ catch (Exception ex) {
+ throw new CrudException("Unable to transform response: " + jsonString, javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR);
+ }
+
+ return builder.build();
}
@Override
diff --git a/src/main/java/org/onap/crud/service/AbstractGraphDataService.java b/src/main/java/org/onap/crud/service/AbstractGraphDataService.java
index ef276a3..1163623 100644
--- a/src/main/java/org/onap/crud/service/AbstractGraphDataService.java
+++ b/src/main/java/org/onap/crud/service/AbstractGraphDataService.java
@@ -67,7 +67,7 @@ public abstract class AbstractGraphDataService {
public String getVertex(String version, String id, String type) throws CrudException {
type = OxmModelValidator.resolveCollectionType(version, type);
- Vertex vertex = dao.getVertex(id, type);
+ Vertex vertex = dao.getVertex(id, type, version);
List<Edge> edges = dao.getVertexEdges(id);
return CrudResponseBuilder.buildGetVertexResponse(OxmModelValidator.validateOutgoingPayload(version, vertex), edges,
version);
@@ -166,7 +166,7 @@ public abstract class AbstractGraphDataService {
vertexPayload.setProperties(CrudServiceUtil.mergeHeaderInFoToPayload(vertexPayload.getProperties(),
headers, false));
- Vertex existingVertex = dao.getVertex(vertexPayload.getId(), OxmModelValidator.resolveCollectionType(version, vertexPayload.getType()));
+ Vertex existingVertex = dao.getVertex(vertexPayload.getId(), OxmModelValidator.resolveCollectionType(version, vertexPayload.getType()), version);
Vertex validatedVertex = OxmModelValidator.validateIncomingPatchPayload(vertexPayload.getId(),
version, vertexPayload.getType(), vertexPayload.getProperties(), existingVertex);
Vertex persistedVertex = updateBulkVertex(validatedVertex, vertexPayload.getId(), version, txId);
diff --git a/src/main/java/org/onap/crud/service/CrudAsyncGraphDataService.java b/src/main/java/org/onap/crud/service/CrudAsyncGraphDataService.java
index 60a18d3..b3e7551 100644
--- a/src/main/java/org/onap/crud/service/CrudAsyncGraphDataService.java
+++ b/src/main/java/org/onap/crud/service/CrudAsyncGraphDataService.java
@@ -261,7 +261,7 @@ public class CrudAsyncGraphDataService extends AbstractGraphDataService {
public String patchVertex(String version, String id, String type, VertexPayload payload)
throws CrudException {
Vertex existingVertex
- = dao.getVertex(id, OxmModelValidator.resolveCollectionType(version, type));
+ = dao.getVertex(id, OxmModelValidator.resolveCollectionType(version, type), version);
Vertex patchedVertex = OxmModelValidator.validateIncomingPatchPayload(id, version,
type, payload.getProperties(),
existingVertex);
diff --git a/src/main/java/org/onap/crud/service/CrudGraphDataService.java b/src/main/java/org/onap/crud/service/CrudGraphDataService.java
index a18ab3b..61550b2 100644
--- a/src/main/java/org/onap/crud/service/CrudGraphDataService.java
+++ b/src/main/java/org/onap/crud/service/CrudGraphDataService.java
@@ -46,7 +46,7 @@ public class CrudGraphDataService extends AbstractGraphDataService {
}
private String addVertex(String version, Vertex vertex) throws CrudException {
- Vertex addedVertex = dao.addVertex(vertex.getType(), vertex.getProperties());
+ Vertex addedVertex = dao.addVertex(vertex.getType(), vertex.getProperties(), version);
return CrudResponseBuilder
.buildUpsertVertexResponse(OxmModelValidator.validateOutgoingPayload(version, addedVertex), version);
}
@@ -57,7 +57,7 @@ public class CrudGraphDataService extends AbstractGraphDataService {
}
private String addEdge(String version, Edge edge) throws CrudException {
- Edge addedEdge = dao.addEdge(edge.getType(), edge.getSource(), edge.getTarget(), edge.getProperties());
+ Edge addedEdge = dao.addEdge(edge.getType(), edge.getSource(), edge.getTarget(), edge.getProperties(), version);
return CrudResponseBuilder
.buildUpsertEdgeResponse(RelationshipSchemaValidator.validateOutgoingPayload(version, addedEdge), version);
}
@@ -69,13 +69,13 @@ public class CrudGraphDataService extends AbstractGraphDataService {
}
private String updateVertex(String version, Vertex vertex) throws CrudException {
- Vertex updatedVertex = dao.updateVertex(vertex.getId().get(), vertex.getType(), vertex.getProperties());
+ Vertex updatedVertex = dao.updateVertex(vertex.getId().get(), vertex.getType(), vertex.getProperties(), version);
return CrudResponseBuilder
.buildUpsertVertexResponse(OxmModelValidator.validateOutgoingPayload(version, updatedVertex), version);
}
public String patchVertex(String version, String id, String type, VertexPayload payload) throws CrudException {
- Vertex existingVertex = dao.getVertex(id, OxmModelValidator.resolveCollectionType(version, type));
+ Vertex existingVertex = dao.getVertex(id, OxmModelValidator.resolveCollectionType(version, type), version);
Vertex vertex = OxmModelValidator.validateIncomingPatchPayload(id, version, type, payload.getProperties(),
existingVertex);
return updateVertex(version, vertex);
@@ -112,18 +112,18 @@ public class CrudGraphDataService extends AbstractGraphDataService {
}
- public Vertex getVertex(String id) throws CrudException {
- return dao.getVertex(id);
+ public Vertex getVertex(String id, String version) throws CrudException {
+ return dao.getVertex(id, version);
}
@Override
protected Vertex addBulkVertex(Vertex vertex, String version, String dbTransId) throws CrudException {
- return dao.addVertex(vertex.getType(), vertex.getProperties(), dbTransId);
+ return dao.addVertex(vertex.getType(), vertex.getProperties(), version, dbTransId);
}
@Override
protected Vertex updateBulkVertex(Vertex vertex, String id, String version, String dbTransId) throws CrudException {
- return dao.updateVertex(id, vertex.getType(), vertex.getProperties(), dbTransId);
+ return dao.updateVertex(id, vertex.getType(), vertex.getProperties(), version, dbTransId);
}
@Override
@@ -133,7 +133,7 @@ public class CrudGraphDataService extends AbstractGraphDataService {
@Override
protected Edge addBulkEdge(Edge edge, String version, String dbTransId) throws CrudException {
- return dao.addEdge(edge.getType(), edge.getSource(), edge.getTarget(), edge.getProperties(), dbTransId);
+ return dao.addEdge(edge.getType(), edge.getSource(), edge.getTarget(), edge.getProperties(), version, dbTransId);
}
@Override
diff --git a/src/main/java/org/onap/schema/OxmModelValidator.java b/src/main/java/org/onap/schema/OxmModelValidator.java
index d23804c..6260f83 100644
--- a/src/main/java/org/onap/schema/OxmModelValidator.java
+++ b/src/main/java/org/onap/schema/OxmModelValidator.java
@@ -44,8 +44,12 @@ import javax.ws.rs.core.Response.Status;
public class OxmModelValidator {
public enum Metadata {
- NODE_TYPE("aai-node-type"), URI("aai-uri"), CREATED_TS("aai-created-ts"), SOT("source-of-truth"), LAST_MOD_SOT(
- "last-mod-source-of-truth");
+ NODE_TYPE("aai-node-type"),
+ URI("aai-uri"),
+ CREATED_TS("aai-created-ts"),
+ UPDATED_TS("aai-last-mod-ts"),
+ SOT("source-of-truth"),
+ LAST_MOD_SOT("last-mod-source-of-truth");
private final String propName;
@@ -143,7 +147,7 @@ public class OxmModelValidator {
public static Vertex validateIncomingUpsertPayload(String id, String version, String type, JsonElement properties)
throws CrudException {
-
+
try {
type = resolveCollectionType(version, type);
DynamicJAXBContext jaxbContext = OxmModelLoader.getContextForVersion(version);
@@ -226,7 +230,6 @@ public class OxmModelValidator {
public static Vertex validateIncomingPatchPayload(String id, String version, String type, JsonElement properties,
Vertex existingVertex) throws CrudException {
-
try {
type = resolveCollectionType(version, type);
DynamicJAXBContext jaxbContext = OxmModelLoader.getContextForVersion(version);
@@ -276,14 +279,12 @@ public class OxmModelValidator {
Object value = CrudServiceUtil.validateFieldType(entry.getValue().getAsString(), field.getType());
existingVertex.getProperties().put(entry.getKey(), value);
}
-
}
return existingVertex;
} catch (Exception e) {
throw new CrudException(e.getMessage(), Status.BAD_REQUEST);
}
-
}
private static DatabaseField getDatabaseField(String fieldName, DynamicType modelObjectType) {
@@ -301,8 +302,7 @@ public class OxmModelValidator {
return null;
}
- public static Vertex validateOutgoingPayload(String version, Vertex vertex) {
-
+ public static Vertex validateOutgoingPayload(String version, Vertex vertex) {
Vertex.Builder modelVertexBuilder = new Vertex.Builder(vertex.getType()).id(vertex.getId().get());
try {
@@ -321,6 +321,7 @@ public class OxmModelValidator {
}
}
}
+
return modelVertexBuilder.build();
} catch (Exception ex) {
return vertex;