aboutsummaryrefslogtreecommitdiffstats
path: root/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentPersistService.java
diff options
context:
space:
mode:
Diffstat (limited to 'blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentPersistService.java')
-rw-r--r--blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentPersistService.java55
1 files changed, 29 insertions, 26 deletions
diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentPersistService.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentPersistService.java
index e27d57a79..320f4369b 100644
--- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentPersistService.java
+++ b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/config/assignment/service/ConfigAssignmentPersistService.java
@@ -1,15 +1,18 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
- * 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
*
- * 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.ccsdk.config.assignment.service;
@@ -31,59 +34,59 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
public class ConfigAssignmentPersistService {
-
+
private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigAssignmentPersistService.class);
-
+
private ConfigResourceService configResourceService;
-
+
public ConfigAssignmentPersistService(ConfigResourceService configResourceService) {
this.configResourceService = configResourceService;
}
-
+
public void saveResourceMapping(org.onap.ccsdk.config.assignment.data.ResourceAssignmentData resourceAssignmentData,
String templateName, List<ResourceAssignment> resourceAssignments) throws SvcLogicException {
try {
-
+
if (resourceAssignmentData == null) {
throw new SvcLogicException("Resource assignment data is missing");
}
-
+
if (StringUtils.isBlank(resourceAssignmentData.getRequestId())) {
logger.warn("Request Id ({}) is missing, may be getting request for resource update.",
resourceAssignmentData.getRequestId());
}
-
+
if (StringUtils.isBlank(resourceAssignmentData.getResourceId())) {
throw new SvcLogicException("Resource Id is missing");
}
-
+
if (StringUtils.isBlank(resourceAssignmentData.getResourceType())) {
throw new SvcLogicException("Resource type is missing");
}
-
+
if (StringUtils.isBlank(resourceAssignmentData.getActionName())) {
throw new SvcLogicException("Action name is missing");
}
-
+
if (StringUtils.isBlank(templateName)) {
throw new SvcLogicException("template name is missing");
}
-
+
StringBuilder builder = new StringBuilder();
builder.append("Resource Assignment for Template Name :");
builder.append(templateName);
builder.append("\n");
builder.append(TransformationUtils.getJson(resourceAssignments, true));
-
+
configResourceService.save(new TransactionLog(resourceAssignmentData.getRequestId(),
DataAdaptorConstants.LOG_MESSAGE_TYPE_LOG, builder.toString()));
-
+
// Resource Data should be Regenerated based on the new Updates
String resourceData = ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignments);
-
+
List<ResourceAssignmentData> resourceAssignmentDataList =
ConfigAssignmentUtils.convertResoureAssignmentList(resourceAssignments);
-
+
ConfigResource configResource = new ConfigResource();
configResource.setRequestId(resourceAssignmentData.getRequestId());
configResource.setServiceTemplateName(resourceAssignmentData.getServiceTemplateName());
@@ -95,14 +98,14 @@ public class ConfigAssignmentPersistService {
configResource.setTemplateName(templateName);
configResource.setStatus(ConfigModelConstant.STATUS_SUCCESS);
configResource.setUpdatedBy(ConfigModelConstant.USER_SYSTEM);
-
+
if (CollectionUtils.isNotEmpty(resourceAssignmentDataList)) {
configResource.setResourceAssignments(resourceAssignmentDataList);
}
configResource = configResourceService.saveConfigResource(configResource);
logger.info("Resource data saved successfully for the template ({}) with resource id ({})", templateName,
configResource.getResourceId());
-
+
builder = new StringBuilder();
builder.append("Resource Data Template Name :");
builder.append(templateName);
@@ -110,11 +113,11 @@ public class ConfigAssignmentPersistService {
builder.append(resourceData);
configResourceService.save(new TransactionLog(resourceAssignmentData.getRequestId(),
DataAdaptorConstants.LOG_MESSAGE_TYPE_LOG, builder.toString()));
-
+
} catch (Exception e) {
throw new SvcLogicException("ConfigAssignmentPersistService : " + e.getMessage(), e);
}
-
+
}
-
+
}