- } catch (ChampTransactionException e) {
- throw new CrudException("Transaction error occured", javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR);
- }
- }
-
- @Override
- public Vertex addVertex(String type, Map<String, Object> properties) throws CrudException {
-
- if (logger.isDebugEnabled()) {
- logger.debug("Add/update vertex: {label: " + type + " properties:" + propertiesMapToString(properties));
- }
-
- // Add the aai_node_type so that AAI can read the data created by gizmo
- properties.put(org.onap.schema.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
-
- // Create an object to represent our vertex in the format expected by the
- // Champ library.
- ChampObject objectToCreate = buildChampObject(type, properties);
-
- try {
-
- // Ask the Champ library to store our vertex, placing the returned object
- // into a
- // list so that we can easily put that into our result object.
- return vertexFromChampObject(champApi.storeObject(objectToCreate), type);
-
- } catch (ChampMarshallingException | ChampSchemaViolationException | ChampObjectNotExistsException
- | 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 updateVertex(String id, String type, Map<String, Object> properties) throws CrudException {
-
- if (logger.isDebugEnabled()) {
- logger.debug("Update vertex with id: " + id + " with properties: " + propertiesMapToString(properties));
- }
- // Add the aai_node_type so that AAI can read the data created by gizmo
- properties.put(org.onap.schema.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
-
- try {
- // Now, build the updated version of the Champ Object...
- ChampObject updateObject = buildChampObject(id, type, properties);
- // ...and send it to the Champ library.
- return vertexFromChampObject(champApi.replaceObject(updateObject), type);
-
- } catch (ChampObjectNotExistsException e) {
- throw new CrudException("Not Found", javax.ws.rs.core.Response.Status.NOT_FOUND);
- } catch (NumberFormatException | ChampMarshallingException | ChampSchemaViolationException e) {
- throw new CrudException(e.getMessage(), javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR);
- } catch (ChampTransactionException e) {
- throw new CrudException("Transaction error occured", javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR);