diff options
author | waqas.ikram <waqas.ikram@est.tech> | 2019-08-21 16:33:14 +0000 |
---|---|---|
committer | Waqas Ikram <waqas.ikram@est.tech> | 2019-08-21 16:34:25 +0000 |
commit | 6e6227ceeca68aa3d5a066ef10bfe1e8db8ef346 (patch) | |
tree | fe185ebce5fbd6ffcf04cffdb8c83fc51ada7b41 /plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProviderImpl.java | |
parent | ed792f66fccdd6857542badbee5bc884119de97c (diff) |
Adding tenant relationship and generic vnf post endpoints
Change-Id: I7a735cd85e8e4264170df7f99c0adeddfe72684d
Issue-ID: SO-2219
Signed-off-by: waqas.ikram <waqas.ikram@est.tech>
Diffstat (limited to 'plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProviderImpl.java')
-rw-r--r-- | plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProviderImpl.java | 58 |
1 files changed, 41 insertions, 17 deletions
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProviderImpl.java index 472ca172..fed79d8e 100644 --- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProviderImpl.java +++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProviderImpl.java @@ -81,22 +81,6 @@ public class GenericVnfCacheServiceProviderImpl extends AbstractCacheServiceProv } @Override - public boolean addRelationShip(final String vnfId, final Relationship relationship) { - final Optional<GenericVnf> optional = getGenericVnf(vnfId); - if (optional.isPresent()) { - final GenericVnf genericVnf = optional.get(); - RelationshipList relationshipList = genericVnf.getRelationshipList(); - if (relationshipList == null) { - relationshipList = new RelationshipList(); - genericVnf.setRelationshipList(relationshipList); - } - return relationshipList.getRelationship().add(relationship); - } - LOGGER.error("Unable to find GenericVnf ..."); - return false; - } - - @Override public Optional<String> getGenericVnfId(final String vnfName) { final Cache cache = getCache(GENERIC_VNF_CACHE.getName()); if (cache != null) { @@ -133,7 +117,13 @@ public class GenericVnfCacheServiceProviderImpl extends AbstractCacheServiceProv outGoingRelationShip, targetUrl, Relationship.class); if (optionalRelationship.isPresent()) { final Relationship resultantRelationship = optionalRelationship.get(); - if (addRelationShip(vnfId, resultantRelationship)) { + + RelationshipList relationshipList = genericVnf.getRelationshipList(); + if (relationshipList == null) { + relationshipList = new RelationshipList(); + genericVnf.setRelationshipList(relationshipList); + } + if (relationshipList.getRelationship().add(resultantRelationship)) { LOGGER.info("added relationship {} in cache successfully", resultantRelationship); return true; } @@ -146,6 +136,40 @@ public class GenericVnfCacheServiceProviderImpl extends AbstractCacheServiceProv return false; } + @Override + public Optional<Relationship> addRelationShip(final String vnfId, final Relationship relationship, + final String requestURI) { + final Optional<GenericVnf> optional = getGenericVnf(vnfId); + if (optional.isPresent()) { + final GenericVnf genericVnf = optional.get(); + RelationshipList relationshipList = genericVnf.getRelationshipList(); + if (relationshipList == null) { + relationshipList = new RelationshipList(); + genericVnf.setRelationshipList(relationshipList); + } + relationshipList.getRelationship().add(relationship); + LOGGER.info("Successfully added relation to GenericVnf for vnfId: {}", vnfId); + + final Relationship resultantRelationship = getRelationship(requestURI, genericVnf); + return Optional.of(resultantRelationship); + } + return Optional.empty(); + } + + @Override + public boolean patchGenericVnf(final String vnfId, final GenericVnf genericVnf) { + final Optional<GenericVnf> optional = getGenericVnf(vnfId); + if (optional.isPresent()) { + final GenericVnf cachedGenericVnf = optional.get(); + LOGGER.info("Changing OrchestrationStatus from {} to {} ", cachedGenericVnf.getOrchestrationStatus(), + genericVnf.getOrchestrationStatus()); + cachedGenericVnf.setOrchestrationStatus(genericVnf.getOrchestrationStatus()); + return true; + } + LOGGER.error("Unable to find GenericVnf ..."); + return false; + } + private String getTargetUrl(final String targetBaseUrl, final String relatedLink) { return UriComponentsBuilder.fromUriString(targetBaseUrl).path(relatedLink) .path(BI_DIRECTIONAL_RELATIONSHIP_LIST_URL).toUriString(); |