summaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main
diff options
context:
space:
mode:
authorEylon Malin <eylon.malin@intl.att.com>2019-08-29 11:40:46 +0300
committerEylon Malin <eylon.malin@intl.att.com>2019-08-29 11:40:46 +0300
commit0ba9caffd1185fdd16f97830916ae6e3d6b08116 (patch)
treef900d8ade78af05cbb487e0ca0b87ca12270baaa /vid-app-common/src/main
parent9d0908e18d51a4ba1c4a54b01fcbe16598bd352a (diff)
fix url and payload for getting latest model
Issue-ID: VID-378 Signed-off-by: Eylon Malin <eylon.malin@intl.att.com> Change-Id: I5b2dc7df0202838898ab060a71c144f69a54900f
Diffstat (limited to 'vid-app-common/src/main')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java15
1 files changed, 9 insertions, 6 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
index a0296d9d9..8e47bbae5 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
@@ -432,19 +432,18 @@ public class AaiClient implements AaiClientInterface {
throw new GenericUncheckedException("no invariant-id provided to getLatestVersionByInvariantId; request is rejected");
}
- // add the modelInvariantId to the payload
- StringBuilder payload = new StringBuilder(GET_SERVICE_MODELS_REQUEST_BODY);
- payload.insert(50, modelInvariantId);
-
- Response response = doAaiPut("service-design-and-creation/models/model/", payload.toString(),false);
+ Response response = doAaiPut("query?format=resource&depth=0", "{\"start\": [\"service-design-and-creation/models/model/" + modelInvariantId + "\"],\"query\": \"query/serviceModels-byDistributionStatus?distributionStatus=DISTRIBUTION_COMPLETE_OK\"}",false);
AaiResponse<ModelVersions> aaiResponse = processAaiResponse(response, ModelVersions.class, null, VidObjectMapperType.FASTERXML);
+
Stream<ModelVer> modelVerStream = toModelVerStream(aaiResponse.getT());
return maxModelVer(modelVerStream);
-
}
protected Stream<ModelVer> toModelVerStream(ModelVersions modelVersions) {
+ if (modelVersions == null)
+ return null;
+
return Stream.of(modelVersions)
.map(ModelVersions::getResults)
.flatMap(java.util.Collection::stream)
@@ -455,6 +454,10 @@ public class AaiClient implements AaiClientInterface {
}
protected ModelVer maxModelVer(Stream<ModelVer> modelVerStream) {
+
+ if (modelVerStream == null)
+ return null;
+
return modelVerStream
.filter(modelVer -> StringUtils.isNotEmpty(modelVer.getModelVersion()))
.max(comparing(ModelVer::getModelVersion, comparing(DefaultArtifactVersion::new)))