summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-rest/src/main/java/org/onap
diff options
context:
space:
mode:
authorlukegleeson <luke.gleeson@est.tech>2022-06-02 10:56:43 +0100
committerlukegleeson <luke.gleeson@est.tech>2022-06-29 12:03:30 +0100
commit78062a1c3f4e303714103dfcb7d9552a0b081eb0 (patch)
tree5cb2bb77ea3ffa2c440a108b13401e2dc3a53b38 /cps-ncmp-rest/src/main/java/org/onap
parent529f92c549a16ecd9ead36cc00d6f74f775ca638 (diff)
Get cm-handle state endpoint
Added new get cm-handle state endpoint Refactored RestOutputCmHandleState to CmHandleCompositeState Created new RestOutputCmHandleCompositeState OpenApi object ^This is done so that we get '"state: {" at the start of JSON response Refactored RestOutputCmHandleStateMapper to CmHandleStateMapper Added more detailed composite state to get cmHandleDetails endpoint tests Rebased code Code rebased on top of 129658: Unable to change state from LOCKED to ADVISED | https://gerrit.onap.org/r/c/cps/+/129658 which fixes output error Issue-ID: CPS-1019 Signed-off-by: mpriyank <priyank.maheshwari@est.tech> Signed-off-by: lukegleeson <luke.gleeson@est.tech> Change-Id: I361117c98c256a4aa578c13d21926bc6d7876a15
Diffstat (limited to 'cps-ncmp-rest/src/main/java/org/onap')
-rwxr-xr-xcps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java25
-rw-r--r--cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/mapper/CmHandleStateMapper.java (renamed from cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/mapper/RestOutputCmHandleStateMapper.java)6
2 files changed, 24 insertions, 7 deletions
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
index fb234ef71a..7abefe6791 100755
--- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
+++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
@@ -40,15 +40,17 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.onap.cps.ncmp.api.NetworkCmProxyDataService;
import org.onap.cps.ncmp.api.impl.exception.InvalidTopicException;
+import org.onap.cps.ncmp.api.inventory.CompositeState;
import org.onap.cps.ncmp.api.models.CmHandleQueryApiParameters;
import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle;
import org.onap.cps.ncmp.rest.api.NetworkCmProxyApi;
import org.onap.cps.ncmp.rest.executor.CpsNcmpTaskExecutor;
-import org.onap.cps.ncmp.rest.mapper.RestOutputCmHandleStateMapper;
+import org.onap.cps.ncmp.rest.mapper.CmHandleStateMapper;
import org.onap.cps.ncmp.rest.model.CmHandlePublicProperties;
import org.onap.cps.ncmp.rest.model.CmHandleQueryParameters;
import org.onap.cps.ncmp.rest.model.RestModuleReference;
import org.onap.cps.ncmp.rest.model.RestOutputCmHandle;
+import org.onap.cps.ncmp.rest.model.RestOutputCmHandleCompositeState;
import org.onap.cps.ncmp.rest.model.RestOutputCmHandlePublicProperties;
import org.onap.cps.ncmp.rest.util.DeprecationHelper;
import org.onap.cps.utils.CpsValidator;
@@ -73,7 +75,7 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
private final DeprecationHelper deprecationHelper;
private final NcmpRestInputMapper ncmpRestInputMapper;
- private final RestOutputCmHandleStateMapper restOutputCmHandleStateMapper;
+ private final CmHandleStateMapper cmHandleStateMapper;
private final CpsNcmpTaskExecutor cpsNcmpTaskExecutor;
@Value("${notification.async.executor.time-out-value-in-ms:2000}")
@@ -253,7 +255,7 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
/**
* Get Cm Handle Properties by Cm Handle Id.
* @param cmHandleId cm-handle identifier
- * @return cm handle and its properties
+ * @return cm handle properties
*/
@Override
public ResponseEntity<RestOutputCmHandlePublicProperties> getCmHandlePublicPropertiesByCmHandleId(
@@ -267,6 +269,21 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
}
/**
+ * Get Cm Handle State by Cm Handle Id.
+ * @param cmHandleId cm-handle identifier
+ * @return cm handle state
+ */
+ @Override
+ public ResponseEntity<RestOutputCmHandleCompositeState> getCmHandleStateByCmHandleId(
+ final String cmHandleId) {
+ final CompositeState cmHandleState = networkCmProxyDataService.getCmHandleCompositeState(cmHandleId);
+ final RestOutputCmHandleCompositeState restOutputCmHandleCompositeState =
+ new RestOutputCmHandleCompositeState();
+ restOutputCmHandleCompositeState.setState(cmHandleStateMapper.toCmHandleCompositeState(cmHandleState));
+ return ResponseEntity.ok(restOutputCmHandleCompositeState);
+ }
+
+ /**
* Return module references for a cm handle.
*
* @param cmHandle the cm handle
@@ -286,7 +303,7 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
restOutputCmHandle.setCmHandle(ncmpServiceCmHandle.getCmHandleId());
cmHandlePublicProperties.add(ncmpServiceCmHandle.getPublicProperties());
restOutputCmHandle.setPublicCmHandleProperties(cmHandlePublicProperties);
- restOutputCmHandle.setState(restOutputCmHandleStateMapper.toRestOutputCmHandleState(
+ restOutputCmHandle.setState(cmHandleStateMapper.toCmHandleCompositeState(
ncmpServiceCmHandle.getCompositeState()));
return restOutputCmHandle;
}
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/mapper/RestOutputCmHandleStateMapper.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/mapper/CmHandleStateMapper.java
index afad1098c7..933ca88c9e 100644
--- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/mapper/RestOutputCmHandleStateMapper.java
+++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/mapper/CmHandleStateMapper.java
@@ -26,17 +26,17 @@ import org.mapstruct.Named;
import org.mapstruct.NullValueCheckStrategy;
import org.mapstruct.NullValuePropertyMappingStrategy;
import org.onap.cps.ncmp.api.inventory.CompositeState;
+import org.onap.cps.ncmp.rest.model.CmHandleCompositeState;
import org.onap.cps.ncmp.rest.model.DataStores;
-import org.onap.cps.ncmp.rest.model.RestOutputCmHandleState;
import org.onap.cps.ncmp.rest.model.SyncState;
@Mapper(componentModel = "spring", nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS,
nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.SET_TO_DEFAULT)
-public interface RestOutputCmHandleStateMapper {
+public interface CmHandleStateMapper {
@Mapping(target = "dataSyncState", source = "dataStores", qualifiedByName = "dataStoreToDataSyncState")
@Mapping(target = "lockReason.reason", source = "lockReason.lockReasonCategory")
- RestOutputCmHandleState toRestOutputCmHandleState(CompositeState compositeState);
+ CmHandleCompositeState toCmHandleCompositeState(CompositeState compositeState);
/**
* Convert from CompositeState datastore to RestOutput Datastores.