aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/crud/dao
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/java/org/onap/crud/dao
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/java/org/onap/crud/dao')
-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
2 files changed, 36 insertions, 36 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