summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-rest/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'cps-ncmp-rest/src/main/java')
-rwxr-xr-xcps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java23
-rwxr-xr-xcps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/exceptions/NetworkCmProxyRestExceptionHandler.java5
2 files changed, 9 insertions, 19 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 f2f43c9897..419f6e9268 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
@@ -27,8 +27,6 @@ import static org.onap.cps.ncmp.api.impl.operations.DmiRequestBody.OperationEnum
import static org.onap.cps.ncmp.api.impl.operations.DmiRequestBody.OperationEnum.PATCH;
import static org.onap.cps.ncmp.api.impl.operations.DmiRequestBody.OperationEnum.UPDATE;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -36,6 +34,7 @@ import java.util.List;
import java.util.stream.Collectors;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
+import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.modelmapper.ModelMapper;
import org.onap.cps.ncmp.api.NetworkCmProxyDataService;
@@ -48,6 +47,7 @@ import org.onap.cps.ncmp.rest.model.Conditions;
import org.onap.cps.ncmp.rest.model.ModuleNameAsJsonObject;
import org.onap.cps.ncmp.rest.model.ModuleNamesAsJsonArray;
import org.onap.cps.ncmp.rest.model.ModuleReference;
+import org.onap.cps.utils.JsonObjectMapper;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -56,21 +56,14 @@ import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping("${rest.api.ncmp-base-path}")
+@RequiredArgsConstructor
public class NetworkCmProxyController implements NetworkCmProxyApi {
- private static final Gson GSON = new GsonBuilder().create();
private static final String NO_BODY = null;
- private final ModelMapper modelMapper = new ModelMapper();
+ private final ModelMapper modelMapper;
private final NetworkCmProxyDataService networkCmProxyDataService;
-
- /**
- * Constructor Injection for Dependencies.
- * @param networkCmProxyDataService Data Service Interface
- */
- public NetworkCmProxyController(final NetworkCmProxyDataService networkCmProxyDataService) {
- this.networkCmProxyDataService = networkCmProxyDataService;
- }
+ private final JsonObjectMapper jsonObjectMapper;
/**
* Get resource data from operational datastore.
@@ -119,7 +112,7 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
final String cmHandle,
final Object requestBody, final String contentType) {
final Object responseObject = networkCmProxyDataService.writeResourceDataPassThroughRunningForCmHandle(cmHandle,
- resourceIdentifier, PATCH, GSON.toJson(requestBody), contentType);
+ resourceIdentifier, PATCH, jsonObjectMapper.asJsonString(requestBody), contentType);
return ResponseEntity.ok(responseObject);
}
@@ -136,7 +129,7 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
public ResponseEntity<Void> createResourceDataRunningForCmHandle(final String resourceIdentifier,
final String cmHandle, final Object requestBody, final String contentType) {
networkCmProxyDataService.writeResourceDataPassThroughRunningForCmHandle(cmHandle,
- resourceIdentifier, CREATE, GSON.toJson(requestBody), contentType);
+ resourceIdentifier, CREATE, jsonObjectMapper.asJsonString(requestBody), contentType);
return new ResponseEntity<>(HttpStatus.CREATED);
}
@@ -155,7 +148,7 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
final Object requestBody,
final String contentType) {
networkCmProxyDataService.writeResourceDataPassThroughRunningForCmHandle(cmHandle,
- resourceIdentifier, UPDATE, GSON.toJson(requestBody), contentType);
+ resourceIdentifier, UPDATE, jsonObjectMapper.asJsonString(requestBody), contentType);
return new ResponseEntity<>(HttpStatus.OK);
}
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/exceptions/NetworkCmProxyRestExceptionHandler.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/exceptions/NetworkCmProxyRestExceptionHandler.java
index 6729329779..ce9dd5a027 100755
--- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/exceptions/NetworkCmProxyRestExceptionHandler.java
+++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/exceptions/NetworkCmProxyRestExceptionHandler.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Pantheon.tech
- * Modifications Copyright (C) 2021 Nordix Foundation
+ * Modifications Copyright (C) 2021-2022 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,8 +20,6 @@
package org.onap.cps.ncmp.rest.exceptions;
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.onap.cps.ncmp.api.impl.exception.NcmpException;
import org.onap.cps.ncmp.rest.controller.NetworkCmProxyController;
@@ -36,7 +34,6 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
* Exception handler with error message return.
*/
@Slf4j
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
@RestControllerAdvice(assignableTypes = {NetworkCmProxyController.class})
public class NetworkCmProxyRestExceptionHandler {