diff options
author | gfraboni <gino.fraboni@amdocs.com> | 2017-09-01 16:39:10 -0400 |
---|---|---|
committer | gfraboni <gino.fraboni@amdocs.com> | 2017-09-01 16:46:03 -0400 |
commit | 4e29c1eed57fbcd982c38bd96348b0b183f7820c (patch) | |
tree | 8f2bbc9b10ace68bbab71fd14931ca2cd99fa184 /src/main/java/org/openecomp/crud/dao/champ/ChampDao.java | |
parent | 900114bf694a0b34e8de3d283b5929fed4aaf65d (diff) |
New endpoints to auto populate edge properties.
New endpoints created to allow v11 endpoints to have their properties
automatically set based on db edge rules.
Issue-Id: AAI-60
Change-Id: I9b41f654fa9924b1dcb863aca369725a763b3691
Signed-off-by: gfraboni <gino.fraboni@amdocs.com>
Diffstat (limited to 'src/main/java/org/openecomp/crud/dao/champ/ChampDao.java')
-rw-r--r-- | src/main/java/org/openecomp/crud/dao/champ/ChampDao.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/main/java/org/openecomp/crud/dao/champ/ChampDao.java b/src/main/java/org/openecomp/crud/dao/champ/ChampDao.java index 5e9d10a..31bc9ab 100644 --- a/src/main/java/org/openecomp/crud/dao/champ/ChampDao.java +++ b/src/main/java/org/openecomp/crud/dao/champ/ChampDao.java @@ -96,6 +96,40 @@ public class ChampDao implements GraphDao { } @Override + public Vertex getVertex(String id) throws CrudException { + + try { + + if (logger.isDebugEnabled()) { + logger.debug("getVertex with id: " + id); + } + + long idAsLong = Long.parseLong(id); + + Optional<ChampObject> retrievedVertex = champApi.retrieveObject(idAsLong); + + String nodeType = org.openecomp.schema.OxmModelValidator.Metadata.NODE_TYPE.propertyName(); + if(retrievedVertex.isPresent() && + retrievedVertex.get().getProperties().get(nodeType)!=null) { + return vertexFromChampObject(retrievedVertex.get(), + retrievedVertex.get().getProperties().get(nodeType).toString()); + } else { + + // We didn't find a vertex with the supplied id, so just throw an + // exception. + throw new CrudException("No vertex with id " + id + " found in graph", + javax.ws.rs.core.Response.Status.NOT_FOUND); + } + + } catch (ChampUnmarshallingException | ChampTransactionException e) { + + // Something went wrong - throw an exception. + throw new CrudException(e.getMessage(), + javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR); + } + } + + @Override public Vertex getVertex(String id, String type) throws CrudException { try { |