aboutsummaryrefslogtreecommitdiffstats
path: root/champ-service/src
diff options
context:
space:
mode:
Diffstat (limited to 'champ-service/src')
-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) {