aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTian Lee <TianL@amdocs.com>2018-08-06 15:40:42 +0000
committerGerrit Code Review <gerrit@onap.org>2018-08-06 15:40:42 +0000
commit43483ac6f582ea6748e0356ce77849af1eeb1d6f (patch)
tree00c5a843f2fefcdf93ec941b33f60b92c6f2a04b
parenta42cef9af8b569a6da9a6e723df8eaeb5b154577 (diff)
parent4eb6fd36c013d6349d191fbe3c482bb6064d3327 (diff)
Merge "Ensure transaction id utilised for endpoint"
-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 8db8c46..58db3be 100644
--- a/champ-service/src/main/java/org/onap/champ/ChampRESTAPI.java
+++ b/champ-service/src/main/java/org/onap/champ/ChampRESTAPI.java
@@ -284,10 +284,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) {