summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpawel.kadlubanski <pawel.kadlubanski@nokia.com>2018-01-30 14:45:19 +0100
committerpawel.kadlubanski <pawel.kadlubanski@nokia.com>2018-02-02 11:52:07 +0100
commitd85196be5efb35998bc39c198aab9fd1c67631c1 (patch)
tree17174ea7c6f98371be968fd0012b72bd9b774d30
parentb9f83246d75cc0f475d12b92843a089a3a208e61 (diff)
Improve code metrics
Improve code issued identified by Sonar in class vnfapiProvider fixes Change-Id: I7a28380920385f5644eb41767f68d7ae1e176473 Issue-ID: SDNC-243 Signed-off-by: pawel.kadlubanski <pawel.kadlubanski@nokia.com>
-rw-r--r--vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/VnfApiProvider.java71
1 files changed, 14 insertions, 57 deletions
diff --git a/vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/VnfApiProvider.java b/vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/VnfApiProvider.java
index f390eebb..18019724 100644
--- a/vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/VnfApiProvider.java
+++ b/vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/VnfApiProvider.java
@@ -1237,10 +1237,6 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
VfModuleServiceDataBuilder operDataBuilder = new VfModuleServiceDataBuilder();
getVfModuleServiceData(vfid, operDataBuilder, LogicalDatastoreType.OPERATIONAL);
- // save service-data builder object for rollback
- VfModuleServiceDataBuilder rb_vfModuleServiceDataBuilder = vfModuleServiceDataBuilder;
- VfModuleServiceDataBuilder rb_operDataBuilder = operDataBuilder;
-
// 1610 Need to pull vnf-instance-list.vf-module-relationship-list from MD-SAL
VnfInstanceServiceDataBuilder vnfInstanceServiceDataBuilder = new VnfInstanceServiceDataBuilder();
getVnfInstanceServiceData(viid, vnfInstanceServiceDataBuilder);
@@ -1249,9 +1245,6 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
VnfInstanceServiceDataBuilder vnfInstanceOperDataBuilder = new VnfInstanceServiceDataBuilder();
getVnfInstanceServiceData(viid, vnfInstanceOperDataBuilder, LogicalDatastoreType.OPERATIONAL);
- // save operational builder object for rollback
- VnfInstanceServiceDataBuilder rb_vnfInstanceServiceDataBuilder = vnfInstanceServiceDataBuilder;
- VnfInstanceServiceDataBuilder rb_vnfInstanceOperDataBuilder = vnfInstanceOperDataBuilder;
// Set the serviceStatus based on input
setServiceStatus(serviceStatusBuilder, input.getSdncRequestHeader());
@@ -1261,18 +1254,14 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
// setup a service-data object builder
// ACTION vnf-topology-operation
// INPUT:
- // USES sdnc-request-header;
// USES request-information;
// USES service-information;
// USES vnf-request-information
// OUTPUT:
- // USES vnf-topology-response-body;
// USES vnf-information
// USES service-information
//
// container service-data
- // uses vnf-configuration-information;
- // uses oper-status;
log.info(ADDING_INPUT_DATA_STR + SVC_OPERATION + " [" + vfid + INPUT_STR + input);
VfModuleTopologyOperationInputBuilder inputBuilder = new VfModuleTopologyOperationInputBuilder(input);
@@ -1334,7 +1323,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
serviceStatusBuilder.setRequestStatus(RequestStatus.Synccomplete);
serviceStatusBuilder.setRpcName(RpcName.VfModuleTopologyOperation);
- if (errorCode != null && errorCode.length() != 0 && !(errorCode.equals("0") || errorCode.equals("200"))) {
+ if (errorCode != null && errorCode.length() != 0 && !("0".equals(errorCode) || "200".equals(errorCode))) {
responseBuilder.setResponseCode(errorCode);
responseBuilder.setResponseMessage(errorMessage);
responseBuilder.setAckFinalIndicator(ackFinal);
@@ -1364,7 +1353,6 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
VfModuleListBuilder vfModuleListBuilder = new VfModuleListBuilder();
vfModuleListBuilder.setVfModuleServiceData(vfModuleServiceData);
vfModuleListBuilder.setVfModuleId(vfModuleServiceData.getVfModuleId());
- //vfid = vfModuleServiceData.getVfModuleId();
vfModuleListBuilder.setServiceStatus(serviceStatusBuilder.build());
saveVfModuleList(vfModuleListBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null) {
@@ -1410,7 +1398,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
@Override
public Future<RpcResult<VnfTopologyOperationOutput>> vnfTopologyOperation(VnfTopologyOperationInput input) {
final String SVC_OPERATION = "vnf-topology-operation";
- ServiceData serviceData = null;
+ ServiceData serviceData;
ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder();
Properties parms = new Properties();
@@ -1470,17 +1458,13 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
// setup a service-data object builder
// ACTION vnf-topology-operation
// INPUT:
- // USES sdnc-request-header;
// USES request-information;
- // USES service-information;
// USES vnf-request-information
// OUTPUT:
- // USES vnf-topology-response-body;
// USES vnf-information
// USES service-information
//
// container service-data
- // uses vnf-configuration-information;
// uses oper-status;
log.info("Adding INPUT data for " + SVC_OPERATION + " [" + siid + "] input: " + input);
@@ -1534,7 +1518,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
serviceStatusBuilder.setRequestStatus(RequestStatus.Synccomplete);
serviceStatusBuilder.setRpcName(RpcName.VnfTopologyOperation);
- if (errorCode != null && errorCode.length() != 0 && !(errorCode.equals("0") || errorCode.equals("200"))) {
+ if (errorCode != null && errorCode.length() != 0 && !("0".equals(errorCode) || "200".equals(errorCode))) {
responseBuilder.setResponseCode(errorCode);
responseBuilder.setResponseMessage(errorMessage);
responseBuilder.setAckFinalIndicator(ackFinal);
@@ -1611,8 +1595,6 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
NetworkTopologyOperationInput input) {
final String SVC_OPERATION = "network-topology-operation";
- ServiceData serviceData = null;
- ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder();
Properties parms = new Properties();
log.info(SVC_OPERATION + " called.");
@@ -1647,7 +1629,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
}
// Grab the service instance ID from the input buffer
- String siid = null;
+ String siid;
if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Assign)) {
siid = input.getNetworkRequestInformation().getNetworkName();
} else {
@@ -1704,7 +1686,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
networkId = respProps.getProperty("networkId", "0");
}
- if (errorCode != null && errorCode.length() != 0 && !(errorCode.equals("0") || errorCode.equals("200"))) {
+ if (errorCode != null && errorCode.length() != 0 && !("0".equals(errorCode) || "200".equals(errorCode))) {
responseBuilder.setResponseCode(errorCode);
responseBuilder.setResponseMessage(errorMessage);
responseBuilder.setAckFinalIndicator(ackFinal);
@@ -1756,7 +1738,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
PreloadVnfTopologyOperationInput input) {
final String SVC_OPERATION = "preload-vnf-topology-operation";
- PreloadData preloadData = null;
+ PreloadData preloadData;
Properties parms = new Properties();
log.info(SVC_OPERATION + " called.");
@@ -1764,7 +1746,6 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
PreloadVnfTopologyOperationOutputBuilder responseBuilder = new PreloadVnfTopologyOperationOutputBuilder();
// Result from savePreloadData
- final SettableFuture<RpcResult<Void>> futureResult = SettableFuture.create();
if (input == null || input.getVnfTopologyInformation() == null
|| input.getVnfTopologyInformation().getVnfTopologyIdentifier() == null
@@ -1813,7 +1794,6 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
PreloadDataBuilder preloadDataBuilder = new PreloadDataBuilder();
getPreloadData(preload_name, preload_type, preloadDataBuilder);
- //preloadData = preloadDataBuilder.build();
PreloadDataBuilder operDataBuilder = new PreloadDataBuilder();
getPreloadData(preload_name, preload_type, operDataBuilder, LogicalDatastoreType.OPERATIONAL);
@@ -1822,14 +1802,11 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
// setup a preload-data object builder
// ACTION vnf-topology-operation
// INPUT:
- // USES sdnc-request-header;
// USES request-information;
// uses vnf-topology-information;
// OUTPUT:
- // USES vnf-topology-response-body;
//
// container preload-data
- // uses vnf-configuration-information;
log.info(
"Adding INPUT data for " + SVC_OPERATION + " [" + preload_name + "," + preload_type + "] input: " + input);
PreloadVnfTopologyOperationInputBuilder inputBuilder = new PreloadVnfTopologyOperationInputBuilder(input);
@@ -1870,10 +1847,9 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
errorCode = respProps.getProperty("error-code");
errorMessage = respProps.getProperty("error-message");
ackFinal = respProps.getProperty("ack-final", "Y");
- // internalError = respProps.getProperty("internal-error", "false");
}
- if (errorCode != null && errorCode.length() != 0 && !(errorCode.equals("0") || errorCode.equals("200"))) {
+ if (errorCode != null && errorCode.length() != 0 && !("0".equals(errorCode) || "200".equals(errorCode))) {
responseBuilder.setResponseCode(errorCode);
responseBuilder.setResponseMessage(errorMessage);
@@ -1952,7 +1928,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
PreloadVnfInstanceTopologyOperationInput input) {
final String SVC_OPERATION = "preload-vnf-instance-topology-operation";
- VnfInstancePreloadData vnfInstancePreloadData = null;
+ VnfInstancePreloadData vnfInstancePreloadData;
Properties parms = new Properties();
log.info(SVC_OPERATION + " called.");
@@ -1960,8 +1936,6 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
PreloadVnfInstanceTopologyOperationOutputBuilder responseBuilder =
new PreloadVnfInstanceTopologyOperationOutputBuilder();
- // Result from savePreloadData
- final SettableFuture<RpcResult<Void>> futureResult = SettableFuture.create();
if (input == null || input.getVnfInstanceTopologyInformation() == null
|| input.getVnfInstanceTopologyInformation().getVnfInstanceIdentifiers().getVnfInstanceName() == null
@@ -2011,7 +1985,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
VnfInstancePreloadDataBuilder vnfInstancePreloadDataBuilder = new VnfInstancePreloadDataBuilder();
getVnfInstancePreloadData(preload_name, preload_type, vnfInstancePreloadDataBuilder);
- //preloadData = preloadDataBuilder.build();
+
VnfInstancePreloadDataBuilder operDataBuilder = new VnfInstancePreloadDataBuilder();
getVnfInstancePreloadData(preload_name, preload_type, operDataBuilder, LogicalDatastoreType.OPERATIONAL);
@@ -2020,14 +1994,9 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
// setup a preload-data object builder
// ACTION vnf-topology-operation
// INPUT:
- // USES sdnc-request-header;
- // USES request-information;
// uses vnf-topology-information;
// OUTPUT:
- // USES vnf-topology-response-body;
- //
// container preload-data
- // uses vnf-configuration-information;
log.info(
"Adding INPUT data for " + SVC_OPERATION + " [" + preload_name + "," + preload_type + "] input: " + input);
PreloadVnfInstanceTopologyOperationInputBuilder inputBuilder =
@@ -2069,10 +2038,9 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
errorCode = respProps.getProperty("error-code");
errorMessage = respProps.getProperty("error-message");
ackFinal = respProps.getProperty("ack-final", "Y");
- // internalError = respProps.getProperty("internal-error", "false");
}
- if (errorCode != null && errorCode.length() != 0 && !(errorCode.equals("0") || errorCode.equals("200"))) {
+ if (errorCode != null && errorCode.length() != 0 && !("0".equals(errorCode) || "200".equals(errorCode))) {
responseBuilder.setResponseCode(errorCode);
responseBuilder.setResponseMessage(errorMessage);
@@ -2154,7 +2122,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
PreloadVfModuleTopologyOperationInput input) {
final String SVC_OPERATION = "preload-vf-module-topology-operation";
- VfModulePreloadData vfModulePreloadData = null;
+ VfModulePreloadData vfModulePreloadData;
Properties parms = new Properties();
log.info(SVC_OPERATION + " called.");
@@ -2163,7 +2131,6 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
new PreloadVfModuleTopologyOperationOutputBuilder();
// Result from savePreloadData
- final SettableFuture<RpcResult<Void>> futureResult = SettableFuture.create();
if (input == null || input.getVfModuleTopologyInformation() == null
|| input.getVfModuleTopologyInformation().getVfModuleIdentifiers().getVfModuleName() == null
@@ -2212,7 +2179,6 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
VfModulePreloadDataBuilder vfModulePreloadDataBuilder = new VfModulePreloadDataBuilder();
getVfModulePreloadData(preload_name, preload_type, vfModulePreloadDataBuilder);
- //preloadData = preloadDataBuilder.build();
VfModulePreloadDataBuilder operDataBuilder = new VfModulePreloadDataBuilder();
getVfModulePreloadData(preload_name, preload_type, operDataBuilder, LogicalDatastoreType.OPERATIONAL);
@@ -2221,14 +2187,11 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
// setup a preload-data object builder
// ACTION vnf-topology-operation
// INPUT:
- // USES sdnc-request-header;
// USES request-information;
// uses vnf-topology-information;
// OUTPUT:
- // USES vnf-topology-response-body;
//
// container preload-data
- // uses vnf-configuration-information;
log.info(
"Adding INPUT data for " + SVC_OPERATION + " [" + preload_name + "," + preload_type + "] input: " + input);
@@ -2270,10 +2233,9 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
errorCode = respProps.getProperty("error-code");
errorMessage = respProps.getProperty("error-message");
ackFinal = respProps.getProperty("ack-final", "Y");
- // internalError = respProps.getProperty("internal-error", "false");
}
- if (errorCode != null && errorCode.length() != 0 && !(errorCode.equals("0") || errorCode.equals("200"))) {
+ if (errorCode != null && errorCode.length() != 0 && !("0".equals(errorCode) || "200".equals(errorCode))) {
responseBuilder.setResponseCode(errorCode);
responseBuilder.setResponseMessage(errorMessage);
@@ -2352,7 +2314,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
PreloadNetworkTopologyOperationInput input) {
final String SVC_OPERATION = "preload-network-topology-operation";
- PreloadData preloadData = null;
+ PreloadData preloadData;
Properties parms = new Properties();
log.info(SVC_OPERATION + " called.");
@@ -2361,7 +2323,6 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
new PreloadNetworkTopologyOperationOutputBuilder();
// Result from savePreloadData
- final SettableFuture<RpcResult<Void>> futureResult = SettableFuture.create();
if (input == null || input.getNetworkTopologyInformation() == null
|| input.getNetworkTopologyInformation().getNetworkTopologyIdentifier() == null
@@ -2420,14 +2381,11 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
// setup a preload-data object builder
// ACTION vnf-topology-operation
// INPUT:
- // USES sdnc-request-header;
// USES request-information;
// uses vnf-topology-information;
// OUTPUT:
- // USES vnf-topology-response-body;
//
// container preload-data
- // uses vnf-configuration-information;
log.info(
"Adding INPUT data for " + SVC_OPERATION + " [" + preload_name + "," + preload_type + "] input: " + input);
PreloadNetworkTopologyOperationInputBuilder inputBuilder =
@@ -2469,10 +2427,9 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
errorCode = respProps.getProperty("error-code");
errorMessage = respProps.getProperty("error-message");
ackFinal = respProps.getProperty("ack-final", "Y");
- // internalError = respProps.getProperty("internal-error", "false");
}
- if (errorCode != null && errorCode.length() != 0 && !(errorCode.equals("0") || errorCode.equals("200"))) {
+ if (errorCode != null && errorCode.length() != 0 && !("0".equals(errorCode) || "200".equals(errorCode))) {
responseBuilder.setResponseCode(errorCode);
responseBuilder.setResponseMessage(errorMessage);
responseBuilder.setAckFinalIndicator(ackFinal);