From 4eb6fd36c013d6349d191fbe3c482bb6064d3327 Mon Sep 17 00:00:00 2001 From: michaere Date: Wed, 1 Aug 2018 17:20:16 +0100 Subject: 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 --- champ-service/src/main/java/org/onap/champ/ChampRESTAPI.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'champ-service/src/main/java') 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 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) { -- cgit 1.2.3-korg