aboutsummaryrefslogtreecommitdiffstats
path: root/champ-service/src/main/java/org
diff options
context:
space:
mode:
authormichaere <michael.reece@amdocs.com>2018-08-01 17:20:16 +0100
committermichaere <michaere@amdocs.com>2018-08-06 16:29:54 +0100
commit4eb6fd36c013d6349d191fbe3c482bb6064d3327 (patch)
tree82594c00276176cb729a0c800b3678360221d9e3 /champ-service/src/main/java/org
parent549b8c5b7e90621fc4d77fa35e6a7be8d58e3182 (diff)
Ensure transaction id utilised for endpoint
Transaction id is now handled for the end point objects/relationships/ in champ to ensure that edges are retrieved within the context of the transaction Issue-ID: AAI-1439 Change-Id: I5c9e4c3cf99b4e8316701cba41670a17faea381f Signed-off-by: michaere <michaere@amdocs.com>
Diffstat (limited to 'champ-service/src/main/java/org')
-rw-r--r--champ-service/src/main/java/org/onap/champ/ChampRESTAPI.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/champ-service/src/main/java/org/onap/champ/ChampRESTAPI.java b/champ-service/src/main/java/org/onap/champ/ChampRESTAPI.java
index b312af3..093675e 100644
--- a/champ-service/src/main/java/org/onap/champ/ChampRESTAPI.java
+++ b/champ-service/src/main/java/org/onap/champ/ChampRESTAPI.java
@@ -282,10 +282,19 @@ public class ChampRESTAPI {
long startTimeInMs = System.currentTimeMillis();
List<ChampRelationship> retrieved;
Response response = null;
- ChampTransaction transaction = null;
+ logger.info(ChampMsgs.INCOMING_REQUEST, tId, oId);
try {
httpHeadersValidator.validateRequestHeaders(headers);
+ ChampTransaction transaction = tId == null ? null : champDataService.getTransaction(tId);
+
+ if (transaction == null) {
+ throw new ChampServiceException("No transaction found for transaction ID: " + tId, Status.BAD_REQUEST);
+ }
retrieved = champDataService.getRelationshipsByObject(oId, Optional.ofNullable(transaction));
+ if (retrieved == null) {
+ response = Response.status(Status.NOT_FOUND).entity(oId + " not found").build();
+ return response;
+ }
EntityTag eTag = new EntityTag(etagGenerator.computeHashForChampRelationships(retrieved));
response = Response.status(Status.OK).entity(mapper.writeValueAsString(retrieved)).tag(eTag).build();
} catch (JsonProcessingException e) {