summaryrefslogtreecommitdiffstats
path: root/vnfm-simulator/vnfm-service/src/main
diff options
context:
space:
mode:
authorLukasz Muszkieta <lukasz.muszkieta@nokia.com>2019-08-07 15:14:53 +0200
committerLukasz Muszkieta <lukasz.muszkieta@nokia.com>2019-08-07 15:28:09 +0200
commitb99117295515c2876140802974c38cb3d10d0793 (patch)
tree34a3bdfcee333003c1d1ad327065586735cf63ff /vnfm-simulator/vnfm-service/src/main
parente468693695de298bf2282508fa00c3a21496524e (diff)
Sonar fixes for SvnfmController
Change-Id: I70051af78d353447e11985cc1a8fa8e7f2606f89 Issue-ID: SO-2187 Signed-off-by: Lukasz Muszkieta <lukasz.muszkieta@nokia.com>
Diffstat (limited to 'vnfm-simulator/vnfm-service/src/main')
-rw-r--r--vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/controller/SvnfmController.java8
-rw-r--r--vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/SvnfmService.java82
2 files changed, 29 insertions, 61 deletions
diff --git a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/controller/SvnfmController.java b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/controller/SvnfmController.java
index d3ff66aed0..2140b57488 100644
--- a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/controller/SvnfmController.java
+++ b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/controller/SvnfmController.java
@@ -26,7 +26,6 @@ import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.CreateVnfRequest;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse2001;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InstantiateVnfRequest;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.LccnSubscriptionRequest;
import org.onap.svnfm.simulator.constants.Constant;
import org.onap.svnfm.simulator.repository.VnfmCacheRepository;
@@ -101,13 +100,12 @@ public class SvnfmController {
* @throws InterruptedException
*/
@PostMapping(value = "/vnf_instances/{vnfInstanceId}/instantiate")
- public ResponseEntity<Void> instantiateVnf(@PathVariable("vnfInstanceId") final String vnfId,
- @RequestBody final InstantiateVnfRequest instantiateVNFRequest) {
- LOGGER.info("Start instantiateVNFRequest {} ", instantiateVNFRequest);
+ public ResponseEntity<Void> instantiateVnf(@PathVariable("vnfInstanceId") final String vnfId) {
+ LOGGER.info("Start instantiateVNFRequest for vnf id {} ", vnfId);
final HttpHeaders headers = new HttpHeaders();
headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
- headers.add(HttpHeaders.LOCATION, svnfmService.instantiateVnf(vnfId, instantiateVNFRequest));
+ headers.add(HttpHeaders.LOCATION, svnfmService.instantiateVnf(vnfId));
return new ResponseEntity<>(headers, HttpStatus.ACCEPTED);
}
diff --git a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/SvnfmService.java b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/SvnfmService.java
index 21bb00dba7..95043d35ed 100644
--- a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/SvnfmService.java
+++ b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/SvnfmService.java
@@ -32,7 +32,6 @@ import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201.InstantiationStateEnum;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201InstantiatedVnfInfo;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201VimConnectionInfo;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InstantiateVnfRequest;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.LccnSubscriptionRequest;
import org.onap.svnfm.simulator.config.ApplicationConfig;
import org.onap.svnfm.simulator.constants.Constant;
@@ -60,36 +59,31 @@ import org.springframework.stereotype.Service;
@Service
public class SvnfmService {
- @Autowired
- VnfmRepository vnfmRepository;
-
- @Autowired
- VnfOperationRepository vnfOperationRepository;
-
- @Autowired
+ private VnfmRepository vnfmRepository;
+ private VnfOperationRepository vnfOperationRepository;
private VnfmHelper vnfmHelper;
-
- @Autowired
- ApplicationConfig applicationConfig;
-
- @Autowired
- CacheManager cacheManager;
-
- @Autowired
- Vnfds vnfds;
-
- @Autowired
- SubscriptionService subscriptionService;
+ private ApplicationConfig applicationConfig;
+ private CacheManager cacheManager;
+ private Vnfds vnfds;
+ private SubscriptionService subscriptionService;
private final ExecutorService executor = Executors.newCachedThreadPool();
private static final Logger LOGGER = LoggerFactory.getLogger(SvnfmService.class);
- /**
- *
- * @param createVNFRequest
- * @return inlineResponse201
- */
+ @Autowired
+ public SvnfmService(VnfmRepository vnfmRepository, VnfOperationRepository vnfOperationRepository,
+ VnfmHelper vnfmHelper, ApplicationConfig applicationConfig, CacheManager cacheManager, Vnfds vnfds,
+ SubscriptionService subscriptionService) {
+ this.vnfmRepository = vnfmRepository;
+ this.vnfOperationRepository = vnfOperationRepository;
+ this.vnfmHelper = vnfmHelper;
+ this.applicationConfig = applicationConfig;
+ this.cacheManager = cacheManager;
+ this.vnfds = vnfds;
+ this.subscriptionService = subscriptionService;
+ }
+
public InlineResponse201 createVnf(final CreateVnfRequest createVNFRequest, final String id) {
InlineResponse201 inlineResponse201 = null;
try {
@@ -106,24 +100,16 @@ public class SvnfmService {
}
@CachePut(value = Constant.IN_LINE_RESPONSE_201_CACHE, key = "#id")
- public InlineResponse201 updateVnf(final InstantiationStateEnum instantiationState,
+ public void updateVnf(final InstantiationStateEnum instantiationState,
final InlineResponse201InstantiatedVnfInfo instantiatedVnfInfo, final String id,
final List<InlineResponse201VimConnectionInfo> vimConnectionInfo) {
final InlineResponse201 vnf = getVnf(id);
vnf.setInstantiatedVnfInfo(instantiatedVnfInfo);
vnf.setInstantiationState(instantiationState);
vnf.setVimConnectionInfo(vimConnectionInfo);
- return vnf;
}
- /**
- *
- * @param vnfId
- * @param instantiateVNFRequest
- * @param operationId
- * @throws InterruptedException
- */
- public String instantiateVnf(final String vnfId, final InstantiateVnfRequest instantiateVNFRequest) {
+ public String instantiateVnf(final String vnfId) {
final VnfOperation vnfOperation = buildVnfOperation(InlineResponse200.OperationEnum.INSTANTIATE, vnfId);
vnfOperationRepository.save(vnfOperation);
executor.submit(new InstantiateOperationProgressor(vnfOperation, this, vnfOperationRepository,
@@ -131,13 +117,7 @@ public class SvnfmService {
return vnfOperation.getId();
}
- /**
- * vnfOperationRepository
- *
- * @param vnfId
- * @param instantiateOperationId
- */
- public VnfOperation buildVnfOperation(final InlineResponse200.OperationEnum operation, final String vnfId) {
+ private VnfOperation buildVnfOperation(final InlineResponse200.OperationEnum operation, final String vnfId) {
final VnfOperation vnfOperation = new VnfOperation();
vnfOperation.setId(UUID.randomUUID().toString());
vnfOperation.setOperation(operation);
@@ -146,11 +126,6 @@ public class SvnfmService {
return vnfOperation;
}
- /**
- *
- * @param operationId
- * @throws InterruptedException
- */
public InlineResponse200 getOperationStatus(final String operationId) {
LOGGER.info("Getting operation status with id: {}", operationId);
final Thread instantiationNotification = new Thread(new VnfInstantiationNotification());
@@ -165,14 +140,13 @@ public class SvnfmService {
return null;
}
- /**
- *
- * @param vnfId
- * @return inlineResponse201
- */
public InlineResponse201 getVnf(final String vnfId) {
final Cache ca = cacheManager.getCache(Constant.IN_LINE_RESPONSE_201_CACHE);
+ if (ca == null)
+ return null;
final SimpleValueWrapper wrapper = (SimpleValueWrapper) ca.get(vnfId);
+ if (wrapper == null)
+ return null;
final InlineResponse201 inlineResponse201 = (InlineResponse201) wrapper.get();
if (inlineResponse201 != null) {
LOGGER.info("Cache Read Successful");
@@ -181,10 +155,6 @@ public class SvnfmService {
return null;
}
- /**
- * @param vnfId
- * @return
- */
public String terminateVnf(final String vnfId) {
final VnfOperation vnfOperation = buildVnfOperation(InlineResponse200.OperationEnum.TERMINATE, vnfId);
vnfOperationRepository.save(vnfOperation);