summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorMatthieuGeerebaert <matthieu.geerebaert@orange.com>2018-04-15 22:19:46 +0200
committerMatthieuGeerebaert <matthieu.geerebaert@orange.com>2018-04-15 22:19:46 +0200
commit49954e7bd4cef8743611b15f0bc2cc769e8e7c49 (patch)
tree6df73dc072a9906d50cdb4be3fe1e42e5251114c /src/main/java/org
parent6b8c1f5d9844c92774243834aa3f0f7136a1e222 (diff)
Sonar clean code
Issue-ID: EXTAPI-46 Change-Id: Iba029badc0ed15e20599902aef23c849a7eb0e86 Signed-off-by: MatthieuGeerebaert <matthieu.geerebaert@orange.com>
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/onap/nbi/apis/servicecatalog/SdcClient.java20
-rw-r--r--src/main/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessor.java62
-rw-r--r--src/main/java/org/onap/nbi/apis/servicecatalog/jolt/FindServiceSpecJsonTransformer.java28
-rw-r--r--src/main/java/org/onap/nbi/apis/servicecatalog/jolt/GetServiceSpecJsonTransformer.java28
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceinventory/jolt/FindServiceInventoryJsonTransformer.java20
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceinventory/jolt/GetServiceInventoryJsonTransformer.java20
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskManager.java28
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskProcessor.java67
-rw-r--r--src/main/java/org/onap/nbi/commons/BeanUtils.java24
9 files changed, 150 insertions, 147 deletions
diff --git a/src/main/java/org/onap/nbi/apis/servicecatalog/SdcClient.java b/src/main/java/org/onap/nbi/apis/servicecatalog/SdcClient.java
index 65d5b9c..029527c 100644
--- a/src/main/java/org/onap/nbi/apis/servicecatalog/SdcClient.java
+++ b/src/main/java/org/onap/nbi/apis/servicecatalog/SdcClient.java
@@ -1,17 +1,15 @@
/**
- * Copyright (c) 2018 Orange
+ * Copyright (c) 2018 Orange
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
*/
package org.onap.nbi.apis.servicecatalog;
@@ -104,7 +102,7 @@ public class SdcClient {
}
toscaFileStream.close();
} catch (IOException e) {
- LOGGER.error("cannot get TOSCA File for url " + toscaModelUrl);
+ LOGGER.error("cannot get TOSCA File for url " + toscaModelUrl, e);
}
return toscaFile;
diff --git a/src/main/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessor.java b/src/main/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessor.java
index cc07f6f..d71595f 100644
--- a/src/main/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessor.java
+++ b/src/main/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessor.java
@@ -1,17 +1,15 @@
/**
- * Copyright (c) 2018 Orange
+ * Copyright (c) 2018 Orange
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
*/
package org.onap.nbi.apis.servicecatalog;
@@ -69,16 +67,18 @@ public class ToscaInfosProcessor {
serviceCatalogResponse.put("serviceSpecCharacteristic", serviceSpecCharacteristic);
}
- LinkedHashMap node_templates = (LinkedHashMap) toscaInfosTopologyTemplate.get("node_templates");
+ LinkedHashMap nodeTemplate = (LinkedHashMap) toscaInfosTopologyTemplate.get("node_templates");
List<LinkedHashMap> resourceSpecifications =
(List<LinkedHashMap>) serviceCatalogResponse.get("resourceSpecification");
for (LinkedHashMap resourceSpecification : resourceSpecifications) {
String id = (String) resourceSpecification.get("id");
LOGGER.debug("get tosca infos for service id: " + id);
- LinkedHashMap toscaInfosFromResourceId = getToscaInfosFromResourceUUID(node_templates, id);
- resourceSpecification.put("modelCustomizationId", toscaInfosFromResourceId.get("customizationUUID"));
- resourceSpecification.put("modelCustomizationName", toscaInfosFromResourceId.get("name"));
+ LinkedHashMap toscaInfosFromResourceId = getToscaInfosFromResourceUUID(nodeTemplate, id);
+ if (toscaInfosFromResourceId != null) {
+ resourceSpecification.put("modelCustomizationId", toscaInfosFromResourceId.get("customizationUUID"));
+ resourceSpecification.put("modelCustomizationName", toscaInfosFromResourceId.get("name"));
+ }
}
}
@@ -89,10 +89,10 @@ public class ToscaInfosProcessor {
LOGGER.debug("get tosca infos for serviceSpecCharacteristicValues of type map or string : " + parameter);
Object aDefault = parameter.get("default");
if (parameter.get("entry_schema") != null) {
- ArrayList entry_schema = (ArrayList) parameter.get("entry_schema");
- if (CollectionUtils.isNotEmpty(entry_schema)) {
+ ArrayList entrySchema = (ArrayList) parameter.get("entry_schema");
+ if (CollectionUtils.isNotEmpty(entrySchema)) {
buildCharacteristicValuesFormShema(parameterType, serviceSpecCharacteristicValues, aDefault,
- entry_schema);
+ entrySchema);
}
}
}
@@ -138,13 +138,16 @@ public class ToscaInfosProcessor {
public LinkedHashMap getToscaInfos(LinkedHashMap sdcResponse) {
+
+ LinkedHashMap topologyTemplate = null;
+
String toscaModelUrl = (String) sdcResponse.get("toscaModelURL");
String serviceId = (String) sdcResponse.get("uuid");
File toscaFile = sdcClient.callGetWithAttachment(toscaModelUrl);
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
String tempFolderName = serviceId + timestamp;
File folderTemp = null;
- LinkedHashMap topology_template = null;
+
try {
unZipArchive(toscaFile.getName(), tempFolderName);
folderTemp = new File(tempFolderName);
@@ -160,43 +163,44 @@ public class ToscaInfosProcessor {
if (toscaFileHashMap.get("topology_template") == null) {
throw new NullPointerException("no topology_template node in tosca file");
}
- topology_template = (LinkedHashMap) toscaFileHashMap.get("topology_template");
+ topologyTemplate = (LinkedHashMap) toscaFileHashMap.get("topology_template");
} catch (NullPointerException e) {
- LOGGER.error("unable to parse tosca file for id : " + serviceId + ", " + e.getMessage());
+ LOGGER.warn("unable to parse tosca file for id : " + serviceId, e);
return null;
+
} finally {
+
try {
LOGGER.debug("deleting temp folder for tosca files : " + folderTemp.getName());
FileUtils.deleteDirectory(folderTemp);
LOGGER.debug("deleting tosca archive : " + toscaFile.getName());
FileUtils.forceDelete(toscaFile);
- return topology_template;
+ return topologyTemplate;
+
} catch (IOException e) {
- LOGGER.error("unable to delete temp directory tosca file for id : " + serviceId);
+ LOGGER.error("unable to delete temp directory tosca file for id : " + serviceId, e);
return null;
-
}
}
+
}
private LinkedHashMap parseToscaFile(String fileName) {
File toscaFile = new File(fileName);
- if (toscaFile == null) {
+ if (!toscaFile.exists()) {
throw new TechnicalException("unable to find file : " + fileName);
}
try {
return (LinkedHashMap) mapper.readValue(toscaFile, Object.class);
} catch (IOException e) {
- LOGGER.error("unable to parse tosca file : " + fileName);
- LOGGER.error(e.getMessage());
+ LOGGER.warn("unable to parse tosca file : " + fileName, e);
throw new TechnicalException("Unable to parse tosca file : " + fileName);
} catch (NullPointerException e) {
- LOGGER.error("unable to find tosca file : " + fileName);
- LOGGER.error(e.getMessage());
+ LOGGER.warn("unable to find tosca file : " + fileName, e);
throw new TechnicalException("unable to find tosca file : " + fileName);
}
}
@@ -255,7 +259,7 @@ public class ToscaInfosProcessor {
LOGGER.debug("Done");
} catch (IOException ex) {
- LOGGER.error("Error while unzipping ToscaModel archive from ONAP : " + ex.getMessage());
+ LOGGER.error("Error while unzipping ToscaModel archive from ONAP", ex);
throw new TechnicalException("Error while unzipping ToscaModel archive from ONAP");
}
}
diff --git a/src/main/java/org/onap/nbi/apis/servicecatalog/jolt/FindServiceSpecJsonTransformer.java b/src/main/java/org/onap/nbi/apis/servicecatalog/jolt/FindServiceSpecJsonTransformer.java
index 0046adb..f9b889e 100644
--- a/src/main/java/org/onap/nbi/apis/servicecatalog/jolt/FindServiceSpecJsonTransformer.java
+++ b/src/main/java/org/onap/nbi/apis/servicecatalog/jolt/FindServiceSpecJsonTransformer.java
@@ -1,28 +1,26 @@
/**
- * Copyright (c) 2018 Orange
+ * Copyright (c) 2018 Orange
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
*/
package org.onap.nbi.apis.servicecatalog.jolt;
-import com.bazaarvoice.jolt.Chainr;
-import com.bazaarvoice.jolt.JsonUtils;
-import com.bazaarvoice.jolt.exception.JoltException;
+import java.util.List;
import org.onap.nbi.exceptions.TechnicalException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
-import java.util.List;
+import com.bazaarvoice.jolt.Chainr;
+import com.bazaarvoice.jolt.JsonUtils;
+import com.bazaarvoice.jolt.exception.JoltException;
@Service
public class FindServiceSpecJsonTransformer {
@@ -41,7 +39,7 @@ public class FindServiceSpecJsonTransformer {
try {
output = chainr.transform(serviceSpec);
} catch (JoltException joE) {
- LOGGER.error("Unable to transform SDC response with JOLT Transformer : " + joE.getMessage());
+ LOGGER.error("Unable to transform SDC response with JOLT Transformer", joE);
throw new TechnicalException("Error while parsing ONAP response");
}
return output;
diff --git a/src/main/java/org/onap/nbi/apis/servicecatalog/jolt/GetServiceSpecJsonTransformer.java b/src/main/java/org/onap/nbi/apis/servicecatalog/jolt/GetServiceSpecJsonTransformer.java
index d4c47a2..2032e52 100644
--- a/src/main/java/org/onap/nbi/apis/servicecatalog/jolt/GetServiceSpecJsonTransformer.java
+++ b/src/main/java/org/onap/nbi/apis/servicecatalog/jolt/GetServiceSpecJsonTransformer.java
@@ -1,28 +1,26 @@
/**
- * Copyright (c) 2018 Orange
+ * Copyright (c) 2018 Orange
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
*/
package org.onap.nbi.apis.servicecatalog.jolt;
-import com.bazaarvoice.jolt.Chainr;
-import com.bazaarvoice.jolt.JsonUtils;
-import com.bazaarvoice.jolt.exception.JoltException;
+import java.util.List;
import org.onap.nbi.exceptions.TechnicalException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
-import java.util.List;
+import com.bazaarvoice.jolt.Chainr;
+import com.bazaarvoice.jolt.JsonUtils;
+import com.bazaarvoice.jolt.exception.JoltException;
@Service
public class GetServiceSpecJsonTransformer {
@@ -42,7 +40,7 @@ public class GetServiceSpecJsonTransformer {
try {
output = chainr.transform(serviceSpec);
} catch (JoltException joE) {
- LOGGER.error("Unable to transform SDC response with JOLT Transformer : " + joE.getMessage());
+ LOGGER.error("Unable to transform SDC response with JOLT Transformer", joE);
throw new TechnicalException("Error while parsing ONAP response");
}
return output;
diff --git a/src/main/java/org/onap/nbi/apis/serviceinventory/jolt/FindServiceInventoryJsonTransformer.java b/src/main/java/org/onap/nbi/apis/serviceinventory/jolt/FindServiceInventoryJsonTransformer.java
index 326248e..05f789f 100644
--- a/src/main/java/org/onap/nbi/apis/serviceinventory/jolt/FindServiceInventoryJsonTransformer.java
+++ b/src/main/java/org/onap/nbi/apis/serviceinventory/jolt/FindServiceInventoryJsonTransformer.java
@@ -1,17 +1,15 @@
/**
- * Copyright (c) 2018 Orange
+ * Copyright (c) 2018 Orange
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
*/
package org.onap.nbi.apis.serviceinventory.jolt;
@@ -41,7 +39,7 @@ public class FindServiceInventoryJsonTransformer {
try {
output = chainr.transform(serviceSpec);
} catch (JoltException joE) {
- LOGGER.error("Unable to transform SDC response with JOLT Transformer : " + joE.getMessage());
+ LOGGER.error("Unable to transform SDC response with JOLT Transformer", joE);
throw new TechnicalException("Error while parsing ONAP response");
}
return output;
diff --git a/src/main/java/org/onap/nbi/apis/serviceinventory/jolt/GetServiceInventoryJsonTransformer.java b/src/main/java/org/onap/nbi/apis/serviceinventory/jolt/GetServiceInventoryJsonTransformer.java
index 33a7edf..b1d2566 100644
--- a/src/main/java/org/onap/nbi/apis/serviceinventory/jolt/GetServiceInventoryJsonTransformer.java
+++ b/src/main/java/org/onap/nbi/apis/serviceinventory/jolt/GetServiceInventoryJsonTransformer.java
@@ -1,17 +1,15 @@
/**
- * Copyright (c) 2018 Orange
+ * Copyright (c) 2018 Orange
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
*/
package org.onap.nbi.apis.serviceinventory.jolt;
@@ -42,7 +40,7 @@ public class GetServiceInventoryJsonTransformer {
try {
output = chainr.transform(serviceSpec);
} catch (JoltException joE) {
- LOGGER.error("Unable to transform SDC response with JOLT Transformer : " + joE.getMessage());
+ LOGGER.error("Unable to transform SDC response with JOLT Transformer", joE);
throw new TechnicalException("Error while parsing ONAP response");
}
return output;
diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskManager.java b/src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskManager.java
index c3f29b1..954c1c3 100644
--- a/src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskManager.java
+++ b/src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskManager.java
@@ -1,20 +1,22 @@
/**
- * Copyright (c) 2018 Orange
+ * Copyright (c) 2018 Orange
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
*/
package org.onap.nbi.apis.serviceorder.workflow;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.onap.nbi.apis.serviceorder.model.OrderItemRelationship;
import org.onap.nbi.apis.serviceorder.model.ServiceOrder;
import org.onap.nbi.apis.serviceorder.model.ServiceOrderItem;
@@ -30,10 +32,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
@Service
@EnableScheduling
@@ -100,7 +98,7 @@ public class SOTaskManager {
@Scheduled(fixedRate = 2000)
- private void processExecutionPlan() {
+ private void processExecutionPlan() throws InterruptedException {
List<ExecutionTask> taskToExecute = executionTaskRepository.findByReliedTasksIsEmpty();
for (ExecutionTask executionTask : taskToExecute) {
soTaskProcessor.processOrderItem(executionTask);
diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskProcessor.java b/src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskProcessor.java
index f1d7915..84a198c 100644
--- a/src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskProcessor.java
+++ b/src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskProcessor.java
@@ -1,17 +1,15 @@
/**
- * Copyright (c) 2018 Orange
+ * Copyright (c) 2018 Orange
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
*/
package org.onap.nbi.apis.serviceorder.workflow;
@@ -77,8 +75,10 @@ public class SOTaskProcessor {
/**
* Run the ServiceOrchestrator processing for a serviceOrderItem which with any sub relations
+ *
+ * @throws InterruptedException
*/
- public void processOrderItem(ExecutionTask executionTask) {
+ public void processOrderItem(ExecutionTask executionTask) throws InterruptedException {
ServiceOrderInfoJson serviceOrderInfoJson = executionTask.getServiceOrderInfoJson();
@@ -95,21 +95,31 @@ public class SOTaskProcessor {
serviceOrderInfo =
JsonEntityConverter.convertJsonToServiceOrderInfo(serviceOrderInfoJson.getServiceOrderInfoJson());
} catch (IOException e) {
- LOGGER.error("Unable to read ServiceOrderInfo Json for serviceOrderId " + serviceOrder.getId() + ", "
- + e.getMessage());
+ LOGGER.warn("Unable to read ServiceOrderInfo Json for serviceOrderId " + serviceOrder.getId(), e);
}
- if (StateType.ACKNOWLEDGED == serviceOrderItem.getState()) {
-
- ResponseEntity<CreateServiceInstanceResponse> response = postSORequest(serviceOrderItem, serviceOrderInfo);
+ if (serviceOrderItem != null && StateType.ACKNOWLEDGED == serviceOrderItem.getState()) {
- updateServiceOrderItem(response.getBody(), serviceOrderItem);
+ ResponseEntity<CreateServiceInstanceResponse> response = null;
+ try {
+ response = postSORequest(serviceOrderItem, serviceOrderInfo);
+ } catch (NullPointerException e) {
+ LOGGER.warn("Enable to create service instance for serviceOrderItem.id=" + serviceOrderItem.getId(), e);
+ response = null;
+ }
- if (response.getStatusCode() != HttpStatus.CREATED || response.getBody() == null
- || response.getBody().getRequestReference() == null) {
+ if (response == null) {
+ LOGGER.warn("response=null for serviceOrderItem.id=" + serviceOrderItem.getId());
serviceOrderItem.setState(StateType.FAILED);
} else {
- serviceOrderItem.setState(StateType.INPROGRESS);
+ updateServiceOrderItem(response.getBody(), serviceOrderItem);
+
+ if (response.getStatusCode() != HttpStatus.CREATED || response.getBody() == null
+ || response.getBody().getRequestReference() == null) {
+ serviceOrderItem.setState(StateType.FAILED);
+ } else {
+ serviceOrderItem.setState(StateType.INPROGRESS);
+ }
}
}
@@ -196,8 +206,10 @@ public class SOTaskProcessor {
/**
* * @param orderItem
+ *
+ * @throws InterruptedException
*/
- private void pollSoRequestStatus(ServiceOrderItem orderItem) {
+ private void pollSoRequestStatus(ServiceOrderItem orderItem) throws InterruptedException {
boolean stopPolling = false;
String requestId = orderItem.getRequestId();
GetRequestStatusResponse response = null;
@@ -209,11 +221,7 @@ public class SOTaskProcessor {
if (response.getRequest().getRequestStatus().getPercentProgress() != 100) {
nbRetries++;
orderItem.setState(StateType.INPROGRESS);
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
+ Thread.sleep(1000);
} else if (RequestState.COMPLETE != response.getRequest().getRequestStatus().getRequestState()) {
orderItem.setState(StateType.FAILED);
stopPolling = true;
@@ -272,8 +280,8 @@ public class SOTaskProcessor {
}
/**
- * Build a list of UserParams for the SO request by browsing a list of ServiceCharacteristics
- * from SDC
+ * Build a list of UserParams for the SO request by browsing a list of ServiceCharacteristics from
+ * SDC
*
* @param characteristics
* @return
@@ -294,8 +302,7 @@ public class SOTaskProcessor {
/**
- * Update ServiceOrderItem with SO response by using serviceOrderRepository with the
- * serviceOrderId
+ * Update ServiceOrderItem with SO response by using serviceOrderRepository with the serviceOrderId
*
* @param createServiceInstanceResponse
* @param orderItem
diff --git a/src/main/java/org/onap/nbi/commons/BeanUtils.java b/src/main/java/org/onap/nbi/commons/BeanUtils.java
index 9cab9f7..164ed83 100644
--- a/src/main/java/org/onap/nbi/commons/BeanUtils.java
+++ b/src/main/java/org/onap/nbi/commons/BeanUtils.java
@@ -1,27 +1,29 @@
/**
- * Copyright (c) 2018 Orange
+ * Copyright (c) 2018 Orange
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
*/
package org.onap.nbi.commons;
import org.apache.commons.beanutils.PropertyUtilsBean;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
*/
public class BeanUtils {
+ private static final Logger LOGGER = LoggerFactory.getLogger(BeanUtils.class);
+
private static final PropertyUtilsBean PUB = new PropertyUtilsBean();
/**
@@ -34,6 +36,7 @@ public class BeanUtils {
try {
return BeanUtils.PUB.getNestedProperty(bean, name);
} catch (Exception e) {
+ LOGGER.warn("Enable to retrieve nested property name=" + name, e);
return null;
}
}
@@ -48,6 +51,7 @@ public class BeanUtils {
try {
BeanUtils.PUB.setNestedProperty(bean, name, value);
} catch (Exception ex) {
+ LOGGER.warn("Enable to set nested property name=" + name + " value=" + value, ex);
}
}