/**
- * 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;
}
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;
/**
- * 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;
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"));
+ }
}
}
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);
}
}
}
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);
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);
}
}
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");
}
}
/**
- * 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 {
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;
/**
- * 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 {
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;
/**
- * 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;
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;
/**
- * 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;
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;
/**
- * 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;
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
@Scheduled(fixedRate = 2000)
- private void processExecutionPlan() {
+ private void processExecutionPlan() throws InterruptedException {
List<ExecutionTask> taskToExecute = executionTaskRepository.findByReliedTasksIsEmpty();
for (ExecutionTask executionTask : taskToExecute) {
soTaskProcessor.processOrderItem(executionTask);
/**
- * 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;
/**
* 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();
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);
+ }
}
}
/**
* * @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;
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;
}
/**
- * 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
/**
- * 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
/**
- * 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();
/**
try {
return BeanUtils.PUB.getNestedProperty(bean, name);
} catch (Exception e) {
+ LOGGER.warn("Enable to retrieve nested property name=" + name, e);
return null;
}
}
try {
BeanUtils.PUB.setNestedProperty(bean, name, value);
} catch (Exception ex) {
+ LOGGER.warn("Enable to set nested property name=" + name + " value=" + value, ex);
}
}