Add collaboration feature
Issue-ID: SDC-767
Change-Id: I14fb4c1f54086ed03a56a7ff7fab9ecd40381795
Signed-off-by: talig <talig@amdocs.com>
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/ActionsForSwaggerFileUpload.java b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/ActionsForSwaggerFileUpload.java
index 5dc79eb..5a7232b 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/ActionsForSwaggerFileUpload.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/ActionsForSwaggerFileUpload.java
@@ -26,7 +26,6 @@
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
import org.springframework.validation.annotation.Validated;
-import java.io.InputStream;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.HeaderParam;
@@ -38,6 +37,7 @@
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import java.io.InputStream;
@Path("/workflow/v1.0/actions")
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java
index 875b515..b186852 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java
@@ -31,7 +31,11 @@
import org.openecomp.sdc.action.errors.ActionException;
import org.openecomp.sdc.action.logging.CategoryLogLevel;
import org.openecomp.sdc.action.logging.StatusCode;
-import org.openecomp.sdc.action.types.*;
+import org.openecomp.sdc.action.types.Action;
+import org.openecomp.sdc.action.types.ActionArtifact;
+import org.openecomp.sdc.action.types.ActionArtifactProtection;
+import org.openecomp.sdc.action.types.ActionRequest;
+import org.openecomp.sdc.action.types.OpenEcompComponent;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdcrests.action.rest.Actions;
@@ -53,11 +57,85 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
-import static org.openecomp.sdc.action.ActionConstants.*;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.*;
-import static org.openecomp.sdc.action.util.ActionUtil.*;
+import static org.openecomp.sdc.action.ActionConstants.ACTION_REQUEST_PARAM_NAME;
+import static org.openecomp.sdc.action.ActionConstants.ACTION_REQUEST_PARAM_SUPPORTED_MODELS;
+import static org.openecomp.sdc.action.ActionConstants.ARTIFACT_FILE;
+import static org.openecomp.sdc.action.ActionConstants.ARTIFACT_NAME;
+import static org.openecomp.sdc.action.ActionConstants.BE_FQDN;
+import static org.openecomp.sdc.action.ActionConstants.CATEGORY_LOG_LEVEL;
+import static org.openecomp.sdc.action.ActionConstants.CLIENT_IP;
+import static org.openecomp.sdc.action.ActionConstants.ERROR_DESCRIPTION;
+import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_CATEGORY;
+import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_MODEL;
+import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_NAME;
+import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_NONE;
+import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_OPEN_ECOMP_COMPONENT;
+import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_VENDOR;
+import static org.openecomp.sdc.action.ActionConstants.INSTANCE_UUID;
+import static org.openecomp.sdc.action.ActionConstants.LOCAL_ADDR;
+import static org.openecomp.sdc.action.ActionConstants.MAX_ACTION_ARTIFACT_SIZE;
+import static org.openecomp.sdc.action.ActionConstants.MDC_ASDC_INSTANCE_UUID;
+import static org.openecomp.sdc.action.ActionConstants.PARTNER_NAME;
+import static org.openecomp.sdc.action.ActionConstants.REMOTE_HOST;
+import static org.openecomp.sdc.action.ActionConstants.REQUEST_EMPTY_BODY;
+import static org.openecomp.sdc.action.ActionConstants.REQUEST_ID;
+import static org.openecomp.sdc.action.ActionConstants.REQUEST_TYPE_CREATE_ACTION;
+import static org.openecomp.sdc.action.ActionConstants.REQUEST_TYPE_UPDATE_ACTION;
+import static org.openecomp.sdc.action.ActionConstants.REQUEST_TYPE_VERSION_ACTION;
+import static org.openecomp.sdc.action.ActionConstants.SERVICE_INSTANCE_ID;
+import static org.openecomp.sdc.action.ActionConstants.SERVICE_METRIC_BEGIN_TIMESTAMP;
+import static org.openecomp.sdc.action.ActionConstants.SERVICE_NAME;
+import static org.openecomp.sdc.action.ActionConstants.STATUS;
+import static org.openecomp.sdc.action.ActionConstants.STATUS_CODE;
+import static org.openecomp.sdc.action.ActionConstants.SUPPORTED_COMPONENTS_ID;
+import static org.openecomp.sdc.action.ActionConstants.SUPPORTED_MODELS_VERSION_ID;
+import static org.openecomp.sdc.action.ActionConstants.TARGET_ENTITY;
+import static org.openecomp.sdc.action.ActionConstants.TARGET_ENTITY_API;
+import static org.openecomp.sdc.action.ActionConstants.TARGET_SERVICE_NAME;
+import static org.openecomp.sdc.action.ActionConstants.TIMESTAMP;
+import static org.openecomp.sdc.action.ActionConstants.UPDATED_BY;
+import static org.openecomp.sdc.action.ActionConstants.X_OPEN_ECOMP_INSTANCE_ID_HEADER_PARAM;
+import static org.openecomp.sdc.action.ActionConstants.X_OPEN_ECOMP_REQUEST_ID_HEADER_PARAM;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_CHECKSUM_ERROR_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_INVALID_NAME;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_INVALID_NAME_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_INVALID_PROTECTION_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_READ_FILE_ERROR;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_TOO_BIG_ERROR;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_TOO_BIG_ERROR_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_NOT_EXIST;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_NOT_EXIST_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_FILTER_MULTIPLE_QUERY_PARAM_NOT_SUPPORTED;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INTERNAL_SERVER_ERR_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INVALID_INSTANCE_ID_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INVALID_PARAM_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INVALID_REQUEST_BODY_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INVALID_REQUEST_ID_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INVALID_SEARCH_CRITERIA;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_MULT_SEARCH_CRITERIA;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_ARTIFACT_CHECKSUM_ERROR;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_ARTIFACT_INVALID_PROTECTION_VALUE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_ARTIFACT_OPERATION_ALLOWED;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_BODY_EMPTY;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_CONTENT_TYPE_INVALID;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_FILTER_PARAM_INVALID;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_INVALID_GENERIC_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_INVALID_NAME;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_MISSING_MANDATORY_PARAM;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_OPEN_ECOMP_INSTANCE_ID_INVALID;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_OPEN_ECOMP_REQUEST_ID_INVALID;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_UNSUPPORTED_OPERATION;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_UPDATE_NOT_ALLOWED_CODE;
+import static org.openecomp.sdc.action.util.ActionUtil.actionErrorLogProcessor;
+import static org.openecomp.sdc.action.util.ActionUtil.actionLogPostProcessor;
+import static org.openecomp.sdc.action.util.ActionUtil.getUtcDateStringFromTimestamp;
/**
* Implements various CRUD API that can be performed on Action
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/ActivityLog.java b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/ActivityLog.java
deleted file mode 100644
index be4cc1b..0000000
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/ActivityLog.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdcrests.activitylog.rest;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import org.openecomp.sdcrests.activitylog.types.ActivityLogDto;
-import org.springframework.validation.annotation.Validated;
-
-import javax.validation.constraints.NotNull;
-import javax.ws.rs.*;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
-import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
-
-
-@Path("/v1.0/activity-logs")
-@Produces(MediaType.APPLICATION_JSON)
-@Consumes(MediaType.APPLICATION_JSON)
-@Api(value = "Item Activity Log")
-@Validated
-public interface ActivityLog {
-
- @GET
- @Path("/{itemId}/versions/{versionId}")
- @ApiOperation(value = "List actions log of item",
- response = ActivityLogDto.class,
- responseContainer = "List")
- Response getActivityLog(@ApiParam("Item Id") @PathParam("itemId") String itemId,
- @ApiParam("Version Id") @PathParam("versionId") String versionId,
- @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
- String user);
-
-}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/services/ActivityLogImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/services/ActivityLogImpl.java
deleted file mode 100644
index c42d72b..0000000
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/services/ActivityLogImpl.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdcrests.activitylog.rest.services;
-
-import org.openecomp.sdc.activityLog.ActivityLogManager;
-import org.openecomp.sdc.activityLog.ActivityLogManagerFactory;
-import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
-import org.openecomp.sdc.logging.context.MdcUtil;
-import org.openecomp.sdc.logging.types.LoggerServiceName;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdcrests.activitylog.rest.ActivityLog;
-import org.openecomp.sdcrests.activitylog.rest.mapping.MapActivityLogEntityToActivityLogDto;
-import org.openecomp.sdcrests.activitylog.types.ActivityLogDto;
-import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Service;
-
-import javax.inject.Named;
-import javax.ws.rs.core.Response;
-import java.util.Collection;
-
-@Named
-@Service("activityLog")
-@Scope(value = "prototype")
-public class ActivityLogImpl implements ActivityLog {
-
- private ActivityLogManager activityLogManager =
- ActivityLogManagerFactory.getInstance().createInterface();
-
-
- @Override
- public Response getActivityLog(String vspId, String versionId, String user) {
- MdcUtil.initMdc(LoggerServiceName.Get_List_Activity_Log.toString());
-
- Collection<ActivityLogEntity> activityLogs =
- activityLogManager.listActivityLogs(vspId, Version.valueOf(versionId), user);
-
- MapActivityLogEntityToActivityLogDto mapper = new MapActivityLogEntityToActivityLogDto();
- GenericCollectionWrapper<ActivityLogDto> results = new GenericCollectionWrapper<>();
- for (ActivityLogEntity activityLog : activityLogs) {
- results.add(mapper.applyMapping(activityLog, ActivityLogDto.class));
- }
-
- return Response.ok(results).build();
- }
-}
-
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/pom.xml
deleted file mode 100644
index 70f029a..0000000
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/pom.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>activity-log-rest-types</artifactId>
-
- <parent>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>activity-log-rest</artifactId>
- <version>1.2.0-SNAPSHOT</version>
- </parent>
-
-</project>
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityLogDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityLogDto.java
deleted file mode 100644
index dde5795..0000000
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityLogDto.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdcrests.activitylog.types;
-
-
-
-import java.util.Date;
-
-public class ActivityLogDto {
-
- private String id;
- private Date timestamp;
- private String type;
- private String comment;
- private String user;
- private ActivityStatus status;
-
- public ActivityLogDto(){}
-
- public String getId() { return id; }
-
- public void setId(String id) { this.id = id; }
-
- public Date getTimestamp() {
- return timestamp;
- }
-
- public void setTimestamp(Date timestamp) {
- this.timestamp = timestamp;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getComment() {
- return comment;
- }
-
- public void setComment(String comment) {
- this.comment = comment;
- }
-
- public String getUser() {
- return user;
- }
-
- public void setUser(String user) {
- this.user = user;
- }
-
- public ActivityStatus getStatus() {
- return status;
- }
-
- public void setStatus(ActivityStatus status) {
- this.status = status;
- }
-}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityType.java b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityType.java
deleted file mode 100644
index 80160bc..0000000
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityType.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdcrests.activitylog.types;
-
-import java.io.Serializable;
-
-public enum ActivityType implements Serializable {
-
- CREATE_NEW("Create New"),
- CHECKOUT("Check Out"),
- UNDO_CHECKOUT("Undo Check Out"),
- CHECKIN("Check In"),
- UPLOAD_HEAT("Upload Heat"),
- UPLOAD_MONITORING_FILE("Upload Monitoring File"),
- SUBMIT("Submit");
-
- // after collaboration will be added - this will be added:
- /*
- CREATE_NEW,
- COMMIT,
- ADD_PERMISSION,
- REMOVE_PERMISSION,
- */
-
- private String name;
-
- ActivityType(String name) {
- this.name = name;
- }
-
- @Override
- public String toString() {
- return name;
- }
-}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/ApplicationConfiguration.java b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/ApplicationConfiguration.java
index 6c95a14..6042060 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/ApplicationConfiguration.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/ApplicationConfiguration.java
@@ -26,7 +26,6 @@
import org.openecomp.sdcrests.applicationconfiguration.types.ConfigurationDataDto;
import org.springframework.validation.annotation.Validated;
-import java.io.InputStream;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
@@ -36,6 +35,7 @@
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import java.io.InputStream;
@Path("/v1.0/application-configuration")
@Produces(MediaType.APPLICATION_JSON)
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/services/ApplicationConfigurationImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/services/ApplicationConfigurationImpl.java
index c7f3f25..27557e1 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/services/ApplicationConfigurationImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/services/ApplicationConfigurationImpl.java
@@ -38,10 +38,10 @@
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
-import java.io.InputStream;
-import java.util.Collection;
import javax.inject.Named;
import javax.ws.rs.core.Response;
+import java.io.InputStream;
+import java.util.Collection;
/**
* Created by Talio on 8/8/2016.
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/pom.xml
similarity index 68%
copy from openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/pom.xml
copy to openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/pom.xml
index 10685db..534aea1 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/pom.xml
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/pom.xml
@@ -4,55 +4,55 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
- <artifactId>activity-log-rest-services</artifactId>
-
<parent>
<groupId>org.openecomp.sdc</groupId>
- <artifactId>activity-log-rest</artifactId>
+ <artifactId>conflict-rest</artifactId>
<version>1.2.0-SNAPSHOT</version>
</parent>
+ <artifactId>conflict-rest-services</artifactId>
+
+
+
<dependencies>
-
<dependency>
- <groupId>javax.ws.rs</groupId>
- <artifactId>javax.ws.rs-api</artifactId>
- <version>${ws.rs.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <version>${spring.framework.version}</version>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-common-rest</artifactId>
+ <version>${project.version}</version>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
- <dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-activity-log-manager</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>activity-log-rest-types</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-common-rest</artifactId>
- <version>${project.version}</version>
- </dependency>
<!-- CXF -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<version>${cxf.version}</version>
</dependency>
-
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-conflict-manager</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>conflict-rest-types</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.onboarding</groupId>
+ <artifactId>vendor-software-products-rest-services</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.onboarding</groupId>
+ <artifactId>vendor-license-rest-services</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
-</project>
+</project>
\ No newline at end of file
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/Conflicts.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/Conflicts.java
new file mode 100644
index 0000000..396c4ee
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/Conflicts.java
@@ -0,0 +1,61 @@
+package org.openecomp.sdcrests.conflict.rest;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.openecomp.sdcrests.common.RestConstants;
+import org.openecomp.sdcrests.conflict.types.ConflictDto;
+import org.openecomp.sdcrests.conflict.types.ConflictResolutionDto;
+import org.openecomp.sdcrests.conflict.types.ItemVersionConflictDto;
+import org.springframework.validation.annotation.Validated;
+
+import javax.validation.constraints.NotNull;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+@Path("/v1.0/items/{itemId}/versions/{versionId}/conflicts")
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+@Api(value = "Item Version Conflicts")
+@Validated
+public interface Conflicts {
+
+ @GET
+ @Path("/")
+ @ApiOperation(value = "item version conflicts",
+ notes = "Item version private copy conflicts against its public copy",
+ response = ItemVersionConflictDto.class)
+ Response getConflict(@ApiParam("Item Id") @PathParam("itemId") String itemId,
+ @ApiParam("Version Id") @PathParam("versionId") String versionId,
+ @NotNull(message = RestConstants.USER_MISSING_ERROR_MSG)
+ @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user);
+
+ @GET
+ @Path("/{conflictId}")
+ @ApiOperation(value = "Gets item version conflict",
+ notes = "Gets an item version private copy conflict against its public copy",
+ response = ConflictDto.class)
+ Response getConflict(@ApiParam("Item Id") @PathParam("itemId") String itemId,
+ @ApiParam("Version Id") @PathParam("versionId") String versionId,
+ @ApiParam("Version Id") @PathParam("conflictId") String conflictId,
+ @NotNull(message = RestConstants.USER_MISSING_ERROR_MSG)
+ @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user);
+
+ @PUT
+ @Path("/{conflictId}")
+ @ApiOperation(value = "Resolves item version conflict",
+ notes = "Resolves an item version private copy conflict against its public copy")
+ Response resolveConflict(ConflictResolutionDto conflictResolution,
+ @ApiParam("Item Id") @PathParam("itemId") String itemId,
+ @ApiParam("Version Id") @PathParam("versionId") String versionId,
+ @ApiParam("Version Id") @PathParam("conflictId") String conflictId,
+ @NotNull(message = RestConstants.USER_MISSING_ERROR_MSG)
+ @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user);
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictInfoToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictInfoToDto.java
new file mode 100644
index 0000000..e80ef56
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictInfoToDto.java
@@ -0,0 +1,14 @@
+package org.openecomp.sdcrests.conflict.rest.mapping;
+
+import org.openecomp.conflicts.types.ConflictInfo;
+import org.openecomp.sdcrests.conflict.types.ConflictInfoDto;
+import org.openecomp.sdcrests.mapping.MappingBase;
+
+public class MapConflictInfoToDto extends MappingBase<ConflictInfo, ConflictInfoDto> {
+ @Override
+ public void doMapping(ConflictInfo source, ConflictInfoDto target) {
+ target.setId(source.getId());
+ target.setType(source.getType());
+ target.setName(source.getName());
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictToDto.java
new file mode 100644
index 0000000..83a0f52
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictToDto.java
@@ -0,0 +1,134 @@
+package org.openecomp.sdcrests.conflict.rest.mapping;
+
+import org.openecomp.conflicts.types.Conflict;
+import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
+import org.openecomp.sdcrests.conflict.types.ConflictDto;
+import org.openecomp.sdcrests.mapping.EchoMapMapping;
+import org.openecomp.sdcrests.mapping.MappingBase;
+import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapEntitlementPoolEntityToEntitlementPoolEntityDto;
+import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapFeatureGroupEntityToFeatureGroupDescriptorDto;
+import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapLicenseAgreementEntityToLicenseAgreementDescriptorDto;
+import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto;
+import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapLimitEntityToLimitDto;
+import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapVendorLicenseModelEntityToDto;
+import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolEntityDto;
+import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupDescriptorDto;
+import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementDescriptorDto;
+import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupEntityDto;
+import org.openecomp.sdcrests.vendorlicense.types.LimitEntityDto;
+import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelEntityDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyModel;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.FileDataStructureDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessEntityDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspComputeDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDetailsDto;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentDependencyModelEntityToDto;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentEntityToComponentDto;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapComputeEntityToVspComputeDto;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapDeploymentFlavorEntityToDeploymentFlavorDto;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapFilesDataStructureToDto;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapImageEntityToImageDto;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapNetworkEntityToNetworkDto;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapNicEntityToNicDto;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapProcessEntityToProcessEntityDto;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapQuestionnaireToQuestionnaireDto;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapVspDetailsToDto;
+
+import java.util.AbstractMap;
+import java.util.HashMap;
+import java.util.Map;
+
+public class MapConflictToDto extends MappingBase<Conflict, ConflictDto> {
+
+ @Override
+ public void doMapping(Conflict source, ConflictDto target) {
+ target.setId(source.getId());
+ target.setType(source.getType());
+ target.setName(source.getName());
+
+ Map.Entry<MappingBase, Class> mapperToTargetClass = getMapper(source.getType());
+ target.setTheirs(map(mapperToTargetClass, source.getTheirs()));
+ target.setYours(map(mapperToTargetClass, source.getYours()));
+ }
+
+ private Map map(Map.Entry<MappingBase, Class> mapperToTargetClass, Object object) {
+ return JsonUtil
+ .json2Object(JsonUtil.object2Json(
+ mapperToTargetClass.getKey().applyMapping(object, mapperToTargetClass.getValue())),
+ Map.class);
+ }
+
+ private Map.Entry<MappingBase, Class> getMapper(ElementType type) {
+ switch (type) {
+ case VendorLicenseModel:
+ return new AbstractMap.SimpleEntry<>(new MapVendorLicenseModelEntityToDto(),
+ VendorLicenseModelEntityDto.class);
+ case LicenseAgreement:
+ return new AbstractMap.SimpleEntry<>(
+ new MapLicenseAgreementEntityToLicenseAgreementDescriptorDto(),
+ LicenseAgreementDescriptorDto.class);
+ case FeatureGroup:
+ return new AbstractMap.SimpleEntry<>(new MapFeatureGroupEntityToFeatureGroupDescriptorDto(),
+ FeatureGroupDescriptorDto.class);
+ case LicenseKeyGroup:
+ return new AbstractMap.SimpleEntry<>(
+ new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto(), LicenseKeyGroupEntityDto
+ .class);
+ case EntitlementPool:
+ return new AbstractMap.SimpleEntry<>(
+ new MapEntitlementPoolEntityToEntitlementPoolEntityDto(), EntitlementPoolEntityDto
+ .class);
+ case Limit:
+ return new AbstractMap.SimpleEntry<>(new MapLimitEntityToLimitDto(), LimitEntityDto.class);
+ case VendorSoftwareProduct:
+ return new AbstractMap.SimpleEntry<>(new MapVspDetailsToDto(), VspDetailsDto.class);
+ case Network:
+ return new AbstractMap.SimpleEntry<>(new MapNetworkEntityToNetworkDto(), NetworkDto.class);
+ case Component:
+ return new AbstractMap.SimpleEntry<>(new MapComponentEntityToComponentDto(),
+ ComponentDto.class);
+ case ComponentDependencies:
+ return new AbstractMap.SimpleEntry<>(new MapComponentDependencyModelEntityToDto(),
+ ComponentDependencyModel.class);
+ case Nic:
+ return new AbstractMap.SimpleEntry<>(new MapNicEntityToNicDto(), NicDto.class);
+ case Process:
+ return new AbstractMap.SimpleEntry<>(new MapProcessEntityToProcessEntityDto(),
+ ProcessEntityDto.class);
+ case DeploymentFlavor:
+ return new AbstractMap.SimpleEntry<>(new MapDeploymentFlavorEntityToDeploymentFlavorDto(),
+ DeploymentFlavorDto.class);
+ case Compute:
+ return new AbstractMap.SimpleEntry<>(new MapComputeEntityToVspComputeDto(),
+ VspComputeDto.class);
+ case Image:
+ return new AbstractMap.SimpleEntry<>(new MapImageEntityToImageDto(), ImageDto.class);
+ case VSPQuestionnaire:
+ case NicQuestionnaire:
+ case ComponentQuestionnaire:
+ case ImageQuestionnaire:
+ case ComputeQuestionnaire:
+ return new AbstractMap.SimpleEntry<>(new MapQuestionnaireToQuestionnaireDto(),
+ QuestionnaireDto.class);
+ case SNMP_POLL:
+ case SNMP_TRAP:
+ case VES_EVENTS:
+ case OrchestrationTemplateCandidate:
+ return new AbstractMap.SimpleEntry<>(new MapFilesDataStructureToDto(),
+ FileDataStructureDto.class);
+ case ServiceModel:
+ case NetworkPackage:
+ return new AbstractMap.SimpleEntry<>(new EchoMapMapping(), HashMap.class);
+ case itemVersion:
+ return new AbstractMap.SimpleEntry<>(new EchoMapMapping(), HashMap.class);
+ }
+ throw new RuntimeException("Get conflict does not support element type: " + type.name());
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapDtoToConflictResolution.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapDtoToConflictResolution.java
new file mode 100644
index 0000000..1a03a6b
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapDtoToConflictResolution.java
@@ -0,0 +1,15 @@
+package org.openecomp.sdcrests.conflict.rest.mapping;
+
+import org.openecomp.conflicts.types.ConflictResolution;
+import org.openecomp.sdcrests.conflict.types.ConflictResolutionDto;
+import org.openecomp.sdcrests.mapping.MappingBase;
+
+public class MapDtoToConflictResolution
+ extends MappingBase<ConflictResolutionDto, ConflictResolution> {
+
+ @Override
+ public void doMapping(ConflictResolutionDto source, ConflictResolution target) {
+ target.setResolution(source.getResolution());
+ target.setOtherResolution(source.getOtherResolution());
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapItemVersionConflictToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapItemVersionConflictToDto.java
new file mode 100644
index 0000000..fb5d013
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapItemVersionConflictToDto.java
@@ -0,0 +1,22 @@
+package org.openecomp.sdcrests.conflict.rest.mapping;
+
+
+import org.openecomp.conflicts.types.ItemVersionConflict;
+import org.openecomp.sdcrests.conflict.types.ConflictDto;
+import org.openecomp.sdcrests.conflict.types.ConflictInfoDto;
+import org.openecomp.sdcrests.conflict.types.ItemVersionConflictDto;
+import org.openecomp.sdcrests.mapping.MappingBase;
+
+public class MapItemVersionConflictToDto
+ extends MappingBase<ItemVersionConflict, ItemVersionConflictDto> {
+
+ @Override
+ public void doMapping(ItemVersionConflict source, ItemVersionConflictDto target) {
+ target
+ .setConflict(new MapConflictToDto().applyMapping(source.getVersionConflict(), ConflictDto.class));
+
+ MapConflictInfoToDto conflictInfoMapper = new MapConflictInfoToDto();
+ source.getElementConflicts().forEach(conflictInfo -> target
+ .addConflictInfo(conflictInfoMapper.applyMapping(conflictInfo, ConflictInfoDto.class)));
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/services/ConflictsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/services/ConflictsImpl.java
new file mode 100644
index 0000000..fda12ef
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/services/ConflictsImpl.java
@@ -0,0 +1,62 @@
+package org.openecomp.sdcrests.conflict.rest.services;
+
+import org.openecomp.conflicts.types.Conflict;
+import org.openecomp.conflicts.types.ConflictResolution;
+import org.openecomp.conflicts.types.ItemVersionConflict;
+import org.openecomp.sdc.conflicts.ConflictsManager;
+import org.openecomp.sdc.conflicts.ConflictsManagerFactory;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdcrests.conflict.rest.Conflicts;
+import org.openecomp.sdcrests.conflict.rest.mapping.MapConflictToDto;
+import org.openecomp.sdcrests.conflict.rest.mapping.MapDtoToConflictResolution;
+import org.openecomp.sdcrests.conflict.rest.mapping.MapItemVersionConflictToDto;
+import org.openecomp.sdcrests.conflict.types.ConflictDto;
+import org.openecomp.sdcrests.conflict.types.ConflictResolutionDto;
+import org.openecomp.sdcrests.conflict.types.ItemVersionConflictDto;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
+import javax.inject.Named;
+import javax.ws.rs.core.Response;
+
+@Named
+@Service("conflicts")
+@Scope(value = "prototype")
+public class ConflictsImpl implements Conflicts {
+
+ @Override
+ public Response getConflict(String itemId, String versionId, String user) {
+
+ ConflictsManager conflictsManager = ConflictsManagerFactory.getInstance().createInterface();
+ ItemVersionConflict itemVersionConflict = conflictsManager.getConflict
+ (itemId, new Version(versionId));
+ ItemVersionConflictDto result = (new MapItemVersionConflictToDto()).applyMapping
+ (itemVersionConflict, ItemVersionConflictDto.class);
+ return Response.ok(result).build();
+ }
+
+ @Override
+ public Response getConflict(String itemId, String versionId, String conflictId, String user) {
+ ConflictsManager conflictsManager = ConflictsManagerFactory.getInstance().createInterface();
+ Conflict conflict = conflictsManager.getConflict(itemId, new Version(versionId), conflictId);
+
+ ConflictDto result = new MapConflictToDto().applyMapping(conflict, ConflictDto.class);
+
+ return Response.ok(result).build();
+
+ }
+
+ @Override
+ public Response resolveConflict(ConflictResolutionDto conflictResolution, String itemId,
+ String versionId, String conflictId, String user) {
+ ConflictsManager conflictsManager = ConflictsManagerFactory.getInstance().createInterface();
+
+ Version version = new Version(versionId);
+ conflictsManager.resolveConflict(itemId, version, conflictId,
+ new MapDtoToConflictResolution()
+ .applyMapping(conflictResolution, ConflictResolution.class));
+ conflictsManager.finalizeMerge(itemId, version);
+
+ return Response.ok().build();
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/pom.xml
new file mode 100644
index 0000000..e016933
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/pom.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>conflict-rest</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>conflict-rest-types</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-conflict-manager</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictDto.java
new file mode 100644
index 0000000..47f0abd
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictDto.java
@@ -0,0 +1,24 @@
+package org.openecomp.sdcrests.conflict.types;
+
+import java.util.Map;
+
+public class ConflictDto extends ConflictInfoDto {
+ private Map<String, Object> yours;
+ private Map<String, Object> theirs;
+
+ public Map<String, Object> getYours() {
+ return yours;
+ }
+
+ public void setYours(Map<String, Object> yours) {
+ this.yours = yours;
+ }
+
+ public Map<String, Object> getTheirs() {
+ return theirs;
+ }
+
+ public void setTheirs(Map<String, Object> theirs) {
+ this.theirs = theirs;
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictInfoDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictInfoDto.java
new file mode 100644
index 0000000..e2e842a
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictInfoDto.java
@@ -0,0 +1,33 @@
+package org.openecomp.sdcrests.conflict.types;
+
+import org.openecomp.sdc.datatypes.model.ElementType;
+
+public class ConflictInfoDto {
+ private String id;
+ private ElementType type;
+ private String name;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public ElementType getType() {
+ return type;
+ }
+
+ public void setType(ElementType type) {
+ this.type = type;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictResolutionDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictResolutionDto.java
new file mode 100644
index 0000000..1aaf18f
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictResolutionDto.java
@@ -0,0 +1,27 @@
+package org.openecomp.sdcrests.conflict.types;
+
+import org.openecomp.conflicts.types.Resolution;
+
+import java.util.Map;
+
+public class ConflictResolutionDto {
+ private Resolution resolution;
+ // sits in lower level...
+ private Map<String, Object> otherResolution;
+
+ public Resolution getResolution() {
+ return resolution;
+ }
+
+ public void setResolution(Resolution resolution) {
+ this.resolution = resolution;
+ }
+
+ public Map<String, Object> getOtherResolution() {
+ return otherResolution;
+ }
+
+ public void setOtherResolution(Map<String, Object> otherResolution) {
+ this.otherResolution = otherResolution;
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ItemVersionConflictDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ItemVersionConflictDto.java
new file mode 100644
index 0000000..3dbfcf0
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ItemVersionConflictDto.java
@@ -0,0 +1,29 @@
+package org.openecomp.sdcrests.conflict.types;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+public class ItemVersionConflictDto{
+ private ConflictDto conflict;
+ private Collection<ConflictInfoDto> conflictInfoList = new ArrayList<>();
+
+ public ConflictDto getConflict() {
+ return conflict;
+ }
+
+ public void setConflict(ConflictDto conflict) {
+ this.conflict = conflict;
+ }
+
+ public Collection<ConflictInfoDto> getConflictInfoList() {
+ return conflictInfoList;
+ }
+
+ public void setConflictInfoList(Collection<ConflictInfoDto> conflictInfoList) {
+ this.conflictInfoList = conflictInfoList;
+ }
+
+ public void addConflictInfo(ConflictInfoDto conflictInfo){
+ conflictInfoList.add(conflictInfo);
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/pom.xml
new file mode 100644
index 0000000..d29b22a
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/pom.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-conflict-manager</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-common-rest</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-rest-webapp</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>conflict-rest</artifactId>
+
+ <packaging>pom</packaging>
+
+
+ <modules>
+ <module>conflict-rest-services</module>
+ <module>conflict-rest-types</module>
+ </modules>
+
+</project>
\ No newline at end of file
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/HealthCheck.java b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/HealthCheck.java
index 446a80e..4be72a5 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/HealthCheck.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/HealthCheck.java
@@ -39,10 +39,10 @@
@Validated
public interface HealthCheck {
- @GET
- @ApiOperation(value = "Perform health check",
- response = HealthInfoDtos.class,
- responseContainer = "List")
- Response checkHealth( );
+ @GET
+ @ApiOperation(value = "Perform health check",
+ response = HealthInfoDtos.class,
+ responseContainer = "List")
+ Response checkHealth();
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/services/HealthCheckImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/services/HealthCheckImpl.java
index 38858c0..5bdc034 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/services/HealthCheckImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/services/HealthCheckImpl.java
@@ -21,6 +21,7 @@
package org.openecomp.sdcrests.health.rest.services;
import org.apache.cxf.jaxrs.impl.ResponseBuilderImpl;
+import org.openecomp.sdc.common.session.SessionContextProviderFactory;
import org.openecomp.sdc.health.HealthCheckManager;
import org.openecomp.sdc.health.HealthCheckManagerFactory;
import org.openecomp.sdc.health.data.HealthCheckResult;
@@ -35,58 +36,60 @@
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
-import java.util.Arrays;
-import java.util.Collection;
import javax.inject.Named;
import javax.ws.rs.core.Response;
+import java.util.Arrays;
+import java.util.Collection;
@Named
@Service("healthCheck")
@Scope(value = "prototype")
public class HealthCheckImpl implements org.openecomp.sdcrests.health.rest.HealthCheck {
- private HealthCheckManager healthCheckManager;
- private static final Logger logger = LoggerFactory.getLogger(HealthCheckImpl.class);
+ private HealthCheckManager healthCheckManager;
+ private static final Logger logger = LoggerFactory.getLogger(HealthCheckImpl.class);
- public HealthCheckImpl() {
- try {
- healthCheckManager = HealthCheckManagerFactory.getInstance().createInterface();
- } catch (Exception e){
- logger.error(e.getMessage(),e);
- }
+ public HealthCheckImpl() {
+ try {
+ healthCheckManager = HealthCheckManagerFactory.getInstance().createInterface();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
}
+ }
- @Override
- public Response checkHealth() {
- HealthCheckResult healthCheckResult = new HealthCheckResult();
+ @Override
+ public Response checkHealth() {
+ HealthCheckResult healthCheckResult = new HealthCheckResult();
+ SessionContextProviderFactory.getInstance().createInterface().create("public");
- try {
- MdcUtil.initMdc(LoggerServiceName.Health_check.toString());
- Collection<HealthInfo> healthInfos = healthCheckManager.checkHealth();
- healthCheckResult.setComponentsInfo(healthInfos);
- boolean someIsDown = healthInfos.stream()
- .anyMatch(healthInfo -> healthInfo.getHealthCheckStatus().equals(HealthCheckStatus.DOWN));
- healthInfos.stream().
- filter(healthInfo -> healthInfo.getHealthCheckComponent()
- .equals(org.openecomp.sdc.health.data.MonitoredModules.BE)).
- findFirst().ifPresent(healthInfo -> healthCheckResult.setSdcVersion(healthInfo.getVersion()));
- if (someIsDown) {
- Response.ResponseBuilder responseBuilder = new ResponseBuilderImpl();
- return responseBuilder.entity(healthCheckResult).status(500).build();
- }
- return Response.ok(healthCheckResult).build();
- } catch (Exception ex) {
- logger.error("Health check failed", ex);
- Response.ResponseBuilder responseBuilder = new ResponseBuilderImpl();
- GenericCollectionWrapper<HealthInfoDtos> results = new GenericCollectionWrapper<>();
- HealthInfo healthInfo = new HealthInfo(org.openecomp.sdc.health.data.MonitoredModules.BE ,
- HealthCheckStatus.DOWN,
- "", "Failed to perform Health Check");
- Collection<HealthInfo> healthInfos = Arrays.asList(healthInfo);
- healthCheckResult.setComponentsInfo(healthInfos);
- return responseBuilder.entity(healthCheckResult).status(500).build();
- }
+ try {
+ MdcUtil.initMdc(LoggerServiceName.Health_check.toString());
+ Collection<HealthInfo> healthInfos = healthCheckManager.checkHealth();
+ healthCheckResult.setComponentsInfo(healthInfos);
+ boolean someIsDown = healthInfos.stream()
+ .anyMatch(healthInfo -> healthInfo.getHealthCheckStatus().equals(HealthCheckStatus.DOWN));
+ healthInfos.stream().
+ filter(healthInfo -> healthInfo.getHealthCheckComponent()
+ .equals(org.openecomp.sdc.health.data.MonitoredModules.BE)).
+ findFirst()
+ .ifPresent(healthInfo -> healthCheckResult.setSdcVersion(healthInfo.getVersion()));
+ if (someIsDown) {
+ Response.ResponseBuilder responseBuilder = new ResponseBuilderImpl();
+ return responseBuilder.entity(healthCheckResult).status(500).build();
+ }
+ return Response.ok(healthCheckResult).build();
+ } catch (Exception ex) {
+ logger.error("Health check failed", ex);
+ Response.ResponseBuilder responseBuilder = new ResponseBuilderImpl();
+ GenericCollectionWrapper<HealthInfoDtos> results = new GenericCollectionWrapper<>();
+ HealthInfo healthInfo = new HealthInfo(org.openecomp.sdc.health.data.MonitoredModules.BE,
+ HealthCheckStatus.DOWN,
+ "", "Failed to perform Health Check");
+ Collection<HealthInfo> healthInfos = Arrays.asList(healthInfo);
+ healthCheckResult.setComponentsInfo(healthInfos);
+ return responseBuilder.entity(healthCheckResult).status(500).build();
}
+ }
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/pom.xml
new file mode 100644
index 0000000..cec27da
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/pom.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>item-permissions-rest</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>item-permissions-rest-services</artifactId>
+
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>item-permissions-rest-types</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-common-rest</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-item-permissions-manager</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
+ </dependency>
+
+
+ <!--<dependency>-->
+ <!--<groupId>javax.ws.rs</groupId>-->
+ <!--<artifactId>javax.ws.rs-api</artifactId>-->
+ <!--<version>${ws.rs.version}</version>-->
+ <!--</dependency>-->
+
+ <!--<dependency>-->
+ <!--<groupId>org.apache.cxf</groupId>-->
+ <!--<artifactId>cxf-rt-frontend-jaxrs</artifactId>-->
+ <!--<version>${cxf.version}</version>-->
+ <!--</dependency>-->
+
+ <dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-models</artifactId>
+ <version>RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>${spring.framework.version}</version>
+ </dependency>
+ </dependencies>
+
+
+</project>
\ No newline at end of file
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/ItemPermissions.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/ItemPermissions.java
new file mode 100644
index 0000000..e73595c
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/ItemPermissions.java
@@ -0,0 +1,53 @@
+package org.openecomp.sdcrests.itempermissions.rest;
+
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.openecomp.sdcrests.itempermissions.types.ItemPermissionsDto;
+import org.openecomp.sdcrests.itempermissions.types.ItemPermissionsRequestDto;
+import org.springframework.validation.annotation.Validated;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
+import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
+
+/**
+ * Created by ayalaben on 6/18/2017.
+ */
+@Path("/v1.0/items/{itemId}/permissions")
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+@Api(value = "Item Permissions")
+@Validated
+public interface ItemPermissions {
+
+ @GET
+ @Path("/")
+ @ApiOperation(value = "List users permissions assigned on item",
+ response = ItemPermissionsDto.class,
+ responseContainer = "List")
+
+ Response list(@PathParam("itemId") String itemId,
+ @HeaderParam(USER_ID_HEADER_PARAM) String user);
+
+ @PUT
+ @Path("/{permission}")
+ @ApiOperation(value = "Update useres permission on item")
+ Response updatePermissions(@Valid ItemPermissionsRequestDto request,
+ @PathParam("itemId") String itemId,
+ @PathParam("permission") String permission,
+ @NotNull(message = USER_MISSING_ERROR_MSG)
+ @HeaderParam(USER_ID_HEADER_PARAM) String user);
+
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/mapping/MapItemPermissionsToItemPermissionsDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/mapping/MapItemPermissionsToItemPermissionsDto.java
new file mode 100644
index 0000000..88c3d4d
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/mapping/MapItemPermissionsToItemPermissionsDto.java
@@ -0,0 +1,20 @@
+package org.openecomp.sdcrests.itempermissions.rest.mapping;
+
+import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity;
+import org.openecomp.sdcrests.itempermissions.types.ItemPermissionsDto;
+import org.openecomp.sdcrests.mapping.MappingBase;
+
+/**
+ * Created by ayalaben on 6/18/2017.
+ */
+
+public class MapItemPermissionsToItemPermissionsDto extends
+ MappingBase<ItemPermissionsEntity, ItemPermissionsDto> {
+
+
+ @Override
+ public void doMapping(ItemPermissionsEntity source, ItemPermissionsDto target) {
+ target.setUserId(source.getUserId());
+ target.setPermission(source.getPermission());
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/services/ItemPermissionsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/services/ItemPermissionsImpl.java
new file mode 100644
index 0000000..4fe93c2
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/services/ItemPermissionsImpl.java
@@ -0,0 +1,52 @@
+//package org.openecomp.sdcrests.itempermissions.rest.mapping.mapping.services;
+package org.openecomp.sdcrests.itempermissions.rest.services;
+
+
+import org.openecomp.sdc.itempermissions.ItemPermissionsManager;
+import org.openecomp.sdc.itempermissions.ItemPermissionsManagerFactory;
+import org.openecomp.sdcrests.itempermissions.rest.ItemPermissions;
+import org.openecomp.sdcrests.itempermissions.rest.mapping.MapItemPermissionsToItemPermissionsDto;
+import org.openecomp.sdcrests.itempermissions.types.ItemPermissionsDto;
+import org.openecomp.sdcrests.itempermissions.types.ItemPermissionsRequestDto;
+import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
+import javax.inject.Named;
+import javax.ws.rs.core.Response;
+
+/**
+ * Created by ayalaben on 6/18/2017.
+ */
+
+@Named
+@Service("itemPermissions")
+@Scope(value = "prototype")
+public class ItemPermissionsImpl implements ItemPermissions {
+
+ private ItemPermissionsManager itemPermissionsManager =
+ ItemPermissionsManagerFactory.getInstance().createInterface();
+
+ @Override
+ public Response list(String itemId, String user) {
+
+ GenericCollectionWrapper<ItemPermissionsDto> results = new GenericCollectionWrapper<>();
+ MapItemPermissionsToItemPermissionsDto mapper = new MapItemPermissionsToItemPermissionsDto();
+
+ itemPermissionsManager.listItemPermissions(itemId)
+ .forEach(itemPermission -> results.add(mapper.applyMapping
+ (itemPermission, ItemPermissionsDto.class)));
+
+ return Response.ok(results).build();
+ }
+
+ @Override
+ public Response updatePermissions(ItemPermissionsRequestDto request, String itemId,
+ String permission, String user) {
+
+ itemPermissionsManager.updateItemPermissions(itemId,permission,request.getAddedUsersIds(),
+ request.getRemovedUsersIds());
+
+ return Response.ok().build();
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/pom.xml
new file mode 100644
index 0000000..49f1f2b
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/pom.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <dependencies>
+ <dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-annotations</artifactId>
+ <version>1.5.3</version>
+ </dependency>
+
+ </dependencies>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>item-permissions-rest</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>item-permissions-rest-types</artifactId>
+
+
+</project>
\ No newline at end of file
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/main/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/main/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsDto.java
new file mode 100644
index 0000000..d7f0b9f
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/main/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsDto.java
@@ -0,0 +1,27 @@
+package org.openecomp.sdcrests.itempermissions.types;
+
+/**
+ * Created by ayalaben on 6/18/2017.
+ */
+public class ItemPermissionsDto {
+
+ private String userId;
+ private String permission;
+
+ public String getUserId() {
+ return userId;
+ }
+
+ public void setUserId(String id) {
+ this.userId = id;
+ }
+
+ public String getPermission() {
+ return permission;
+ }
+
+ public void setPermission(String permission) {
+ this.permission = permission;
+ }
+
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/main/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/main/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsRequestDto.java
new file mode 100644
index 0000000..82a960c
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/main/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsRequestDto.java
@@ -0,0 +1,32 @@
+package org.openecomp.sdcrests.itempermissions.types;
+
+import io.swagger.annotations.ApiModel;
+
+import java.util.Set;
+
+/**
+ * Created by ayalaben on 6/20/2017.
+ */
+
+@ApiModel(value = "ItemPermissionsRequest")
+public class ItemPermissionsRequestDto {
+
+ private Set<String> addedUsersIds;
+ private Set<String> removedUsersIds;
+
+ public Set<String> getAddedUsersIds() {
+ return addedUsersIds;
+ }
+
+ public void setAddedUsersIds(Set<String> addedUsersIds) {
+ this.addedUsersIds = addedUsersIds;
+ }
+
+ public Set<String> getRemovedUsersIds() {
+ return removedUsersIds;
+ }
+
+ public void setRemovedUsersIds(Set<String> removedUsersIds) {
+ this.removedUsersIds = removedUsersIds;
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/pom.xml
similarity index 78%
rename from openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/pom.xml
rename to openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/pom.xml
index 0b3c83c..f89fb07 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/pom.xml
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/pom.xml
@@ -4,19 +4,21 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>activity-log-rest</artifactId>
- <packaging>pom</packaging>
-
<parent>
<groupId>org.openecomp.sdc</groupId>
<artifactId>openecomp-sdc-rest-webapp</artifactId>
<version>1.2.0-SNAPSHOT</version>
</parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>item-permissions-rest</artifactId>
+
+ <packaging>pom</packaging>
+
+
<modules>
- <module>activity-log-rest-services</module>
- <module>activity-log-rest-types</module>
+ <module>item-permissions-rest-types</module>
+ <module>item-permissions-rest-services</module>
</modules>
-
-</project>
+
+</project>
\ No newline at end of file
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/pom.xml
similarity index 77%
rename from openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/pom.xml
rename to openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/pom.xml
index 10685db..6b96a4d 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/pom.xml
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/pom.xml
@@ -4,40 +4,23 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
- <artifactId>activity-log-rest-services</artifactId>
-
<parent>
<groupId>org.openecomp.sdc</groupId>
- <artifactId>activity-log-rest</artifactId>
+ <artifactId>item-rest</artifactId>
<version>1.2.0-SNAPSHOT</version>
</parent>
+ <artifactId>item-rest-services</artifactId>
+
<dependencies>
-
-
- <dependency>
- <groupId>javax.ws.rs</groupId>
- <artifactId>javax.ws.rs-api</artifactId>
- <version>${ws.rs.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <version>${spring.framework.version}</version>
- </dependency>
- <dependency>
- <groupId>javax.inject</groupId>
- <artifactId>javax.inject</artifactId>
- <version>1</version>
- </dependency>
<dependency>
<groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-activity-log-manager</artifactId>
+ <artifactId>openecomp-sdc-item-permissions-manager</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>activity-log-rest-types</artifactId>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>item-rest-types</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
@@ -45,14 +28,28 @@
<artifactId>openecomp-sdc-common-rest</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
+ </dependency>
<!-- CXF -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<version>${cxf.version}</version>
</dependency>
-
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-conflict-manager</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>${spring.framework.version}</version>
+ </dependency>
</dependencies>
-</project>
+</project>
\ No newline at end of file
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/Versions.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/Versions.java
new file mode 100644
index 0000000..7d7b085
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/Versions.java
@@ -0,0 +1,88 @@
+package org.openecomp.sdcrests.item.rest;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.openecomp.sdcrests.item.types.ActivityLogDto;
+import org.openecomp.sdcrests.item.types.RevisionDto;
+import org.openecomp.sdcrests.item.types.VersionActionRequestDto;
+import org.openecomp.sdcrests.item.types.VersionDto;
+import org.openecomp.sdcrests.item.types.VersionRequestDto;
+import org.springframework.validation.annotation.Validated;
+
+import javax.validation.constraints.NotNull;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
+import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
+
+@Path("/v1.0/items/{itemId}/versions")
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+@Api(value = "Item Versions")
+@Validated
+public interface Versions {
+
+ @GET
+ @Path("/")
+ @ApiOperation(value = "Lists item versions",
+ response = VersionDto.class,
+ responseContainer = "List")
+ Response list(@PathParam("itemId") String itemId,
+ @NotNull(message = USER_MISSING_ERROR_MSG)
+ @HeaderParam(USER_ID_HEADER_PARAM) String user);
+
+ @POST
+ @Path("/{versionId}")
+ @ApiOperation(value = "Creates a new item version")
+ Response create(VersionRequestDto request,
+ @PathParam("itemId") String itemId,
+ @PathParam("versionId") String versionId,
+ @NotNull(message = USER_MISSING_ERROR_MSG)
+ @HeaderParam(USER_ID_HEADER_PARAM) String user);
+
+ @GET
+ @Path("/{versionId}")
+ @ApiOperation(value = "Gets item version", response = VersionDto.class)
+ Response get(@PathParam("itemId") String itemId,
+ @PathParam("versionId") String versionId,
+ @NotNull(message = USER_MISSING_ERROR_MSG)
+ @HeaderParam(USER_ID_HEADER_PARAM) String user);
+
+ @GET
+ @Path("/{versionId}/activity-logs")
+ @ApiOperation(value = "Gets item version activity log",
+ response = ActivityLogDto.class,
+ responseContainer = "List")
+ Response getActivityLog(@ApiParam("Item Id") @PathParam("itemId") String itemId,
+ @ApiParam("Version Id") @PathParam("versionId") String versionId,
+ @NotNull(message = USER_MISSING_ERROR_MSG)
+ @HeaderParam(USER_ID_HEADER_PARAM) String user);
+
+ @GET
+ @Path("/{versionId}/revisions")
+ @ApiOperation(value = "Gets item version revisions", response = RevisionDto.class,
+ responseContainer = "List")
+ Response listRevisions(@PathParam("itemId") String itemId,
+ @PathParam("versionId") String versionId,
+ @NotNull(message = USER_MISSING_ERROR_MSG)
+ @HeaderParam(USER_ID_HEADER_PARAM) String user);
+
+ @PUT
+ @Path("/{versionId}/actions")
+ @ApiOperation(value = "Acts on item version")
+ Response actOn(VersionActionRequestDto request,
+ @PathParam("itemId") String itemId,
+ @PathParam("versionId") String versionId,
+ @NotNull(message = USER_MISSING_ERROR_MSG)
+ @HeaderParam(USER_ID_HEADER_PARAM) String user);
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/mapping/MapActivityLogEntityToActivityLogDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapActivityLogEntityToDto.java
similarity index 60%
rename from openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/mapping/MapActivityLogEntityToActivityLogDto.java
rename to openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapActivityLogEntityToDto.java
index 023dedf..307b555 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/mapping/MapActivityLogEntityToActivityLogDto.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapActivityLogEntityToDto.java
@@ -18,23 +18,24 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdcrests.activitylog.rest.mapping;
+package org.openecomp.sdcrests.item.rest.mapping;
import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
-import org.openecomp.sdcrests.activitylog.types.ActivityLogDto;
-import org.openecomp.sdcrests.activitylog.types.ActivityStatus;
+import org.openecomp.sdcrests.item.types.ActivityLogDto;
+import org.openecomp.sdcrests.item.types.ActivityStatus;
import org.openecomp.sdcrests.mapping.MappingBase;
-public class MapActivityLogEntityToActivityLogDto extends MappingBase<ActivityLogEntity, ActivityLogDto> {
+public class MapActivityLogEntityToDto
+ extends MappingBase<ActivityLogEntity, ActivityLogDto> {
- @Override
- public void doMapping(ActivityLogEntity source, ActivityLogDto target) {
- target.setId(source.getId());
- target.setTimestamp(source.getTimestamp());
- target.setType(source.getType());
- target.setComment(source.getComment());
- target.setUser(source.getUser());
- target.setStatus(new ActivityStatus(source.isSuccess(), source.getMessage()));
- }
+ @Override
+ public void doMapping(ActivityLogEntity source, ActivityLogDto target) {
+ target.setId(source.getId());
+ target.setTimestamp(source.getTimestamp());
+ target.setType(source.getType().name());
+ target.setComment(source.getComment());
+ target.setUser(source.getUser());
+ target.setStatus(new ActivityStatus(source.isSuccess(), source.getMessage()));
+ }
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapItemToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapItemToDto.java
new file mode 100644
index 0000000..26bd58d
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapItemToDto.java
@@ -0,0 +1,15 @@
+package org.openecomp.sdcrests.item.rest.mapping;
+
+import org.openecomp.sdc.versioning.types.Item;
+import org.openecomp.sdcrests.item.types.ItemDto;
+import org.openecomp.sdcrests.mapping.MappingBase;
+
+public class MapItemToDto extends MappingBase<Item, ItemDto> {
+ @Override
+ public void doMapping(Item source, ItemDto target) {
+ target.setId(source.getId());
+ target.setType(source.getType());
+ target.setName(source.getName());
+ target.setDescription(source.getDescription());
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapRevisionToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapRevisionToDto.java
new file mode 100644
index 0000000..861f571
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapRevisionToDto.java
@@ -0,0 +1,15 @@
+package org.openecomp.sdcrests.item.rest.mapping;
+
+import org.openecomp.sdc.versioning.dao.types.Revision;
+import org.openecomp.sdcrests.item.types.RevisionDto;
+import org.openecomp.sdcrests.mapping.MappingBase;
+
+public class MapRevisionToDto extends MappingBase<Revision, RevisionDto> {
+ @Override
+ public void doMapping(Revision source, RevisionDto target) {
+ target.setId(source.getId());
+ target.setMessage(source.getMessage());
+ target.setUser(source.getUser());
+ target.setTime(source.getTime());
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapVersionToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapVersionToDto.java
new file mode 100644
index 0000000..5fbd9a9
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapVersionToDto.java
@@ -0,0 +1,20 @@
+package org.openecomp.sdcrests.item.rest.mapping;
+
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdcrests.item.types.VersionDto;
+import org.openecomp.sdcrests.mapping.MappingBase;
+
+public class MapVersionToDto extends MappingBase<Version, VersionDto> {
+ @Override
+ public void doMapping(Version source, VersionDto target) {
+ target.setId(source.getId());
+ target.setName(source.getName());
+ target.setDescription(source.getDescription());
+ target.setBaseId(source.getBaseId());
+ target.setStatus(source.getStatus());
+ target.setState(source.getState());
+ target.setCreationTime(source.getCreationTime());
+ target.setModificationTime(source.getModificationTime());
+ target.setAdditionalInfo(source.getAdditionalInfo());
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/VersionsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/VersionsImpl.java
new file mode 100644
index 0000000..4667342
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/VersionsImpl.java
@@ -0,0 +1,270 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdcrests.item.rest.services;
+
+import org.openecomp.sdc.activitylog.ActivityLogManager;
+import org.openecomp.sdc.activitylog.ActivityLogManagerFactory;
+import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
+import org.openecomp.sdc.activitylog.dao.type.ActivityType;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.Messages;
+import org.openecomp.sdc.conflicts.ConflictsManager;
+import org.openecomp.sdc.conflicts.ConflictsManagerFactory;
+import org.openecomp.sdc.itempermissions.ItemPermissionsManager;
+import org.openecomp.sdc.itempermissions.ItemPermissionsManagerFactory;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+import org.openecomp.sdc.logging.context.MdcUtil;
+import org.openecomp.sdc.logging.types.LoggerServiceName;
+import org.openecomp.sdc.notification.dtos.Event;
+import org.openecomp.sdc.notification.factories.NotificationPropagationManagerFactory;
+import org.openecomp.sdc.notification.services.NotificationPropagationManager;
+import org.openecomp.sdc.versioning.ItemManager;
+import org.openecomp.sdc.versioning.ItemManagerFactory;
+import org.openecomp.sdc.versioning.VersioningManager;
+import org.openecomp.sdc.versioning.VersioningManagerFactory;
+import org.openecomp.sdc.versioning.dao.types.SynchronizationState;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.errors.RevisionIdNotFoundErrorBuilder;
+import org.openecomp.sdc.versioning.types.NotificationEventTypes;
+import org.openecomp.sdcrests.item.rest.Versions;
+import org.openecomp.sdcrests.item.rest.mapping.MapActivityLogEntityToDto;
+import org.openecomp.sdcrests.item.rest.mapping.MapRevisionToDto;
+import org.openecomp.sdcrests.item.rest.mapping.MapVersionToDto;
+import org.openecomp.sdcrests.item.types.ActivityLogDto;
+import org.openecomp.sdcrests.item.types.CommitRequestDto;
+import org.openecomp.sdcrests.item.types.RevisionDto;
+import org.openecomp.sdcrests.item.types.RevisionRequestDto;
+import org.openecomp.sdcrests.item.types.VersionActionRequestDto;
+import org.openecomp.sdcrests.item.types.VersionDto;
+import org.openecomp.sdcrests.item.types.VersionRequestDto;
+import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
+import javax.inject.Named;
+import javax.ws.rs.core.Response;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_USER;
+import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_ID;
+import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_NAME;
+import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.SUBMIT_DESCRIPTION;
+import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_ID;
+import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_NAME;
+
+@Named
+@Service("versions")
+@Scope(value = "prototype")
+public class VersionsImpl implements Versions {
+
+ private static final String COMMIT_ITEM_ACTION = "Commit_Item";
+ private static final Logger LOGGER = LoggerFactory.getLogger(VersionsImpl.class);
+
+ private ItemPermissionsManager permissionsManager =
+ ItemPermissionsManagerFactory.getInstance().createInterface();
+ private ItemManager itemManager =
+ ItemManagerFactory.getInstance().createInterface();
+ private VersioningManager versioningManager =
+ VersioningManagerFactory.getInstance().createInterface();
+ private ConflictsManager conflictsManager =
+ ConflictsManagerFactory.getInstance().createInterface();
+ private ActivityLogManager activityLogManager =
+ ActivityLogManagerFactory.getInstance().createInterface();
+ private NotificationPropagationManager notifier =
+ NotificationPropagationManagerFactory.getInstance().createInterface();
+
+ @Override
+ public Response list(String itemId, String user) {
+ GenericCollectionWrapper<VersionDto> results = new GenericCollectionWrapper<>();
+ MapVersionToDto mapper = new MapVersionToDto();
+
+ versioningManager.list(itemId)
+ .forEach(version -> results.add(mapper.applyMapping(version, VersionDto.class)));
+ return Response.ok(results).build();
+ }
+
+ @Override
+ public Response create(VersionRequestDto request, String itemId, String baseVersionId,
+ String user) {
+ Version version = new Version();
+ version.setBaseId(baseVersionId);
+ version.setDescription(request.getDescription());
+
+ version = versioningManager.create(itemId, version, request.getCreationMethod());
+
+ VersionDto versionDto = new MapVersionToDto().applyMapping(version, VersionDto.class);
+
+ activityLogManager.logActivity(new ActivityLogEntity(itemId, version,
+ ActivityType.Create_Version, user, true, "", ""));
+
+ return Response.ok(versionDto).build();
+ }
+
+ @Override
+ public Response get(String itemId, String versionId, String user) {
+ Version version = getVersion(itemId, new Version(versionId));
+ VersionDto versionDto = new MapVersionToDto().applyMapping(version, VersionDto.class);
+ return Response.ok(versionDto).build();
+ }
+
+ @Override
+ public Response getActivityLog(String itemId, String versionId, String user) {
+ MdcUtil.initMdc(LoggerServiceName.Get_List_Activity_Log.toString());
+
+ GenericCollectionWrapper<ActivityLogDto> results = new GenericCollectionWrapper<>();
+ MapActivityLogEntityToDto mapper = new MapActivityLogEntityToDto();
+
+ activityLogManager.listLoggedActivities(itemId, new Version(versionId))
+ .forEach(loggedActivity -> results
+ .add(mapper.applyMapping(loggedActivity, ActivityLogDto.class)));
+
+ return Response.ok(results).build();
+ }
+
+ @Override
+ public Response listRevisions(String itemId, String versionId, String user) {
+ GenericCollectionWrapper<RevisionDto> results = new GenericCollectionWrapper<>();
+ MapRevisionToDto mapper = new MapRevisionToDto();
+
+ versioningManager.listRevisions(itemId, new Version(versionId))
+ .forEach(revision -> results.add(mapper.applyMapping(revision, RevisionDto.class)));
+ return Response.ok(results).build();
+ }
+
+ @Override
+ public Response actOn(VersionActionRequestDto request, String itemId, String versionId,
+ String user) {
+ Version version = new Version(versionId);
+ switch (request.getAction()) {
+ case Sync:
+ sync(itemId, version);
+ break;
+ case Commit:
+ if (!permissionsManager.isAllowed(itemId, user, COMMIT_ITEM_ACTION)) {
+ return Response.status(Response.Status.FORBIDDEN)
+ .entity(new Exception(Messages.PERMISSIONS_ERROR.getErrorMessage())).build();
+ }
+ commit(request.getCommitRequest(), itemId, version, user);
+ break;
+ case Revert:
+ revert(request.getRevisionRequest(), itemId, versionId);
+ break;
+ case Reset:
+ throw new UnsupportedOperationException("Action reset not supported.");
+ default:
+ }
+ return Response.ok().build();
+ }
+
+
+ private void revert(RevisionRequestDto request, String itemId, String versionId) {
+ if (request.getRevisionId() == null) {
+ throw new CoreException(new RevisionIdNotFoundErrorBuilder().build());
+ }
+
+ versioningManager.revert(itemId, new Version(versionId), request.getRevisionId());
+ }
+
+ private void sync(String itemId, Version version) {
+ versioningManager.sync(itemId, version);
+ conflictsManager.finalizeMerge(itemId, version);
+ }
+
+ private void commit(CommitRequestDto request, String itemId, Version version, String user) {
+
+ String message = request == null ? "" : request.getMessage();
+
+ versioningManager.publish(itemId, version, message);
+ notifyUsers(itemId, version, message, user, NotificationEventTypes.COMMIT);
+
+ activityLogManager.logActivity(new ActivityLogEntity(itemId, version,
+ ActivityType.Commit, user, true, "", message));
+ }
+
+ private void notifyUsers(String itemId, Version version, String message,
+ String userName, NotificationEventTypes eventType) {
+ Map<String, Object> eventProperties = new HashMap<>();
+ eventProperties.put(ITEM_NAME, itemManager.get(itemId).getName());
+ eventProperties.put(ITEM_ID, itemId);
+
+ Version ver = versioningManager.get(itemId, version);
+ eventProperties.put(VERSION_NAME, ver.getName());
+ eventProperties.put(VERSION_ID, ver.getId());
+
+ eventProperties.put(SUBMIT_DESCRIPTION, message);
+ eventProperties.put(PERMISSION_USER, userName);
+
+ Event syncEvent = new SyncEvent(eventType.getEventName(), itemId, eventProperties, itemId);
+ try {
+ notifier.notifySubscribers(syncEvent, userName);
+ } catch (Exception e) {
+ LOGGER.error("Failed to send sync notification to users subscribed o item '" + itemId);
+ }
+ }
+
+ private class SyncEvent implements Event {
+
+ private String eventType;
+ private String originatorId;
+ private Map<String, Object> attributes;
+ private String entityId;
+
+ public SyncEvent(String eventType, String originatorId,
+ Map<String, Object> attributes, String entityId) {
+ this.eventType = eventType;
+ this.originatorId = originatorId;
+ this.attributes = attributes;
+ this.entityId = entityId;
+ }
+
+ @Override
+ public String getEventType() {
+ return eventType;
+ }
+
+ @Override
+ public String getOriginatorId() {
+ return originatorId;
+ }
+
+ @Override
+ public Map<String, Object> getAttributes() {
+ return attributes;
+ }
+
+ @Override
+ public String getEntityId() {
+ return entityId;
+ }
+ }
+
+ private Version getVersion(String itemId, Version version) {
+ version = versioningManager.get(itemId, version);
+
+ if (version.getState().getSynchronizationState() != SynchronizationState.Merging &&
+ conflictsManager.isConflicted(itemId, version)) { // looks for sdc applicative conflicts
+ version.getState().setSynchronizationState(SynchronizationState.Merging);
+ }
+ return version;
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/pom.xml
new file mode 100644
index 0000000..6b97480
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/pom.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>item-rest</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>item-rest-types</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-versioning-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-activity-log-manager</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-conflict-manager</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+
+</project>
\ No newline at end of file
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ActivityLogDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ActivityLogDto.java
new file mode 100644
index 0000000..40fb918
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ActivityLogDto.java
@@ -0,0 +1,85 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdcrests.item.types;
+
+
+import java.util.Date;
+
+public class ActivityLogDto {
+
+ private String id;
+ private Date timestamp;
+ private String type;
+ private String comment;
+ private String user;
+ private ActivityStatus status;
+
+ public ActivityLogDto() {
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public Date getTimestamp() {
+ return timestamp;
+ }
+
+ public void setTimestamp(Date timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+ public void setComment(String comment) {
+ this.comment = comment;
+ }
+
+ public String getUser() {
+ return user;
+ }
+
+ public void setUser(String user) {
+ this.user = user;
+ }
+
+ public ActivityStatus getStatus() {
+ return status;
+ }
+
+ public void setStatus(ActivityStatus status) {
+ this.status = status;
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityStatus.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ActivityStatus.java
similarity index 96%
rename from openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityStatus.java
rename to openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ActivityStatus.java
index 326b1b6..601a211 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityStatus.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ActivityStatus.java
@@ -17,7 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdcrests.activitylog.types;
+package org.openecomp.sdcrests.item.types;
public class ActivityStatus {
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/CommitRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/CommitRequestDto.java
new file mode 100644
index 0000000..a1d46cb
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/CommitRequestDto.java
@@ -0,0 +1,13 @@
+package org.openecomp.sdcrests.item.types;
+
+public class CommitRequestDto {
+ private String message;
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ItemCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ItemCreationDto.java
new file mode 100644
index 0000000..afba96f
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ItemCreationDto.java
@@ -0,0 +1,22 @@
+package org.openecomp.sdcrests.item.types;
+
+public class ItemCreationDto {
+ private String itemId;
+ private VersionDto version;
+
+ public String getItemId() {
+ return itemId;
+ }
+
+ public void setItemId(String itemId) {
+ this.itemId = itemId;
+ }
+
+ public VersionDto getVersion() {
+ return version;
+ }
+
+ public void setVersion(VersionDto version) {
+ this.version = version;
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ItemDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ItemDto.java
new file mode 100644
index 0000000..1eebf197
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ItemDto.java
@@ -0,0 +1,40 @@
+package org.openecomp.sdcrests.item.types;
+
+public class ItemDto {
+ private String id;
+ private String type;
+ private String name;
+ private String description;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/RevisionDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/RevisionDto.java
new file mode 100644
index 0000000..241d285
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/RevisionDto.java
@@ -0,0 +1,43 @@
+package org.openecomp.sdcrests.item.types;
+
+import java.util.Date;
+
+public class RevisionDto {
+ private String id;
+ private String message;
+ private Date time;
+ private String user;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public void setTime(Date time) {
+ this.time = time;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public Date getTime() {
+ return time;
+ }
+
+ public String getUser() {
+ return user;
+ }
+
+ public void setUser(String user) {
+ this.user = user;
+ }
+
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/RevisionRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/RevisionRequestDto.java
new file mode 100644
index 0000000..49ea9fc
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/RevisionRequestDto.java
@@ -0,0 +1,14 @@
+package org.openecomp.sdcrests.item.types;
+
+public class RevisionRequestDto {
+
+ private String revisionId;
+
+ public String getRevisionId() {
+ return revisionId;
+ }
+
+ public void setRevisionId(String revisionId) {
+ this.revisionId = revisionId;
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/SubmitRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/SubmitRequestDto.java
new file mode 100644
index 0000000..2591560
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/SubmitRequestDto.java
@@ -0,0 +1,13 @@
+package org.openecomp.sdcrests.item.types;
+
+public class SubmitRequestDto {
+ private String message;
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionAction.java
similarity index 76%
copy from openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspCreationDto.java
copy to openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionAction.java
index f77005f..c9d6f4e 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspCreationDto.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionAction.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,19 +18,11 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdcrests.vendorsoftwareproducts.types;
+package org.openecomp.sdcrests.item.types;
-/**
- * Created by TALIO on 4/26/2016.
- */
-public class VspCreationDto {
- private String vspId;
-
- public String getVspId() {
- return vspId;
- }
-
- public void setVspId(String vspId) {
- this.vspId = vspId;
- }
+public enum VersionAction {
+ Sync,
+ Commit,
+ Revert,
+ Reset
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionActionRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionActionRequestDto.java
new file mode 100644
index 0000000..98a5bb9
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionActionRequestDto.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdcrests.item.types;
+
+public class VersionActionRequestDto {
+ private VersionAction action;
+ private CommitRequestDto commitRequest;
+
+ private RevisionRequestDto revisionRequest;
+
+ public VersionAction getAction() {
+ return action;
+ }
+
+ public void setAction(VersionAction action) {
+ this.action = action;
+ }
+
+ public CommitRequestDto getCommitRequest() {
+ return commitRequest;
+ }
+
+ public void setCommitRequest(CommitRequestDto commitRequest) {
+ this.commitRequest = commitRequest;
+ }
+
+ public RevisionRequestDto getRevisionRequest() {
+ return revisionRequest;
+ }
+
+ public void setRevisionRequest(RevisionRequestDto revisionRequest) {
+ this.revisionRequest = revisionRequest;
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionDto.java
new file mode 100644
index 0000000..a0c1942
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionDto.java
@@ -0,0 +1,94 @@
+package org.openecomp.sdcrests.item.types;
+
+import org.openecomp.sdc.versioning.dao.types.VersionState;
+import org.openecomp.sdc.versioning.dao.types.VersionStatus;
+
+import java.util.Date;
+import java.util.Map;
+
+public class VersionDto {
+ private String id;
+ private String name;
+ private String description;
+ private String baseId;
+ private VersionStatus status;
+ private VersionState state;
+ private Date creationTime;
+ private Date modificationTime;
+ private Map<String,Object> additionalInfo;
+ public VersionDto() {
+
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getBaseId() {
+ return baseId;
+ }
+
+ public void setBaseId(String baseId) {
+ this.baseId = baseId;
+ }
+
+ public VersionStatus getStatus() {
+ return status;
+ }
+
+ public void setStatus(VersionStatus status) {
+ this.status = status;
+ }
+
+ public VersionState getState() {
+ return state;
+ }
+
+ public void setState(VersionState state) {
+ this.state = state;
+ }
+
+ public Date getCreationTime() {
+ return creationTime;
+ }
+
+ public void setCreationTime(Date creationTime) {
+ this.creationTime = creationTime;
+ }
+
+ public Date getModificationTime() {
+ return modificationTime;
+ }
+
+ public void setModificationTime(Date modificationTime) {
+ this.modificationTime = modificationTime;
+ }
+
+ public Map<String, Object> getAdditionalInfo() {
+ return additionalInfo;
+ }
+
+ public void setAdditionalInfo(Map<String, Object> additionalInfo) {
+ this.additionalInfo = additionalInfo;
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionRequestDto.java
new file mode 100644
index 0000000..629bc2d
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionRequestDto.java
@@ -0,0 +1,24 @@
+package org.openecomp.sdcrests.item.types;
+
+import org.openecomp.sdc.versioning.types.VersionCreationMethod;
+
+public class VersionRequestDto {
+ private String description;
+ private VersionCreationMethod creationMethod;
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public VersionCreationMethod getCreationMethod() {
+ return creationMethod;
+ }
+
+ public void setCreationMethod(VersionCreationMethod creationMethod) {
+ this.creationMethod = creationMethod;
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/pom.xml
similarity index 73%
copy from openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/pom.xml
copy to openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/pom.xml
index 0b3c83c..6623de8 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/pom.xml
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/pom.xml
@@ -4,19 +4,19 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>activity-log-rest</artifactId>
- <packaging>pom</packaging>
-
<parent>
<groupId>org.openecomp.sdc</groupId>
<artifactId>openecomp-sdc-rest-webapp</artifactId>
<version>1.2.0-SNAPSHOT</version>
</parent>
+ <artifactId>item-rest</artifactId>
+ <packaging>pom</packaging>
+
+
<modules>
- <module>activity-log-rest-services</module>
- <module>activity-log-rest-types</module>
+ <module>item-rest-services</module>
+ <module>item-rest-types</module>
</modules>
-
-</project>
+
+</project>
\ No newline at end of file
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/pom.xml
new file mode 100644
index 0000000..319b028
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/pom.xml
@@ -0,0 +1,161 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.openecomp.sdc.onboarding</groupId>
+ <artifactId>notifications-fe</artifactId>
+ <name>notification-war</name>
+ <packaging>war</packaging>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc</artifactId>
+ <relativePath>../../..</relativePath>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <properties>
+ <spring.version>4.3.4.RELEASE</spring.version>
+ <jetty.version>9.3.6.v20151106</jetty.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-notification-websocket</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>${javax.servlet.version}</version>
+ </dependency>
+ <!-- JSON -->
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-jaxrs</artifactId>
+ <version>${org.codehaus.jackson.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-core-asl</artifactId>
+ <version>${org.codehaus.jackson.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-servlets</artifactId>
+ <version>${jetty.version}</version>
+ </dependency>
+ <!-- START required for websocket -->
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-util</artifactId>
+ <version>${jetty.version}</version>
+ </dependency>
+ <!-- END required for websocket -->
+ <dependency>
+ <groupId>javax.validation</groupId>
+ <artifactId>validation-api</artifactId>
+ <version>1.0.0.GA</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ <version>4.3.1.Final</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>javax.ws.rs-api</artifactId>
+ <version>2.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy</artifactId>
+ <version>${groovy.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>${logback.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-core</artifactId>
+ <version>${logback.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.janino</groupId>
+ <artifactId>janino</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>${spring.framework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <version>${spring.framework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-web</artifactId>
+ <version>${spring.framework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-aop</artifactId>
+ <version>${spring.framework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-webmvc</artifactId>
+ <version>${spring.framework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjweaver</artifactId>
+ <version>1.8.9</version>
+ </dependency>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjrt</artifactId>
+ <version>1.8.9</version>
+ </dependency>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjtools</artifactId>
+ <version>1.8.9</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.3.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-http</artifactId>
+ <version>2.2.2</version>
+ </dependency>
+ </dependencies>
+
+ <!-- Should be removed once TogglZ usage in pom files is fixed -->
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>3.0.0</version>
+ <configuration>
+ <packagingExcludes>WEB-INF/lib/togglz*.jar</packagingExcludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/java/org/openecomp/server/listeners/OnboardingAppStartupListener.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/java/org/openecomp/server/listeners/OnboardingAppStartupListener.java
new file mode 100644
index 0000000..96300b5
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/java/org/openecomp/server/listeners/OnboardingAppStartupListener.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.server.listeners;
+
+
+import org.springframework.web.context.ContextLoaderListener;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+public class OnboardingAppStartupListener implements ServletContextListener {
+
+ ContextLoaderListener springListener;
+
+ @Override
+ public void contextInitialized(ServletContextEvent servletContextEvent) {
+ springListener = new ContextLoaderListener();
+ springListener.initWebApplicationContext(servletContextEvent.getServletContext());
+ }
+
+ @Override
+ public void contextDestroyed(ServletContextEvent servletContextEvent) {
+ springListener.closeWebApplicationContext(servletContextEvent.getServletContext());
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/resources/keyfile.txt b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/resources/keyfile.txt
new file mode 100644
index 0000000..d6c2c25
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/resources/keyfile.txt
@@ -0,0 +1,27 @@
+hfLSGGYWU2SyTlltV0HVwU6o3GtrtccAU8aFwq65OHsl6JeEAirXaNl73xz2uTrfiFqVJD7GTxXr
+_qlY4BnLFZ7q3KNRZ0VQssjF_REjB8p7YMkEiTzbJL0pSaI6s0GRotuM432Jbsoksh8WZeui7svx
+I_KD124t73d1EpIAQwHldZXRZEoDrLjfJUSCAcmsXSu5OlIMZDKOy7vR0aXPw6Dpn9sZBcpFHFQL
+Xkp63yTf81snlVBGXApwS852_u4nEYmQrGQo9u6iLRg4dodOUD7wG7jbNB_KtmIspxL87i75hJ_0
+PXkLN8H2K14Rvk9ILYjdASpPOyVMK8avylRRyRy5HFBUJfeWk4YJEPus79Ol-j3QefWxX2hEOe_Y
+AcA5xYgwsYylSARWcQ7aZ8M781-CNaM1yDkFCBRNLQoOo3k_yyspfHC0fOwIOPZdh9YiXIop3MAM
+FC0SdPTUQrQxlF3IOC7tfEp7Wu2XezkcbIBe8mDy7dcYa87KqrL0zRju80R_gl-UCkxMLZpEKhnB
+zWxjDNOGCC4VaLMrW6uREFlanw2yg3XAXZD2vl60r1WNUrRUJcYRs9FwNkdVhKH7o_D7GLXCxlEF
+ltapyC4i1xgeXiEH35WrqlmS1PexaWkRloFmpLXY56D3iqg9RYrZnqQAift20LLQ_ZMFS_fOlb8w
+pu-VqjifrOthE9B375Nq-_YdMCLRAdAXf5wiMC1AlimLE6gmE6cl0SopHpmtmLX--4jy8IUSOceG
+xhTKpfO_7Gnn-V5m-ourtkj_UivEiM3eIyzilamlEtac50e-mg1sEHjPvAQd7p_oqaGd4NveSUeG
+_WsLUZJgKI6Nu0545J1tDmlgZ4atd1b4Mkutl1CbijYg9c6Nu_zxMs9RwN9_-C3JJJxQpBUieXFY
+f38PD62P8Ihb8VmNmBhOT8abRmH7Zx1adz6fcjFtaO0wSsfWr8M04W_GrbrGO_yr7GeJwqdYEP8r
+rUoQWkNRuapL09KUHhHTdc8hQoCNUx4p2H2_ADA8j6gp62z54LUQDaTOHJI3Vs6mdfP7oDr2H_VK
+LLWR7fHcDzS89opwtp7NO56jpmmq4q-U9kxpY1lMYJhKBuVMCm038l_eMGL35jD6OcgOCC2GL9U9
+wfyjwumJMNIND8I3viuyouMy_B5q00v27M2im6Q814Mg5Cw-RCiKy4kjhutkqTw8hXh7RLkm-QeJ
+KlsrH98snwWLaw9LBeGoMbqzHzWl93inEsTyLutMPA8xSIj5kySLIcJCXq9-RMp8cnOYy8TY9Jix
+oaB2u4ofHDDrrMzKY88ZPdMiGQX2BNdsOG6o4ifSVyyYwIWBtQvtO7SDvGhRUGEV1JHloBdIos0M
+87SMERYd_UPKK_yl2RaqloQZRlDSgUR7i0hoqrhtPe5Ef4cJFX_CSt_oQnEu0JatwAuwybkLLPbO
+mArd3rtrOh-uR_0Y77zb7Uw4H5_oX_ANIecH0sgRcvQESaq-ioYrvS94VqvxU8ByuxqxJLMo90Rc
+oOAk3pq0b-16x_WRxWTfbnnNLDSQ_DwS-Xeav1nPwm-ELy1AVEQdpgbjONThjkZp3AuljaH_1Fs4
+u0A8HeCgIa4g7jsvIRxw6zLKspYENdvoHvQLWGRpaA-vfT3i3lR0MEu53v8M9hI8U8MqJo_J0xe6
+z2mtQWPiCLtW99vTqhKOm621_GNYmp10TEXVMkXumEk2rTgLBDaFEFwpgS5LqkEOObVChd9jx9oa
+DW4LjhzO1EE5twGvbTiRAJsO6j5UNTonGFLLttYKq9CMvDiBZ8-whFGOM8D2qAWYiwDCI-dLqwat
+jxQP1cYKGHMS2-VJ5QJa6EINEx2zo3VmnHYCE9gM71fC26018Y2T-sQfE1MRE9SU_Xma7Qbl5OBp
+IflyJCTyhZfgFlqU9f2cq12bjoNuMrgOlKwap6325LGZK1XsmsHuHmASRE4-E-qmQY7GI9oJLmbl
+425swlxRA-mr1eGZU0hK3ZFjz_4clBMLJBYMFYhdGzi4VYGPzaO0z0wNJzOQf3V5NbReFjxl
\ No newline at end of file
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/webapp/WEB-INF/beans-services.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/webapp/WEB-INF/beans-services.xml
new file mode 100644
index 0000000..c41bc03
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/webapp/WEB-INF/beans-services.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:jaxrs="http://cxf.apache.org/jaxrs"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:websocket="http://www.springframework.org/schema/websocket"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
+ http://www.springframework.org/schema/websocket
+ http://www.springframework.org/schema/websocket/spring-websocket.xsd">
+
+
+ <!-- CXF -->
+ <context:component-scan base-package="org.openecomp.sdcrests"/>
+
+ <!-- Needed for JSR-303 validations. May be removed when moving to JAX-RS 2.0 -->
+ <bean class="org.springframework.validation.beanvalidation.MethodValidationPostProcessor"/>
+
+ <bean id="jacksonObjectMapper" class="org.codehaus.jackson.map.ObjectMapper">
+ <property name="serializationInclusion" value="NON_NULL"/>
+ </bean>
+
+ <bean id="jsonProvider" class="org.codehaus.jackson.jaxrs.JacksonJsonProvider">
+ <property name="mapper" ref="jacksonObjectMapper"/>
+ </bean>
+
+ <!-- WEB-SOCKETS -->
+ <websocket:handlers allowed-origins="*">
+ <websocket:mapping path="/notificationHandler" handler="notificationHandler"/>
+ <websocket:handshake-handler ref="handshakeHandler"/>
+ </websocket:handlers>
+
+ <bean id="newNotificationsReader" class="org.openecomp.sdc.notification.workers.impl.NewNotificationsReaderRestImpl"/>
+
+ <bean id="notificationWorker" class="org.openecomp.sdc.notification.workers.NotificationWorker">
+ <constructor-arg ref="newNotificationsReader"/>
+ </bean>
+
+ <bean id="notificationHandler" class="org.openecomp.sdc.notification.websocket.NotificationWebsocketHandler">
+ <constructor-arg ref="notificationWorker"/>
+ </bean>
+
+ <bean class="org.springframework.web.socket.server.standard.ServletServerContainerFactoryBean">
+ <property name="maxTextMessageBufferSize" value="8192"/>
+ <property name="maxBinaryMessageBufferSize" value="8192"/>
+ </bean>
+
+ <bean id="handshakeHandler" class="org.springframework.web.socket.server.support.DefaultHandshakeHandler">
+ <constructor-arg ref="upgradeStrategy"/>
+ </bean>
+
+ <bean id="upgradeStrategy" class="org.springframework.web.socket.server.jetty.JettyRequestUpgradeStrategy">
+ <constructor-arg ref="serverFactory"/>
+ </bean>
+
+ <bean id="serverFactory" class="org.eclipse.jetty.websocket.server.WebSocketServerFactory">
+ <constructor-arg>
+ <bean class="org.eclipse.jetty.websocket.api.WebSocketPolicy">
+ <constructor-arg value="SERVER"/>
+ <property name="inputBufferSize" value="8092"/>
+ <property name="idleTimeout" value="600000"/>
+ </bean>
+ </constructor-arg>
+ </bean>
+
+</beans>
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/webapp/WEB-INF/jetty-web.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/webapp/WEB-INF/jetty-web.xml
new file mode 100644
index 0000000..443b6a1
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/webapp/WEB-INF/jetty-web.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE Configure PUBLIC
+ "-//Mort Bay Consulting//DTD Configure//EN"
+ "http://www.eclipse.org/jetty/configure_9_0.dtd">
+
+<Configure class="org.eclipse.jetty.webapp.WebAppContext">
+ <Set name="contextPath">/notification-api</Set>
+</Configure>
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/webapp/WEB-INF/spring-mapper-servlet.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/webapp/WEB-INF/spring-mapper-servlet.xml
new file mode 100644
index 0000000..2851d56
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/webapp/WEB-INF/spring-mapper-servlet.xml
@@ -0,0 +1,12 @@
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
+ <property name="mappings">
+ <props>
+ </props>
+ </property>
+ </bean>
+
+</beans>
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/webapp/WEB-INF/web.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..354fcbf
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,81 @@
+<web-app
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
+
+
+ <!-- Spring -->
+ <context-param>
+ <param-name>contextConfigLocation</param-name>
+ <param-value>WEB-INF/beans-services.xml</param-value>
+ </context-param>
+
+ <listener>
+ <listener-class>org.openecomp.server.listeners.OnboardingAppStartupListener</listener-class>
+ </listener>
+
+ <filter>
+ <filter-name>cross-origin</filter-name>
+ <filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>
+ <init-param>
+ <param-name>allowedOrigins</param-name>
+ <param-value>*</param-value>
+ </init-param>
+ <init-param>
+ <param-name>allowedMethods</param-name>
+ <param-value>*</param-value>
+ </init-param>
+ <init-param>
+ <param-name>allowedHeaders</param-name>
+ <param-value>*</param-value>
+ </init-param>
+ </filter>
+ <filter-mapping>
+ <filter-name>cross-origin</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+ <!-- Spring WS Mapping -->
+ <servlet>
+ <servlet-name>spring-mapper</servlet-name>
+ <servlet-class>
+ org.springframework.web.servlet.DispatcherServlet
+ </servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <!-- CXF -->
+ <servlet>
+ <servlet-name>CXFServlet</servlet-name>
+ <display-name>CXF Servlet</display-name>
+ <servlet-class>
+ org.apache.cxf.transport.servlet.CXFServlet
+ </servlet-class>
+ <init-param>
+ <param-name>redirects-list</param-name>
+ <param-value>
+ /docs/(\S)+\.json
+ </param-value>
+ </init-param>
+ <init-param>
+ <param-name>redirect-attributes</param-name>
+ <param-value>
+ javax.servlet.include.request_uri
+ </param-value>
+ </init-param>
+ <init-param>
+ <param-name>redirect-servlet-name</param-name>
+ <param-value>default</param-value>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>spring-mapper</servlet-name>
+ <url-pattern>/ws/*</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>CXFServlet</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/pom.xml
similarity index 74%
copy from openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/pom.xml
copy to openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/pom.xml
index 10685db..597b017 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/pom.xml
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/pom.xml
@@ -4,55 +4,53 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
- <artifactId>activity-log-rest-services</artifactId>
-
<parent>
<groupId>org.openecomp.sdc</groupId>
- <artifactId>activity-log-rest</artifactId>
+ <artifactId>notifications-rest</artifactId>
<version>1.2.0-SNAPSHOT</version>
</parent>
+ <artifactId>notifications-rest-services</artifactId>
+
<dependencies>
-
-
- <dependency>
- <groupId>javax.ws.rs</groupId>
- <artifactId>javax.ws.rs-api</artifactId>
- <version>${ws.rs.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <version>${spring.framework.version}</version>
- </dependency>
- <dependency>
- <groupId>javax.inject</groupId>
- <artifactId>javax.inject</artifactId>
- <version>1</version>
- </dependency>
- <dependency>
+ <dependency>
<groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-activity-log-manager</artifactId>
+ <artifactId>openecomp-sdc-application-config-manager</artifactId>
<version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>activity-log-rest-types</artifactId>
- <version>${project.version}</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.openecomp.sdc</groupId>
<artifactId>openecomp-sdc-common-rest</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
+ </dependency>
<!-- CXF -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<version>${cxf.version}</version>
</dependency>
-
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>notifications-rest-types</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-notification-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>${spring.framework.version}</version>
+ </dependency>
</dependencies>
-</project>
+</project>
\ No newline at end of file
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsStatusToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsStatusToDto.java
new file mode 100644
index 0000000..41376b0
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsStatusToDto.java
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdcrests.notifications.rest.mapping;
+
+import com.datastax.driver.core.utils.UUIDs;
+import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.sdc.notification.dao.types.NotificationEntity;
+import org.openecomp.sdc.notification.dtos.NotificationsStatus;
+import org.openecomp.sdcrests.mapping.MappingBase;
+import org.openecomp.sdcrests.notifications.types.NotificationEntityDto;
+import org.openecomp.sdcrests.notifications.types.NotificationsStatusDto;
+
+import java.text.DateFormat;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class MapNotificationsStatusToDto
+ extends MappingBase<NotificationsStatus, NotificationsStatusDto> {
+
+ private static final DateFormat formatter =
+ DateFormat.getDateTimeInstance(DateFormat.LONG,
+ DateFormat.SHORT);
+
+ @Override
+ public void doMapping(NotificationsStatus source, NotificationsStatusDto target) {
+
+ target.setLastScanned(source.getLastScanned());
+ target.setNewEntries(source.getNewEntries());
+ target.setEndOfPage(source.getEndOfPage());
+ target.setNumOfNotSeenNotifications(source.getNumOfNotSeenNotifications());
+ List<NotificationEntityDto> entityDtos = new ArrayList<>();
+ source.getNotifications()
+ .forEach(notification -> entityDtos.add(new NotificationEntityDto(notification.isRead(),
+ notification.getEventId(), notification.getEventType(),
+ JsonUtil.json2Object(notification.getEventAttributes(), Map.class),
+ extractDate(notification))));
+ target.setNotifications(entityDtos);
+ }
+
+ private String extractDate(NotificationEntity notification) {
+ return formatter.format(UUIDs.unixTimestamp
+ (notification
+ .getEventId()));
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsToDto.java
new file mode 100644
index 0000000..558453b
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsToDto.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdcrests.notifications.rest.mapping;
+
+import com.datastax.driver.core.utils.UUIDs;
+import org.apache.commons.collections4.CollectionUtils;
+import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.sdc.notification.dao.types.NotificationEntity;
+import org.openecomp.sdcrests.mapping.MappingBase;
+import org.openecomp.sdcrests.notifications.types.NotificationEntityDto;
+import org.openecomp.sdcrests.notifications.types.NotificationsStatusDto;
+
+import java.text.DateFormat;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class MapNotificationsToDto extends MappingBase<List<NotificationEntity>, NotificationsStatusDto> {
+ private static final DateFormat formatter =
+ DateFormat.getDateTimeInstance(DateFormat.LONG,
+ DateFormat.SHORT);
+ @Override
+ public void doMapping(List<NotificationEntity> source, NotificationsStatusDto target) {
+ List<NotificationEntityDto> entityDtos = new ArrayList<>();
+ if(CollectionUtils.isNotEmpty(source)) {
+ source.forEach(notification -> entityDtos.add(new NotificationEntityDto(notification.isRead(),
+ notification.getEventId(), notification.getEventType(), JsonUtil.json2Object(notification.getEventAttributes(), Map.class),
+ extractDate(notification))));
+ target.setNotifications(entityDtos);
+ target.setLastScanned(source.get(0).getEventId());
+ }
+ }
+
+ private String extractDate(NotificationEntity notification) {
+ return formatter.format(UUIDs.unixTimestamp
+ (notification
+ .getEventId()));
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/services/Notifications.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/services/Notifications.java
new file mode 100644
index 0000000..97199f6
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/services/Notifications.java
@@ -0,0 +1,94 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdcrests.notifications.rest.services;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.openecomp.sdcrests.notifications.types.NotificationsStatusDto;
+import org.openecomp.sdcrests.notifications.types.UpdateNotificationResponseStatus;
+import org.springframework.validation.annotation.Validated;
+
+import javax.validation.constraints.NotNull;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.lang.reflect.InvocationTargetException;
+import java.util.UUID;
+
+import static org.openecomp.sdcrests.common.RestConstants.LAST_DELIVERED_QUERY_PARAM;
+import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
+import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
+
+@Path("/v1.0/notifications")
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+@Api(value = "Notifications")
+@Validated
+public interface Notifications {
+ String LIMIT_QUERY_PARAM = "NOTIFICATION_ROWS_LIMIT";
+ String END_OF_PAGE_QUERY_PARAM = "END_OF_PAGE_EVENT_ID";
+
+ @GET
+ @ApiOperation(value = "Retrive all user notifications",
+ response = NotificationsStatusDto.class,
+ responseContainer = "List")
+ Response getNotifications(
+ @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user,
+ @QueryParam(LAST_DELIVERED_QUERY_PARAM) UUID lastDelvered,
+ @QueryParam(END_OF_PAGE_QUERY_PARAM) UUID endOfPage);
+
+ @PUT
+ @Path("/{notificationId}")
+ @ApiOperation(value = "Mark notification as read",
+ response = UpdateNotificationResponseStatus.class)
+ Response markAsRead(
+ @ApiParam(value = "Notification Id") @PathParam("notificationId") String notificationId,
+ @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user)
+ throws InvocationTargetException, IllegalAccessException;
+
+ @PUT
+ @Path("/last-seen/{notificationId}")
+ @ApiOperation(value = "Update Last Seen Notification",
+ response = UpdateNotificationResponseStatus.class)
+ Response updateLastSeenNotification(
+ @ApiParam(value = "Notification Id") @PathParam("notificationId") String notificationId,
+ @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user)
+ throws InvocationTargetException, IllegalAccessException;
+
+ @GET
+ @Path("/worker")
+ @ApiOperation(value = "Retrive user not delivered notifications",
+ response = NotificationsStatusDto.class,
+ responseContainer = "List")
+ Response getNewNotificationsByOwnerId(
+ @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user,
+ @QueryParam(LAST_DELIVERED_QUERY_PARAM) String eventId,
+ @QueryParam(LIMIT_QUERY_PARAM) String limit);
+
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/services/impl/NotificationsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/services/impl/NotificationsImpl.java
new file mode 100644
index 0000000..8ff0ac0
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/services/impl/NotificationsImpl.java
@@ -0,0 +1,117 @@
+package org.openecomp.sdcrests.notifications.rest.services.impl;
+
+import org.openecomp.sdc.common.errors.Messages;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+import org.openecomp.sdc.logging.context.MdcUtil;
+import org.openecomp.sdc.logging.types.LoggerServiceName;
+import org.openecomp.sdc.notification.dao.types.NotificationEntity;
+import org.openecomp.sdc.notification.dtos.NotificationsStatus;
+import org.openecomp.sdc.notification.exceptons.NotificationNotExistException;
+import org.openecomp.sdc.notification.factories.NotificationsServiceFactory;
+import org.openecomp.sdc.notification.services.NotificationsService;
+import org.openecomp.sdcrests.notifications.rest.mapping.MapNotificationsStatusToDto;
+import org.openecomp.sdcrests.notifications.rest.mapping.MapNotificationsToDto;
+import org.openecomp.sdcrests.notifications.rest.services.Notifications;
+import org.openecomp.sdcrests.notifications.types.NotificationsStatusDto;
+import org.openecomp.sdcrests.notifications.types.UpdateNotificationResponseStatus;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
+import javax.inject.Named;
+import javax.ws.rs.core.Response;
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+import java.util.Objects;
+import java.util.UUID;
+
+/**
+ * @author Avrahamg
+ * @since June 22, 2017
+ */
+@Named
+@Service("notifications")
+@Scope(value = "prototype")
+public class NotificationsImpl implements Notifications {
+
+ private static int selectionLimit = 10;
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(NotificationsImpl.class);
+ private NotificationsService notificationsService = NotificationsServiceFactory.getInstance().createInterface();
+
+ @Override
+ public Response getNotifications(String user, UUID lastDelivered, UUID endOfPage) {
+ MdcUtil.initMdc(LoggerServiceName.notifications.toString());
+ NotificationsStatus notificationsStatus = notificationsService
+ .getNotificationsStatus(user, lastDelivered, selectionLimit, endOfPage);
+ MapNotificationsStatusToDto converter = new MapNotificationsStatusToDto();
+ NotificationsStatusDto notificationsStatusDto = new NotificationsStatusDto();
+ converter.doMapping(notificationsStatus, notificationsStatusDto);
+
+ return Response.ok(notificationsStatusDto).build();
+ }
+
+ @Override
+ public Response updateLastSeenNotification(String notificationId, String user)
+ throws InvocationTargetException, IllegalAccessException {
+ UpdateNotificationResponseStatus
+ updateNotificationResponseStatus = new UpdateNotificationResponseStatus();
+ try {
+ notificationsService.updateLastSeenNotification(user, UUID.fromString(notificationId));
+ } catch (Exception ex) {
+ LOGGER.error(
+ String.format(Messages.FAILED_TO_UPDATE_LAST_SEEN_NOTIFICATION.getErrorMessage(),
+ user), ex);
+ updateNotificationResponseStatus.addStructureError(notificationId,
+ new ErrorMessage(ErrorLevel.ERROR,
+ Messages.FAILED_TO_UPDATE_LAST_SEEN_NOTIFICATION.getErrorMessage()));
+ }
+ return Response.ok(updateNotificationResponseStatus).build();
+ }
+
+ @Override
+ public Response markAsRead(String notificationId, String user)
+ throws InvocationTargetException, IllegalAccessException {
+
+ UpdateNotificationResponseStatus
+ updateNotificationResponseStatus = new UpdateNotificationResponseStatus();
+ try {
+ notificationsService.markAsRead(user, notificationId);
+ } catch (NotificationNotExistException ex) {
+ LOGGER.error(Messages.FAILED_TO_MARK_NOTIFICATION_AS_READ.getErrorMessage(), ex);
+ updateNotificationResponseStatus.addStructureError(
+ notificationId, new ErrorMessage(ErrorLevel.ERROR, Messages
+ .FAILED_TO_MARK_NOTIFICATION_AS_READ
+ .getErrorMessage()));
+ }
+ return Response.ok(updateNotificationResponseStatus).build();
+ }
+
+ @Override
+ public Response getNewNotificationsByOwnerId(String user, String eventId, String limitStr) {
+ MdcUtil.initMdc(LoggerServiceName.notifications.toString());
+
+ int limit = selectionLimit;
+
+ if (Objects.nonNull(limitStr)) {
+ try {
+ limit = Integer.parseInt(limitStr);
+ }
+ catch (NumberFormatException f) {
+ LOGGER.error("Non numeric selection list size value specified: " + limitStr);
+ }
+ }
+
+ List<NotificationEntity> notifications = Objects.isNull(eventId)
+ ? notificationsService.getNotificationsByOwnerId(user, limit)
+ : notificationsService.getNewNotificationsByOwnerId(user, UUID.fromString(eventId), limit);
+
+ MapNotificationsToDto converter = new MapNotificationsToDto();
+ NotificationsStatusDto notificationsStatusDto = new NotificationsStatusDto();
+ converter.doMapping(notifications, notificationsStatusDto);
+
+ return Response.ok(notificationsStatusDto).build();
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/pom.xml
new file mode 100644
index 0000000..4a3300a
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/pom.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-datatypes-lib</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>notifications-rest</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>notifications-rest-types</artifactId>
+
+
+</project>
\ No newline at end of file
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationEntityDto.java
new file mode 100644
index 0000000..d41deb3
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationEntityDto.java
@@ -0,0 +1,91 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdcrests.notifications.types;
+
+import java.util.Map;
+import java.util.UUID;
+
+public class NotificationEntityDto {
+ private boolean read;
+ private UUID eventId;
+ private String dateTime;
+ private String eventType;
+ private Map<String, Object> eventAttributes;
+
+ public NotificationEntityDto() {
+ }
+ public NotificationEntityDto(boolean read, UUID eventId, String eventType,
+ Map<String, Object> eventAttributes) {
+ this.read = read;
+ this.eventId = eventId;
+ this.eventType = eventType;
+ this.eventAttributes = eventAttributes;
+ }
+
+ public NotificationEntityDto(boolean read, UUID eventId,String eventType,
+ Map<String, Object> eventAttributes, String dateTime) {
+ this.read = read;
+ this.eventId = eventId;
+ this.dateTime = dateTime;
+ this.eventType = eventType;
+ this.eventAttributes = eventAttributes;
+ }
+
+ public boolean isRead() {
+ return read;
+ }
+
+ public void setRead(boolean read) {
+ this.read = read;
+ }
+
+ public UUID getEventId() {
+ return eventId;
+ }
+
+ public void setEventId(UUID eventId) {
+ this.eventId = eventId;
+ }
+
+ public String getEventType() {
+ return eventType;
+ }
+
+ public void setEventType(String eventType) {
+ this.eventType = eventType;
+ }
+
+ public Map<String, Object> getEventAttributes() {
+ return eventAttributes;
+ }
+
+ public void setEventAttributes(Map<String, Object> eventAttributes) {
+ this.eventAttributes = eventAttributes;
+ }
+
+ public String getDateTime() {
+ return dateTime;
+ }
+
+ public void setDateTime(String dateTime) {
+ this.dateTime = dateTime;
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationResponseStatus.java
similarity index 76%
copy from openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspCreationDto.java
copy to openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationResponseStatus.java
index f77005f..a0273d5 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspCreationDto.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationResponseStatus.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,19 +18,9 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdcrests.vendorsoftwareproducts.types;
+package org.openecomp.sdcrests.notifications.types;
-/**
- * Created by TALIO on 4/26/2016.
- */
-public class VspCreationDto {
- private String vspId;
-
- public String getVspId() {
- return vspId;
- }
-
- public void setVspId(String vspId) {
- this.vspId = vspId;
- }
+public enum NotificationResponseStatus {
+ Success,
+ Failure
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationsStatusDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationsStatusDto.java
new file mode 100644
index 0000000..182245c
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationsStatusDto.java
@@ -0,0 +1,61 @@
+package org.openecomp.sdcrests.notifications.types;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+/**
+ * @author avrahamg
+ * @since June 29, 2017
+ */
+public class NotificationsStatusDto {
+ private List<NotificationEntityDto> notifications;
+ private List<UUID> newEntries = new ArrayList<>();
+ private UUID lastScanned;
+ private UUID endOfPage;
+ private long numOfNotSeenNotifications;
+
+ public NotificationsStatusDto() {
+ }
+
+ public List<NotificationEntityDto> getNotifications() {
+ return notifications;
+ }
+
+ public void setNotifications(
+ List<NotificationEntityDto> notifications) {
+ this.notifications = notifications;
+ }
+
+ public List<UUID> getNewEntries() {
+ return newEntries;
+ }
+
+ public void setNewEntries(List<UUID> newEntries) {
+ this.newEntries = newEntries;
+ }
+
+ public UUID getLastScanned() {
+ return lastScanned;
+ }
+
+ public void setLastScanned(UUID lastScanned) {
+ this.lastScanned = lastScanned;
+ }
+
+ public UUID getEndOfPage() {
+ return endOfPage;
+ }
+
+ public void setEndOfPage(UUID endOfPage) {
+ this.endOfPage = endOfPage;
+ }
+
+ public long getNumOfNotSeenNotifications() {
+ return numOfNotSeenNotifications;
+ }
+
+ public void setNumOfNotSeenNotifications(long numOfNotSeenNotifications) {
+ this.numOfNotSeenNotifications = numOfNotSeenNotifications;
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/UpdateNotificationResponseStatus.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/UpdateNotificationResponseStatus.java
new file mode 100644
index 0000000..9e98572
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/UpdateNotificationResponseStatus.java
@@ -0,0 +1,65 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdcrests.notifications.types;
+
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.openecomp.sdcrests.notifications.types.NotificationResponseStatus.Failure;
+import static org.openecomp.sdcrests.notifications.types.NotificationResponseStatus.Success;
+
+/**
+ * Created by TALIO on 4/27/2016.
+ */
+public class UpdateNotificationResponseStatus {
+ private Map<String, List<ErrorMessage>> errors = new HashMap<>();
+ private NotificationResponseStatus status = Success;
+
+ public Map<String, List<ErrorMessage>> getErrors() {
+ return errors;
+ }
+
+ public void setErrors(Map<String, List<ErrorMessage>> errors) {
+ this.errors = errors;
+ }
+
+ public NotificationResponseStatus getStatus() {
+ return status;
+ }
+
+ public void setStatus(NotificationResponseStatus status) {
+ this.status = status;
+ }
+
+ public void addStructureError(String notificationId, ErrorMessage errorMessage) {
+ List<ErrorMessage> errorList =
+ errors.computeIfAbsent(notificationId, k -> new ArrayList<>());
+ errorList.add(errorMessage);
+ if (ErrorLevel.ERROR.equals(errorMessage.getLevel())) {
+ status = Failure;
+ }
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/pom.xml
similarity index 77%
copy from openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/pom.xml
copy to openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/pom.xml
index 0b3c83c..d35c5af 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/pom.xml
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/pom.xml
@@ -4,19 +4,21 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>activity-log-rest</artifactId>
- <packaging>pom</packaging>
-
<parent>
<groupId>org.openecomp.sdc</groupId>
<artifactId>openecomp-sdc-rest-webapp</artifactId>
<version>1.2.0-SNAPSHOT</version>
</parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>notifications-rest</artifactId>
+
+ <packaging>pom</packaging>
+
+
<modules>
- <module>activity-log-rest-services</module>
- <module>activity-log-rest-types</module>
- </modules>
-
-</project>
+ <module>notifications-rest-types</module>
+ <module>notifications-rest-services</module>
+ </modules>
+
+</project>
\ No newline at end of file
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/pom.xml
index 84c4eb4..32975b3 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/pom.xml
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/pom.xml
@@ -16,13 +16,23 @@
<dependencies>
<dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>item-rest-services</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.openecomp.sdc.onboarding</groupId>
<artifactId>vendor-license-rest-services</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openecomp.sdc</groupId>
- <artifactId>activity-log-rest-services</artifactId>
+ <artifactId>openecomp-sdc-notification-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-notification-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
@@ -42,6 +52,21 @@
</dependency>
<dependency>
<groupId>org.openecomp.sdc</groupId>
+ <artifactId>conflict-rest-services</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>item-permissions-rest-services</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>notifications-rest-services</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
<artifactId>application-config-rest-services</artifactId>
<version>${project.version}</version>
</dependency>
@@ -108,6 +133,11 @@
</dependency>
<dependency>
<groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>${spring.framework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.framework.version}</version>
</dependency>
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthenticationFilter.java b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthenticationFilter.java
index 18465cd..e10f6a5 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthenticationFilter.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthenticationFilter.java
@@ -23,9 +23,6 @@
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
-import java.io.IOException;
-import java.security.Principal;
-import java.util.Base64;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
@@ -35,6 +32,9 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.security.Principal;
+import java.util.Base64;
public class ActionAuthenticationFilter implements Filter {
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthorizationFilter.java b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthorizationFilter.java
index 82e4fa8..f54b06d 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthorizationFilter.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthorizationFilter.java
@@ -20,7 +20,6 @@
package org.openecomp.server.filters;
-import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
@@ -29,6 +28,7 @@
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
public class ActionAuthorizationFilter implements Filter {
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/SessionContextFilter.java b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/SessionContextFilter.java
new file mode 100644
index 0000000..b317fa6
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/SessionContextFilter.java
@@ -0,0 +1,45 @@
+package org.openecomp.server.filters;
+
+import org.openecomp.sdc.common.session.SessionContextProvider;
+import org.openecomp.sdc.common.session.SessionContextProviderFactory;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+
+import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
+
+public class SessionContextFilter implements Filter {
+ @Override
+ public void init(FilterConfig filterConfig) throws ServletException {
+
+ }
+
+ @Override
+ public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,
+ FilterChain filterChain) throws IOException, ServletException {
+ SessionContextProvider contextProvider =
+ SessionContextProviderFactory.getInstance().createInterface();
+
+ try {
+ if (servletRequest instanceof HttpServletRequest) {
+ String userName = ((HttpServletRequest) servletRequest).getHeader(USER_ID_HEADER_PARAM);
+ contextProvider.create(userName);
+ }
+
+ filterChain.doFilter(servletRequest, servletResponse);
+ } finally {
+ contextProvider.close();
+ }
+ }
+
+ @Override
+ public void destroy() {
+
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/beans-services.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/beans-services.xml
index 8f4a2db..e43fa01 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/beans-services.xml
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/beans-services.xml
@@ -36,24 +36,14 @@
<!-- aspect beans -->
<bean id = "healthCheck" class="org.openecomp.sdcrests.health.rest.services.HealthCheckImpl"/>
- <!--aop:config>
- < aspect pointcuts>
- <aop:pointcut id="loggingDebugPointcut" expression="execution(* org.openecomp.sdc.*.*.*(..))"/>
-
- <advices>
- <aop:aspect id="logDebugAspect" ref="debugAspect">
- <aop:before pointcut-ref="loggingDebugPointcut" method="debugEnterMethod"/>
- <aop:after-returning pointcut-ref="loggingDebugPointcut" method="debugExitMethod"/>
- </aop:aspect>
- </aop:config-->
-
-
-
-
+ <bean id = "itemPermissions" class="org.openecomp.sdcrests.itempermissions.rest.services.ItemPermissionsImpl"/>
+ <bean id = "notifications" class="org.openecomp.sdcrests.notifications.rest.services.impl.NotificationsImpl"/>
<!-- RESTful Services -->
<jaxrs:server id="restContainer" address="/">
<jaxrs:serviceBeans>
+ <ref bean="versions"/>
+ <ref bean="conflicts"/>
<ref bean="vendorLicenseModels"/>
<ref bean="licenseAgreements"/>
<ref bean="featureGroups"/>
@@ -75,9 +65,10 @@
<ref bean="deploymentFlavors"/>
<ref bean="images"/>
<ref bean="orchestrationTemplateCandidate"/>
- <ref bean="componentDependencyModel"/>
- <ref bean="activityLog"/>
+ <ref bean="componentDependencies"/>
<ref bean="healthCheck"/>
+ <ref bean="itemPermissions"/>
+ <ref bean="notifications"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/spring-mapper-servlet.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/spring-mapper-servlet.xml
new file mode 100644
index 0000000..437df79
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/spring-mapper-servlet.xml
@@ -0,0 +1,13 @@
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+
+ <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
+ <property name="mappings">
+ <props>
+ </props>
+ </property>
+ </bean>
+
+</beans>
\ No newline at end of file
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/web.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/web.xml
index 35865f9..de88197 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/web.xml
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/web.xml
@@ -23,6 +23,19 @@
</listener>
<filter>
+ <filter-name>PermissionsFilter</filter-name>
+ <filter-class>org.openecomp.sdc.itempermissions.servlet.PermissionsFilter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>PermissionsFilter</filter-name>
+ <url-pattern>/v1.0/vendor-license-models/*</url-pattern>
+ </filter-mapping>
+ <filter-mapping>
+ <filter-name>PermissionsFilter</filter-name>
+ <url-pattern>/v1.0/vendor-software-products/*</url-pattern>
+ </filter-mapping>
+
+ <filter>
<filter-name>cross-origin</filter-name>
<filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>
<init-param>
@@ -68,6 +81,22 @@
<filter-name>LoggingServletFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
+ <filter>
+ <filter-name>SessionContextFilter</filter-name>
+ <filter-class>org.openecomp.server.filters.SessionContextFilter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>SessionContextFilter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+ <!-- Spring WS Mapping -->
+ <servlet>
+ <servlet-name>spring-mapper</servlet-name>
+ <servlet-class>
+ org.springframework.web.servlet.DispatcherServlet
+ </servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
<!-- CXF -->
<servlet>
<servlet-name>CXFServlet</servlet-name>
@@ -94,7 +123,10 @@
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
- <!--servlet-name>logger-aspect</servlet-name-->
+ <servlet-name>spring-mapper</servlet-name>
+ <url-pattern>/ws/*</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/RestConstants.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/RestConstants.java
index 7bc1082..302af10 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/RestConstants.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/RestConstants.java
@@ -21,10 +21,12 @@
package org.openecomp.sdcrests.common;
public class RestConstants {
- public static final String USER_ID_HEADER_PARAM = "USER_ID";
// value Should be equal to com.tlv.sdc.common.api.Constants#USER_ID_HEADER
+ public static final String USER_ID_HEADER_PARAM = "USER_ID";
+ public static final String LAST_DELIVERED_QUERY_PARAM = "LAST_DELIVERED_EVENT_ID";
public static final String USER_MISSING_ERROR_MSG =
"Field does not conform to predefined criteria : user : may not be null";
+
public static final String INVALID_JSON_ERROR_MESSAGE =
"Field does not conform to predefined criteria : body :must be in JSON format";
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/VersionDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/VersionDto.java
deleted file mode 100644
index b5b86c6..0000000
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/VersionDto.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.openecomp.sdcrests.common.types;
-
-/**
- * Created by SVISHNEV on 3/5/2017.
- */
-public class VersionDto {
- String id;
- String label;
-
- public VersionDto(){
-
- }
-
- public VersionDto(String id, String label) {
- this.id = id;
- this.label = label;
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getLabel() {
- return label;
- }
-
- public void setLabel(String label) {
- this.label = label;
- }
-}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/EchoMapMapping.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/EchoMapMapping.java
new file mode 100644
index 0000000..81c2f37
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/EchoMapMapping.java
@@ -0,0 +1,14 @@
+package org.openecomp.sdcrests.mapping;
+
+import java.util.HashMap;
+
+/**
+ * Created by ayalaben on 9/12/2017
+ */
+public class EchoMapMapping extends MappingBase<HashMap<String,String>,HashMap<String,String>> {
+
+ @Override
+public void doMapping(HashMap<String,String> source, HashMap<String, String> target) {
+ target.putAll(source);
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/EchoMapping.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/EchoMapping.java
new file mode 100644
index 0000000..4e5a22e
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/EchoMapping.java
@@ -0,0 +1,8 @@
+package org.openecomp.sdcrests.mapping;
+
+public class EchoMapping extends MappingBase <Object,Object>{
+ @Override
+ public void doMapping(Object source, Object target) {
+ target = source;
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/MappingBase.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/MappingBase.java
index 2310c0f..25c2be9 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/MappingBase.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/MappingBase.java
@@ -23,15 +23,11 @@
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
-import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
import org.openecomp.sdc.logging.types.LoggerConstants;
import org.openecomp.sdc.logging.types.LoggerServiceName;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-
/**
* Base class for all mapping classes. Mapping classes will perform data mapping from source object
* to target object Base class provides following<br> <ol> <li>provides life cycle of
@@ -55,8 +51,6 @@
* @return <code>T</code> - instance of type <code>T</code>
*/
- private final Logger logger = (Logger) LoggerFactory.getLogger(this.getClass().getName());
-
public final T applyMapping(final S source, Class<T> clazz) {
T target = (T) instantiateTarget(clazz);
if (source == null || target == null) {
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml
index 9970dfb..d44e0c8 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml
@@ -22,8 +22,12 @@
<module>/validation-rest</module>
<module>/action-library-rest</module>
<module>/application-config-rest</module>
- <module>/activity-log-rest</module>
<module>/healthcheck-rest</module>
+ <module>conflict-rest</module>
+ <module>item-permissions-rest</module>
+ <module>item-rest</module>
+ <module>notifications-fe</module>
+ <module>notifications-rest</module>
</modules>
</project>
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/Validation.java b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/Validation.java
index b08bc10..349f0bd 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/Validation.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/Validation.java
@@ -24,7 +24,6 @@
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
import org.springframework.validation.annotation.Validated;
-import java.io.InputStream;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
@@ -32,6 +31,7 @@
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import java.io.InputStream;
@Path("/v1.0/validation")
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/ValidationForSwaggerUsage.java b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/ValidationForSwaggerUsage.java
index fd5bea3..399f665 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/ValidationForSwaggerUsage.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/ValidationForSwaggerUsage.java
@@ -25,7 +25,6 @@
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
-import java.io.InputStream;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
@@ -33,6 +32,7 @@
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import java.io.InputStream;
@Path("/v1.0/validation")
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/services/ValidationImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/services/ValidationImpl.java
index 15675f1..f43ff60 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/services/ValidationImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/services/ValidationImpl.java
@@ -39,10 +39,10 @@
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
-import java.io.IOException;
-import java.io.InputStream;
import javax.inject.Named;
import javax.ws.rs.core.Response;
+import java.io.IOException;
+import java.io.InputStream;
@Named
@Service("validation")
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/pom.xml
index 643addc..cec09f0 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/pom.xml
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/pom.xml
@@ -30,13 +30,13 @@
</dependency>
<dependency>
<groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-vendor-license-manager</artifactId>
+ <artifactId>openecomp-sdc-item-permissions-manager</artifactId>
<version>${project.version}</version>
</dependency>
<!-- Spring -->
- <dependency>
+<!-- <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.framework.version}</version>
@@ -60,7 +60,7 @@
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.framework.version}</version>
- </dependency>
+ </dependency>-->
<!-- CXF -->
<dependency>
@@ -79,11 +79,11 @@
<version>${http.client.version}</version>
</dependency>
- <dependency>
+<!-- <dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>${ws.rs.version}</version>
- </dependency>
+ </dependency>-->
<!-- Other Stuff-->
<!--dependency>
@@ -105,8 +105,13 @@
<artifactId>openecomp-sdc-vendor-software-product-manager</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>item-rest-services</artifactId>
+ <version>${project.version}</version>
+ </dependency>
- </dependencies>
+ </dependencies>
<build>
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/EntitlementPoolLimits.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/EntitlementPoolLimits.java
index 3e7adc8..fb71b0a 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/EntitlementPoolLimits.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/EntitlementPoolLimits.java
@@ -1,12 +1,8 @@
package org.openecomp.sdcrests.vendorlicense.rest;
-import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
-import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
-
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
-
import org.openecomp.sdcrests.vendorlicense.types.LimitEntityDto;
import org.openecomp.sdcrests.vendorlicense.types.LimitRequestDto;
import org.springframework.validation.annotation.Validated;
@@ -15,9 +11,9 @@
import javax.validation.constraints.NotNull;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
-import javax.ws.rs.POST;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
+import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
@@ -25,8 +21,11 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-@Path("/v1.0/vendor-license-models/{vlmId}/versions/{versionId}/entitlement-pools" +
- "/{entitlementPoolId}/limits")
+import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
+import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
+
+@Path(
+ "/v1.0/vendor-license-models/{vlmId}/versions/{versionId}/entitlement-pools/{entitlementPoolId}/limits")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Api(value = "Vendor License Model - Entitlement Pool Limits")
@@ -37,16 +36,16 @@
@Path("/")
@ApiOperation(value = "Create vendor entitlement pool limits")
Response createLimit(@Valid LimitRequestDto request,
- @ApiParam(value = "Vendor license model Id") @PathParam("vlmId")
- String vlmId,
- @ApiParam(value = "Vendor license model version Id") @PathParam
- ("versionId")
- String versionId,
- @ApiParam(value = "Vendor license model Entitlement Pool Id")
- @PathParam("entitlementPoolId")
- String entitlementPoolId ,
- @NotNull(message = USER_MISSING_ERROR_MSG)
- @HeaderParam(USER_ID_HEADER_PARAM) String user);
+ @ApiParam(value = "Vendor license model Id") @PathParam("vlmId")
+ String vlmId,
+ @ApiParam(value = "Vendor license model version Id") @PathParam
+ ("versionId")
+ String versionId,
+ @ApiParam(value = "Vendor license model Entitlement Pool Id")
+ @PathParam("entitlementPoolId")
+ String entitlementPoolId,
+ @NotNull(message = USER_MISSING_ERROR_MSG)
+ @HeaderParam(USER_ID_HEADER_PARAM) String user);
@GET
@@ -72,7 +71,7 @@
String versionId,
@ApiParam(value = "Vendor license model Entitlement Pool Id")
@PathParam("entitlementPoolId")
- String entitlementPoolId ,
+ String entitlementPoolId,
@NotNull(message = USER_MISSING_ERROR_MSG)
@PathParam("limitId") String limitId,
@HeaderParam(USER_ID_HEADER_PARAM) String user);
@@ -94,10 +93,11 @@
@Path("/{limitId}")
@ApiOperation(value = "Delete vendor entitlement pool limit")
Response deleteLimit(
- @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId,
- @ApiParam(value = "Vendor license model version Id") @PathParam("versionId") String versionId,
- @ApiParam(value = "Vendor license model Entitlement pool Id") @PathParam("entitlementPoolId") String entitlementPoolId,
- @PathParam("limitId") String limitId,
- @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
+ @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId,
+ @ApiParam(value = "Vendor license model version Id") @PathParam("versionId") String versionId,
+ @ApiParam(value = "Vendor license model Entitlement pool Id") @PathParam("entitlementPoolId")
+ String entitlementPoolId,
+ @PathParam("limitId") String limitId,
+ @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/FeatureGroups.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/FeatureGroups.java
index a3a4e4d..7344459 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/FeatureGroups.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/FeatureGroups.java
@@ -20,9 +20,6 @@
package org.openecomp.sdcrests.vendorlicense.rest;
-import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
-import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
-
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@@ -46,6 +43,9 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
+import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
+
@Path("/v1.0/vendor-license-models/{vlmId}/versions/{versionId}/feature-groups")
@Produces(MediaType.APPLICATION_JSON)
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseKeyGroupLimits.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseKeyGroupLimits.java
index bd31dc5..0033304 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseKeyGroupLimits.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseKeyGroupLimits.java
@@ -1,8 +1,5 @@
package org.openecomp.sdcrests.vendorlicense.rest;
-import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
-import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
-
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@@ -24,8 +21,11 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-@Path("/v1.0/vendor-license-models/{vlmId}/versions/{versionId}/license-key-groups" +
- "/{licenseKeyGroupId}/limits")
+import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
+import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
+
+@Path(
+ "/v1.0/vendor-license-models/{vlmId}/versions/{versionId}/license-key-groups/{licenseKeyGroupId}/limits")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Api(value = "Vendor License Model - License Key Group Limits")
@@ -43,7 +43,7 @@
String versionId,
@ApiParam(value = "Vendor license model License Key Group Id")
@PathParam("licenseKeyGroupId")
- String licenseKeyGroupId ,
+ String licenseKeyGroupId,
@NotNull(message = USER_MISSING_ERROR_MSG)
@HeaderParam(USER_ID_HEADER_PARAM) String user);
@@ -70,7 +70,7 @@
String versionId,
@ApiParam(value = "Vendor license model License Key Group Id")
@PathParam("licenseKeyGroupId")
- String licenseKeyGroupId ,
+ String licenseKeyGroupId,
@NotNull(message = USER_MISSING_ERROR_MSG)
@PathParam("limitId") String limitId,
@HeaderParam(USER_ID_HEADER_PARAM) String user);
@@ -88,13 +88,14 @@
String limitId,
@NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
- @DELETE
- @Path("/{limitId}")
- @ApiOperation(value = "Delete vendor license key group limit")
- Response deleteLimit(
- @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId,
- @ApiParam(value = "Vendor license model version Id") @PathParam("versionId") String versionId,
- @ApiParam(value = "Vendor license model license key group Id") @PathParam("licenseKeyGroupId") String licenseKeyGroupId,
- @PathParam("limitId") String limitId,
- @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
+ @DELETE
+ @Path("/{limitId}")
+ @ApiOperation(value = "Delete vendor license key group limit")
+ Response deleteLimit(
+ @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId,
+ @ApiParam(value = "Vendor license model version Id") @PathParam("versionId") String versionId,
+ @ApiParam(value = "Vendor license model license key group Id") @PathParam("licenseKeyGroupId")
+ String licenseKeyGroupId,
+ @PathParam("limitId") String limitId,
+ @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/VendorLicenseModels.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/VendorLicenseModels.java
index 23a0960..9b1c096 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/VendorLicenseModels.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/VendorLicenseModels.java
@@ -24,6 +24,7 @@
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.openecomp.sdcrests.common.RestConstants;
+import org.openecomp.sdcrests.item.types.ItemDto;
import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelActionRequestDto;
import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelEntityDto;
import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelRequestDto;
@@ -31,7 +32,16 @@
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
-import javax.ws.rs.*;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@@ -45,65 +55,65 @@
@Validated
public interface VendorLicenseModels {
- @GET
- @Path("/")
- @ApiOperation(value = "List vendor license models",
- response = VendorLicenseModelEntityDto.class,
- responseContainer = "List")
- Response listLicenseModels(@ApiParam(
- value = "Currently supported value: 'Final' - only vendor License models with final versions "
- + "will be return - with their latest final version")
- @QueryParam("versionFilter") String versionFilter,
- @NotNull(message = USER_MISSING_ERROR_MSG)
- @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user);
+ @GET
+ @Path("/")
+ @ApiOperation(value = "List vendor license models",
+ response = ItemDto.class,
+ responseContainer = "List")
+ Response listLicenseModels(@ApiParam(value =
+ "Currently supported value: 'Certified' - only vendor License models with final versions "
+ + "will be return - with their latest final version")
+ @QueryParam("versionFilter") String versionStatus,
+ @NotNull(message = USER_MISSING_ERROR_MSG)
+ @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user);
- @POST
- @Path("/")
- @ApiOperation(value = "Create vendor license model")
- Response createLicenseModel(@Valid VendorLicenseModelRequestDto request,
- @NotNull(message = USER_MISSING_ERROR_MSG)
- @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user);
+ @POST
+ @Path("/")
+ @ApiOperation(value = "Create vendor license model")
+ Response createLicenseModel(@Valid VendorLicenseModelRequestDto request,
+ @NotNull(message = USER_MISSING_ERROR_MSG)
+ @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user);
- @PUT
- @Path("/{vlmId}/versions/{versionId}")
- @ApiOperation(value = "Update vendor license model")
- Response updateLicenseModel(@Valid VendorLicenseModelRequestDto request,
- @ApiParam(value = "Vendor license model Id") @PathParam("vlmId")
- String vlmId,
- @ApiParam(value = "Vendor license model version Id") @PathParam
- ("versionId") String versionId,
- @NotNull(message = USER_MISSING_ERROR_MSG)
- @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user);
+ @PUT
+ @Path("/{vlmId}/versions/{versionId}")
+ @ApiOperation(value = "Update vendor license model")
+ Response updateLicenseModel(@Valid VendorLicenseModelRequestDto request,
+ @ApiParam(value = "Vendor license model Id")
+ @PathParam("vlmId") String vlmId,
+ @ApiParam(value = "Vendor license model version Id")
+ @PathParam("versionId") String versionId,
+ @NotNull(message = USER_MISSING_ERROR_MSG)
+ @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user);
- @GET
- @Path("/{vlmId}/versions/{versionId}")
- @ApiOperation(value = "Get vendor license model",
- response = VendorLicenseModelEntityDto.class)
- Response getLicenseModel(
- @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId,
- @ApiParam(value = "Vendor license model version Id") @PathParam
- ("versionId") String versionId,
- @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(RestConstants.USER_ID_HEADER_PARAM)
- String user);
+ @GET
+ @Path("/{vlmId}/versions/{versionId}")
+ @ApiOperation(value = "Get vendor license model",
+ response = VendorLicenseModelEntityDto.class)
+ Response getLicenseModel(
+ @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId,
+ @ApiParam(value = "Vendor license model version Id") @PathParam
+ ("versionId") String versionId,
+ @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(RestConstants.USER_ID_HEADER_PARAM)
+ String user);
- @DELETE
- @Path("/{vlmId}/versions/{versionId}")
- @ApiOperation(value = "Delete vendor license model")
- Response deleteLicenseModel(
- @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId,
- @ApiParam(value = "Vendor license model version Id") @PathParam
- ("versionId") String versionId,
- @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(RestConstants.USER_ID_HEADER_PARAM)
- String user);
+ @DELETE
+ @Path("/{vlmId}/versions/{versionId}")
+ @ApiOperation(value = "Delete vendor license model")
+ Response deleteLicenseModel(
+ @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId,
+ @ApiParam(value = "Vendor license model version Id") @PathParam
+ ("versionId") String versionId,
+ @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(RestConstants.USER_ID_HEADER_PARAM)
+ String user);
- @PUT
- @Path("/{vlmId}/versions/{versionId}/actions")
- @ApiOperation(value = "Update vendor license model")
- Response actOnLicenseModel(@Valid VendorLicenseModelActionRequestDto request,
- @ApiParam(value = "Vendor license model Id") @PathParam("vlmId")
- String vlmId,
- @ApiParam(value = "Vendor license model version Id") @PathParam
- ("versionId") String versionId,
- @NotNull(message = USER_MISSING_ERROR_MSG)
- @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user);
+ @PUT
+ @Path("/{vlmId}/versions/{versionId}/actions")
+ @ApiOperation(value = "Update vendor license model")
+ Response actOnLicenseModel(@Valid VendorLicenseModelActionRequestDto request,
+ @ApiParam(value = "Vendor license model Id") @PathParam("vlmId")
+ String vlmId,
+ @ApiParam(value = "Vendor license model version Id") @PathParam
+ ("versionId") String versionId,
+ @NotNull(message = USER_MISSING_ERROR_MSG)
+ @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user);
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDetailsToVspCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVendorLicenseModelEntityToDto.java
similarity index 62%
rename from openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDetailsToVspCreationDto.java
rename to openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVendorLicenseModelEntityToDto.java
index f009d8b..7bdde1d 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDetailsToVspCreationDto.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVendorLicenseModelEntityToDto.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,15 +18,19 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdcrests.vsp.rest.mapping;
+package org.openecomp.sdcrests.vendorlicense.rest.mapping;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
import org.openecomp.sdcrests.mapping.MappingBase;
-import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspCreationDto;
+import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelEntityDto;
-public class MapVspDetailsToVspCreationDto extends MappingBase<VspDetails, VspCreationDto> {
+public class MapVendorLicenseModelEntityToDto
+ extends MappingBase<VendorLicenseModelEntity, VendorLicenseModelEntityDto> {
@Override
- public void doMapping(VspDetails source, VspCreationDto target) {
- target.setVspId(source.getId());
+ public void doMapping(VendorLicenseModelEntity source, VendorLicenseModelEntityDto target) {
+ target.setId(source.getId());
+ target.setVendorName(source.getVendorName());
+ target.setDescription(source.getDescription());
+ target.setIconRef(source.getIconRef());
}
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVersionedVendorLicenseModelToVendorLicenseModelEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVersionedVendorLicenseModelToVendorLicenseModelEntityDto.java
deleted file mode 100644
index 7c2db85..0000000
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVersionedVendorLicenseModelToVendorLicenseModelEntityDto.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdcrests.vendorlicense.rest.mapping;
-
-import org.openecomp.core.utilities.CommonMethods;
-import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
-import org.openecomp.sdc.vendorlicense.types.VersionedVendorLicenseModel;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.VersionInfo;
-import org.openecomp.sdcrests.common.types.VersionDto;
-import org.openecomp.sdcrests.mapping.MappingBase;
-import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelEntityDto;
-
-import java.util.stream.Collectors;
-
-public class MapVersionedVendorLicenseModelToVendorLicenseModelEntityDto
- extends MappingBase<VersionedVendorLicenseModel, VendorLicenseModelEntityDto> {
- @Override
- public void doMapping(VersionedVendorLicenseModel source, VendorLicenseModelEntityDto target) {
- VendorLicenseModelEntity sourceVlm = source.getVendorLicenseModel();
- target.setId(sourceVlm.getId());
- target.setVendorName(sourceVlm.getVendorName());
- target.setDescription(sourceVlm.getDescription());
- target.setIconRef(sourceVlm.getIconRef());
-
- VersionInfo versionInfo = source.getVersionInfo();
- if (versionInfo != null) {
- target.setVersion(new VersionDto(versionInfo.getActiveVersion().toString(),versionInfo
- .getActiveVersion().toString()));
- target.setStatus(versionInfo.getStatus());
- target.setLockingUser(versionInfo.getLockingUser());
-
- if (!CommonMethods.isEmpty(versionInfo.getViewableVersions())) {
- target.setViewableVersions(versionInfo.getViewableVersions().stream().map(version->new
- VersionDto(version.toString(),version.toString()))
- .collect(Collectors.toList()));
- }
-
- if (!CommonMethods.isEmpty(versionInfo.getFinalVersions())) {
- target.setFinalVersions(versionInfo.getFinalVersions().stream().map(version->new
- VersionDto(version.toString(),version.toString()))
- .collect(Collectors.toList()));
- }
- }
- }
-}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolLimitsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolLimitsImpl.java
index 4365ace..a866278 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolLimitsImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolLimitsImpl.java
@@ -17,14 +17,12 @@
import org.openecomp.sdcrests.vendorlicense.types.LimitEntityDto;
import org.openecomp.sdcrests.vendorlicense.types.LimitRequestDto;
import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper;
-import org.openecomp.sdcrests.wrappers.StringWrapperResponse;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
-import java.util.Collection;
import javax.inject.Named;
import javax.ws.rs.core.Response;
+import java.util.Collection;
@Named
@Service("entitlementPoolLimits")
@@ -32,7 +30,7 @@
public class EntitlementPoolLimitsImpl implements EntitlementPoolLimits {
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
private VendorLicenseManager vendorLicenseManager =
- VendorLicenseManagerFactory.getInstance().createInterface();
+ VendorLicenseManagerFactory.getInstance().createInterface();
public static final String parent = "EntitlementPool";
@@ -45,20 +43,20 @@
mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId, "EP id", entitlementPoolId);
MdcUtil.initMdc(LoggerServiceName.Create_LIMIT.toString());
- vendorLicenseManager.getEntitlementPool(new EntitlementPoolEntity(vlmId, Version.valueOf
- (versionId), entitlementPoolId), user);
+ Version version = new Version(versionId);
+ vendorLicenseManager
+ .getEntitlementPool(new EntitlementPoolEntity(vlmId, version, entitlementPoolId));
LimitEntity limitEntity =
- new MapLimitRequestDtoToLimitEntity()
- .applyMapping(request, LimitEntity.class);
- limitEntity.setEpLkgId(entitlementPoolId);
+ new MapLimitRequestDtoToLimitEntity().applyMapping(request, LimitEntity.class);
limitEntity.setVendorLicenseModelId(vlmId);
+ limitEntity.setVersion(version);
+ limitEntity.setEpLkgId(entitlementPoolId);
limitEntity.setParent(parent);
- LimitEntity createdLimit = vendorLicenseManager.createLimit(limitEntity, user);
+ LimitEntity createdLimit = vendorLicenseManager.createLimit(limitEntity);
MapLimitEntityToLimitCreationDto mapper = new MapLimitEntityToLimitCreationDto();
- LimitCreationDto createdLimitDto = mapper.applyMapping(createdLimit, LimitCreationDto
- .class);
+ LimitCreationDto createdLimitDto = mapper.applyMapping(createdLimit, LimitCreationDto.class);
/*StringWrapperResponse result =
createdLimit != null ? new StringWrapperResponse(createdLimit.getId())
@@ -67,25 +65,25 @@
mdcDataDebugMessage.debugExitMessage("VLM id", vlmId, "EP id", entitlementPoolId);
//return Response.ok(result).build();
- return Response.ok(createdLimitDto != null ? createdLimitDto : null)
- .build();
+ return Response.ok(createdLimitDto != null ? createdLimitDto : null).build();
}
@Override
public Response listLimits(String vlmId, String versionId, String entitlementPoolId, String
- user) {
+ user) {
mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId, "EP id", entitlementPoolId);
MdcUtil.initMdc(LoggerServiceName.List_EP.toString());
- vendorLicenseManager.getEntitlementPool(new EntitlementPoolEntity(vlmId, Version.valueOf
- (versionId), entitlementPoolId), user);
+ Version version = new Version(versionId);
+ vendorLicenseManager
+ .getEntitlementPool(new EntitlementPoolEntity(vlmId, version, entitlementPoolId));
Collection<LimitEntity> limits =
- vendorLicenseManager.listLimits(vlmId, Version.valueOf(versionId), entitlementPoolId, user);
+ vendorLicenseManager.listLimits(vlmId, version, entitlementPoolId);
GenericCollectionWrapper<LimitEntityDto> result = new GenericCollectionWrapper<>();
MapLimitEntityToLimitDto outputMapper =
- new MapLimitEntityToLimitDto();
+ new MapLimitEntityToLimitDto();
for (LimitEntity limit : limits) {
result.add(outputMapper.applyMapping(limit, LimitEntityDto.class));
}
@@ -96,28 +94,28 @@
}
@Override
- public Response getLimit( String vlmId, String versionId, String entitlementPoolId,
- String limitId, String user) {
- mdcDataDebugMessage.debugEntryMessage("VLM id, EP id, Limit Id", vlmId, entitlementPoolId,
- limitId);
+ public Response getLimit(String vlmId, String versionId, String entitlementPoolId,
+ String limitId, String user) {
+ mdcDataDebugMessage
+ .debugEntryMessage("VLM id, EP id, Limit Id", vlmId, entitlementPoolId, limitId);
MdcUtil.initMdc(LoggerServiceName.Get_LIMIT.toString());
- vendorLicenseManager.getEntitlementPool(new EntitlementPoolEntity(vlmId, Version.valueOf
- (versionId), entitlementPoolId), user);
- LimitEntity epInput = new LimitEntity();
- epInput.setVendorLicenseModelId(vlmId);
- epInput.setVersion(Version.valueOf(versionId));
- epInput.setEpLkgId(entitlementPoolId);
- epInput.setId(limitId);
- LimitEntity limit = vendorLicenseManager.getLimit(epInput, user);
+ Version version = new Version(versionId);
+ vendorLicenseManager
+ .getEntitlementPool(new EntitlementPoolEntity(vlmId, version, entitlementPoolId));
+ LimitEntity limitInput = new LimitEntity();
+ limitInput.setVendorLicenseModelId(vlmId);
+ limitInput.setVersion(version);
+ limitInput.setEpLkgId(entitlementPoolId);
+ limitInput.setId(limitId);
+ LimitEntity limit = vendorLicenseManager.getLimit(limitInput);
LimitEntityDto entitlementPoolEntityDto = limit == null ? null :
- new MapLimitEntityToLimitDto()
- .applyMapping(limit, LimitEntityDto.class);
+ new MapLimitEntityToLimitDto().applyMapping(limit, LimitEntityDto.class);
- mdcDataDebugMessage.debugExitMessage("VLM id, EP id, Limit Id", vlmId, entitlementPoolId,
- limitId);
+ mdcDataDebugMessage
+ .debugExitMessage("VLM id, EP id, Limit Id", vlmId, entitlementPoolId, limitId);
return Response.ok(entitlementPoolEntityDto).build();
}
@@ -129,26 +127,27 @@
String entitlementPoolId,
String limitId,
String user) {
- mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId, "EP id", entitlementPoolId, "limit Id",
- limitId);
+ mdcDataDebugMessage
+ .debugEntryMessage("VLM id", vlmId, "EP id", entitlementPoolId, "limit Id", limitId);
MdcUtil.initMdc(LoggerServiceName.Update_LIMIT.toString());
- vendorLicenseManager.getEntitlementPool(new EntitlementPoolEntity(vlmId, Version.valueOf
- (versionId), entitlementPoolId), user);
+ Version version = new Version(versionId);
+ vendorLicenseManager
+ .getEntitlementPool(new EntitlementPoolEntity(vlmId, version, entitlementPoolId));
LimitEntity limitEntity =
- new MapLimitRequestDtoToLimitEntity()
- .applyMapping(request, LimitEntity.class);
- limitEntity.setEpLkgId(entitlementPoolId);
+ new MapLimitRequestDtoToLimitEntity().applyMapping(request, LimitEntity.class);
limitEntity.setVendorLicenseModelId(vlmId);
+ limitEntity.setVersion(version);
+ limitEntity.setEpLkgId(entitlementPoolId);
limitEntity.setId(limitId);
limitEntity.setParent(parent);
- vendorLicenseManager.updateLimit(limitEntity, user);
+ vendorLicenseManager.updateLimit(limitEntity);
- mdcDataDebugMessage.debugExitMessage("VLM id", vlmId, "EP id", entitlementPoolId, "limit Id",
- limitId);
+ mdcDataDebugMessage
+ .debugExitMessage("VLM id", vlmId, "EP id", entitlementPoolId, "limit Id", limitId);
return Response.ok().build();
}
@@ -156,29 +155,33 @@
/**
* Delete entitlement pool.
*
- * @param vlmId the vlm id
- * @param entitlementPoolId the entitlement pool id
- * @param limitId the limitId
- * @param user the user
+ * @param vlmId the vlm id
+ * @param entitlementPoolId the entitlement pool id
+ * @param limitId the limitId
+ * @param user the user
* @return the response
*/
public Response deleteLimit(String vlmId, String versionId, String entitlementPoolId,
String limitId, String user) {
- mdcDataDebugMessage.debugEntryMessage("VLM id, Verison Id, EP id, Limit Id", vlmId, versionId, entitlementPoolId, limitId);
-
+ mdcDataDebugMessage.debugEntryMessage("VLM id, Verison Id, EP id, Limit Id", vlmId, versionId,
+ entitlementPoolId, limitId);
MdcUtil.initMdc(LoggerServiceName.Delete_LIMIT.toString());
- vendorLicenseManager.getEntitlementPool(new EntitlementPoolEntity(vlmId, Version.valueOf
- (versionId), entitlementPoolId), user);
+
+ Version version = new Version(versionId);
+ vendorLicenseManager.getEntitlementPool(
+ new EntitlementPoolEntity(vlmId, version, entitlementPoolId));
LimitEntity limitInput = new LimitEntity();
limitInput.setVendorLicenseModelId(vlmId);
+ limitInput.setVersion(version);
limitInput.setEpLkgId(entitlementPoolId);
limitInput.setId(limitId);
limitInput.setParent(parent);
- vendorLicenseManager.deleteLimit(limitInput, user);
+ vendorLicenseManager.deleteLimit(limitInput);
- mdcDataDebugMessage.debugExitMessage("VLM id, Verison Id, EP id, Limit Id", vlmId, versionId, entitlementPoolId, limitId);
+ mdcDataDebugMessage.debugExitMessage("VLM id, Verison Id, EP id, Limit Id", vlmId, versionId,
+ entitlementPoolId, limitId);
return Response.ok().build();
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolsImpl.java
index 120bb3d..8c31303 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolsImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolsImpl.java
@@ -34,7 +34,6 @@
import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolRequestDto;
import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper;
import org.openecomp.sdcrests.wrappers.StringWrapperResponse;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
@@ -64,7 +63,7 @@
MdcUtil.initMdc(LoggerServiceName.List_EP.toString());
Collection<EntitlementPoolEntity> entitlementPools =
- vendorLicenseManager.listEntitlementPools(vlmId, Version.valueOf(versionId), user);
+ vendorLicenseManager.listEntitlementPools(vlmId, new Version(versionId));
GenericCollectionWrapper<EntitlementPoolEntityDto> result = new GenericCollectionWrapper<>();
MapEntitlementPoolEntityToEntitlementPoolEntityDto outputMapper =
@@ -96,9 +95,10 @@
new MapEntitlementPoolRequestDtoToEntitlementPoolEntity()
.applyMapping(request, EntitlementPoolEntity.class);
entitlementPoolEntity.setVendorLicenseModelId(vlmId);
+ entitlementPoolEntity.setVersion(new Version(versionId));
EntitlementPoolEntity createdEntitlementPool =
- vendorLicenseManager.createEntitlementPool(entitlementPoolEntity, user);
+ vendorLicenseManager.createEntitlementPool(entitlementPoolEntity);
StringWrapperResponse result =
createdEntitlementPool != null ? new StringWrapperResponse(createdEntitlementPool.getId())
: null;
@@ -127,9 +127,10 @@
new MapEntitlementPoolRequestDtoToEntitlementPoolEntity()
.applyMapping(request, EntitlementPoolEntity.class);
entitlementPoolEntity.setVendorLicenseModelId(vlmId);
+ entitlementPoolEntity.setVersion(new Version(versionId));
entitlementPoolEntity.setId(entitlementPoolId);
- vendorLicenseManager.updateEntitlementPool(entitlementPoolEntity, user);
+ vendorLicenseManager.updateEntitlementPool(entitlementPoolEntity);
mdcDataDebugMessage.debugExitMessage("VLM id, EP id", vlmId, entitlementPoolId);
@@ -140,12 +141,12 @@
* Gets entitlement pool.
*
* @param vlmId the vlm id
- * @param version the version
+ * @param versionId the version id
* @param entitlementPoolId the entitlement pool id
* @param user the user
* @return the entitlement pool
*/
- public Response getEntitlementPool(String vlmId, String version, String entitlementPoolId,
+ public Response getEntitlementPool(String vlmId, String versionId, String entitlementPoolId,
String user) {
mdcDataDebugMessage.debugEntryMessage("VLM id, EP id", vlmId, entitlementPoolId);
@@ -153,9 +154,9 @@
MdcUtil.initMdc(LoggerServiceName.Get_EP.toString());
EntitlementPoolEntity epInput = new EntitlementPoolEntity();
epInput.setVendorLicenseModelId(vlmId);
- epInput.setVersion(Version.valueOf(version));
+ epInput.setVersion(new Version(versionId));
epInput.setId(entitlementPoolId);
- EntitlementPoolEntity entitlementPool = vendorLicenseManager.getEntitlementPool(epInput, user);
+ EntitlementPoolEntity entitlementPool = vendorLicenseManager.getEntitlementPool(epInput);
EntitlementPoolEntityDto entitlementPoolEntityDto = entitlementPool == null ? null :
new MapEntitlementPoolEntityToEntitlementPoolEntityDto()
@@ -183,7 +184,8 @@
EntitlementPoolEntity epInput = new EntitlementPoolEntity();
epInput.setVendorLicenseModelId(vlmId);
epInput.setId(entitlementPoolId);
- vendorLicenseManager.deleteEntitlementPool(epInput, user);
+ epInput.setVersion(new Version(versionId));
+ vendorLicenseManager.deleteEntitlementPool(epInput);
mdcDataDebugMessage.debugExitMessage("VLM id, EP id", vlmId, entitlementPoolId);
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/FeatureGroupsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/FeatureGroupsImpl.java
index 593ed19..9f87f98 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/FeatureGroupsImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/FeatureGroupsImpl.java
@@ -44,7 +44,6 @@
import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupEntityDto;
import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper;
import org.openecomp.sdcrests.wrappers.StringWrapperResponse;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
@@ -69,7 +68,7 @@
MdcUtil.initMdc(LoggerServiceName.List_FG.toString());
Collection<FeatureGroupEntity> featureGroupEntities =
- vendorLicenseManager.listFeatureGroups(vlmId, Version.valueOf(versionId), user);
+ vendorLicenseManager.listFeatureGroups(vlmId, new Version(versionId));
MapFeatureGroupEntityToFeatureGroupDescriptorDto outputMapper =
new MapFeatureGroupEntityToFeatureGroupDescriptorDto();
@@ -101,11 +100,12 @@
FeatureGroupEntity featureGroupEntity = new MapFeatureGroupDescriptorDtoToFeatureGroupEntity()
.applyMapping(request, FeatureGroupEntity.class);
featureGroupEntity.setVendorLicenseModelId(vlmId);
+ featureGroupEntity.setVersion(new Version(versionId));
featureGroupEntity.setLicenseKeyGroupIds(request.getAddedLicenseKeyGroupsIds());
featureGroupEntity.setEntitlementPoolIds(request.getAddedEntitlementPoolsIds());
FeatureGroupEntity createdFeatureGroup =
- vendorLicenseManager.createFeatureGroup(featureGroupEntity, user);
+ vendorLicenseManager.createFeatureGroup(featureGroupEntity);
StringWrapperResponse result =
createdFeatureGroup != null ? new StringWrapperResponse(createdFeatureGroup.getId()) : null;
@@ -125,12 +125,13 @@
FeatureGroupEntity featureGroupEntity = new MapFeatureGroupDescriptorDtoToFeatureGroupEntity()
.applyMapping(request, FeatureGroupEntity.class);
featureGroupEntity.setVendorLicenseModelId(vlmId);
+ featureGroupEntity.setVersion(new Version(versionId));
featureGroupEntity.setId(featureGroupId);
vendorLicenseManager
.updateFeatureGroup(featureGroupEntity, request.getAddedLicenseKeyGroupsIds(),
request.getRemovedLicenseKeyGroupsIds(), request.getAddedEntitlementPoolsIds(),
- request.getRemovedEntitlementPoolsIds(), user);
+ request.getRemovedEntitlementPoolsIds());
mdcDataDebugMessage.debugExitMessage("VLM id, FG id", vlmId, featureGroupId);
@@ -146,9 +147,9 @@
MdcUtil.initMdc(LoggerServiceName.Get_FG.toString());
FeatureGroupEntity fgInput = new FeatureGroupEntity();
fgInput.setVendorLicenseModelId(vlmId);
- fgInput.setVersion(Version.valueOf(versionId));
+ fgInput.setVersion(new Version(versionId));
fgInput.setId(featureGroupId);
- FeatureGroupModel featureGroupModel = vendorLicenseManager.getFeatureGroupModel(fgInput, user);
+ FeatureGroupModel featureGroupModel = vendorLicenseManager.getFeatureGroupModel(fgInput);
if (featureGroupModel == null) {
return Response.ok().build();
@@ -197,8 +198,9 @@
MdcUtil.initMdc(LoggerServiceName.Delete_FG.toString());
FeatureGroupEntity fgInput = new FeatureGroupEntity();
fgInput.setVendorLicenseModelId(vlmId);
+ fgInput.setVersion(new Version(versionId));
fgInput.setId(featureGroupId);
- vendorLicenseManager.deleteFeatureGroup(fgInput, user);
+ vendorLicenseManager.deleteFeatureGroup(fgInput);
mdcDataDebugMessage.debugExitMessage("VLM id, FG id", vlmId, featureGroupId);
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseAgreementsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseAgreementsImpl.java
index 60a2d68..210aadc 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseAgreementsImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseAgreementsImpl.java
@@ -41,14 +41,13 @@
import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementUpdateRequestDto;
import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper;
import org.openecomp.sdcrests.wrappers.StringWrapperResponse;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
-import java.util.Collection;
-import java.util.HashSet;
import javax.inject.Named;
import javax.ws.rs.core.Response;
+import java.util.Collection;
+import java.util.HashSet;
@Named
@Service("licenseAgreements")
@@ -62,9 +61,9 @@
/**
* List license agreements response.
*
- * @param vlmId the vlm id
+ * @param vlmId the vlm id
* @param versionId the version
- * @param user the user
+ * @param user the user
* @return the response
*/
public Response listLicenseAgreements(String vlmId, String versionId, String user) {
@@ -73,7 +72,7 @@
MdcUtil.initMdc(LoggerServiceName.List_LA.toString());
Collection<LicenseAgreementEntity> licenseAgreements =
- vendorLicenseManager.listLicenseAgreements(vlmId, Version.valueOf(versionId), user);
+ vendorLicenseManager.listLicenseAgreements(vlmId, new Version(versionId));
GenericCollectionWrapper<LicenseAgreementEntityDto> results = new GenericCollectionWrapper<>();
MapLicenseAgreementEntityToLicenseAgreementDescriptorDto outputMapper =
@@ -100,7 +99,7 @@
* @return the response
*/
public Response createLicenseAgreement(LicenseAgreementRequestDto request, String vlmId,
- String versionId,String user) {
+ String versionId, String user) {
mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId);
@@ -109,11 +108,11 @@
new MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity()
.applyMapping(request, LicenseAgreementEntity.class);
licenseAgreementEntity.setVendorLicenseModelId(vlmId);
- licenseAgreementEntity.setVersion(Version.valueOf(versionId));
+ licenseAgreementEntity.setVersion(new Version(versionId));
licenseAgreementEntity.setFeatureGroupIds(request.getAddedFeatureGroupsIds());
LicenseAgreementEntity createdLicenseAgreement =
- vendorLicenseManager.createLicenseAgreement(licenseAgreementEntity, user);
+ vendorLicenseManager.createLicenseAgreement(licenseAgreementEntity);
StringWrapperResponse result =
createdLicenseAgreement != null ? new StringWrapperResponse(createdLicenseAgreement.getId())
: null;
@@ -133,7 +132,7 @@
* @return the response
*/
public Response updateLicenseAgreement(LicenseAgreementUpdateRequestDto request, String vlmId,
- String versionId,String licenseAgreementId, String user) {
+ String versionId, String licenseAgreementId, String user) {
mdcDataDebugMessage.debugEntryMessage("VLM id, LA id", vlmId, licenseAgreementId);
@@ -142,12 +141,12 @@
new MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity()
.applyMapping(request, LicenseAgreementEntity.class);
licenseAgreementEntity.setVendorLicenseModelId(vlmId);
- licenseAgreementEntity.setVersion(Version.valueOf(versionId));
+ licenseAgreementEntity.setVersion(new Version(versionId));
licenseAgreementEntity.setId(licenseAgreementId);
vendorLicenseManager
.updateLicenseAgreement(licenseAgreementEntity, request.getAddedFeatureGroupsIds(),
- request.getRemovedFeatureGroupsIds(), user);
+ request.getRemovedFeatureGroupsIds());
mdcDataDebugMessage.debugExitMessage("VLM id, LA id", vlmId, licenseAgreementId);
@@ -158,7 +157,7 @@
* Gets license agreement.
*
* @param vlmId the vlm id
- * @param versionId the version
+ * @param versionId the version
* @param licenseAgreementId the license agreement id
* @param user the user
* @return the license agreement
@@ -170,7 +169,7 @@
MdcUtil.initMdc(LoggerServiceName.Get_LA.toString());
LicenseAgreementModel licenseAgreementModel = vendorLicenseManager
- .getLicenseAgreementModel(vlmId, Version.valueOf(versionId), licenseAgreementId, user);
+ .getLicenseAgreementModel(vlmId, new Version(versionId), licenseAgreementId);
if (licenseAgreementModel == null) {
return Response.ok().build();
@@ -206,18 +205,18 @@
* Delete license agreement response.
*
* @param vlmId the vlm id
- * @param versionId the version id
- * @param licenseAgreementId the license agreement id
+ * @param versionId the version id
+ * @param licenseAgreementId the license agreement id
* @param user the user
* @return the response
*/
- public Response deleteLicenseAgreement(String vlmId,String versionId, String licenseAgreementId,
+ public Response deleteLicenseAgreement(String vlmId, String versionId, String licenseAgreementId,
String user) {
mdcDataDebugMessage.debugEntryMessage("VLM id, LA id", vlmId, licenseAgreementId);
MdcUtil.initMdc(LoggerServiceName.Delete_LA.toString());
- vendorLicenseManager.deleteLicenseAgreement(vlmId, Version.valueOf(versionId), licenseAgreementId, user);
+ vendorLicenseManager.deleteLicenseAgreement(vlmId, new Version(versionId), licenseAgreementId);
mdcDataDebugMessage.debugExitMessage("VLM id, LA id", vlmId, licenseAgreementId);
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupLimitsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupLimitsImpl.java
index bedbc92..3aef837 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupLimitsImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupLimitsImpl.java
@@ -16,14 +16,12 @@
import org.openecomp.sdcrests.vendorlicense.types.LimitEntityDto;
import org.openecomp.sdcrests.vendorlicense.types.LimitRequestDto;
import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper;
-import org.openecomp.sdcrests.wrappers.StringWrapperResponse;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
-import java.util.Collection;
import javax.inject.Named;
import javax.ws.rs.core.Response;
+import java.util.Collection;
@Named
@Service("licenseKeyGroupLimits")
@@ -32,10 +30,11 @@
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
private VendorLicenseManager vendorLicenseManager =
- VendorLicenseManagerFactory.getInstance().createInterface();
+ VendorLicenseManagerFactory.getInstance().createInterface();
public static final String parent = "LicenseKeyGroup";
+
@Override
public Response createLimit(LimitRequestDto request,
String vlmId,
@@ -46,20 +45,20 @@
mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId, "LKG id", licenseKeyGroupId);
MdcUtil.initMdc(LoggerServiceName.Create_LIMIT.toString());
- vendorLicenseManager.getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, Version.valueOf
- (versionId), licenseKeyGroupId), user);
+ Version version = new Version(versionId);
+ vendorLicenseManager.getLicenseKeyGroup(
+ new LicenseKeyGroupEntity(vlmId, version, licenseKeyGroupId));
LimitEntity limitEntity =
- new MapLimitRequestDtoToLimitEntity()
- .applyMapping(request, LimitEntity.class);
- limitEntity.setEpLkgId(licenseKeyGroupId);
+ new MapLimitRequestDtoToLimitEntity().applyMapping(request, LimitEntity.class);
limitEntity.setVendorLicenseModelId(vlmId);
+ limitEntity.setVersion(version);
+ limitEntity.setEpLkgId(licenseKeyGroupId);
limitEntity.setParent(parent);
- LimitEntity createdLimit = vendorLicenseManager.createLimit(limitEntity, user);
+ LimitEntity createdLimit = vendorLicenseManager.createLimit(limitEntity);
MapLimitEntityToLimitCreationDto mapper = new MapLimitEntityToLimitCreationDto();
- LimitCreationDto createdLimitDto = mapper.applyMapping(createdLimit, LimitCreationDto
- .class);
+ LimitCreationDto createdLimitDto = mapper.applyMapping(createdLimit, LimitCreationDto.class);
/*StringWrapperResponse result =
createdLimit != null ? new StringWrapperResponse(createdLimit.getId())
: null;*/
@@ -67,25 +66,25 @@
mdcDataDebugMessage.debugExitMessage("VLM id", vlmId, "LKG id", licenseKeyGroupId);
//return Response.ok(result).build();
- return Response.ok(createdLimitDto != null ? createdLimitDto : null)
- .build();
+ return Response.ok(createdLimitDto != null ? createdLimitDto : null).build();
}
@Override
- public Response listLimits(String vlmId, String versionId, String licenseKeyGroupId, String
- user) {
+ public Response listLimits(String vlmId, String versionId, String licenseKeyGroupId,
+ String user) {
mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId, "LKG id", licenseKeyGroupId);
MdcUtil.initMdc(LoggerServiceName.List_EP.toString());
- vendorLicenseManager.getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, Version.valueOf
- (versionId), licenseKeyGroupId), user);
+ Version version = new Version(versionId);
+ vendorLicenseManager
+ .getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, version, licenseKeyGroupId));
Collection<LimitEntity> limits =
- vendorLicenseManager.listLimits(vlmId, Version.valueOf(versionId), licenseKeyGroupId, user);
+ vendorLicenseManager.listLimits(vlmId, version, licenseKeyGroupId);
GenericCollectionWrapper<LimitEntityDto> result = new GenericCollectionWrapper<>();
MapLimitEntityToLimitDto outputMapper =
- new MapLimitEntityToLimitDto();
+ new MapLimitEntityToLimitDto();
for (LimitEntity limit : limits) {
result.add(outputMapper.applyMapping(limit, LimitEntityDto.class));
}
@@ -103,25 +102,26 @@
String limitId,
String user) {
mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId, "LKG id", licenseKeyGroupId, "limit Id",
- limitId);
+ limitId);
MdcUtil.initMdc(LoggerServiceName.Update_LIMIT.toString());
- vendorLicenseManager.getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, Version.valueOf
- (versionId), licenseKeyGroupId), user);
+ Version version = new Version(versionId);
+ vendorLicenseManager
+ .getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, version, licenseKeyGroupId));
LimitEntity limitEntity =
- new MapLimitRequestDtoToLimitEntity()
- .applyMapping(request, LimitEntity.class);
- limitEntity.setEpLkgId(licenseKeyGroupId);
+ new MapLimitRequestDtoToLimitEntity().applyMapping(request, LimitEntity.class);
limitEntity.setVendorLicenseModelId(vlmId);
+ limitEntity.setVersion(version);
+ limitEntity.setEpLkgId(licenseKeyGroupId);
limitEntity.setId(limitId);
limitEntity.setParent(parent);
- vendorLicenseManager.updateLimit(limitEntity, user);
+ vendorLicenseManager.updateLimit(limitEntity);
- mdcDataDebugMessage.debugExitMessage("VLM id", vlmId, "LKG id", licenseKeyGroupId, "limit Id",
- limitId);
+ mdcDataDebugMessage
+ .debugExitMessage("VLM id", vlmId, "LKG id", licenseKeyGroupId, "limit Id", limitId);
return Response.ok().build();
}
@@ -129,57 +129,59 @@
/**
* Delete License Key Group.
*
- * @param vlmId the vlm id
- * @param licenseKeyGroupId the license Key Group id
- * @param limitId the limitId
- * @param user the user
+ * @param vlmId the vlm id
+ * @param licenseKeyGroupId the license Key Group id
+ * @param limitId the limitId
+ * @param user the user
* @return the response
*/
public Response deleteLimit(String vlmId, String versionId, String licenseKeyGroupId,
String limitId, String user) {
mdcDataDebugMessage.debugEntryMessage("VLM id, Verison Id, LKG id, Limit Id", vlmId, versionId,
- licenseKeyGroupId, limitId);
-
+ licenseKeyGroupId, limitId);
MdcUtil.initMdc(LoggerServiceName.Delete_LIMIT.toString());
- vendorLicenseManager.getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, Version.valueOf
- (versionId), licenseKeyGroupId), user);
+
+ Version version = new Version(versionId);
+ vendorLicenseManager
+ .getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, version, licenseKeyGroupId));
LimitEntity limitInput = new LimitEntity();
limitInput.setVendorLicenseModelId(vlmId);
+ limitInput.setVersion(version);
limitInput.setEpLkgId(licenseKeyGroupId);
limitInput.setId(limitId);
limitInput.setParent(parent);
- vendorLicenseManager.deleteLimit(limitInput, user);
+ vendorLicenseManager.deleteLimit(limitInput);
mdcDataDebugMessage.debugExitMessage("VLM id, Verison Id, LKG id, Limit Id", vlmId, versionId,
- licenseKeyGroupId, limitId);
+ licenseKeyGroupId, limitId);
return Response.ok().build();
}
@Override
- public Response getLimit( String vlmId, String versionId, String licenseKeyGroupId,
- String limitId, String user) {
+ public Response getLimit(String vlmId, String versionId, String licenseKeyGroupId,
+ String limitId, String user) {
mdcDataDebugMessage.debugEntryMessage("VLM id, LKG id, Limit Id", vlmId, licenseKeyGroupId,
- limitId);
+ limitId);
MdcUtil.initMdc(LoggerServiceName.Get_LIMIT.toString());
- vendorLicenseManager.getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, Version.valueOf
- (versionId), licenseKeyGroupId), user);
- LimitEntity epInput = new LimitEntity();
- epInput.setVendorLicenseModelId(vlmId);
- epInput.setVersion(Version.valueOf(versionId));
- epInput.setEpLkgId(licenseKeyGroupId);
- epInput.setId(limitId);
- LimitEntity limit = vendorLicenseManager.getLimit(epInput, user);
+ Version version = new Version(versionId);
+ vendorLicenseManager
+ .getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, version, licenseKeyGroupId));
+ LimitEntity limitInput = new LimitEntity();
+ limitInput.setVendorLicenseModelId(vlmId);
+ limitInput.setVersion(version);
+ limitInput.setEpLkgId(licenseKeyGroupId);
+ limitInput.setId(limitId);
+ LimitEntity limit = vendorLicenseManager.getLimit(limitInput);
- LimitEntityDto entitlementPoolEntityDto = limit == null ? null :
- new MapLimitEntityToLimitDto()
- .applyMapping(limit, LimitEntityDto.class);
+ LimitEntityDto entitlementPoolEntityDto = limit == null ? null
+ : new MapLimitEntityToLimitDto().applyMapping(limit, LimitEntityDto.class);
- mdcDataDebugMessage.debugExitMessage("VLM id, LKG id, Limit Id", vlmId, licenseKeyGroupId,
- limitId);
+ mdcDataDebugMessage
+ .debugExitMessage("VLM id, LKG id, Limit Id", vlmId, licenseKeyGroupId, limitId);
return Response.ok(entitlementPoolEntityDto).build();
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupsImpl.java
index 4c4bf13..6fe33d7 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupsImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupsImpl.java
@@ -34,7 +34,6 @@
import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupRequestDto;
import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper;
import org.openecomp.sdcrests.wrappers.StringWrapperResponse;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@@ -67,7 +66,7 @@
MdcUtil.initMdc(LoggerServiceName.List_LKG.toString());
Collection<LicenseKeyGroupEntity> licenseKeyGroups =
- vendorLicenseManager.listLicenseKeyGroups(vlmId, Version.valueOf(versionId), user);
+ vendorLicenseManager.listLicenseKeyGroups(vlmId, new Version(versionId));
GenericCollectionWrapper<LicenseKeyGroupEntityDto> result = new GenericCollectionWrapper<>();
MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto outputMapper =
@@ -99,9 +98,10 @@
new MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity()
.applyMapping(request, LicenseKeyGroupEntity.class);
licenseKeyGroupEntity.setVendorLicenseModelId(vlmId);
+ licenseKeyGroupEntity.setVersion(new Version(versionId));
LicenseKeyGroupEntity createdLicenseKeyGroup =
- vendorLicenseManager.createLicenseKeyGroup(licenseKeyGroupEntity, user);
+ vendorLicenseManager.createLicenseKeyGroup(licenseKeyGroupEntity);
StringWrapperResponse result =
createdLicenseKeyGroup != null ? new StringWrapperResponse(createdLicenseKeyGroup.getId())
: null;
@@ -131,9 +131,10 @@
new MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity()
.applyMapping(request, LicenseKeyGroupEntity.class);
licenseKeyGroupEntity.setVendorLicenseModelId(vlmId);
+ licenseKeyGroupEntity.setVersion(new Version(versionId));
licenseKeyGroupEntity.setId(licenseKeyGroupId);
- vendorLicenseManager.updateLicenseKeyGroup(licenseKeyGroupEntity, user);
+ vendorLicenseManager.updateLicenseKeyGroup(licenseKeyGroupEntity);
mdcDataDebugMessage.debugExitMessage("VLM id, LKG id", vlmId, licenseKeyGroupId);
@@ -157,9 +158,9 @@
MdcUtil.initMdc(LoggerServiceName.Get_LKG.toString());
LicenseKeyGroupEntity lkgInput = new LicenseKeyGroupEntity();
lkgInput.setVendorLicenseModelId(vlmId);
- lkgInput.setVersion(Version.valueOf(versionId));
+ lkgInput.setVersion(new Version(versionId));
lkgInput.setId(licenseKeyGroupId);
- LicenseKeyGroupEntity licenseKeyGroup = vendorLicenseManager.getLicenseKeyGroup(lkgInput, user);
+ LicenseKeyGroupEntity licenseKeyGroup = vendorLicenseManager.getLicenseKeyGroup(lkgInput);
LicenseKeyGroupEntityDto licenseKeyGroupEntityDto = licenseKeyGroup == null ? null :
new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto()
@@ -186,8 +187,9 @@
MdcUtil.initMdc(LoggerServiceName.Delete_LKG.toString());
LicenseKeyGroupEntity lkgInput = new LicenseKeyGroupEntity();
lkgInput.setVendorLicenseModelId(vlmId);
+ lkgInput.setVersion(new Version(versionId));
lkgInput.setId(licenseKeyGroupId);
- vendorLicenseManager.deleteLicenseKeyGroup(lkgInput, user);
+ vendorLicenseManager.deleteLicenseKeyGroup(lkgInput);
mdcDataDebugMessage.debugExitMessage("VLM id, LKG id", vlmId, licenseKeyGroupId);
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImpl.java
index 6d88e4c..2b8e5a3 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImpl.java
@@ -20,37 +20,67 @@
package org.openecomp.sdcrests.vendorlicense.rest.services;
+import org.openecomp.core.util.UniqueValueUtil;
+import org.openecomp.sdc.activitylog.ActivityLogManager;
+import org.openecomp.sdc.activitylog.ActivityLogManagerFactory;
+import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
+import org.openecomp.sdc.activitylog.dao.type.ActivityType;
+import org.openecomp.sdc.common.errors.Messages;
+import org.openecomp.sdc.datatypes.model.ItemType;
+import org.openecomp.sdc.healing.factory.HealingManagerFactory;
+import org.openecomp.sdc.itempermissions.ItemPermissionsManager;
+import org.openecomp.sdc.itempermissions.ItemPermissionsManagerFactory;
+import org.openecomp.sdc.itempermissions.impl.types.PermissionTypes;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.MdcUtil;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.logging.messages.AuditMessages;
-import org.openecomp.sdc.logging.types.LoggerConstants;
import org.openecomp.sdc.logging.types.LoggerServiceName;
+import org.openecomp.sdc.notification.dtos.Event;
+import org.openecomp.sdc.notification.factories.NotificationPropagationManagerFactory;
+import org.openecomp.sdc.notification.services.NotificationPropagationManager;
+import org.openecomp.sdc.vendorlicense.VendorLicenseConstants;
import org.openecomp.sdc.vendorlicense.VendorLicenseManager;
import org.openecomp.sdc.vendorlicense.VendorLicenseManagerFactory;
import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
-import org.openecomp.sdc.vendorlicense.types.VersionedVendorLicenseModel;
-import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
-import org.openecomp.sdc.vendorsoftwareproduct.VspManagerFactory;
+import org.openecomp.sdc.versioning.ItemManager;
+import org.openecomp.sdc.versioning.ItemManagerFactory;
+import org.openecomp.sdc.versioning.VersioningManager;
+import org.openecomp.sdc.versioning.VersioningManagerFactory;
import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.dao.types.VersionStatus;
+import org.openecomp.sdc.versioning.types.Item;
+import org.openecomp.sdc.versioning.types.NotificationEventTypes;
+import org.openecomp.sdcrests.item.rest.mapping.MapItemToDto;
+import org.openecomp.sdcrests.item.rest.mapping.MapVersionToDto;
+import org.openecomp.sdcrests.item.types.ItemCreationDto;
+import org.openecomp.sdcrests.item.types.ItemDto;
+import org.openecomp.sdcrests.item.types.VersionDto;
import org.openecomp.sdcrests.vendorlicense.rest.VendorLicenseModels;
+import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapVendorLicenseModelEntityToDto;
import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity;
-import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapVersionedVendorLicenseModelToVendorLicenseModelEntityDto;
import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelActionRequestDto;
import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelEntityDto;
import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelRequestDto;
import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper;
-import org.openecomp.sdcrests.wrappers.StringWrapperResponse;
-import org.slf4j.MDC;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.inject.Named;
import javax.ws.rs.core.Response;
-import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import java.util.function.Predicate;
+
+import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_USER;
+import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_ID;
+import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_NAME;
+import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.SUBMIT_DESCRIPTION;
+import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_ID;
+import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_NAME;
@Named
@Service("vendorLicenseModels")
@@ -59,140 +89,248 @@
public class VendorLicenseModelsImpl implements VendorLicenseModels {
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private static final Logger logger = LoggerFactory.getLogger(VendorLicenseModelsImpl.class);
+ public static final String SUBMIT_ITEM = "Submit_Item";
+ private ItemPermissionsManager permissionsManager = ItemPermissionsManagerFactory.getInstance()
+ .createInterface();
+ private NotificationPropagationManager notifier =
+ NotificationPropagationManagerFactory.getInstance().createInterface();
+
+ private ItemManager itemManager = ItemManagerFactory.getInstance().createInterface();
+ private VersioningManager versioningManager =
+ VersioningManagerFactory.getInstance().createInterface();
private VendorLicenseManager vendorLicenseManager =
VendorLicenseManagerFactory.getInstance().createInterface();
+ private ActivityLogManager activityLogManager =
+ ActivityLogManagerFactory.getInstance().createInterface();
- private static final Logger logger =
- LoggerFactory.getLogger(VendorLicenseModelsImpl.class);
+ @Override
+ public Response listLicenseModels(String versionStatus, String user) {
+ mdcDataDebugMessage.debugEntryMessage(null);
+ MdcUtil.initMdc(LoggerServiceName.List_VLM.toString());
- @Override
- public Response listLicenseModels(String versionFilter, String user) {
+ Predicate<Item> itemPredicate;
+ if (VersionStatus.Certified.name().equals(versionStatus)) {
+ itemPredicate = item -> ItemType.vlm.name().equals(item.getType()) &&
+ item.getVersionStatusCounters().containsKey(VersionStatus.Certified);
- mdcDataDebugMessage.debugEntryMessage(null, null);
- MdcUtil.initMdc(LoggerServiceName.List_VLM.toString());
- Collection<VersionedVendorLicenseModel> versionedVendorLicenseModels =
- vendorLicenseManager.listVendorLicenseModels(versionFilter, user);
+ } else if (VersionStatus.Draft.name().equals(versionStatus)) {
+ itemPredicate = item -> ItemType.vlm.name().equals(item.getType()) &&
+ item.getVersionStatusCounters().containsKey(VersionStatus.Draft) &&
+ userHasPermission(item.getId(), user);
- GenericCollectionWrapper<VendorLicenseModelEntityDto> results =
- new GenericCollectionWrapper<>();
- MapVersionedVendorLicenseModelToVendorLicenseModelEntityDto outputMapper =
- new MapVersionedVendorLicenseModelToVendorLicenseModelEntityDto();
- for (VersionedVendorLicenseModel versionedVlm : versionedVendorLicenseModels) {
- results.add(outputMapper.applyMapping(versionedVlm, VendorLicenseModelEntityDto.class));
- }
-
- mdcDataDebugMessage.debugExitMessage(null, null);
-
- return Response.ok(results).build();
+ } else {
+ itemPredicate = item -> ItemType.vlm.name().equals(item.getType());
}
- @Override
- public Response createLicenseModel(VendorLicenseModelRequestDto request, String user) {
+ GenericCollectionWrapper<ItemDto> results = new GenericCollectionWrapper<>();
+ MapItemToDto mapper = new MapItemToDto();
+ itemManager.list(itemPredicate).stream()
+ .sorted((o1, o2) -> o2.getModificationTime().compareTo(o1.getModificationTime()))
+ .forEach(vspItem -> results.add(mapper.applyMapping(vspItem, ItemDto.class)));
- mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null);
+ return Response.ok(results).build();
+ }
- logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.CREATE_VLM
- + request.getVendorName());
-
+ @Override
+ public Response createLicenseModel(VendorLicenseModelRequestDto request, String user) {
+ mdcDataDebugMessage.debugEntryMessage(null);
+ logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.CREATE_VLM + request.getVendorName());
MdcUtil.initMdc(LoggerServiceName.Create_VLM.toString());
- VendorLicenseModelEntity vendorLicenseModelEntity =
+
+ Item item = new Item();
+ item.setType(ItemType.vlm.name());
+ item.setName(request.getVendorName());
+ item.setDescription(request.getDescription());
+
+ UniqueValueUtil
+ .validateUniqueValue(VendorLicenseConstants.UniqueValues.VENDOR_NAME, item.getName());
+ item = itemManager.create(item);
+ UniqueValueUtil
+ .createUniqueValue(VendorLicenseConstants.UniqueValues.VENDOR_NAME, item.getName());
+
+ Version version = versioningManager.create(item.getId(), new Version(), null);
+
+ VendorLicenseModelEntity vlm = new MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity()
+ .applyMapping(request, VendorLicenseModelEntity.class);
+ vlm.setId(item.getId());
+ vlm.setVersion(version);
+
+ vendorLicenseManager.createVendorLicenseModel(vlm);
+ versioningManager.publish(item.getId(), version, "Initial vlm:" + vlm.getVendorName());
+
+ ItemCreationDto itemCreationDto = new ItemCreationDto();
+ itemCreationDto.setItemId(item.getId());
+ itemCreationDto.setVersion(new MapVersionToDto().applyMapping(version, VersionDto.class));
+
+ activityLogManager.logActivity(new ActivityLogEntity(vlm.getId(), version,
+ ActivityType.Create, user, true, "", ""));
+
+ mdcDataDebugMessage.debugExitMessage(null);
+ return Response.ok(itemCreationDto).build();
+ }
+
+ @Override
+ public Response updateLicenseModel(VendorLicenseModelRequestDto request, String vlmId,
+ String versionId, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId);
+ MdcUtil.initMdc(LoggerServiceName.Update_VLM.toString());
+
+ VendorLicenseModelEntity vlm =
new MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity()
.applyMapping(request, VendorLicenseModelEntity.class);
- VendorLicenseModelEntity createdVendorLicenseModel =
- vendorLicenseManager.createVendorLicenseModel(vendorLicenseModelEntity, user);
- StringWrapperResponse result = createdVendorLicenseModel != null ? new StringWrapperResponse(
- createdVendorLicenseModel.getId()) : null;
+ vlm.setId(vlmId);
+ vlm.setVersion(new Version(versionId));
- mdcDataDebugMessage.debugExitMessage(null, null);
+ vendorLicenseManager.updateVendorLicenseModel(vlm);
- return Response.ok(result).build();
+ mdcDataDebugMessage.debugExitMessage("VLM id", vlmId);
+ return Response.ok().build();
+ }
+
+ @Override
+ public Response getLicenseModel(String vlmId, String versionId, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId);
+ MdcUtil.initMdc(LoggerServiceName.Get_VLM.toString());
+
+ Version version = versioningManager.get(vlmId, new Version(versionId));
+ VendorLicenseModelEntity vlm = vendorLicenseManager.getVendorLicenseModel(vlmId, version);
+ vlm.setWritetimeMicroSeconds(version.getModificationTime().getTime());
+
+ try {
+ Optional<Version> healedVersion = HealingManagerFactory.getInstance().createInterface()
+ .healItemVersion(vlmId, version, ItemType.vlm, false);
+ healedVersion.ifPresent(vlm::setVersion);
+
+ if (healedVersion.isPresent() && version.getStatus() == VersionStatus.Certified) {
+ try {
+ submit(vlmId, healedVersion.get(), "Submit after heal", user);
+ } catch (Exception ex) {
+ logger.error("VLM Id {}: Error while submitting version {} " +
+ "created based on Certified version {} for healing purpose.",
+ vlmId, healedVersion.get().getId(), versionId, ex.getMessage());
+ }
+ }
+ } catch (Exception e) {
+ logger.error(String.format("Error while auto healing VLM with Id %s and version %s: %s",
+ vlmId, versionId, e.getMessage()));
}
- @Override
- public Response updateLicenseModel(VendorLicenseModelRequestDto request, String vlmId,
- String versionId, String user) {
+ VendorLicenseModelEntityDto vlmDto =
+ new MapVendorLicenseModelEntityToDto().applyMapping(vlm, VendorLicenseModelEntityDto.class);
- mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId);
+ mdcDataDebugMessage.debugExitMessage("VLM id", vlmId);
+ return Response.ok(vlmDto).build();
+ }
- MdcUtil.initMdc(LoggerServiceName.Update_VLM.toString());
- VendorLicenseModelEntity vendorLicenseModelEntity =
- new MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity()
- .applyMapping(request, VendorLicenseModelEntity.class);
- vendorLicenseModelEntity.setId(vlmId);
+ @Override
+ public Response deleteLicenseModel(String vlmId, String versionId, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId);
- vendorLicenseManager.updateVendorLicenseModel(vendorLicenseModelEntity, user);
+ MdcUtil.initMdc(LoggerServiceName.Delete_VLM.toString());
+ vendorLicenseManager.deleteVendorLicenseModel(vlmId, new Version(versionId));
- mdcDataDebugMessage.debugExitMessage("VLM id", vlmId);
+ mdcDataDebugMessage.debugExitMessage("VLM id", vlmId);
- return Response.ok().build();
- }
+ return Response.ok().build();
+ }
- @Override
- public Response getLicenseModel(String vlmId, String versionId, String user) {
-
- mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId);
-
- MdcUtil.initMdc(LoggerServiceName.Get_VLM.toString());
- VersionedVendorLicenseModel versionedVlm =
- vendorLicenseManager.getVendorLicenseModel(vlmId, Version.valueOf(versionId), user);
-
- VendorLicenseModelEntityDto vlmDto = versionedVlm == null ? null :
- new MapVersionedVendorLicenseModelToVendorLicenseModelEntityDto()
- .applyMapping(versionedVlm, VendorLicenseModelEntityDto.class);
-
- mdcDataDebugMessage.debugExitMessage("VLM id", vlmId);
-
- return Response.ok(vlmDto).build();
- }
-
- @Override
- public Response deleteLicenseModel(String vlmId, String versionId, String user) {
-
- mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId);
-
- MdcUtil.initMdc(LoggerServiceName.Delete_VLM.toString());
- vendorLicenseManager.deleteVendorLicenseModel(vlmId, user);
-
- mdcDataDebugMessage.debugExitMessage("VLM id", vlmId);
-
- return Response.ok().build();
- }
-
- @Override
- public Response actOnLicenseModel(VendorLicenseModelActionRequestDto request, String vlmId,
- String versionId, String user) {
+ @Override
+ public Response actOnLicenseModel(VendorLicenseModelActionRequestDto request, String vlmId,
+ String versionId, String user) {
+ Version version = new Version(versionId);
switch (request.getAction()) {
- case Checkout:
- MDC.put(LoggerConstants.SERVICE_NAME,
- LoggerServiceName.Checkout_VLM.toString());
- logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.CHECK_OUT_VLM
- + vlmId);
- vendorLicenseManager.checkout(vlmId, user);
- break;
- case Undo_Checkout:
- MDC.put(LoggerConstants.SERVICE_NAME,
- LoggerServiceName.Undo_Checkout_VLM.toString());
- vendorLicenseManager.undoCheckout(vlmId, user);
- break;
- case Checkin:
- MDC.put(LoggerConstants.SERVICE_NAME,
- LoggerServiceName.Checkin_VLM.toString());
- logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.CHECK_IN_VLM
- + vlmId);
- vendorLicenseManager.checkin(vlmId, user);
- break;
case Submit:
- MDC.put(LoggerConstants.SERVICE_NAME,
- LoggerServiceName.Submit_VLM.toString());
- logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.SUBMIT_VLM
- + vlmId);
- vendorLicenseManager.submit(vlmId, user);
+ if (!permissionsManager.isAllowed(vlmId, user, SUBMIT_ITEM)) {
+ return Response.status(Response.Status.FORBIDDEN).entity
+ (new Exception(Messages.PERMISSIONS_ERROR.getErrorMessage())).build();
+ }
+ String message =
+ request.getSubmitRequest() == null ? "" : request.getSubmitRequest().getMessage();
+ submit(vlmId, version, message, user);
+
+ notifyUsers(vlmId, version, message, user, NotificationEventTypes.SUBMIT);
break;
default:
}
- return Response.ok().build();
+ return Response.ok().build();
+ }
+
+ private void submit(String vlmId, Version version, String message, String user) {
+ MdcUtil.initMdc(LoggerServiceName.Submit_VLM.toString());
+ logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.SUBMIT_VLM + vlmId);
+
+ vendorLicenseManager.validate(vlmId, version);
+ versioningManager.submit(vlmId, version, message);
+
+ activityLogManager.logActivity(
+ new ActivityLogEntity(vlmId, version, ActivityType.Submit, user, true, "", message));
+ }
+
+ private void notifyUsers(String itemId, Version version, String message,
+ String userName, NotificationEventTypes eventType) {
+ Map<String, Object> eventProperties = new HashMap<>();
+ eventProperties.put(ITEM_NAME, itemManager.get(itemId).getName());
+ eventProperties.put(ITEM_ID, itemId);
+
+ Version ver = versioningManager.get(itemId, version);
+ eventProperties.put(VERSION_NAME, ver.getName());
+ eventProperties.put(VERSION_ID, ver.getId());
+
+ eventProperties.put(SUBMIT_DESCRIPTION, message);
+ eventProperties.put(PERMISSION_USER, userName);
+
+ Event syncEvent = new SyncEvent(eventType.getEventName(), itemId, eventProperties, itemId);
+ try {
+ notifier.notifySubscribers(syncEvent, userName);
+ } catch (Exception e) {
+ logger.error("Failed to send sync notification to users subscribed o item '" + itemId);
}
+ }
+
+ private class SyncEvent implements Event {
+
+ private String eventType;
+ private String originatorId;
+ private Map<String, Object> attributes;
+ private String entityId;
+
+ public SyncEvent(String eventType, String originatorId,
+ Map<String, Object> attributes, String entityId) {
+ this.eventType = eventType;
+ this.originatorId = originatorId;
+ this.attributes = attributes;
+ this.entityId = entityId;
+ }
+
+ @Override
+ public String getEventType() {
+ return eventType;
+ }
+
+ @Override
+ public String getOriginatorId() {
+ return originatorId;
+ }
+
+ @Override
+ public Map<String, Object> getAttributes() {
+ return attributes;
+ }
+
+ @Override
+ public String getEntityId() {
+ return entityId;
+ }
+ }
+
+ private boolean userHasPermission(String itemId, String userId) {
+ String permission = permissionsManager.getUserItemPermiission(itemId, userId);
+ return (permission != null && permission
+ .matches(PermissionTypes.Contributor.name() + "|" + PermissionTypes.Owner.name()));
+ }
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/pom.xml
index 6b30f95..daeb720 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/pom.xml
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/pom.xml
@@ -12,17 +12,17 @@
<relativePath>../</relativePath>
</parent>
- <dependencies>
- <dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-common-rest</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-vendor-license-manager</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-vendor-license-manager</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>item-rest-types</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
</project>
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupEntityDto.java
index aebb171..3edf283 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupEntityDto.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupEntityDto.java
@@ -22,8 +22,8 @@
import io.swagger.annotations.ApiModel;
-import java.util.Set;
import javax.validation.constraints.Size;
+import java.util.Set;
@ApiModel(value = "FeatureGroupEntity")
public class FeatureGroupEntityDto extends FeatureGroupDescriptorDto {
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementEntityDto.java
index 7c9f03d..23d1218 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementEntityDto.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementEntityDto.java
@@ -23,8 +23,8 @@
import io.swagger.annotations.ApiModel;
-import java.util.Set;
import javax.validation.constraints.Size;
+import java.util.Set;
@ApiModel(value = "LicenseAgreementEntity")
public class LicenseAgreementEntityDto extends LicenseAgreementDescriptorDto {
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/MultiChoiceOrOtherDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/MultiChoiceOrOtherDto.java
index 6039a81..1dc8ff2 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/MultiChoiceOrOtherDto.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/MultiChoiceOrOtherDto.java
@@ -24,9 +24,9 @@
import org.openecomp.sdcrests.vendorlicense.types.validation.MultiChoiceOrOtherSequenceProvider;
import org.openecomp.sdcrests.vendorlicense.types.validation.OtherChoiceValidation;
-import java.util.Set;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
+import java.util.Set;
@GroupSequenceProvider(value = MultiChoiceOrOtherSequenceProvider.class)
public class MultiChoiceOrOtherDto<E extends Enum<E>> {
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelActionRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelActionRequestDto.java
index cfae94c..68e0fd8 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelActionRequestDto.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelActionRequestDto.java
@@ -20,17 +20,30 @@
package org.openecomp.sdcrests.vendorlicense.types;
-import org.openecomp.sdcrests.versioning.types.VersioningAction;
+import org.openecomp.sdcrests.item.types.SubmitRequestDto;
public class VendorLicenseModelActionRequestDto {
- private VersioningAction action;
+ private VendorLicenseModelAction action;
+ private SubmitRequestDto submitRequest;
- public VersioningAction getAction() {
+ public VendorLicenseModelAction getAction() {
return action;
}
- public void setAction(VersioningAction action) {
+ public void setAction(VendorLicenseModelAction action) {
this.action = action;
}
+
+ public SubmitRequestDto getSubmitRequest() {
+ return submitRequest;
+ }
+
+ public void setSubmitRequest(SubmitRequestDto submitRequest) {
+ this.submitRequest = submitRequest;
+ }
+
+ public enum VendorLicenseModelAction {
+ Submit
+ }
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelEntityDto.java
index e8a900a..f88926c 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelEntityDto.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelEntityDto.java
@@ -21,19 +21,10 @@
package org.openecomp.sdcrests.vendorlicense.types;
import io.swagger.annotations.ApiModel;
-import org.openecomp.sdc.versioning.dao.types.VersionStatus;
-import org.openecomp.sdcrests.common.types.VersionDto;
-
-import java.util.List;
@ApiModel(value = "VendorLicenseModelEntity")
public class VendorLicenseModelEntityDto extends VendorLicenseModelRequestDto {
private String id;
- private VersionDto version;
- private VersionStatus status;
- private String lockingUser;
- private List<VersionDto> viewableVersions;
- private List<VersionDto> finalVersions;
public String getId() {
return id;
@@ -42,44 +33,4 @@
public void setId(String id) {
this.id = id;
}
-
- public VersionDto getVersion() {
- return version;
- }
-
- public void setVersion(VersionDto version) {
- this.version = version;
- }
-
- public VersionStatus getStatus() {
- return status;
- }
-
- public void setStatus(VersionStatus status) {
- this.status = status;
- }
-
- public String getLockingUser() {
- return lockingUser;
- }
-
- public void setLockingUser(String lockingUser) {
- this.lockingUser = lockingUser;
- }
-
- public List<VersionDto> getViewableVersions() {
- return viewableVersions;
- }
-
- public void setViewableVersions(List<VersionDto> viewableVersions) {
- this.viewableVersions = viewableVersions;
- }
-
- public List<VersionDto> getFinalVersions() {
- return finalVersions;
- }
-
- public void setFinalVersions(List<VersionDto> finalVersions) {
- this.finalVersions = finalVersions;
- }
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentDependencies.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentDependencies.java
new file mode 100644
index 0000000..44626ff
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentDependencies.java
@@ -0,0 +1,87 @@
+package org.openecomp.sdcrests.vsp.rest;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyModel;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyResponseDto;
+import org.springframework.validation.annotation.Validated;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
+import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
+
+@Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/component-dependencies")
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+@Api(value = "Vendor Software Product Component Dependencies")
+@Validated
+public interface ComponentDependencies extends VspEntities {
+
+ @POST
+ @Path("/")
+ @ApiOperation(value = "Create a vendor software product component dependency")
+ Response create(@Valid ComponentDependencyModel request,
+ @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId,
+ @ApiParam(value = "Version Id") @PathParam("versionId") String versionId,
+ @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
+ String user);
+
+ @GET
+ @Path("/")
+ @ApiOperation(value = "Get component dependencies for vendor software product",
+ response = ComponentDependencyResponseDto.class,
+ responseContainer = "List")
+ Response list(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId,
+ @ApiParam(value = "Vendor software product version Id") @PathParam("versionId")
+ String versionId,
+ @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
+ String user);
+
+ @DELETE
+ @Path("/{dependencyId}")
+ @ApiOperation(value = "Delete component dependency for vendor software product")
+ Response delete(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId,
+ @ApiParam(value = "Vendor software product version Id")
+ @PathParam("versionId") String versionId,
+ @ApiParam(value = "Vendor software product Component Dependency Id") @PathParam
+ ("dependencyId") String dependencyId,
+ @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
+ String user);
+
+ @PUT
+ @Path("/{dependencyId}")
+ @ApiOperation(value = "Update component dependency for vendor software product")
+ Response update(@Valid ComponentDependencyModel request,
+ @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId,
+ @ApiParam(value = "Vendor software product version Id") @PathParam("versionId")
+ String versionId,
+ @ApiParam(value = "Vendor software product Component Dependency Id") @PathParam
+ ("dependencyId") String dependencyId,
+ @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
+ String user);
+
+ @GET
+ @Path("/{dependencyId}")
+ @ApiOperation(value = "Get component dependency for vendor software product",
+ response = ComponentDependencyResponseDto.class)
+ Response get(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId,
+ @ApiParam(value = "Version Id") @PathParam("versionId") String versionId,
+ @ApiParam(value = "Vendor software product Component Dependency Id") @PathParam
+ ("dependencyId") String dependencyId,
+ @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
+ String user);
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentDependencyModels.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentDependencyModels.java
deleted file mode 100644
index d7ba65f..0000000
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentDependencyModels.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.openecomp.sdcrests.vsp.rest;
-
-import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
-import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyModelRequestDto;
-import org.springframework.validation.annotation.Validated;
-
-import javax.validation.Valid;
-import javax.validation.constraints.NotNull;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.HeaderParam;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-@Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/component-dependency-model")
-@Produces(MediaType.APPLICATION_JSON)
-@Consumes(MediaType.APPLICATION_JSON)
-@Api(value = "Vendor Software Product Component Dependency Model")
-@Validated
-public interface ComponentDependencyModels extends VspEntities {
-
- @POST
- @Path("/")
- @ApiOperation(value = "Create a vendor software product component dependency model")
- Response create(@Valid ComponentDependencyModelRequestDto request,
- @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId,
- @ApiParam(value = "Version Id") @PathParam("versionId") String versionId,
- @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
- String user);
-
- @GET
- @Path("/")
- @ApiOperation(value = "Get component dependency Model for vendor software product",
- response = ComponentDependencyModelRequestDto.class,
- responseContainer = "List")
- Response list(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId,
- @ApiParam(value = "Vendor software product version Id") @PathParam("versionId")
- String versionId,
- @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
- String user);
-}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentProcesses.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentProcesses.java
index edb3b5b..5595dc1 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentProcesses.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentProcesses.java
@@ -31,7 +31,15 @@
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
-import javax.ws.rs.*;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Compute.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Compute.java
index d5125c9..635d312 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Compute.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Compute.java
@@ -1,8 +1,5 @@
package org.openecomp.sdcrests.vsp.rest;
-import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
-import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
-
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@@ -26,6 +23,9 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
+import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
+
@Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/components/{componentId" +
"}/compute-flavors")
@Produces(MediaType.APPLICATION_JSON)
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/DeploymentFlavors.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/DeploymentFlavors.java
index 1ba2f71..a154f9f 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/DeploymentFlavors.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/DeploymentFlavors.java
@@ -1,8 +1,5 @@
package org.openecomp.sdcrests.vsp.rest;
-import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
-import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
-
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@@ -25,6 +22,9 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
+import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
+
@Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/deployment-flavors")
@Produces(MediaType.APPLICATION_JSON)
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Images.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Images.java
index ffa1675..b3d2e5c 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Images.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Images.java
@@ -1,8 +1,5 @@
package org.openecomp.sdcrests.vsp.rest;
-import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
-import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
-
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@@ -26,6 +23,9 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
+import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
+
@Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/components/{componentId}/images")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Nics.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Nics.java
index 21bd65e..67be168 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Nics.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Nics.java
@@ -20,9 +20,6 @@
package org.openecomp.sdcrests.vsp.rest;
-import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
-import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
-
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@@ -46,6 +43,9 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
+import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
+
@Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/components/{componentId}/nics")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/OrchestrationTemplateCandidate.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/OrchestrationTemplateCandidate.java
index fa7f421..4f5e31a 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/OrchestrationTemplateCandidate.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/OrchestrationTemplateCandidate.java
@@ -25,7 +25,7 @@
import io.swagger.annotations.ApiParam;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
-import org.openecomp.sdc.vendorsoftwareproduct.types.FileDataStructureDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.FileDataStructureDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto;
import org.springframework.validation.annotation.Validated;
@@ -43,7 +43,6 @@
import javax.ws.rs.core.Response;
import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Processes.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Processes.java
index 458a1c6..caf03b4 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Processes.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Processes.java
@@ -20,9 +20,6 @@
package org.openecomp.sdcrests.vsp.rest;
-import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
-import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
-
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@@ -46,6 +43,9 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
+import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
+
@Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/processes")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProducts.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProducts.java
index 20fe64b..d848d41 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProducts.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProducts.java
@@ -23,12 +23,13 @@
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
+import org.openecomp.sdcrests.item.types.ItemCreationDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.PackageInfoDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.VersionSoftwareProductActionRequestDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspComputeDto;
-import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspCreationDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDescriptionDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspRequestDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.IsValidJson;
import org.springframework.validation.annotation.Validated;
@@ -51,6 +52,7 @@
import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
+
@Path("/v1.0/vendor-software-products")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@@ -61,8 +63,8 @@
@POST
@Path("/")
@ApiOperation(value = "Create a new vendor software product",
- response = VspCreationDto.class)
- Response createVsp(@Valid VspDescriptionDto vspDescriptionDto,
+ response = ItemCreationDto.class)
+ Response createVsp(@Valid VspRequestDto vspRequestDto,
@NotNull(message = USER_MISSING_ERROR_MSG)
@HeaderParam(USER_ID_HEADER_PARAM) String user);
@@ -71,13 +73,12 @@
@ApiOperation(value = "Get list of vendor software products and their description",
responseContainer = "List")
Response listVsps(@ApiParam(
- value = "Currently supported values: 'Final' - only vendor software products with final "
+ value = "Currently supported values: 'Certified' - only vendor software products with final "
+ " version will be return - with their latest final version")
- @QueryParam("versionFilter") String versionFilter,
+ @QueryParam("versionFilter") String versionStatus,
@NotNull(message = USER_MISSING_ERROR_MSG)
@HeaderParam(USER_ID_HEADER_PARAM) String user);
-
@GET
@Path("/{vspId}/versions/{versionId}")
@ApiOperation(value = "Get details of a vendor software product")
@@ -140,9 +141,9 @@
+ "Checkin: Unlocks it and activates the edited version to all users.| "
+ "Submit: Finalize its active version.|"
+ "Create_Package: Creates a CSAR zip file.|")
- Response actOnVendorSoftwareProduct(@PathParam("vspId") String vspId,
+ Response actOnVendorSoftwareProduct(VersionSoftwareProductActionRequestDto request,
+ @PathParam("vspId") String vspId,
@PathParam("versionId") String versionId,
- VersionSoftwareProductActionRequestDto request,
@NotNull(message = USER_MISSING_ERROR_MSG)
@HeaderParam(USER_ID_HEADER_PARAM) String user)
throws IOException;
@@ -201,18 +202,9 @@
@ApiOperation(value = "Get list of vendor software product compute-flavors",
response = VspComputeDto.class,
responseContainer = "List")
- Response listCompute(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String
- vspId,
- @PathParam("versionId") String versionId,
- @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
- String user);
-
- @PUT
- @Path("/reSubmitAll")
- @ApiOperation(value = "Performs healing ,check out, check in and submit for Network Package " +
- "Based VSPs",
- notes
- = "Please note - only submitted VSPs will be processed")
- Response reSubmitAll(@NotNull(message = USER_MISSING_ERROR_MSG)
- @HeaderParam(USER_ID_HEADER_PARAM) String user) throws IOException;
+ Response listComputes(@ApiParam(value = "Vendor software product Id")
+ @PathParam("vspId") String vspId,
+ @PathParam("versionId") String versionId,
+ @NotNull(message = USER_MISSING_ERROR_MSG)
+ @HeaderParam(USER_ID_HEADER_PARAM) String user);
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProductsForSwaggerFileUpload.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProductsForSwaggerFileUpload.java
index eb70394..c2a4940 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProductsForSwaggerFileUpload.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProductsForSwaggerFileUpload.java
@@ -27,7 +27,12 @@
import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.NotNull;
-import javax.ws.rs.*;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.InputStream;
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VspEntities.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VspEntities.java
index bd53305..4514af6 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VspEntities.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VspEntities.java
@@ -20,27 +20,6 @@
package org.openecomp.sdcrests.vsp.rest;
-import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
-import org.openecomp.sdc.versioning.VersioningManager;
-import org.openecomp.sdc.versioning.VersioningManagerFactory;
-import org.openecomp.sdc.versioning.VersioningUtil;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.VersionInfo;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
-
public interface VspEntities {
- VersioningManager versioningManager = VersioningManagerFactory.getInstance().createInterface();
- default Version resolveVspVersion(String vspId, String version, String user,
- VersionableEntityAction action) {
- return VersioningUtil
- .resolveVersion(Version.valueOf(version), getVersionInfo(vspId, action, user), user);
- }
-
- default VersionInfo getVersionInfo(String vendorSoftwareProductId, VersionableEntityAction action,
- String user) {
- return versioningManager.getEntityVersionInfo(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
- vendorSoftwareProductId, user, action);
- }
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyEntityToCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyEntityToCreationDto.java
new file mode 100644
index 0000000..cb480b2
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyEntityToCreationDto.java
@@ -0,0 +1,16 @@
+package org.openecomp.sdcrests.vsp.rest.mapping;
+
+
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
+import org.openecomp.sdcrests.mapping.MappingBase;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyCreationDto;
+
+public class MapComponentDependencyEntityToCreationDto extends MappingBase
+ <ComponentDependencyModelEntity, ComponentDependencyCreationDto> {
+
+ @Override
+ public void doMapping(ComponentDependencyModelEntity source,
+ ComponentDependencyCreationDto target) {
+ target.setId(source.getId());
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyEntityToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyEntityToDto.java
new file mode 100644
index 0000000..0fe5117
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyEntityToDto.java
@@ -0,0 +1,18 @@
+package org.openecomp.sdcrests.vsp.rest.mapping;
+
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
+import org.openecomp.sdcrests.mapping.MappingBase;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyResponseDto;
+
+public class MapComponentDependencyEntityToDto extends
+ MappingBase<ComponentDependencyModelEntity, ComponentDependencyResponseDto> {
+
+ @Override
+ public void doMapping(ComponentDependencyModelEntity source,
+ ComponentDependencyResponseDto target) {
+ target.setSourceId(source.getSourceComponentId());
+ target.setTargetId(source.getTargetComponentId());
+ target.setRelationType(source.getRelation());
+ target.setId(source.getId());
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeDetailsDtoToComputeEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeDetailsDtoToComputeEntity.java
index ee98823..7db9a0a 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeDetailsDtoToComputeEntity.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeDetailsDtoToComputeEntity.java
@@ -12,6 +12,6 @@
public void doMapping(ComputeDetailsDto source, ComputeEntity target) {
ComputeDescription computeDesc = new ComputeDescription(source.getName(), source
.getDescription());
- target.setCompositionData(JsonUtil.object2Json(computeDesc));
+ target.setCompositionData(computeDesc == null ? null : JsonUtil.object2Json(computeDesc));
}
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapFilesDataStructureToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapFilesDataStructureToDto.java
new file mode 100644
index 0000000..09e4d22
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapFilesDataStructureToDto.java
@@ -0,0 +1,17 @@
+package org.openecomp.sdcrests.vsp.rest.mapping;
+
+import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure;
+import org.openecomp.sdcrests.mapping.MappingBase;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.FileDataStructureDto;
+
+public class MapFilesDataStructureToDto
+ extends MappingBase<FilesDataStructure, FileDataStructureDto> {
+
+ @Override
+ public void doMapping(FilesDataStructure source, FileDataStructureDto target) {
+ target.setModules(source.getModules());
+ target.setArtifacts(source.getArtifacts());
+ target.setNested(source.getNested());
+ target.setUnassigned(source.getUnassigned());
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapFilesDataStructureToGetFileDataStructureResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapFilesDataStructureToGetFileDataStructureResponseDto.java
deleted file mode 100644
index b7d4670..0000000
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapFilesDataStructureToGetFileDataStructureResponseDto.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdcrests.vsp.rest.mapping;
-
-
-import org.openecomp.sdc.vendorsoftwareproduct.types.GetFileDataStructureResponseDTO;
-import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure;
-import org.openecomp.sdcrests.mapping.MappingBase;
-
-/**
- * Created by TALIO on 4/27/2016.
- */
-public class MapFilesDataStructureToGetFileDataStructureResponseDto
- extends MappingBase<FilesDataStructure, GetFileDataStructureResponseDTO> {
- @Override
- public void doMapping(FilesDataStructure source, GetFileDataStructureResponseDTO target) {
- target.setModules(source.getModules());
- target.setArtifacts(source.getArtifacts());
- target.setUnassigned(source.getUnassigned());
- target.setNested(source.getNested());
- }
-}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapImageDataToImageDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapImageDataToImageDto.java
index 684cd4c..f938c52 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapImageDataToImageDto.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapImageDataToImageDto.java
@@ -1,6 +1,5 @@
package org.openecomp.sdcrests.vsp.rest.mapping;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ImageData;
import org.openecomp.sdcrests.mapping.MappingBase;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageDto;
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapItemToVspDetailsDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapItemToVspDetailsDto.java
new file mode 100644
index 0000000..ad45e63
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapItemToVspDetailsDto.java
@@ -0,0 +1,18 @@
+package org.openecomp.sdcrests.vsp.rest.mapping;
+
+import org.openecomp.sdc.versioning.types.Item;
+import org.openecomp.sdcrests.mapping.MappingBase;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDetailsDto;
+import org.openecomp.sdcrests.vsp.rest.services.VspItemProperty;
+
+public class MapItemToVspDetailsDto extends MappingBase<Item, VspDetailsDto> {
+ @Override
+ public void doMapping(Item source, VspDetailsDto target) {
+ target.setId(source.getId());
+ target.setName(source.getName());
+ target.setDescription(source.getDescription());
+ target.setVendorId((String) source.getProperties().get(VspItemProperty.VENDOR_ID));
+ target.setVendorName((String) source.getProperties().get(VspItemProperty.VENDOR_NAME));
+ target.setOnboardingMethod((String) source.getProperties().get(VspItemProperty.ONBOARDING_METHOD));
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapPackageInfoToPackageInfoDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapPackageInfoToPackageInfoDto.java
index 34616b4..eeee4e9 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapPackageInfoToPackageInfoDto.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapPackageInfoToPackageInfoDto.java
@@ -33,7 +33,7 @@
target.setVspName(source.getVspName());
target.setPackageId(source.getVspId());
target.setDescription(source.getVspDescription());
- target.setVersion(source.getVersion() == null ? null : source.getVersion().toString());
+ target.setVersion(source.getVersion());
target.setPackageType(source.getPackageType());
target.setCategory(source.getCategory());
target.setSubCategory(source.getSubCategory());
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapQuestionnaireToQuestionnaireDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapQuestionnaireToQuestionnaireDto.java
new file mode 100644
index 0000000..f47f783
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapQuestionnaireToQuestionnaireDto.java
@@ -0,0 +1,21 @@
+package org.openecomp.sdcrests.vsp.rest.mapping;
+
+import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.CompositionEntity;
+import org.openecomp.sdcrests.mapping.MappingBase;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireDto;
+
+import java.util.HashMap;
+
+/**
+ * Created by ayalaben on 9/26/2017
+ */
+public class MapQuestionnaireToQuestionnaireDto extends
+ MappingBase<CompositionEntity, QuestionnaireDto> {
+
+ @Override
+ public void doMapping(CompositionEntity source, QuestionnaireDto target) {
+ target.setId(source.getId());
+ target.setQuestionareData(JsonUtil.json2Object(source.getQuestionnaireData(), HashMap.class));
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapValidationResponseToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapValidationResponseToDto.java
index 3cabebb..85b5567 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapValidationResponseToDto.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapValidationResponseToDto.java
@@ -32,9 +32,7 @@
import org.openecomp.sdcrests.common.types.ErrorCodeDto;
import org.openecomp.sdcrests.common.types.ErrorMessageDto;
import org.openecomp.sdcrests.mapping.MappingBase;
-import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentValidationResultDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto;
-import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorValidationResultDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireValidationResultDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.ValidationResponseDto;
@@ -47,30 +45,31 @@
import java.util.stream.Collectors;
public class MapValidationResponseToDto
- extends MappingBase<ValidationResponse, ValidationResponseDto> {
+ extends MappingBase<ValidationResponse, ValidationResponseDto> {
private static Map<String, List<ErrorMessageDto>> mapUploadDataErrors(
- Map<String, List<ErrorMessage>> uploadDataErrors) {
+ Map<String, List<ErrorMessage>> uploadDataErrors) {
if (MapUtils.isEmpty(uploadDataErrors)) {
return null;
}
return uploadDataErrors.entrySet().stream().collect(
- Collectors.toMap(entry -> entry.getKey(), entry -> mapErrorMessages(entry.getValue())));
+ Collectors.toMap(entry -> entry.getKey(), entry -> mapErrorMessages(entry.getValue())));
}
private static QuestionnaireValidationResultDto mapQuestionnaireValidationResult(
- QuestionnaireValidationResult questionnaireValidationResult) {
+ QuestionnaireValidationResult questionnaireValidationResult) {
if (Objects.isNull(questionnaireValidationResult)
- || Objects.isNull(questionnaireValidationResult.getValidationData())) {
+ || Objects.isNull(questionnaireValidationResult.getValidationData())) {
return null;
}
QuestionnaireValidationResultDto questionnaireValidationResultDto =
- new QuestionnaireValidationResultDto();
+ new QuestionnaireValidationResultDto();
questionnaireValidationResultDto.setValid(questionnaireValidationResult.isValid());
Set<CompositionEntityValidationDataDto> validationDataDto = new HashSet<>();
- for(CompositionEntityValidationData validationData : questionnaireValidationResult.getValidationData()){
+ for (CompositionEntityValidationData validationData : questionnaireValidationResult
+ .getValidationData()) {
validationDataDto.add(new MapCompositionEntityValidationDataToDto().applyMapping
- (validationData, CompositionEntityValidationDataDto.class));
+ (validationData, CompositionEntityValidationDataDto.class));
}
questionnaireValidationResultDto.setValidationData(validationDataDto);
@@ -87,7 +86,7 @@
componentValidationResultDto.setValid(componentValidationResult.isValid());
Set<CompositionEntityValidationDataDto> validationDataDto = new HashSet<>();
- for(CompositionEntityValidationData validationData : componentValidationResult.getValidationData()){
+ for(CompositionEntityValidationData validationData : componentValidationResult.getInfo()){
validationDataDto.add(new MapCompositionEntityValidationDataToDto().applyMapping
(validationData, CompositionEntityValidationDataDto.class));
}
@@ -106,7 +105,7 @@
deploymentFlavorValidationResultDto.setValid(deploymentFlavorValidationResult.isValid());
Set<CompositionEntityValidationDataDto> validationDataDto = new HashSet<>();
- for(CompositionEntityValidationData validationData : deploymentFlavorValidationResult.getValidationData()){
+ for(CompositionEntityValidationData validationData : deploymentFlavorValidationResult.getInfo()){
validationDataDto.add(new MapCompositionEntityValidationDataToDto().applyMapping
(validationData, CompositionEntityValidationDataDto.class));
}
@@ -117,14 +116,14 @@
private static List<ErrorMessageDto> mapErrorMessages(List<ErrorMessage> errorMessages) {
return errorMessages == null ? null : errorMessages.stream().map(
- errorMessage -> new MapErrorMessageToDto()
- .applyMapping(errorMessage, ErrorMessageDto.class)).collect(Collectors.toList());
+ errorMessage -> new MapErrorMessageToDto()
+ .applyMapping(errorMessage, ErrorMessageDto.class)).collect(Collectors.toList());
}
private static Collection<ErrorCodeDto> mapErrorCodes(Collection<ErrorCode> errorCodes) {
return CollectionUtils.isEmpty(errorCodes) ? null : errorCodes.stream()
- .map(errorCode -> new MapErrorCodeToDto().applyMapping(errorCode, ErrorCodeDto.class))
- .collect(Collectors.toList());
+ .map(errorCode -> new MapErrorCodeToDto().applyMapping(errorCode, ErrorCodeDto.class))
+ .collect(Collectors.toList());
}
@Override
@@ -134,6 +133,6 @@
target.setLicensingDataErrors(mapErrorCodes(source.getLicensingDataErrors()));
target.setUploadDataErrors(mapUploadDataErrors(source.getUploadDataErrors()));
target.setQuestionnaireValidationResult(
- mapQuestionnaireValidationResult(source.getQuestionnaireValidationResult()));
+ mapQuestionnaireValidationResult(source.getQuestionnaireValidationResult()));
}
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVersionedVendorSoftwareProductInfoToVspDetailsDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVersionedVendorSoftwareProductInfoToVspDetailsDto.java
deleted file mode 100644
index 815135f..0000000
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVersionedVendorSoftwareProductInfoToVspDetailsDto.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdcrests.vsp.rest.mapping;
-
-import org.openecomp.core.utilities.CommonMethods;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
-import org.openecomp.sdc.vendorsoftwareproduct.types.LicensingData;
-import org.openecomp.sdc.vendorsoftwareproduct.types.VersionedVendorSoftwareProductInfo;
-import org.openecomp.sdcrests.common.types.VersionDto;
-import org.openecomp.sdcrests.mapping.MappingBase;
-import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDetailsDto;
-
-import java.util.stream.Collectors;
-
-public class MapVersionedVendorSoftwareProductInfoToVspDetailsDto
- extends MappingBase<VersionedVendorSoftwareProductInfo, VspDetailsDto> {
-
- @Override
- public void doMapping(VersionedVendorSoftwareProductInfo source, VspDetailsDto target) {
- VspDetails vsp = source.getVspDetails();
-
- target.setId(vsp.getId());
- target.setVersion(new VersionDto(vsp.getVersion().toString(), vsp.getVersion().toString()));
- target.setName(vsp.getName());
- target.setDescription(vsp.getDescription());
- target.setCategory(vsp.getCategory());
- target.setSubCategory(vsp.getSubCategory());
- target.setVendorId(vsp.getVendorId());
- target.setVendorName(vsp.getVendorName());
- target.setOnboardingOrigin(vsp.getOnboardingOrigin());
- target.setLicensingVersion(vsp.getVlmVersion() == null ? null : new VersionDto(vsp.getVlmVersion().toString(), vsp.getVlmVersion().toString()));
- target.setIsOldVersion("False");
- target.setNetworkPackageName(vsp.getNetworkPackageName());
-
- if (vsp.getLicenseAgreement() != null || vsp.getFeatureGroups() != null) {
- LicensingData licensingData = new LicensingData();
- licensingData.setLicenseAgreement(vsp.getLicenseAgreement());
- licensingData.setFeatureGroups(vsp.getFeatureGroups());
- target.setLicensingData(licensingData);
- }
-
- target.setValidationData(vsp.getValidationDataStructure());
-
- target.setStatus(source.getVersionInfo().getStatus());
- target.setLockingUser(source.getVersionInfo().getLockingUser());
-
- if (!CommonMethods.isEmpty(source.getVersionInfo().getViewableVersions())) {
- target.setViewableVersions(
- source.getVersionInfo().getViewableVersions().stream()
- .map(version -> new VersionDto(version.toString(), version.toString()))
- .collect(Collectors.toList()));
- }
-
- if (!CommonMethods.isEmpty(source.getVersionInfo().getFinalVersions())) {
- target.setFinalVersions(
- source.getVersionInfo().getFinalVersions().stream()
- .map(version -> new VersionDto(version.toString(), version.toString()))
- .collect(Collectors.toList()));
- }
-
- //Onboarding Method valid value will always be present in VSP saved in DB
- target.setOnboardingMethod(vsp.getOnboardingMethod());
-
- }
-}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToItem.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToItem.java
new file mode 100644
index 0000000..3a7800f
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToItem.java
@@ -0,0 +1,16 @@
+package org.openecomp.sdcrests.vsp.rest.mapping;
+
+import org.openecomp.sdc.versioning.types.Item;
+import org.openecomp.sdcrests.mapping.MappingBase;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDescriptionDto;
+import org.openecomp.sdcrests.vsp.rest.services.VspItemProperty;
+
+public class MapVspDescriptionDtoToItem extends MappingBase<VspDescriptionDto, Item> {
+ @Override
+ public void doMapping(VspDescriptionDto source, Item target) {
+ target.setName(source.getName());
+ target.setDescription(source.getDescription());
+ target.addProperty(VspItemProperty.VENDOR_ID, source.getVendorId());
+ target.addProperty(VspItemProperty.VENDOR_NAME, source.getVendorName());
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToVspDetails.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToVspDetails.java
index ba3d92e..634bd90 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToVspDetails.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToVspDetails.java
@@ -23,7 +23,6 @@
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.types.LicensingData;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdcrests.common.types.VersionDto;
import org.openecomp.sdcrests.mapping.MappingBase;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDescriptionDto;
@@ -38,17 +37,9 @@
target.setIcon(source.getIcon());
target.setVendorName(source.getVendorName());
target.setVendorId(source.getVendorId());
- target.setOnboardingMethod(source.getOnboardingMethod());
- target.setOnboardingOrigin(source.getOnboardingOrigin());
- target.setNetworkPackageName(source.getNetworkPackageName());
- VersionDto vlmVersion = source.getLicensingVersion();
- if (vlmVersion != null) {
- Version version = Version.valueOf(vlmVersion.getId());
- target.setVlmVersion(version);
-// target.setVlmVersion(
-// Pattern.compile(Version.VERSION_REGEX).matcher(vlmVersion.getId()).find() ? Version
-// .valueOf(vlmVersion.getId()) : null);
+ if (source.getLicensingVersion() != null) {
+ target.setVlmVersion(new Version(source.getLicensingVersion()));
}
LicensingData licensingData = source.getLicensingData();
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDetailsToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDetailsToDto.java
new file mode 100644
index 0000000..6e659cb
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDetailsToDto.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdcrests.vsp.rest.mapping;
+
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.vendorsoftwareproduct.types.LicensingData;
+import org.openecomp.sdcrests.mapping.MappingBase;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDetailsDto;
+
+public class MapVspDetailsToDto extends MappingBase<VspDetails, VspDetailsDto> {
+
+ @Override
+ public void doMapping(VspDetails source, VspDetailsDto target) {
+ target.setId(source.getId());
+ target.setVersion(source.getVersion() == null ? null : source.getVersion().getId());
+ target.setName(source.getName());
+ target.setDescription(source.getDescription());
+ target.setIcon(source.getIcon());
+ target.setCategory(source.getCategory());
+ target.setSubCategory(source.getSubCategory());
+ target.setVendorId(source.getVendorId());
+ target.setVendorName(source.getVendorName());
+ target.setLicensingVersion(
+ source.getVlmVersion() == null ? null : source.getVlmVersion().getId());
+
+ if (source.getLicenseAgreement() != null || source.getFeatureGroups() != null) {
+ LicensingData licensingData = new LicensingData();
+ licensingData.setLicenseAgreement(source.getLicenseAgreement());
+ licensingData.setFeatureGroups(source.getFeatureGroups());
+ target.setLicensingData(licensingData);
+ }
+
+ target.setOnboardingMethod(source.getOnboardingMethod());
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentDependenciesImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentDependenciesImpl.java
new file mode 100644
index 0000000..73c2bac
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentDependenciesImpl.java
@@ -0,0 +1,119 @@
+package org.openecomp.sdcrests.vsp.rest.services;
+
+import org.openecomp.sdc.logging.context.MdcUtil;
+import org.openecomp.sdc.logging.types.LoggerServiceName;
+import org.openecomp.sdc.vendorsoftwareproduct.ComponentDependencyModelManager;
+import org.openecomp.sdc.vendorsoftwareproduct.ComponentDependencyModelManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyCreationDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyModel;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyResponseDto;
+import org.openecomp.sdcrests.vsp.rest.ComponentDependencies;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentDependencyEntityToCreationDto;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentDependencyEntityToDto;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentDependencyModelRequestToEntity;
+import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
+import javax.inject.Named;
+import javax.ws.rs.core.Response;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+@Named
+@Service("componentDependencies")
+@Scope(value = "prototype")
+public class ComponentDependenciesImpl implements ComponentDependencies {
+
+ private ComponentDependencyModelManager componentDependencyModelManager =
+ ComponentDependencyModelManagerFactory.getInstance().createInterface();
+
+ @Override
+ public Response create(ComponentDependencyModel request, String vspId, String versionId,
+ String user) {
+ MdcUtil.initMdc(LoggerServiceName.CREATE_COMPONENT_DEPENDENCY_MODEL.toString());
+ List<ComponentDependencyModelEntity> modelEntities = new
+ ArrayList<ComponentDependencyModelEntity>();
+
+ final Version version = new Version(versionId);
+
+ ComponentDependencyModelEntity modelEntity =
+ new MapComponentDependencyModelRequestToEntity().applyMapping(request,
+ ComponentDependencyModelEntity.class);
+
+ modelEntity.setVspId(vspId);
+ modelEntity.setVersion(version);
+
+ ComponentDependencyModelEntity componentDependency =
+ componentDependencyModelManager.createComponentDependency(modelEntity, vspId, version);
+
+ MapComponentDependencyEntityToCreationDto mapping =
+ new MapComponentDependencyEntityToCreationDto();
+ ComponentDependencyCreationDto createdComponentDependencyDto = mapping.applyMapping(
+ componentDependency, ComponentDependencyCreationDto.class);
+ return Response.ok(componentDependency != null ? createdComponentDependencyDto : null)
+ .build();
+ }
+
+ @Override
+ public Response list(String vspId, String versionId, String user) {
+ MdcUtil.initMdc(LoggerServiceName.GET_LIST_COMPONENT_DEPENDENCY.toString());
+ Version vspVersion = new Version(versionId);
+
+ Collection<ComponentDependencyModelEntity> componentDependencies =
+ componentDependencyModelManager.list(vspId, vspVersion);
+
+ MapComponentDependencyEntityToDto mapper = new MapComponentDependencyEntityToDto();
+ GenericCollectionWrapper<ComponentDependencyResponseDto> results = new GenericCollectionWrapper
+ <ComponentDependencyResponseDto>();
+ for (ComponentDependencyModelEntity entity : componentDependencies) {
+ results.add(mapper.applyMapping(entity, ComponentDependencyResponseDto.class));
+ }
+
+ return Response.ok(results).build();
+ }
+
+ @Override
+ public Response delete(String vspId, String versionId, String dependencyId, String user) {
+ MdcUtil.initMdc(LoggerServiceName.DELETE_COMPONENT_DEPENDENCY.toString());
+ Version vspVersion = new Version(versionId);
+ componentDependencyModelManager.delete(vspId, vspVersion, dependencyId);
+ return Response.ok().build();
+ }
+
+ @Override
+ public Response update(ComponentDependencyModel request, String vspId, String versionId, String
+ dependencyId, String user) {
+
+ MdcUtil.initMdc(LoggerServiceName.UPDATE_COMPONENT_DEPENDENCY.toString());
+
+ final Version version = new Version(versionId);
+ ComponentDependencyModelEntity modelEntity =
+ new MapComponentDependencyModelRequestToEntity().applyMapping(request,
+ ComponentDependencyModelEntity.class);
+
+ modelEntity.setId(dependencyId);
+ modelEntity.setVspId(vspId);
+ modelEntity.setVersion(version);
+ componentDependencyModelManager.update(modelEntity);
+ return Response.ok().build();
+ }
+
+ @Override
+ public Response get(String vspId, String version, String dependencyId, String user) {
+ MdcUtil.initMdc(LoggerServiceName.GET_COMPONENT_DEPENDENCY.toString());
+ ComponentDependencyModelEntity componentDependencyModelEntity = componentDependencyModelManager
+ .get(vspId, new Version(version), dependencyId);
+
+ MapComponentDependencyEntityToDto mapper = new MapComponentDependencyEntityToDto();
+ ComponentDependencyResponseDto componentDependencyResponseDto =
+ mapper.applyMapping(componentDependencyModelEntity, ComponentDependencyResponseDto.class);
+
+ return Response.ok(componentDependencyModelEntity != null ? componentDependencyResponseDto :
+ null).build();
+ }
+
+}
\ No newline at end of file
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentDependencyModelsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentDependencyModelsImpl.java
deleted file mode 100644
index 4a23140..0000000
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentDependencyModelsImpl.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package org.openecomp.sdcrests.vsp.rest.services;
-
-import org.openecomp.sdc.logging.context.MdcUtil;
-import org.openecomp.sdc.logging.types.LoggerServiceName;
-import org.openecomp.sdc.vendorsoftwareproduct.ComponentDependencyModelManager;
-import org.openecomp.sdc.vendorsoftwareproduct.ComponentDependencyModelManagerFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
-import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyModel;
-import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyModelRequestDto;
-import org.openecomp.sdcrests.vsp.rest.ComponentDependencyModels;
-import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentDependencyModelEntityToDto;
-import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentDependencyModelRequestToEntity;
-
-import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Service;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import javax.inject.Named;
-import javax.ws.rs.core.Response;
-
-@Named
-@Service("componentDependencyModel")
-@Scope(value = "prototype")
-public class ComponentDependencyModelsImpl implements ComponentDependencyModels {
-
- private ComponentDependencyModelManager componentDependencyModelManager =
- ComponentDependencyModelManagerFactory.getInstance().createInterface();
-
- @Override
- public Response create(ComponentDependencyModelRequestDto request, String vspId,
- String versionId, String user) {
- MdcUtil.initMdc(LoggerServiceName.CREATE_COMPONENT_DEPENDENCY_MODEL.toString());
- List<ComponentDependencyModelEntity> modelEntities = new
- ArrayList<ComponentDependencyModelEntity>();
-
- final Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write);
-
- if (request.getComponentDependencyModels() != null) {
- for(ComponentDependencyModel model : request.getComponentDependencyModels()) {
- ComponentDependencyModelEntity modelEntity =
- new MapComponentDependencyModelRequestToEntity().applyMapping(model,
- ComponentDependencyModelEntity.class);
-
- modelEntity.setVspId(vspId);
- modelEntity.setVersion(version);
- modelEntities.add(modelEntity);
- }
- }
-
- componentDependencyModelManager
- .createComponentDependencyModel(modelEntities, vspId, version, user);
-
- return Response.ok().build();
- }
-
- @Override
- public Response list(String vspId, String versionId, String user) {
- MdcUtil.initMdc(LoggerServiceName.GET_COMPONENT_DEPENDENCY_MODEL.toString());
- Version vspVersion = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read);
-
- Collection<ComponentDependencyModelEntity> componentDependencies =
- componentDependencyModelManager.list(vspId, vspVersion, user);
-
- MapComponentDependencyModelEntityToDto mapper = new MapComponentDependencyModelEntityToDto();
- GenericCollectionWrapper<ComponentDependencyModel> results = new GenericCollectionWrapper
- <ComponentDependencyModel>();
- for (ComponentDependencyModelEntity entity : componentDependencies) {
- results.add(mapper.applyMapping(entity, ComponentDependencyModel.class));
- }
-
- return Response.ok(results).build();
- }
-}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentMonitoringUploadsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentMonitoringUploadsImpl.java
index a971782..a997d94 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentMonitoringUploadsImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentMonitoringUploadsImpl.java
@@ -16,7 +16,6 @@
import org.openecomp.sdc.vendorsoftwareproduct.MonitoringUploadsManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.MonitoringUploadStatus;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.MonitoringUploadStatusDto;
import org.openecomp.sdcrests.vsp.rest.ComponentMonitoringUploads;
import org.openecomp.sdcrests.vsp.rest.mapping.MapMonitoringUploadStatusToDto;
@@ -54,13 +53,13 @@
logger.audit(AuditMessages.AUDIT_MSG + String.format(AuditMessages
.UPLOAD_MONITORING_FILE, type, vspId, componentId));
- Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write);
- componentManager.validateComponentExistence(vspId, version, componentId, user);
+ Version version = new Version(versionId);
+ componentManager.validateComponentExistence(vspId, version, componentId);
MonitoringUploadType monitoringUploadType = getMonitoringUploadType(vspId, componentId, type);
monitoringUploadsManager.upload(attachment.getObject(InputStream.class),
attachment.getContentDisposition().getParameter("filename"), vspId, version, componentId,
- monitoringUploadType, user);
+ monitoringUploadType);
mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId + "," + componentId);
return Response.ok().build();
@@ -88,10 +87,9 @@
MonitoringUploadType monitoringUploadType = getMonitoringUploadType(vspId, componentId, type);
- Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write);
- componentManager.validateComponentExistence(vspId, version, componentId, user);
- monitoringUploadsManager
- .delete(vspId, version, componentId, monitoringUploadType, user);
+ Version version = new Version(versionId);
+ componentManager.validateComponentExistence(vspId, version, componentId);
+ monitoringUploadsManager.delete(vspId, version, componentId, monitoringUploadType);
mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId + "," + componentId);
return Response.ok().build();
@@ -102,16 +100,15 @@
String user) {
MdcUtil.initMdc(LoggerServiceName.List_Monitoring_Artifacts.toString());
- Version version = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read);
- componentManager.validateComponentExistence(vspId, version, componentId, user);
+ Version version = new Version(versionId);
+ componentManager.validateComponentExistence(vspId, version, componentId);
- MonitoringUploadStatus response = monitoringUploadsManager
- .listFilenames(vspId, version, componentId, user);
+ MonitoringUploadStatus response =
+ monitoringUploadsManager.listFilenames(vspId, version, componentId);
MonitoringUploadStatusDto returnEntity =
new MapMonitoringUploadStatusToDto()
.applyMapping(response, MonitoringUploadStatusDto.class);
return Response.status(Response.Status.OK).entity(returnEntity).build();
-
}
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentProcessesImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentProcessesImpl.java
index abcb3c5..bad6f16 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentProcessesImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentProcessesImpl.java
@@ -21,6 +21,10 @@
package org.openecomp.sdcrests.vsp.rest.services;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
+import org.openecomp.sdc.activitylog.ActivityLogManager;
+import org.openecomp.sdc.activitylog.ActivityLogManagerFactory;
+import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
+import org.openecomp.sdc.activitylog.dao.type.ActivityType;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.MdcUtil;
@@ -30,10 +34,8 @@
import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.ProcessManager;
import org.openecomp.sdc.vendorsoftwareproduct.ProcessManagerFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessEntityDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessRequestDto;
import org.openecomp.sdcrests.vsp.rest.ComponentProcesses;
@@ -50,8 +52,6 @@
import java.io.InputStream;
import java.util.Collection;
-import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.GENERAL_COMPONENT_ID;
-
@Named
@Service("componentProcesses")
@Scope(value = "prototype")
@@ -60,21 +60,18 @@
private ProcessManager processManager = ProcessManagerFactory.getInstance().createInterface();
private ComponentManager componentManager =
ComponentManagerFactory.getInstance().createInterface();
- private static final Logger logger =
- LoggerFactory.getLogger(ComponentProcessesImpl.class);
+ private ActivityLogManager activityLogManager =
+ ActivityLogManagerFactory.getInstance().createInterface();
+
+ private static final Logger logger =
+ LoggerFactory.getLogger(ComponentProcessesImpl.class);
@Override
public Response list(String vspId, String versionId, String componentId, String user) {
MdcUtil.initMdc(LoggerServiceName.List_Component_Processes.toString());
- Version vspVersion = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read);
- validateComponentExistence(vspId, vspVersion, componentId, user);
- Collection<ProcessEntity> processes;
- if (componentId.equals(VendorSoftwareProductConstants.GENERAL_COMPONENT_ID)) {
- processes = processManager.listProcesses(vspId, vspVersion, null, user);
- } else {
- processes = processManager.listProcesses(vspId, vspVersion, componentId, user);
- }
-
+ Version version = new Version(versionId);
+ validateComponentExistence(vspId, version, componentId, user);
+ Collection<ProcessEntity> processes = processManager.listProcesses(vspId, version, componentId);
MapProcessEntityToProcessEntityDto mapper = new MapProcessEntityToProcessEntityDto();
GenericCollectionWrapper<ProcessEntityDto> results = new GenericCollectionWrapper<>();
@@ -88,9 +85,9 @@
@Override
public Response deleteList(String vspId, String versionId, String componentId, String user) {
MdcUtil.initMdc(LoggerServiceName.Delete_List_Component_Processes.toString());
- Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write);
+ Version version = new Version(versionId);
validateComponentExistence(vspId, version, componentId, user);
- processManager.deleteProcesses(vspId, version, componentId, user);
+ processManager.deleteProcesses(vspId, version, componentId);
return Response.ok().build();
}
@@ -102,13 +99,11 @@
ProcessEntity process =
new MapProcessRequestDtoToProcessEntity().applyMapping(request, ProcessEntity.class);
process.setVspId(vspId);
- process.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write));
- if (!componentId.equals(VendorSoftwareProductConstants.GENERAL_COMPONENT_ID)) {
- process.setComponentId(componentId);
- }
+ process.setVersion(new Version(versionId));
+ process.setComponentId(componentId);
validateComponentExistence(vspId, process.getVersion(), componentId, user);
- ProcessEntity createdProcess = processManager.createProcess(process, user);
+ ProcessEntity createdProcess = processManager.createProcess(process);
return Response
.ok(createdProcess != null ? new StringWrapperResponse(createdProcess.getId()) : null)
@@ -119,10 +114,9 @@
public Response get(String vspId, String versionId, String componentId, String processId,
String user) {
MdcUtil.initMdc(LoggerServiceName.Get_Component_Processes.toString());
- Version vspVersion = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read);
- validateComponentExistence(vspId, vspVersion, componentId, user);
- ProcessEntity process =
- processManager.getProcess(vspId, vspVersion, componentId, processId, user);
+ Version version = new Version(versionId);
+ validateComponentExistence(vspId, version, componentId, user);
+ ProcessEntity process = processManager.getProcess(vspId, version, componentId, processId);
ProcessEntityDto result =
new MapProcessEntityToProcessEntityDto().applyMapping(process, ProcessEntityDto.class);
return Response.ok(result).build();
@@ -132,9 +126,9 @@
public Response delete(String vspId, String versionId, String componentId, String processId,
String user) {
MdcUtil.initMdc(LoggerServiceName.Delete_Component_Processes.toString());
- Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write);
+ Version version = new Version(versionId);
validateComponentExistence(vspId, version, componentId, user);
- processManager.deleteProcess(vspId, version, componentId, processId, user);
+ processManager.deleteProcess(vspId, version, componentId, processId);
return Response.ok().build();
}
@@ -146,11 +140,11 @@
ProcessEntity process =
new MapProcessRequestDtoToProcessEntity().applyMapping(request, ProcessEntity.class);
process.setVspId(vspId);
- process.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write));
+ process.setVersion(new Version(versionId));
process.setComponentId(componentId);
process.setId(processId);
validateComponentExistence(vspId, process.getVersion(), componentId, user);
- processManager.updateProcess(process, user);
+ processManager.updateProcess(process);
return Response.ok().build();
}
@@ -158,9 +152,9 @@
public Response getUploadedFile(String vspId, String versionId, String componentId,
String processId, String user) {
MdcUtil.initMdc(LoggerServiceName.Get_Uploaded_File_Component_Processes.toString());
- Version vspVersion = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read);
+ Version vspVersion = new Version(versionId);
validateComponentExistence(vspId, vspVersion, componentId, user);
- File file = processManager.getProcessArtifact(vspId, vspVersion, componentId, processId, user);
+ File file = processManager.getProcessArtifact(vspId, vspVersion, componentId, processId);
Response.ResponseBuilder response = Response.ok(file);
if (file == null) {
@@ -175,9 +169,9 @@
String processId,
String user) {
MdcUtil.initMdc(LoggerServiceName.Delete_Uploaded_File_Component_Processes.toString());
- Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write);
+ Version version = new Version(versionId);
validateComponentExistence(vspId, version, componentId, user);
- processManager.deleteProcessArtifact(vspId, version, componentId, processId, user);
+ processManager.deleteProcessArtifact(vspId, version, componentId, processId);
return Response.ok().build();
}
@@ -186,21 +180,26 @@
String componentId,
String processId, String user) {
MdcUtil.initMdc(LoggerServiceName.Upload_File_Component_Processes.toString());
- logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.UPLOAD_PROCESS_ARTIFACT + vspId);
- Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write);
+ logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.UPLOAD_PROCESS_ARTIFACT + vspId);
+ Version version = new Version(versionId);
validateComponentExistence(vspId, version, componentId, user);
processManager.uploadProcessArtifact(attachment.getObject(InputStream.class),
attachment.getContentDisposition().getParameter("filename"), vspId, version, componentId,
- processId, user);
+ processId);
+
+
+ activityLogManager.logActivity(new ActivityLogEntity(vspId, version,
+ ActivityType.Upload_Artifact, user, true, "", ""));
+
return Response.ok().build();
}
private void validateComponentExistence(String vspId, Version version, String componentId,
String user) {
- if (GENERAL_COMPONENT_ID.equals(componentId)) {
+ if (componentId == null) {
return;
}
- componentManager.validateComponentExistence(vspId, version, componentId, user);
+ componentManager.validateComponentExistence(vspId, version, componentId);
}
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentsImpl.java
index fa7e924..de422ec 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentsImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentsImpl.java
@@ -31,7 +31,6 @@
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentCreationDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentRequestDto;
@@ -50,9 +49,9 @@
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
-import java.util.Collection;
import javax.inject.Named;
import javax.ws.rs.core.Response;
+import java.util.Collection;
@Named
@Service("components")
@@ -65,8 +64,7 @@
public Response list(String vspId, String versionId, String user) {
MdcUtil.initMdc(LoggerServiceName.List_Components.toString());
Collection<ComponentEntity> components =
- componentManager.listComponents(vspId, resolveVspVersion(vspId, versionId, user,
- VersionableEntityAction.Read), user);
+ componentManager.listComponents(vspId, new Version(versionId));
MapComponentEntityToComponentDto mapper = new MapComponentEntityToComponentDto();
GenericCollectionWrapper<ComponentDto> results = new GenericCollectionWrapper<>();
@@ -80,8 +78,7 @@
@Override
public Response deleteList(String vspId, String versionId, String user) {
MdcUtil.initMdc(LoggerServiceName.Delete_List_Components.toString());
- Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write);
- componentManager.deleteComponents(vspId, version, user);
+ componentManager.deleteComponents(vspId, new Version(versionId));
return Response.ok().build();
}
@@ -91,9 +88,9 @@
ComponentEntity component =
new MapComponentRequestDtoToComponentEntity().applyMapping(request, ComponentEntity.class);
component.setVspId(vspId);
- component.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write));
+ component.setVersion(new Version(versionId));
- ComponentEntity createdComponent = componentManager.createComponent(component, user);
+ ComponentEntity createdComponent = componentManager.createComponent(component);
MapComponentEntityToComponentCreationDto mapping =
new MapComponentEntityToComponentCreationDto();
ComponentCreationDto createdComponentDto = mapping.applyMapping(createdComponent,
@@ -106,9 +103,8 @@
@Override
public Response get(String vspId, String versionId, String componentId, String user) {
MdcUtil.initMdc(LoggerServiceName.Get_Component.toString());
- CompositionEntityResponse<ComponentData> response = componentManager
- .getComponent(vspId, resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read),
- componentId, user);
+ CompositionEntityResponse<ComponentData> response =
+ componentManager.getComponent(vspId, new Version(versionId), componentId);
CompositionEntityResponseDto<ComponentDto> responseDto = new CompositionEntityResponseDto<>();
new MapCompositionEntityResponseToDto<>(new MapComponentDataToComponentDto(),
@@ -119,23 +115,23 @@
@Override
public Response delete(String vspId, String versionId, String componentId, String user) {
MdcUtil.initMdc(LoggerServiceName.Delete_Component.toString());
- Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write);
- componentManager.deleteComponent(vspId, version, componentId, user);
+ componentManager.deleteComponent(vspId, new Version(versionId), componentId);
return Response.ok().build();
}
@Override
- public Response update(ComponentRequestDto request, String vspId, String versionId, String componentId,
+ public Response update(ComponentRequestDto request, String vspId, String versionId,
+ String componentId,
String user) {
MdcUtil.initMdc(LoggerServiceName.Update_Component.toString());
ComponentEntity componentEntity =
new MapComponentRequestDtoToComponentEntity().applyMapping(request, ComponentEntity.class);
componentEntity.setVspId(vspId);
- componentEntity.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write));
+ componentEntity.setVersion(new Version(versionId));
componentEntity.setId(componentId);
CompositionEntityValidationData validationData =
- componentManager.updateComponent(componentEntity, user);
+ componentManager.updateComponent(componentEntity);
return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors())
? Response.status(Response.Status.EXPECTATION_FAILED).entity(
new MapCompositionEntityValidationDataToDto().applyMapping(validationData,
@@ -143,12 +139,11 @@
}
@Override
- public Response getQuestionnaire(String vspId, String versionId, String componentId, String user) {
+ public Response getQuestionnaire(String vspId, String versionId, String componentId,
+ String user) {
MdcUtil.initMdc(LoggerServiceName.Get_Questionnaire_Component.toString());
- QuestionnaireResponse questionnaireResponse = componentManager
- .getQuestionnaire(vspId,
- resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read), componentId,
- user);
+ QuestionnaireResponse questionnaireResponse =
+ componentManager.getQuestionnaire(vspId, new Version(versionId), componentId);
QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto()
.applyMapping(questionnaireResponse, QuestionnaireResponseDto.class);
@@ -156,11 +151,11 @@
}
@Override
- public Response updateQuestionnaire(String questionnaireData, String vspId, String versionId, String componentId,
- String user) {
+ public Response updateQuestionnaire(String questionnaireData, String vspId, String versionId,
+ String componentId, String user) {
MdcUtil.initMdc(LoggerServiceName.Update_Questionnaire_Component.toString());
- Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write);
- componentManager.updateQuestionnaire(vspId, version, componentId, questionnaireData, user);
+ componentManager
+ .updateQuestionnaire(vspId, new Version(versionId), componentId, questionnaireData);
return Response.ok().build();
}
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComputeImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComputeImpl.java
index 599b5ad..081024a 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComputeImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComputeImpl.java
@@ -14,7 +14,6 @@
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComputeData;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeCreationDto;
@@ -33,9 +32,9 @@
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
-import java.util.Collection;
import javax.inject.Named;
import javax.ws.rs.core.Response;
+import java.util.Collection;
@Named
@Service("computes")
@@ -47,13 +46,12 @@
ComponentManagerFactory.getInstance().createInterface();
@Override
- public Response list(String vspId, String version, String componentId, String user) {
+ public Response list(String vspId, String versionId, String componentId, String user) {
MdcUtil.initMdc(LoggerServiceName.List_Computes.toString());
- Version vspVersion = resolveVspVersion(vspId, version, user, VersionableEntityAction.Read);
- componentManager.validateComponentExistence(vspId, vspVersion, componentId, user);
+ Version version = new Version(versionId);
+ componentManager.validateComponentExistence(vspId, version, componentId);
Collection<ListComputeResponse> computes =
- computetManager
- .listCompute(vspId, vspVersion, componentId, user);
+ computetManager.listComputes(vspId, version, componentId);
MapComputeEntityToComputeDto mapper = new MapComputeEntityToComputeDto();
GenericCollectionWrapper<ComputeDto> results = new GenericCollectionWrapper<>();
@@ -65,13 +63,13 @@
}
@Override
- public Response get(String vspId, String version, String componentId, String computeId,
+ public Response get(String vspId, String versionId, String componentId, String computeId,
String user) {
MdcUtil.initMdc(LoggerServiceName.Get_Compute.toString());
- Version vspVersion = resolveVspVersion(vspId, version, user, VersionableEntityAction.Read);
- componentManager.validateComponentExistence(vspId, vspVersion, componentId, user);
- CompositionEntityResponse<ComputeData> response = computetManager
- .getCompute(vspId, vspVersion, componentId, computeId, user);
+ Version version = new Version(versionId);
+ componentManager.validateComponentExistence(vspId, version, componentId);
+ CompositionEntityResponse<ComputeData> response =
+ computetManager.getCompute(vspId, version, componentId, computeId);
CompositionEntityResponseDto<ComputeDetailsDto> responseDto = new
CompositionEntityResponseDto<>();
@@ -87,33 +85,31 @@
ComputeEntity compute = new MapComputeDetailsDtoToComputeEntity().applyMapping(request,
ComputeEntity.class);
compute.setVspId(vspId);
+ compute.setVersion(new Version(versionId));
compute.setComponentId(componentId);
- compute.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write));
- componentManager.validateComponentExistence(vspId, compute.getVersion(), componentId, user);
+ componentManager.validateComponentExistence(vspId, compute.getVersion(), componentId);
- ComputeEntity createdCompute = computetManager.createCompute(compute, user);
+ ComputeEntity createdCompute = computetManager.createCompute(compute);
MapComputeEntityToComputeCreationDto mapper = new MapComputeEntityToComputeCreationDto();
- ComputeCreationDto createdComputeDto = mapper.applyMapping(createdCompute, ComputeCreationDto
- .class);
- return Response.ok(createdComputeDto != null ? createdComputeDto : null)
- .build();
+ ComputeCreationDto createdComputeDto =
+ mapper.applyMapping(createdCompute, ComputeCreationDto.class);
+ return Response.ok(createdComputeDto != null ? createdComputeDto : null).build();
}
@Override
- public Response update(ComputeDetailsDto request, String vspId, String versionId, String
- componentId, String computeFlavorId, String user) {
+ public Response update(ComputeDetailsDto request, String vspId, String versionId,
+ String componentId, String computeFlavorId, String user) {
MdcUtil.initMdc(LoggerServiceName.Update_Compute.toString());
- ComputeEntity compute = new MapComputeDetailsDtoToComputeEntity().applyMapping(request,
- ComputeEntity.class);
+ ComputeEntity compute =
+ new MapComputeDetailsDtoToComputeEntity().applyMapping(request, ComputeEntity.class);
compute.setVspId(vspId);
+ compute.setVersion(new Version(versionId));
compute.setComponentId(componentId);
- compute.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write));
compute.setId(computeFlavorId);
- componentManager.validateComponentExistence(vspId, compute.getVersion(), componentId, user);
- CompositionEntityValidationData validationData =
- computetManager.updateCompute(compute, user);
+ componentManager.validateComponentExistence(vspId, compute.getVersion(), componentId);
+ CompositionEntityValidationData validationData = computetManager.updateCompute(compute);
return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors())
? Response.status(Response.Status.EXPECTATION_FAILED).entity(
new MapCompositionEntityValidationDataToDto().applyMapping(validationData,
@@ -121,23 +117,23 @@
}
@Override
- public Response delete(String vspId, String versionId, String componentId, String
- computeFlavorId, String user) {
+ public Response delete(String vspId, String versionId, String componentId, String computeFlavorId,
+ String user) {
MdcUtil.initMdc(LoggerServiceName.Delete_Compute.toString());
- Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write);
- componentManager.validateComponentExistence(vspId, version, componentId, user);
- computetManager.deleteCompute(vspId, version, componentId, computeFlavorId, user);
+ Version version = new Version(versionId);
+ componentManager.validateComponentExistence(vspId, version, componentId);
+ computetManager.deleteCompute(vspId, version, componentId, computeFlavorId);
return Response.ok().build();
}
@Override
- public Response getQuestionnaire(String vspId, String versionId, String componentId, String
- computeFlavorId, String user) {
+ public Response getQuestionnaire(String vspId, String versionId, String componentId,
+ String computeFlavorId, String user) {
MdcUtil.initMdc(LoggerServiceName.Get_Questionnaire_Compute.toString());
- Version vspVersion = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read);
- componentManager.validateComponentExistence(vspId, vspVersion, componentId, user);
- QuestionnaireResponse questionnaireResponse = computetManager
- .getComputeQuestionnaire(vspId, vspVersion, componentId, computeFlavorId, user);
+ Version version = new Version(versionId);
+ componentManager.validateComponentExistence(vspId, version, componentId);
+ QuestionnaireResponse questionnaireResponse =
+ computetManager.getComputeQuestionnaire(vspId, version, componentId, computeFlavorId);
QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto()
.applyMapping(questionnaireResponse, QuestionnaireResponseDto.class);
@@ -146,16 +142,12 @@
@Override
public Response updateQuestionnaire(String questionnaireData, String vspId, String versionId,
- String componentId,
- String computeFlavorId, String user) {
- MdcUtil
- .initMdc(LoggerServiceName.Update_Questionnaire_Compute.toString()
- );
- Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write);
- componentManager.validateComponentExistence(vspId, version, componentId, user);
- computetManager
- .updateComputeQuestionnaire(vspId, version, componentId, computeFlavorId,
- questionnaireData, user);
+ String componentId, String computeFlavorId, String user) {
+ MdcUtil.initMdc(LoggerServiceName.Update_Questionnaire_Compute.toString());
+ Version version = new Version(versionId);
+ componentManager.validateComponentExistence(vspId, version, componentId);
+ computetManager.updateComputeQuestionnaire(vspId, version, componentId, computeFlavorId,
+ questionnaireData);
return Response.ok().build();
}
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/DeploymentFlavorsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/DeploymentFlavorsImpl.java
index 0337226..d1486b6 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/DeploymentFlavorsImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/DeploymentFlavorsImpl.java
@@ -10,7 +10,6 @@
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorCreationDto;
@@ -28,15 +27,14 @@
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
-import java.util.Collection;
import javax.inject.Named;
import javax.ws.rs.core.Response;
+import java.util.Collection;
@Named
@Service("deploymentFlavors")
@Scope(value = "prototype")
-public class DeploymentFlavorsImpl implements DeploymentFlavors
-{
+public class DeploymentFlavorsImpl implements DeploymentFlavors {
private DeploymentFlavorManager deploymentFlavorManager =
DeploymentFlavorManagerFactory.getInstance().createInterface();
@@ -48,29 +46,28 @@
new MapDeploymentFlavorRequestDtoToDeploymentFlavorEntity()
.applyMapping(request, DeploymentFlavorEntity.class);
deploymentFlavorEntity.setVspId(vspId);
- deploymentFlavorEntity.setVersion(resolveVspVersion(vspId, null, user,
- VersionableEntityAction.Write));
+ deploymentFlavorEntity.setVersion(new Version(versionId));
DeploymentFlavorEntity createdDeploymentFlavor =
- deploymentFlavorManager.createDeploymentFlavor(deploymentFlavorEntity, user);
+ deploymentFlavorManager.createDeploymentFlavor(deploymentFlavorEntity);
MapDeploymentFlavorEntityToDeploymentFlavorCreationDto mapping =
new MapDeploymentFlavorEntityToDeploymentFlavorCreationDto();
- DeploymentFlavorCreationDto deploymentFlavorCreatedDto= mapping.applyMapping
- (createdDeploymentFlavor,DeploymentFlavorCreationDto.class);
+ DeploymentFlavorCreationDto deploymentFlavorCreatedDto = mapping.applyMapping
+ (createdDeploymentFlavor, DeploymentFlavorCreationDto.class);
return Response
.ok(createdDeploymentFlavor != null ? deploymentFlavorCreatedDto : null)
.build();
}
@Override
- public Response list(String vspId,String version,String user) {
+ public Response list(String vspId, String versionId, String user) {
MdcUtil.initMdc(LoggerServiceName.Get_List_Deployment_flavor.toString());
Collection<DeploymentFlavorEntity> deploymentFlavors =
- deploymentFlavorManager.listDeploymentFlavors(vspId, resolveVspVersion(vspId, version, user,
- VersionableEntityAction.Read), user);
+ deploymentFlavorManager.listDeploymentFlavors(vspId, new Version(versionId));
MapDeploymentFlavorEntityDeploymentFlavorToListResponse mapper = new
MapDeploymentFlavorEntityDeploymentFlavorToListResponse();
- GenericCollectionWrapper<DeploymentFlavorListResponseDto> results = new GenericCollectionWrapper<>();
+ GenericCollectionWrapper<DeploymentFlavorListResponseDto> results =
+ new GenericCollectionWrapper<>();
for (DeploymentFlavorEntity deploymentFlavor : deploymentFlavors) {
results.add(mapper.applyMapping(deploymentFlavor, DeploymentFlavorListResponseDto.class));
}
@@ -78,32 +75,32 @@
}
@Override
- public Response get(String vspId, String version, String deploymentFlavorId, String user) {
+ public Response get(String vspId, String versionId, String deploymentFlavorId, String user) {
MdcUtil.initMdc(LoggerServiceName.Get_Deployment_flavor.toString());
CompositionEntityResponse<DeploymentFlavor> response = deploymentFlavorManager
- .getDeploymentFlavor(vspId, resolveVspVersion(vspId, version, user,
- VersionableEntityAction.Read), deploymentFlavorId, user);
+ .getDeploymentFlavor(vspId, new Version(versionId), deploymentFlavorId);
CompositionEntityResponseDto<DeploymentFlavorDto> responseDto = new
CompositionEntityResponseDto<>();
- new MapCompositionEntityResponseToDto<>(new MapDeploymentFlavorToDeploymentDto(), DeploymentFlavorDto.class)
+ new MapCompositionEntityResponseToDto<>(new MapDeploymentFlavorToDeploymentDto(),
+ DeploymentFlavorDto.class)
.doMapping(response, responseDto);
return Response.ok(responseDto).build();
}
@Override
- public Response getSchema(String vspId, String version, String user) {
+ public Response getSchema(String vspId, String versionId, String user) {
MdcUtil.initMdc(LoggerServiceName.Get_Deployment_flavor.toString());
CompositionEntityResponse<DeploymentFlavor> response = deploymentFlavorManager
- .getDeploymentFlavorSchema(vspId, Version.valueOf(version), user);
+ .getDeploymentFlavorSchema(vspId, new Version(versionId));
return Response.ok(response).build();
}
@Override
public Response delete(String vspId, String versionId, String deploymentFlavorId, String user) {
MdcUtil.initMdc(LoggerServiceName.Delete_Deployment_flavor.toString());
- Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write);
- deploymentFlavorManager.deleteDeploymentFlavor(vspId, version, deploymentFlavorId, user);
+ Version version = new Version(versionId);
+ deploymentFlavorManager.deleteDeploymentFlavor(vspId, version, deploymentFlavorId);
return Response.ok().build();
}
@@ -115,11 +112,11 @@
new MapDeploymentFlavorRequestDtoToDeploymentFlavorEntity().applyMapping(request,
DeploymentFlavorEntity.class);
deploymentFlavorEntity.setVspId(vspId);
- deploymentFlavorEntity.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write));
+ deploymentFlavorEntity.setVersion(new Version(versionId));
deploymentFlavorEntity.setId(deploymentFlavorId);
CompositionEntityValidationData validationData =
- deploymentFlavorManager.updateDeploymentFlavor(deploymentFlavorEntity, user);
+ deploymentFlavorManager.updateDeploymentFlavor(deploymentFlavorEntity);
return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors())
? Response.status(Response.Status.EXPECTATION_FAILED).entity(
new MapCompositionEntityValidationDataToDto().applyMapping(validationData,
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ImagesImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ImagesImpl.java
index fcaf038..b8e0f64 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ImagesImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ImagesImpl.java
@@ -14,7 +14,6 @@
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Image;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageCreationDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageDto;
@@ -30,32 +29,31 @@
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
-import java.util.Collection;
import javax.inject.Named;
import javax.ws.rs.core.Response;
+import java.util.Collection;
@Named
@Service("images")
@Scope(value = "prototype")
-public class ImagesImpl implements Images
- {
+public class ImagesImpl implements Images {
private ImageManager imageManager = ImageManagerFactory.getInstance().createInterface();
private ComponentManager componentManager =
ComponentManagerFactory.getInstance().createInterface();
@Override
- public Response create(ImageRequestDto request, String vspId, String versionId,String
- componentId, String user) {
+ public Response create(ImageRequestDto request, String vspId, String versionId,
+ String componentId, String user) {
MdcUtil.initMdc(LoggerServiceName.Create_Image.toString());
ImageEntity image =
new MapImageRequestDtoToImageEntity().applyMapping(request, ImageEntity.class);
image.setVspId(vspId);
image.setComponentId(componentId);
- image.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write));
- componentManager.validateComponentExistence(vspId, image.getVersion(), componentId, user);
- ImageEntity createdImage = imageManager.createImage(image, user);
+ image.setVersion(new Version(versionId));
+ componentManager.validateComponentExistence(vspId, image.getVersion(), componentId);
+ ImageEntity createdImage = imageManager.createImage(image);
MapImageEntityToImageCreationDto mapping = new MapImageEntityToImageCreationDto();
ImageCreationDto createdImageDto = mapping.applyMapping(createdImage, ImageCreationDto.class);
return Response
@@ -66,19 +64,18 @@
@Override
public Response getImageSchema(String vspId, String versionId, String componentId, String user) {
MdcUtil.initMdc(LoggerServiceName.GET_Image_Schema.toString());
- CompositionEntityResponse<Image> response =
- imageManager.getImageSchema(vspId, user);
+ CompositionEntityResponse<Image> response = imageManager.getImageSchema(vspId);
return Response.ok(response).build();
}
@Override
- public Response get(String vspId, String versionId, String componentId, String imageId, String
- user) {
+ public Response get(String vspId, String versionId, String componentId, String imageId,
+ String user) {
MdcUtil.initMdc(LoggerServiceName.GET_Image.toString());
- Version vspVersion = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read);
- componentManager.validateComponentExistence(vspId, vspVersion, componentId, user);
- CompositionEntityResponse<Image> response = imageManager.getImage(vspId,
- vspVersion, componentId, imageId, user);
+ Version version = new Version(versionId);
+ componentManager.validateComponentExistence(vspId, version, componentId);
+ CompositionEntityResponse<Image> response =
+ imageManager.getImage(vspId, version, componentId, imageId);
return Response.ok(response).build();
}
@@ -86,10 +83,9 @@
@Override
public Response list(String vspId, String versionId, String componentId, String user) {
MdcUtil.initMdc(LoggerServiceName.List_Images.toString());
- Version vspVersion = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read);
- componentManager.validateComponentExistence(vspId, vspVersion, componentId, user);
- Collection<ImageEntity> images =
- imageManager.listImages(vspId, vspVersion, componentId, user);
+ Version vspVersion = new Version(versionId);
+ componentManager.validateComponentExistence(vspId, vspVersion, componentId);
+ Collection<ImageEntity> images = imageManager.listImages(vspId, vspVersion, componentId);
MapImageEntityToImageDto mapper = new MapImageEntityToImageDto();
GenericCollectionWrapper<ImageDto> results = new GenericCollectionWrapper<>();
@@ -104,28 +100,25 @@
public Response delete(String vspId, String versionId, String componentId, String imageId,
String user) {
MdcUtil.initMdc(LoggerServiceName.Delete_Image.toString());
- Version vspVersion = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write);
- componentManager.validateComponentExistence(vspId, vspVersion, componentId, user);
- imageManager.deleteImage(vspId, vspVersion, componentId, imageId, user);
+ Version vspVersion = new Version(versionId);
+ componentManager.validateComponentExistence(vspId, vspVersion, componentId);
+ imageManager.deleteImage(vspId, vspVersion, componentId, imageId);
return Response.ok().build();
}
@Override
- public Response update(ImageRequestDto request, String vspId, String versionId, String
- componentId,
- String imageId,
- String user) {
+ public Response update(ImageRequestDto request, String vspId, String versionId,
+ String componentId, String imageId, String user) {
MdcUtil.initMdc(LoggerServiceName.Update_Image.toString());
ImageEntity imageEntity = new MapImageRequestDtoToImageEntity().applyMapping(request,
ImageEntity.class);
imageEntity.setVspId(vspId);
- imageEntity.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write));
+ imageEntity.setVersion(new Version(versionId));
imageEntity.setComponentId(componentId);
imageEntity.setId(imageId);
- componentManager.validateComponentExistence(vspId, imageEntity.getVersion(), componentId, user);
+ componentManager.validateComponentExistence(vspId, imageEntity.getVersion(), componentId);
- CompositionEntityValidationData validationData =
- imageManager.updateImage(imageEntity, user);
+ CompositionEntityValidationData validationData = imageManager.updateImage(imageEntity);
return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors())
? Response.status(Response.Status.EXPECTATION_FAILED).entity(
new MapCompositionEntityValidationDataToDto()
@@ -134,14 +127,13 @@
}
@Override
- public Response getQuestionnaire(String vspId, String versionId, String componentId, String
- imageId, String user) {
+ public Response getQuestionnaire(String vspId, String versionId, String componentId,
+ String imageId, String user) {
MdcUtil.initMdc(LoggerServiceName.Get_Questionnaire_Compute.toString());
- Version vspVersion = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read);
- componentManager.validateComponentExistence(vspId, vspVersion, componentId, user);
- QuestionnaireResponse questionnaireResponse = imageManager
- .getImageQuestionnaire(vspId, vspVersion, componentId, imageId,
- user);
+ Version vspVersion = new Version(versionId);
+ componentManager.validateComponentExistence(vspId, vspVersion, componentId);
+ QuestionnaireResponse questionnaireResponse =
+ imageManager.getImageQuestionnaire(vspId, vspVersion, componentId, imageId);
QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto()
.applyMapping(questionnaireResponse, QuestionnaireResponseDto.class);
@@ -150,15 +142,12 @@
}
@Override
- public Response updateQuestionnaire(String questionnaireData, String vspId, String
- versionId,String componentId,String imageId, String user) {
- MdcUtil
- .initMdc(LoggerServiceName.Update_Questionnaire_Compute.toString()
- );
- Version vspVersion = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write);
- componentManager.validateComponentExistence(vspId, vspVersion, componentId, user);
- imageManager.updateImageQuestionnaire(vspId, vspVersion, componentId, imageId,
- questionnaireData, user);
+ public Response updateQuestionnaire(String questionnaireData, String vspId, String versionId,
+ String componentId, String imageId, String user) {
+ MdcUtil.initMdc(LoggerServiceName.Update_Questionnaire_Compute.toString());
+ Version version = new Version(versionId);
+ componentManager.validateComponentExistence(vspId, version, componentId);
+ imageManager.updateImageQuestionnaire(vspId, version, componentId, imageId, questionnaireData);
return Response.ok().build();
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NetworksImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NetworksImpl.java
index 471138f..5478327 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NetworksImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NetworksImpl.java
@@ -29,7 +29,7 @@
import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
+import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkDto;
@@ -61,8 +61,7 @@
public Response list(String vspId, String versionId, String user) {
MdcUtil.initMdc(LoggerServiceName.List_Network.toString());
Collection<NetworkEntity> networks =
- networkManager.listNetworks(vspId,
- resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read), user);
+ networkManager.listNetworks(vspId, new Version(versionId));
MapNetworkEntityToNetworkDto mapper = new MapNetworkEntityToNetworkDto();
GenericCollectionWrapper<NetworkDto> results = new GenericCollectionWrapper<>();
@@ -79,8 +78,8 @@
NetworkEntity network =
new MapNetworkRequestDtoToNetworkEntity().applyMapping(request, NetworkEntity.class);
network.setVspId(vspId);
- network.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write));
- NetworkEntity createdNetwork = networkManager.createNetwork(network, user);
+ network.setVersion(new Version(versionId));
+ NetworkEntity createdNetwork = networkManager.createNetwork(network);
return Response
.ok(createdNetwork != null ? new StringWrapperResponse(createdNetwork.getId()) : null)
.build();
@@ -91,8 +90,8 @@
MdcUtil.initMdc(LoggerServiceName.Get_Network.toString());
CompositionEntityResponse<Network> response =
networkManager.getNetwork(vspId,
- resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read), networkId,
- user);
+ new Version(versionId), networkId
+ );
CompositionEntityResponseDto<NetworkDto> responseDto = new CompositionEntityResponseDto<>();
new MapCompositionEntityResponseToDto<>(new MapNetworkToNetworkDto(), NetworkDto.class)
@@ -104,22 +103,23 @@
public Response delete(String vspId, String versionId, String networkId, String user) {
MdcUtil.initMdc(LoggerServiceName.Delete_Network.toString());
networkManager
- .deleteNetwork(vspId, resolveVspVersion(vspId, null, user, VersionableEntityAction.Write),
- networkId, user);
+ .deleteNetwork(vspId, new Version(versionId),
+ networkId);
return Response.ok().build();
}
@Override
- public Response update(NetworkRequestDto request, String vspId, String versionId, String networkId, String user) {
+ public Response update(NetworkRequestDto request, String vspId, String versionId,
+ String networkId, String user) {
MdcUtil.initMdc(LoggerServiceName.Update_Network.toString());
NetworkEntity networkEntity =
new MapNetworkRequestDtoToNetworkEntity().applyMapping(request, NetworkEntity.class);
networkEntity.setVspId(vspId);
- networkEntity.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write));
+ networkEntity.setVersion(new Version(versionId));
networkEntity.setId(networkId);
CompositionEntityValidationData validationData =
- networkManager.updateNetwork(networkEntity, user);
+ networkManager.updateNetwork(networkEntity);
return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors())
? Response.status(Response.Status.EXPECTATION_FAILED).entity(
new MapCompositionEntityValidationDataToDto()
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NicsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NicsImpl.java
index 73ca82a..738609a 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NicsImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NicsImpl.java
@@ -33,7 +33,6 @@
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicCreationResponseDto;
@@ -52,9 +51,9 @@
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
-import java.util.Collection;
import javax.inject.Named;
import javax.ws.rs.core.Response;
+import java.util.Collection;
@Named
@Service("nics")
@@ -67,9 +66,9 @@
@Override
public Response list(String vspId, String versionId, String componentId, String user) {
MdcUtil.initMdc(LoggerServiceName.List_nics.toString());
- Version vspVersion = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read);
- componentManager.validateComponentExistence(vspId, vspVersion, componentId, user);
- Collection<NicEntity> nics = nicManager.listNics(vspId, vspVersion, componentId, user);
+ Version vspVersion = new Version(versionId);
+ componentManager.validateComponentExistence(vspId, vspVersion, componentId);
+ Collection<NicEntity> nics = nicManager.listNics(vspId, vspVersion, componentId);
MapNicEntityToNicDto mapper = new MapNicEntityToNicDto();
GenericCollectionWrapper<NicDto> results = new GenericCollectionWrapper<>();
@@ -81,15 +80,16 @@
}
@Override
- public Response create(NicRequestDto request, String vspId, String versionId, String componentId, String user) {
+ public Response create(NicRequestDto request, String vspId, String versionId, String componentId,
+ String user) {
MdcUtil.initMdc(LoggerServiceName.Create_nic.toString());
NicEntity nic = new MapNicRequestDtoToNicEntity().applyMapping(request, NicEntity.class);
nic.setVspId(vspId);
- nic.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write));
+ nic.setVersion(new Version(versionId));
nic.setComponentId(componentId);
- componentManager.validateComponentExistence(vspId, nic.getVersion(), componentId, user);
+ componentManager.validateComponentExistence(vspId, nic.getVersion(), componentId);
- NicEntity createdNic = nicManager.createNic(nic, user);
+ NicEntity createdNic = nicManager.createNic(nic);
MapNicEntityToNicCreationResponseDto mapping =
new MapNicEntityToNicCreationResponseDto();
NicCreationResponseDto createdNicDto = mapping.applyMapping(createdNic,
@@ -99,12 +99,13 @@
}
@Override
- public Response get(String vspId, String versionId, String componentId, String nicId, String user) {
+ public Response get(String vspId, String versionId, String componentId, String nicId,
+ String user) {
MdcUtil.initMdc(LoggerServiceName.Get_nic.toString());
- Version vspVersion = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read);
- componentManager.validateComponentExistence(vspId, vspVersion, componentId, user);
+ Version vspVersion = new Version(versionId);
+ componentManager.validateComponentExistence(vspId, vspVersion, componentId);
CompositionEntityResponse<Nic> response =
- nicManager.getNic(vspId, vspVersion, componentId, nicId, user);
+ nicManager.getNic(vspId, vspVersion, componentId, nicId);
CompositionEntityResponseDto<NicDto> responseDto = new CompositionEntityResponseDto<>();
new MapCompositionEntityResponseToDto<>(new MapNicToNicDto(), NicDto.class)
@@ -113,27 +114,29 @@
}
@Override
- public Response delete(String vspId, String versionId, String componentId, String nicId, String user) {
+ public Response delete(String vspId, String versionId, String componentId, String nicId,
+ String user) {
MdcUtil.initMdc(LoggerServiceName.Delete_nic.toString());
- Version vspVersion = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write);
- componentManager.validateComponentExistence(vspId, vspVersion, componentId, user);
- nicManager.deleteNic(vspId, vspVersion, componentId, nicId, user);
+ Version vspVersion = new Version(versionId);
+ componentManager.validateComponentExistence(vspId, vspVersion, componentId);
+ nicManager.deleteNic(vspId, vspVersion, componentId, nicId);
return Response.ok().build();
}
@Override
- public Response update(NicRequestDto request, String vspId, String versionId, String componentId, String nicId,
+ public Response update(NicRequestDto request, String vspId, String versionId, String componentId,
+ String nicId,
String user) {
MdcUtil.initMdc(LoggerServiceName.Update_nic.toString());
NicEntity nicEntity = new MapNicRequestDtoToNicEntity().applyMapping(request, NicEntity.class);
nicEntity.setVspId(vspId);
- nicEntity.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write));
+ nicEntity.setVersion(new Version(versionId));
nicEntity.setComponentId(componentId);
nicEntity.setId(nicId);
- componentManager.validateComponentExistence(vspId, nicEntity.getVersion(), componentId, user);
+ componentManager.validateComponentExistence(vspId, nicEntity.getVersion(), componentId);
CompositionEntityValidationData validationData =
- nicManager.updateNic(nicEntity, user);
+ nicManager.updateNic(nicEntity);
return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors())
? Response.status(Response.Status.EXPECTATION_FAILED).entity(
new MapCompositionEntityValidationDataToDto()
@@ -145,10 +148,10 @@
public Response getQuestionnaire(String vspId, String versionId, String componentId, String nicId,
String user) {
MdcUtil.initMdc(LoggerServiceName.Get_Questionnaire_nic.toString());
- Version vspVersion = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read);
- componentManager.validateComponentExistence(vspId, vspVersion, componentId, user);
+ Version vspVersion = new Version(versionId);
+ componentManager.validateComponentExistence(vspId, vspVersion, componentId);
QuestionnaireResponse questionnaireResponse =
- nicManager.getNicQuestionnaire(vspId, vspVersion, componentId, nicId, user);
+ nicManager.getNicQuestionnaire(vspId, vspVersion, componentId, nicId);
QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto()
.applyMapping(questionnaireResponse, QuestionnaireResponseDto.class);
@@ -156,13 +159,14 @@
}
@Override
- public Response updateQuestionnaire(String questionnaireData, String vspId, String versionId, String componentId,
+ public Response updateQuestionnaire(String questionnaireData, String vspId, String versionId,
+ String componentId,
String nicId, String user) {
MdcUtil.initMdc(LoggerServiceName.Update_Questionnaire_nic.toString());
- Version vspVersion = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write);
- componentManager.validateComponentExistence(vspId, vspVersion, componentId, user);
+ Version vspVersion = new Version(versionId);
+ componentManager.validateComponentExistence(vspId, vspVersion, componentId);
nicManager
- .updateNicQuestionnaire(vspId, vspVersion, componentId, nicId, questionnaireData, user);
+ .updateNicQuestionnaire(vspId, vspVersion, componentId, nicId, questionnaireData);
return Response.ok().build();
}
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java
index 172c894..aaee77d 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java
@@ -4,6 +4,10 @@
import org.apache.commons.lang3.tuple.Pair;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
+import org.openecomp.sdc.activitylog.ActivityLogManager;
+import org.openecomp.sdc.activitylog.ActivityLogManagerFactory;
+import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
+import org.openecomp.sdc.activitylog.dao.type.ActivityType;
import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
@@ -12,27 +16,28 @@
import org.openecomp.sdc.logging.types.LoggerServiceName;
import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManager;
import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManagerFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.types.FileDataStructureDto;
import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.FileDataStructureDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.OrchestrationTemplateActionResponseDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto;
import org.openecomp.sdcrests.vendorsoftwareproducts.types.ValidationResponseDto;
import org.openecomp.sdcrests.vsp.rest.OrchestrationTemplateCandidate;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapFilesDataStructureToDto;
import org.openecomp.sdcrests.vsp.rest.mapping.MapUploadFileResponseToUploadFileResponseDto;
import org.openecomp.sdcrests.vsp.rest.mapping.MapValidationResponseToDto;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
+import javax.inject.Named;
+import javax.ws.rs.core.Response;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.util.Optional;
-import javax.inject.Named;
-import javax.ws.rs.core.Response;
import static org.openecomp.core.utilities.file.FileUtils.getFileExtension;
import static org.openecomp.core.utilities.file.FileUtils.getNetworkPackageName;
@@ -44,32 +49,31 @@
private OrchestrationTemplateCandidateManager candidateManager =
OrchestrationTemplateCandidateManagerFactory.getInstance().createInterface();
+ private ActivityLogManager activityLogManager =
+ ActivityLogManagerFactory.getInstance().createInterface();
+
private static final Logger logger =
- LoggerFactory.getLogger(OrchestrationTemplateCandidateImpl.class);
+ LoggerFactory.getLogger(OrchestrationTemplateCandidateImpl.class);
@Override
- public Response upload(String vspId, String versionId, Attachment fileToUpload,
- String user) {
+ public Response upload(String vspId, String versionId, Attachment fileToUpload, String user) {
MdcUtil.initMdc(LoggerServiceName.Upload_File.toString());
logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.UPLOAD_HEAT + vspId);
+
String filename = fileToUpload.getContentDisposition().getParameter("filename");
UploadFileResponse uploadFileResponse = candidateManager
- .upload(vspId, resolveVspVersion(vspId, null, user, VersionableEntityAction
- .Write), fileToUpload.getObject(InputStream.class), user, getFileExtension(filename),
- getNetworkPackageName(filename));
+ .upload(vspId, new Version(versionId), fileToUpload.getObject(InputStream.class),
+ getFileExtension(filename), getNetworkPackageName(filename));
+
UploadFileResponseDto uploadFileResponseDto = new MapUploadFileResponseToUploadFileResponseDto()
.applyMapping(uploadFileResponse, UploadFileResponseDto.class);
return Response.ok(uploadFileResponseDto).build();
}
-
-
@Override
public Response get(String vspId, String versionId, String user) throws IOException {
-
- Optional<Pair<String, byte[]>> zipFile = candidateManager
- .get(vspId, resolveVspVersion(vspId, null, user, VersionableEntityAction.Read), user);
+ Optional<Pair<String, byte[]>> zipFile = candidateManager.get(vspId, new Version(versionId));
if (!zipFile.isPresent()) {
return Response.status(Response.Status.NOT_FOUND).build();
@@ -84,10 +88,12 @@
public Response process(String vspId, String versionId, String user)
throws InvocationTargetException, IllegalAccessException {
- OrchestrationTemplateActionResponse response =
- candidateManager
- .process(vspId, resolveVspVersion(vspId, null, user, VersionableEntityAction.Write),
- user);
+ Version version = new Version(versionId);
+ OrchestrationTemplateActionResponse response = candidateManager.process(vspId, version);
+
+ activityLogManager.logActivity(new ActivityLogEntity(vspId, version,
+ ActivityType.Upload_Network_Package, user, true, "", ""));
+
OrchestrationTemplateActionResponseDto responseDto =
new OrchestrationTemplateActionResponseDto();
BeanUtils.copyProperties(responseDto, response);
@@ -95,8 +101,6 @@
return Response.ok(responseDto).build();
}
-
-
@Override
public Response updateFilesDataStructure(
String vspId, String versionId, FileDataStructureDto fileDataStructureDto, String user)
@@ -112,9 +116,7 @@
throw new Exception(errorWithParameters, exception);
}
ValidationResponse response = candidateManager
- .updateFilesDataStructure(vspId,
- resolveVspVersion(vspId, null, user, VersionableEntityAction
- .Write), user, fileDataStructure);
+ .updateFilesDataStructure(vspId, new Version(versionId), fileDataStructure);
if (!response.isValid()) {
return Response.status(Response.Status.EXPECTATION_FAILED).entity(
@@ -127,20 +129,13 @@
@Override
public Response getFilesDataStructure(String vspId, String versionId, String user)
throws Exception {
- Optional<FilesDataStructure> filesDataStructure = candidateManager
- .getFilesDataStructure(vspId, resolveVspVersion(vspId, null, user, VersionableEntityAction
- .Read), user);
- FileDataStructureDto fileDataStructureDto = new FileDataStructureDto();
- if (filesDataStructure.isPresent()) {
- try {
- BeanUtils.copyProperties(fileDataStructureDto, filesDataStructure.get());
- } catch (IllegalAccessException | InvocationTargetException exception) {
- String errorWithParameters = ErrorMessagesFormatBuilder
- .getErrorWithParameters(Messages.MAPPING_OBJECTS_FAILURE.getErrorMessage(),
- filesDataStructure.toString(), fileDataStructureDto.toString());
- throw new Exception(errorWithParameters, exception);
- }
- }
+ Optional<FilesDataStructure> filesDataStructure =
+ candidateManager.getFilesDataStructure(vspId, new Version(versionId));
+
+ FileDataStructureDto fileDataStructureDto =
+ filesDataStructure.map(dataStructure -> new MapFilesDataStructureToDto()
+ .applyMapping(dataStructure, FileDataStructureDto.class))
+ .orElse(new FileDataStructureDto());
return Response.ok(fileDataStructureDto).build();
}
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ProcessesImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ProcessesImpl.java
index 6bc7a37..ab67b68 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ProcessesImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ProcessesImpl.java
@@ -20,8 +20,6 @@
package org.openecomp.sdcrests.vsp.rest.services;
-import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.GENERAL_COMPONENT_ID;
-
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
@@ -43,67 +41,65 @@
@Scope(value = "prototype")
public class ProcessesImpl implements Processes {
+ private static final Logger logger = LoggerFactory.getLogger(ProcessesImpl.class);
@Autowired
private ComponentProcesses componentProcesses;
- private static final Logger logger =
- LoggerFactory.getLogger(ProcessesImpl.class);
@Override
public Response list(String vspId, String versionId, String user) {
MdcUtil.initMdc(LoggerServiceName.List_Processes.toString());
- return componentProcesses.list(vspId, versionId, GENERAL_COMPONENT_ID, user);
+ return componentProcesses.list(vspId, versionId, null, user);
}
@Override
public Response deleteList(String vspId, String versionId, String user) {
MdcUtil.initMdc(LoggerServiceName.Delete_List_Processes.toString());
- return componentProcesses.deleteList(vspId,versionId, GENERAL_COMPONENT_ID, user);
+ return componentProcesses.deleteList(vspId, versionId, null, user);
}
@Override
public Response create(ProcessRequestDto request, String vspId, String versionId, String user) {
MdcUtil.initMdc(LoggerServiceName.Create_Process.toString());
- return componentProcesses.create(request, vspId, versionId, GENERAL_COMPONENT_ID, user);
+ return componentProcesses.create(request, vspId, versionId, null, user);
}
@Override
public Response get(String vspId, String versionId, String processId, String user) {
MdcUtil.initMdc(LoggerServiceName.Get_Processes.toString());
- return componentProcesses.get(vspId, versionId, GENERAL_COMPONENT_ID, processId, user);
+ return componentProcesses.get(vspId, versionId, null, processId, user);
}
@Override
public Response delete(String vspId, String versionId, String processId, String user) {
MdcUtil.initMdc(LoggerServiceName.Delete_Processes.toString());
- return componentProcesses.delete(vspId, versionId, GENERAL_COMPONENT_ID, processId, user);
+ return componentProcesses.delete(vspId, versionId, null, processId, user);
}
@Override
- public Response update(ProcessRequestDto request, String vspId, String versionId, String processId, String user) {
+ public Response update(ProcessRequestDto request, String vspId, String versionId,
+ String processId, String user) {
MdcUtil.initMdc(LoggerServiceName.Update_Process.toString());
- return componentProcesses.update(request, vspId, versionId, GENERAL_COMPONENT_ID, processId, user);
+ return componentProcesses.update(request, vspId, versionId, null, processId, user);
}
@Override
public Response getUploadedFile(String vspId, String versionId, String processId, String user) {
MdcUtil.initMdc(LoggerServiceName.Get_Uploaded_File_Processes.toString());
- return componentProcesses
- .getUploadedFile(vspId, versionId, GENERAL_COMPONENT_ID, processId, user);
+ return componentProcesses.getUploadedFile(vspId, versionId, null, processId, user);
}
@Override
- public Response deleteUploadedFile(String vspId, String versionId, String processId, String user) {
+ public Response deleteUploadedFile(String vspId, String versionId, String processId,
+ String user) {
MdcUtil.initMdc(LoggerServiceName.Delete_Uploaded_File_Processes.toString());
- return componentProcesses.deleteUploadedFile(vspId, versionId, GENERAL_COMPONENT_ID,
- processId, user);
+ return componentProcesses.deleteUploadedFile(vspId, versionId, null, processId, user);
}
@Override
- public Response uploadFile(Attachment attachment, String vspId, String versionId, String processId, String user) {
+ public Response uploadFile(Attachment attachment, String vspId, String versionId,
+ String processId, String user) {
MdcUtil.initMdc(LoggerServiceName.Upload_File_Processes.toString());
logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.UPLOAD_PROCESS_ARTIFACT + vspId);
- return componentProcesses.uploadFile(attachment, vspId, versionId, GENERAL_COMPONENT_ID,
- processId,
- user);
+ return componentProcesses.uploadFile(attachment, vspId, versionId, null, processId, user);
}
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java
index c38bf8a..feffb91 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java
@@ -20,10 +20,23 @@
package org.openecomp.sdcrests.vsp.rest.services;
+import org.apache.commons.collections4.MapUtils;
+import org.openecomp.core.util.UniqueValueUtil;
+import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
+import org.openecomp.sdc.activitylog.ActivityLogManager;
+import org.openecomp.sdc.activitylog.ActivityLogManagerFactory;
+import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
+import org.openecomp.sdc.activitylog.dao.type.ActivityType;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
+import org.openecomp.sdc.datatypes.model.ItemType;
+import org.openecomp.sdc.healing.factory.HealingManagerFactory;
+import org.openecomp.sdc.itempermissions.ItemPermissionsManager;
+import org.openecomp.sdc.itempermissions.ItemPermissionsManagerFactory;
+import org.openecomp.sdc.itempermissions.impl.types.PermissionTypes;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.MdcUtil;
@@ -33,25 +46,53 @@
import org.openecomp.sdc.logging.types.LoggerErrorCode;
import org.openecomp.sdc.logging.types.LoggerServiceName;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+import org.openecomp.sdc.notification.dtos.Event;
+import org.openecomp.sdc.notification.factories.NotificationPropagationManagerFactory;
+import org.openecomp.sdc.notification.services.NotificationPropagationManager;
+import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
import org.openecomp.sdc.vendorsoftwareproduct.VspManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OnboardingMethod;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.CreatePackageForNonFinalVendorSoftwareProductErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.OnboardingMethodErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.PackageNotFoundErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse;
-import org.openecomp.sdc.vendorsoftwareproduct.types.VersionedVendorSoftwareProductInfo;
+import org.openecomp.sdc.versioning.ItemManager;
+import org.openecomp.sdc.versioning.ItemManagerFactory;
+import org.openecomp.sdc.versioning.VersioningManager;
+import org.openecomp.sdc.versioning.VersioningManagerFactory;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdc.versioning.dao.types.VersionStatus;
-import org.openecomp.sdc.versioning.types.VersionInfo;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
-import org.openecomp.sdcrests.vendorsoftwareproducts.types.*;
+import org.openecomp.sdc.versioning.errors.RequestedVersionInvalidErrorBuilder;
+import org.openecomp.sdc.versioning.types.Item;
+import org.openecomp.sdc.versioning.types.NotificationEventTypes;
+import org.openecomp.sdcrests.item.rest.mapping.MapVersionToDto;
+import org.openecomp.sdcrests.item.types.ItemCreationDto;
+import org.openecomp.sdcrests.item.types.VersionDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.PackageInfoDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.ValidationResponseDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.VersionSoftwareProductActionRequestDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspComputeDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDescriptionDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDetailsDto;
+import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspRequestDto;
import org.openecomp.sdcrests.vsp.rest.VendorSoftwareProducts;
-import org.openecomp.sdcrests.vsp.rest.mapping.*;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapComputeEntityToVspComputeDto;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapItemToVspDetailsDto;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapPackageInfoToPackageInfoDto;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapQuestionnaireResponseToQuestionnaireResponseDto;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapValidationResponseToDto;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapVspDescriptionDtoToItem;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapVspDescriptionDtoToVspDetails;
+import org.openecomp.sdcrests.vsp.rest.mapping.MapVspDetailsToDto;
import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper;
-import org.openecomp.sdcrests.wrappers.StringWrapperResponse;
-import org.slf4j.MDC;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
@@ -60,77 +101,126 @@
import java.io.File;
import java.io.IOException;
import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
-import java.util.Objects;
-import java.util.stream.Collectors;
+import java.util.Map;
+import java.util.Optional;
+import java.util.function.Predicate;
+import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_USER;
import static org.openecomp.sdc.logging.messages.AuditMessages.SUBMIT_VSP_ERROR;
+import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME;
+import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.VALIDATION_VSP_NAME;
+import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_ID;
+import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_NAME;
+import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.SUBMIT_DESCRIPTION;
+import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_ID;
+import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_NAME;
@Named
@Service("vendorSoftwareProducts")
@Scope(value = "prototype")
public class VendorSoftwareProductsImpl implements VendorSoftwareProducts {
+ private static final String SUBMIT_ITEM = "Submit_Item";
- private final VendorSoftwareProductManager vendorSoftwareProductManager =
+ private static final Logger LOGGER = LoggerFactory.getLogger(VendorSoftwareProductsImpl.class);
+
+ private static ItemCreationDto validationVsp;
+
+ private ItemManager itemManager = ItemManagerFactory.getInstance().createInterface();
+ private ItemPermissionsManager permissionsManager =
+ ItemPermissionsManagerFactory.getInstance().createInterface();
+ private VersioningManager versioningManager =
+ VersioningManagerFactory.getInstance().createInterface();
+ private VendorSoftwareProductManager vendorSoftwareProductManager =
VspManagerFactory.getInstance().createInterface();
-
- private static final Logger logger =
- LoggerFactory.getLogger(VendorSoftwareProductsImpl.class);
+ private ActivityLogManager activityLogManager =
+ ActivityLogManagerFactory.getInstance().createInterface();
+ private NotificationPropagationManager notifier =
+ NotificationPropagationManagerFactory.getInstance().createInterface();
@Override
- public Response createVsp(VspDescriptionDto vspDescriptionDto, String user) {
+ public Response createVsp(VspRequestDto vspRequestDto, String user) {
MdcUtil.initMdc(LoggerServiceName.Create_VSP.toString());
- logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.CREATE_VSP
- + vspDescriptionDto.getName());
+ LOGGER.audit(AuditMessages.AUDIT_MSG + AuditMessages.CREATE_VSP + vspRequestDto.getName());
+
+ ItemCreationDto itemCreationDto;
OnboardingMethod onboardingMethod;
-
try {
- onboardingMethod = OnboardingMethod.valueOf(vspDescriptionDto.getOnboardingMethod());
+ onboardingMethod = OnboardingMethod.valueOf(vspRequestDto.getOnboardingMethod());
} catch (IllegalArgumentException e) {
- return handleUnknownOnboardingMethod();
+ throw getUnknownOnboardingMethod();
}
-
switch (onboardingMethod) {
case NetworkPackage:
case Manual:
- VspDetails vspDetails = new MapVspDescriptionDtoToVspDetails().
- applyMapping(vspDescriptionDto, VspDetails.class);
+ Item item = new MapVspDescriptionDtoToItem().applyMapping(vspRequestDto, Item.class);
+ item.setType(ItemType.vsp.name());
+ item.addProperty(VspItemProperty.ONBOARDING_METHOD, onboardingMethod.name());
- vspDetails = vendorSoftwareProductManager.createVsp(vspDetails, user);
+ UniqueValueUtil.validateUniqueValue(VENDOR_SOFTWARE_PRODUCT_NAME, item.getName());
+ item = itemManager.create(item);
+ UniqueValueUtil.createUniqueValue(VENDOR_SOFTWARE_PRODUCT_NAME, item.getName());
- MapVspDetailsToVspCreationDto mapping = new MapVspDetailsToVspCreationDto();
- VspCreationDto vspCreationDto = mapping.applyMapping(vspDetails, VspCreationDto.class);
- return Response.ok(vspCreationDto).build();
+ Version version = versioningManager.create(item.getId(), new Version(), null);
+
+ VspDetails vspDetails =
+ new MapVspDescriptionDtoToVspDetails().applyMapping(vspRequestDto, VspDetails.class);
+ vspDetails.setId(item.getId());
+ vspDetails.setVersion(version);
+ vspDetails.setOnboardingMethod(vspRequestDto.getOnboardingMethod());
+
+ vendorSoftwareProductManager.createVsp(vspDetails);
+ versioningManager.publish(item.getId(), version, "Initial vsp:" + vspDetails.getName());
+
+ itemCreationDto = new ItemCreationDto();
+ itemCreationDto.setItemId(item.getId());
+ itemCreationDto.setVersion(new MapVersionToDto().applyMapping(version, VersionDto.class));
+
+ activityLogManager.logActivity(new ActivityLogEntity(vspDetails.getId(), version,
+ ActivityType.Create, user, true, "", ""));
+ break;
default:
- return handleUnknownOnboardingMethod();
+ throw getUnknownOnboardingMethod();
}
+
+ return Response.ok(itemCreationDto).build();
}
- private Response handleUnknownOnboardingMethod() {
+ private CoreException getUnknownOnboardingMethod() {
ErrorCode onboardingMethodUpdateErrorCode = OnboardingMethodErrorBuilder
.getInvalidOnboardingMethodErrorBuilder();
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
LoggerTragetServiceName.ADD_VSP, ErrorLevel.ERROR.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), onboardingMethodUpdateErrorCode.message());
- throw new CoreException(onboardingMethodUpdateErrorCode);
+ return new CoreException(onboardingMethodUpdateErrorCode);
}
@Override
- public Response listVsps(String versionFilter, String user) {
+ public Response listVsps(String versionStatus, String user) {
MdcUtil.initMdc(LoggerServiceName.List_VSP.toString());
- List<VersionedVendorSoftwareProductInfo> vspList =
- vendorSoftwareProductManager.listVsps(versionFilter, user);
+
+ Predicate<Item> itemPredicate;
+ if (VersionStatus.Certified.name().equals(versionStatus)) {
+ itemPredicate = item -> ItemType.vsp.name().equals(item.getType()) &&
+ item.getVersionStatusCounters().containsKey(VersionStatus.Certified);
+
+ } else if (VersionStatus.Draft.name().equals(versionStatus)) {
+ itemPredicate = item -> ItemType.vsp.name().equals(item.getType()) &&
+ item.getVersionStatusCounters().containsKey(VersionStatus.Draft) &&
+ userHasPermission(item.getId(), user);
+
+ } else {
+ itemPredicate = item -> ItemType.vsp.name().equals(item.getType());
+ }
GenericCollectionWrapper<VspDetailsDto> results = new GenericCollectionWrapper<>();
- if (!vspList.isEmpty()) {
- MapVersionedVendorSoftwareProductInfoToVspDetailsDto mapper =
- new MapVersionedVendorSoftwareProductInfoToVspDetailsDto();
- for (VersionedVendorSoftwareProductInfo versionedVsp : vspList) {
- results.add(mapper.applyMapping(versionedVsp, VspDetailsDto.class));
- }
- }
+ MapItemToVspDetailsDto mapper = new MapItemToVspDetailsDto();
+ itemManager.list(itemPredicate).stream()
+ .sorted((o1, o2) -> o2.getModificationTime().compareTo(o1.getModificationTime()))
+ .forEach(vspItem -> results.add(mapper.applyMapping(vspItem, VspDetailsDto.class)));
return Response.ok(results).build();
}
@@ -139,40 +229,48 @@
public Response getVsp(String vspId, String versionId, String user) {
MdcUtil.initMdc(LoggerServiceName.Get_VSP.toString());
+ Version version = versioningManager.get(vspId, new Version(versionId));
+ VspDetails vspDetails = vendorSoftwareProductManager.getVsp(vspId, version);
+ vspDetails.setWritetimeMicroSeconds(version.getModificationTime().getTime());
- VspDetails vspDetails =
- vendorSoftwareProductManager
- .getVsp(vspId, resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read),
- user);
+ try {
+ Optional<Version> healedVersion = HealingManagerFactory.getInstance().createInterface()
+ .healItemVersion(vspId, version, ItemType.vsp, false);
+ healedVersion.ifPresent(vspDetails::setVersion);
- VersionInfo versionInfo = getVersionInfo(vspId, VersionableEntityAction.Read, user);
-
-
- if (vspDetails.getOldVersion() != null && !"".equals(vspDetails.getOldVersion())) {
- if (Version.valueOf(versionId).equals(versionInfo.getActiveVersion())) {
+ if (healedVersion.isPresent() && version.getStatus() == VersionStatus.Certified) {
try {
- Version healedVersion = vendorSoftwareProductManager.callAutoHeal(vspId, versionInfo,
- vspDetails, user);
- vspDetails =
- vendorSoftwareProductManager
- .getVsp(vspId, resolveVspVersion(vspId, healedVersion.toString(), user,
- VersionableEntityAction.Read), user);
- versionInfo = getVersionInfo(vspId, VersionableEntityAction.Read, user);
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
+ submitHealedVsp(vspId, healedVersion.get(), user);
+ } catch (Exception ex) {
+ LOGGER.error("VSP Id {}: Error while submitting version {} " +
+ "created based on Certified version {} for healing purpose.",
+ vspId, healedVersion.get().getId(), versionId, ex.getMessage());
}
}
+ } catch (Exception e) {
+ LOGGER.error(String.format("Error while auto healing VSP with Id %s and version %s: %s",
+ vspId, versionId, e.getMessage()));
}
- VspDetailsDto vspDetailsDto = vspDetails == null
- ? null
- : new MapVersionedVendorSoftwareProductInfoToVspDetailsDto()
- .applyMapping(new VersionedVendorSoftwareProductInfo(vspDetails, versionInfo),
- VspDetailsDto.class);
+ VspDetailsDto vspDetailsDto =
+ new MapVspDetailsToDto().applyMapping(vspDetails, VspDetailsDto.class);
+ addNetworkPackageInfo(vspId, version, vspDetailsDto);
return Response.ok(vspDetailsDto).build();
}
+ private void submitHealedVsp(String vspId, Version healedVersion, String user)
+ throws IOException {
+ Optional<ValidationResponse>
+ validationResponse = submit(vspId, healedVersion, "Submit healed Vsp", user);
+ if (validationResponse.isPresent()) {
+ // TODO: 8/9/2017 before collaboration checkout was done at this scenario (equivalent
+ // to new version in collaboration). need to decide what should be done now.
+ throw new IllegalStateException("Certified vsp after healing failed on validation");
+ }
+ vendorSoftwareProductManager.createPackage(vspId, healedVersion);
+ }
+
@Override
public Response updateVsp(String vspId, String versionId, VspDescriptionDto vspDescriptionDto,
String user) {
@@ -180,9 +278,9 @@
VspDetails vspDetails =
new MapVspDescriptionDtoToVspDetails().applyMapping(vspDescriptionDto, VspDetails.class);
vspDetails.setId(vspId);
- vspDetails.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write));
+ vspDetails.setVersion(new Version(versionId));
- vendorSoftwareProductManager.updateVsp(vspDetails, user);
+ vendorSoftwareProductManager.updateVsp(vspDetails);
return Response.ok().build();
}
@@ -190,60 +288,38 @@
@Override
public Response deleteVsp(String vspId, String user) {
MdcUtil.initMdc(LoggerServiceName.Delete_VSP.toString());
- vendorSoftwareProductManager.deleteVsp(vspId, user);
+ vendorSoftwareProductManager.deleteVsp(vspId);
return Response.ok().build();
}
@Override
- public Response actOnVendorSoftwareProduct(String vspId, String versionId,
- VersionSoftwareProductActionRequestDto request,
+ public Response actOnVendorSoftwareProduct(VersionSoftwareProductActionRequestDto request,
+ String vspId, String versionId,
String user) throws IOException {
+ Version version = new Version(versionId);
switch (request.getAction()) {
- case Checkout:
- MDC.put(LoggerConstants.SERVICE_NAME, LoggerServiceName.Checkout_VSP.toString());
- vendorSoftwareProductManager.checkout(vspId, user);
- logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.CHECK_OUT_VSP + vspId);
- break;
- case Undo_Checkout:
- MDC.put(LoggerConstants.SERVICE_NAME, LoggerServiceName.Undo_Checkout_VSP.toString());
- vendorSoftwareProductManager.undoCheckout(vspId, user);
- break;
- case Checkin:
- MDC.put(LoggerConstants.SERVICE_NAME, LoggerServiceName.Checkin_VSP.toString());
- vendorSoftwareProductManager.checkin(vspId, user);
- logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.CHECK_IN_VSP + vspId);
- break;
case Submit:
- MDC.put(LoggerConstants.SERVICE_NAME, LoggerServiceName.Submit_VSP.toString());
- ValidationResponse validationResponse = vendorSoftwareProductManager.submit(vspId, user);
- if (!validationResponse.isValid()) {
- logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.SUBMIT_VSP_FAIL + vspId);
- if (validationResponse.getVspErrors() != null) {
- validationResponse.getVspErrors().forEach(errorCode -> logger.audit(AuditMessages
- .AUDIT_MSG + String.format(SUBMIT_VSP_ERROR, errorCode.message(), vspId)));
- }
- if (validationResponse.getUploadDataErrors() != null) {
- validationResponse.getUploadDataErrors().values().forEach(errorMessages
- -> printAuditForErrors(errorMessages, vspId, SUBMIT_VSP_ERROR));
- }
-
- return Response.status(Response.Status.EXPECTATION_FAILED).entity(
- new MapValidationResponseToDto()
- .applyMapping(validationResponse, ValidationResponseDto.class)).build();
+ if (!permissionsManager.isAllowed(vspId, user, SUBMIT_ITEM)) {
+ return Response.status(Response.Status.FORBIDDEN)
+ .entity(new Exception(Messages.PERMISSIONS_ERROR.getErrorMessage())).build();
}
- logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.SUBMIT_VSP + vspId);
+ String message =
+ request.getSubmitRequest() == null ? "" : request.getSubmitRequest().getMessage();
+ Optional<ValidationResponse> validationResponse = submit(vspId, version, message, user);
+
+ if (validationResponse.isPresent()) {
+ ValidationResponseDto validationResponseDto = new MapValidationResponseToDto()
+ .applyMapping(validationResponse.get(), ValidationResponseDto.class);
+ return Response.status(Response.Status.EXPECTATION_FAILED).entity(validationResponseDto)
+ .build();
+ }
+
+ notifyUsers(vspId, version, message, user, NotificationEventTypes.SUBMIT);
break;
case Create_Package:
- MDC.put(LoggerConstants.SERVICE_NAME, LoggerServiceName.Create_Package.toString());
-
- PackageInfo packageInfo = vendorSoftwareProductManager.createPackage(vspId,
- resolveVspVersion(vspId, null, user, VersionableEntityAction.Read), user);
- return Response.ok(packageInfo == null
- ? null
- : new MapPackageInfoToPackageInfoDto().applyMapping(packageInfo, PackageInfoDto.class))
- .build();
+ return createPackage(vspId, version);
default:
}
@@ -251,21 +327,41 @@
}
@Override
- public Response getValidationVsp(String user)
- throws Exception {
- String validationVspId = vendorSoftwareProductManager.fetchValidationVsp(user);
- StringWrapperResponse response = new StringWrapperResponse(validationVspId);
- return Response.ok(response).build();
- }
+ public Response getValidationVsp(String user) throws Exception {
+ if (validationVsp != null) {
+ return Response.ok(validationVsp).build();
+ }
+ VspRequestDto validationVspRequest = new VspRequestDto();
+ validationVspRequest.setOnboardingMethod("HEAT");
+ validationVspRequest.setName(VALIDATION_VSP_NAME);
+
+ try {
+ validationVsp = (ItemCreationDto) createVsp(validationVspRequest, user).getEntity();
+ return Response.ok(validationVsp).build();
+
+ } catch (CoreException validationVspAlreadyExistException) {
+ // find validationVsp
+ String validationVspId = itemManager.list(item ->
+ ItemType.vsp.name().equals(item.getType()) && VALIDATION_VSP_NAME.equals(item.getName()))
+ .stream().findFirst().orElseThrow(() -> new IllegalStateException("Vsp with name %s " +
+ "does not exist even though the name exists according to unique value util")).getId();
+ Version validationVspVersion = versioningManager.list(validationVspId).iterator().next();
+
+ validationVsp = new ItemCreationDto();
+ validationVsp.setItemId(validationVspId);
+ validationVsp
+ .setVersion(new MapVersionToDto().applyMapping(validationVspVersion, VersionDto.class));
+
+ return Response.ok(validationVsp).build();
+ }
+ }
@Override
public Response getOrchestrationTemplate(String vspId, String versionId, String user) {
MdcUtil.initMdc(LoggerServiceName.Get_Uploaded_File.toString());
byte[] orchestrationTemplateFile =
- vendorSoftwareProductManager
- .getOrchestrationTemplateFile(vspId,
- resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read), user);
+ vendorSoftwareProductManager.getOrchestrationTemplateFile(vspId, new Version(versionId));
if (orchestrationTemplateFile == null) {
return Response.status(Response.Status.NOT_FOUND).build();
@@ -293,24 +389,47 @@
}
@Override
- public Response getTranslatedFile(String vspId, String versionId, String user) {
+ public Response getTranslatedFile(String vspId, String versionName, String user) {
MdcUtil.initMdc(LoggerServiceName.Get_Translated_File.toString());
- Version version = Version.valueOf(versionId);
- Version resolvedVersion = version == null
- ? getVersionInfo(vspId, VersionableEntityAction.Read, user).getLatestFinalVersion()
- : version;
+ List<Version> versions = versioningManager.list(vspId);
+ Version version;
+ if (versionName == null) {
+ version = versions.stream().filter(ver -> VersionStatus.Certified == ver.getStatus())
+ .max((o1, o2) -> ((Double) Double.parseDouble(o1.getName()))
+ .compareTo(Double.parseDouble(o2.getName()))).orElseThrow(() -> {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.GET_TRANSLATED_FILE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), "Package not found");
+ return new CoreException(new PackageNotFoundErrorBuilder(vspId).build());
+ });
+ } else {
+ version = versions.stream().filter(ver -> versionName.equals(ver.getName()))
+ .findFirst().orElseThrow(() -> {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.GET_TRANSLATED_FILE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), "Package not found");
+ return new CoreException(new PackageNotFoundErrorBuilder(vspId).build());
+ });
- File zipFile = vendorSoftwareProductManager.getTranslatedFile(vspId, resolvedVersion, user);
+ if (version.getStatus() != VersionStatus.Certified) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.GET_VERSION_INFO, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), "Invalid requested version");
+ throw new CoreException(new RequestedVersionInvalidErrorBuilder().build());
+ }
+ }
+
+ File zipFile = vendorSoftwareProductManager.getTranslatedFile(vspId, version);
Response.ResponseBuilder response = Response.ok(zipFile);
if (zipFile == null) {
- logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.IMPORT_FAIL + vspId);
+ LOGGER.audit(AuditMessages.AUDIT_MSG + AuditMessages.IMPORT_FAIL + vspId);
return Response.status(Response.Status.NOT_FOUND).build();
}
response.header("Content-Disposition", "attachment; filename=" + zipFile.getName());
- logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.IMPORT_SUCCESS + vspId);
+ LOGGER.audit(AuditMessages.AUDIT_MSG + AuditMessages.IMPORT_SUCCESS + vspId);
return response.build();
}
@@ -318,8 +437,7 @@
public Response getQuestionnaire(String vspId, String versionId, String user) {
MdcUtil.initMdc(LoggerServiceName.Get_Questionnaire_VSP.toString());
QuestionnaireResponse questionnaireResponse =
- vendorSoftwareProductManager.getVspQuestionnaire(vspId,
- resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read), user);
+ vendorSoftwareProductManager.getVspQuestionnaire(vspId, new Version(versionId));
if (questionnaireResponse.getErrorMessage() != null) {
return Response.status(Response.Status.EXPECTATION_FAILED).entity(
@@ -336,16 +454,15 @@
public Response updateQuestionnaire(String questionnaireData, String vspId, String
versionId, String user) {
MdcUtil.initMdc(LoggerServiceName.Update_Questionnaire_VSP.toString());
- vendorSoftwareProductManager.updateVspQuestionnaire(vspId,
- resolveVspVersion(vspId, null, user, VersionableEntityAction.Write),
- questionnaireData, user);
+ vendorSoftwareProductManager
+ .updateVspQuestionnaire(vspId, new Version(versionId), questionnaireData);
return Response.ok().build();
}
@Override
public Response heal(String vspId, String versionId, String user) {
- vendorSoftwareProductManager.heal(vspId, Version.valueOf(versionId), user);
-
+ HealingManagerFactory.getInstance().createInterface()
+ .healItemVersion(vspId, new Version(versionId), ItemType.vsp, true);
return Response.ok().build();
}
@@ -353,8 +470,7 @@
public Response getVspInformationArtifact(String vspId, String versionId, String user) {
MdcUtil.initMdc(LoggerServiceName.Get_Information_Artifact.toString());
File textInformationArtifact =
- vendorSoftwareProductManager.getInformationArtifact(vspId,
- resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read), user);
+ vendorSoftwareProductManager.getInformationArtifact(vspId, new Version(versionId));
Response.ResponseBuilder response = Response.ok(textInformationArtifact);
if (textInformationArtifact == null) {
@@ -365,10 +481,11 @@
return response.build();
}
- public Response listCompute(String vspId, String version, String user) {
+ @Override
+ public Response listComputes(String vspId, String version, String user) {
- Collection<ComputeEntity> computes = vendorSoftwareProductManager.getComputeByVsp(vspId,
- resolveVspVersion(vspId, version, user, VersionableEntityAction.Read), user);
+ Collection<ComputeEntity> computes =
+ vendorSoftwareProductManager.getComputeByVsp(vspId, new Version(version));
MapComputeEntityToVspComputeDto mapper = new MapComputeEntityToVspComputeDto();
GenericCollectionWrapper<VspComputeDto> results = new GenericCollectionWrapper<>();
@@ -379,91 +496,152 @@
return Response.ok(results).build();
}
- @Override
- public Response reSubmitAll(String user) throws IOException {
+ private Optional<ValidationResponse> submit(String vspId, Version version, String message,
+ String user) throws IOException {
+ MdcUtil.initMdc(LoggerServiceName.Submit_VSP.toString());
+ LOGGER.audit(AuditMessages.AUDIT_MSG + AuditMessages.SUBMIT_VSP + vspId);
- MDC.put(LoggerConstants.SERVICE_NAME, LoggerServiceName.Re_Submit_ALL_Final_VSPs.toString());
- logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.RESUBMIT_ALL_FINAL_VSPS);
-
- List<VersionedVendorSoftwareProductInfo> latestFinalVsps = Objects
- .requireNonNull(vendorSoftwareProductManager.listVsps(VersionStatus.Final.name(), user));
-
- List<VersionedVendorSoftwareProductInfo> nonLockedLatestFinalVsps = latestFinalVsps.stream()
- .filter(vsp ->
- !isVspLocked(vsp.getVspDetails().getId(), vsp.getVspDetails().getName(), user))
- .collect(Collectors.toList());
-
- logger.info("Removed {} VSPs out of {} from processing due to status LOCKED.\n" +
- "Total number of VSPs: {}. Performing healing and resubmit for all non-Manual VSPs " +
- "in submitted status.\n No need to pre-set oldVersion field",
- latestFinalVsps.size() - nonLockedLatestFinalVsps.size(), latestFinalVsps.size(),
- nonLockedLatestFinalVsps.size());
-
- int healingCounter = 0;
- int failedCounter = 0;
- for (int counter = 0; counter < nonLockedLatestFinalVsps.size(); counter++) {
- VersionedVendorSoftwareProductInfo versionVspInfo = nonLockedLatestFinalVsps.get(counter);
- try {
- final VspDetails vspDetails = versionVspInfo.getVspDetails();
- if (!OnboardingMethod.Manual.name().equals(vspDetails.getOnboardingMethod())) {
- logger.info("Starting on healing and resubmit for VSP [{}], #{} out of total {}",
- vspDetails.getName(), counter + 1, nonLockedLatestFinalVsps.size());
- reSubmit(vspDetails, user);
- healingCounter++;
- }
- } catch (Exception e) {
- failedCounter++;
+ ValidationResponse validationResponse = vendorSoftwareProductManager.validate(vspId, version);
+ Map<String, List<ErrorMessage>> compilationErrors =
+ vendorSoftwareProductManager.compile(vspId, version);
+ if (!validationResponse.isValid() || MapUtils.isNotEmpty(compilationErrors)) {
+ LOGGER.audit(AuditMessages.AUDIT_MSG + AuditMessages.SUBMIT_VSP_FAIL + vspId);
+ if (validationResponse.getVspErrors() != null) {
+ validationResponse.getVspErrors().forEach(errorCode -> LOGGER.audit(AuditMessages
+ .AUDIT_MSG + String.format(SUBMIT_VSP_ERROR, errorCode.message(), vspId)));
}
+ if (validationResponse.getUploadDataErrors() != null) {
+ validationResponse.getUploadDataErrors().values().forEach(errorMessages
+ -> printAuditForErrors(errorMessages, vspId, SUBMIT_VSP_ERROR));
+ }
+ activityLogManager.logActivity(
+ new ActivityLogEntity(vspId, version, ActivityType.Submit, user, false,
+ "Failed on validation before submit", ""));
+ return Optional.of(validationResponse);
}
- logger.info("Total VSPs processed {}. Completed running healing and resubmit for {} VSPs out" +
- " of total # of {} submitted VSPs. Failures count during resubmitAll: {}",
- nonLockedLatestFinalVsps.size(), healingCounter, latestFinalVsps.size(), failedCounter);
+ versioningManager.submit(vspId, version, message);
- return Response.ok().build();
+ LOGGER.audit(AuditMessages.AUDIT_MSG + AuditMessages.SUBMIT_VSP + vspId);
+ activityLogManager.logActivity(
+ new ActivityLogEntity(vspId, version, ActivityType.Submit, user, true, "", message));
+ return Optional.empty();
}
- private boolean isVspLocked(String vspId, String vspName, String user) {
- final VersionInfo versionInfo = getVersionInfo(vspId, VersionableEntityAction.Read, user);
+ private void notifyUsers(String itemId, Version version, String message,
+ String userName, NotificationEventTypes eventType) {
+ Map<String, Object> eventProperties = new HashMap<>();
+ eventProperties.put(ITEM_NAME, itemManager.get(itemId).getName());
+ eventProperties.put(ITEM_ID, itemId);
- if (versionInfo.getStatus().equals(VersionStatus.Locked)) {
- logger.info("VSP name [{}]/id [{}] status is LOCKED", vspName, vspId);
- return true;
- }
- logger.info("VSP Name {}, VSP id [{}], Active Version {} , Status {}, Latest Final Version {}",
- vspName, vspId, versionInfo.getActiveVersion().toString(), versionInfo.getStatus(),
- versionInfo.getLatestFinalVersion().toString());
- return false;
- }
+ Version ver = versioningManager.get(itemId, version);
+ eventProperties.put(VERSION_NAME, ver.getName());
+ eventProperties.put(VERSION_ID, ver.getId());
+ eventProperties.put(SUBMIT_DESCRIPTION, message);
+ eventProperties.put(PERMISSION_USER, userName);
- private void reSubmit(VspDetails vspDetails, String user) throws Exception {
- final Version versionBefore = vspDetails.getVersion();
- vspDetails.setOldVersion("true");
-
- Version finalVersion;
+ Event syncEvent = new SyncEvent(eventType.getEventName(), itemId, eventProperties, itemId);
try {
- finalVersion =
- vendorSoftwareProductManager
- .healAndAdvanceFinalVersion(vspDetails.getId(), vspDetails, user);
+ notifier.notifySubscribers(syncEvent, userName);
} catch (Exception e) {
- logger.error("Failed during resubmit, VSP [{}] , version before:{}, version after:{}, " +
- "status after:{}, with exception:{}",
- vspDetails.getName(), versionBefore.toString(), vspDetails.getVersion().toString(),
- vspDetails
- .getVersion().getStatus().name(), e.getMessage());
- throw e;
+ LOGGER.error("Failed to send sync notification to users subscribed o item '" + itemId);
}
-
- logger.info("Completed healing and resubmit for VSP [{}], version before:{}, version after:" +
- " {}", vspDetails.getName(), versionBefore.toString(), finalVersion);
}
- private static void printAuditForErrors(List<ErrorMessage> errorList, String vspId,
- String auditType) {
+ private class SyncEvent implements Event {
+
+ private String eventType;
+ private String originatorId;
+ private Map<String, Object> attributes;
+ private String entityId;
+
+ public SyncEvent(String eventType, String originatorId,
+ Map<String, Object> attributes, String entityId) {
+ this.eventType = eventType;
+ this.originatorId = originatorId;
+ this.attributes = attributes;
+ this.entityId = entityId;
+ }
+
+ @Override
+ public String getEventType() {
+ return eventType;
+ }
+
+ @Override
+ public String getOriginatorId() {
+ return originatorId;
+ }
+
+ @Override
+ public Map<String, Object> getAttributes() {
+ return attributes;
+ }
+
+ @Override
+ public String getEntityId() {
+ return entityId;
+ }
+ }
+
+ private Response createPackage(String vspId, Version version) throws IOException {
+ MdcUtil.initMdc(LoggerServiceName.Create_Package.toString());
+
+ Version retrievedVersion = versioningManager.get(vspId, version);
+ if (retrievedVersion.getStatus() != VersionStatus.Certified) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_PACKAGE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Can't create package");
+ throw new CoreException(
+ new CreatePackageForNonFinalVendorSoftwareProductErrorBuilder(vspId, version)
+ .build());
+ }
+ PackageInfo packageInfo =
+ vendorSoftwareProductManager.createPackage(vspId, retrievedVersion);
+ return Response.ok(packageInfo == null
+ ? null
+ : new MapPackageInfoToPackageInfoDto().applyMapping(packageInfo, PackageInfoDto.class))
+ .build();
+ }
+
+ private void addNetworkPackageInfo(String vspId, Version version, VspDetailsDto vspDetailsDto) {
+ OrchestrationTemplateEntity orchestrationTemplateInfo =
+ vendorSoftwareProductManager.getOrchestrationTemplateInfo(vspId, version);
+
+ vspDetailsDto.setValidationData(orchestrationTemplateInfo.getValidationDataStructure());
+ vspDetailsDto.setNetworkPackageName(orchestrationTemplateInfo.getFileName());
+ vspDetailsDto.setOnboardingOrigin(orchestrationTemplateInfo.getFileSuffix() == null
+ ? OnboardingTypesEnum.NONE.toString()
+ : orchestrationTemplateInfo.getFileSuffix());
+
+ OrchestrationTemplateCandidateData candidateInfo =
+ OrchestrationTemplateCandidateManagerFactory.getInstance().createInterface()
+ .getInfo(vspId, version);
+
+ //todo - remove after fix missing candidate element
+ if(candidateInfo == null){
+ candidateInfo = new OrchestrationTemplateCandidateData();
+ candidateInfo.setFileSuffix("zip");
+ }
+
+ vspDetailsDto
+ .setCandidateOnboardingOrigin( candidateInfo.getFileSuffix()
+ == null
+ ? OnboardingTypesEnum.NONE.toString()
+ : candidateInfo.getFileSuffix());
+ }
+
+ private boolean userHasPermission(String itemId, String userId) {
+ String permission = permissionsManager.getUserItemPermiission(itemId, userId);
+ return (permission != null && permission
+ .matches(PermissionTypes.Contributor.name() + "|" + PermissionTypes.Owner.name()));
+ }
+
+ private void printAuditForErrors(List<ErrorMessage> errorList, String vspId, String auditType) {
errorList.forEach(errorMessage -> {
if (errorMessage.getLevel().equals(ErrorLevel.ERROR)) {
- logger.audit(AuditMessages.AUDIT_MSG + String.format(auditType, errorMessage.getMessage(),
+ LOGGER.audit(AuditMessages.AUDIT_MSG + String.format(auditType, errorMessage.getMessage(),
vspId));
}
});
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VspItemProperty.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VspItemProperty.java
new file mode 100644
index 0000000..a40f6b1
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VspItemProperty.java
@@ -0,0 +1,7 @@
+package org.openecomp.sdcrests.vsp.rest.services;
+
+public final class VspItemProperty {
+ public static final String VENDOR_ID = "vendorId";
+ public static final String VENDOR_NAME = "vendorName";
+ public static final String ONBOARDING_METHOD = "onboardingMethod";
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/pom.xml
index 9e3f3f3..fca77a8 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/pom.xml
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/pom.xml
@@ -22,6 +22,11 @@
</dependency>
<dependency>
<groupId>org.openecomp.sdc</groupId>
+ <artifactId>item-rest-services</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
<artifactId>openecomp-sdc-vendor-software-product-manager</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDependencyCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDependencyCreationDto.java
new file mode 100644
index 0000000..d9f8354
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDependencyCreationDto.java
@@ -0,0 +1,13 @@
+package org.openecomp.sdcrests.vendorsoftwareproducts.types;
+
+public class ComponentDependencyCreationDto {
+ private String id;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDependencyResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDependencyResponseDto.java
new file mode 100644
index 0000000..91f89a1
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDependencyResponseDto.java
@@ -0,0 +1,41 @@
+package org.openecomp.sdcrests.vendorsoftwareproducts.types;
+
+public class ComponentDependencyResponseDto {
+
+ private String sourceId;
+ private String targetId;
+ private String relationType;
+ private String id;
+
+ public String getSourceId() {
+ return sourceId;
+ }
+
+ public void setSourceId(String sourceId) {
+ this.sourceId = sourceId;
+ }
+
+ public String getTargetId() {
+ return targetId;
+ }
+
+ public void setTargetId(String targetId) {
+ this.targetId = targetId;
+ }
+
+ public String getRelationType() {
+ return relationType;
+ }
+
+ public void setRelationType(String relationType) {
+ this.relationType = relationType;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorRequestDto.java
index 3bc0b95..a24d01a 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorRequestDto.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorRequestDto.java
@@ -4,8 +4,8 @@
import org.hibernate.validator.constraints.NotBlank;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation;
-import java.util.List;
import javax.validation.constraints.Size;
+import java.util.List;
public class DeploymentFlavorRequestDto {
@NotBlank(message = "is mandatory and should not be empty")
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/FileDataStructureDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/FileDataStructureDto.java
similarity index 96%
rename from openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/FileDataStructureDto.java
rename to openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/FileDataStructureDto.java
index 8cb3673..5d1191c 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/FileDataStructureDto.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/FileDataStructureDto.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.vendorsoftwareproduct.types;
+package org.openecomp.sdcrests.vendorsoftwareproducts.types;
import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.Module;
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/OnboardingMethod.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/OnboardingMethod.java
deleted file mode 100644
index 0db4b04..0000000
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/OnboardingMethod.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package org.openecomp.sdcrests.vendorsoftwareproducts.types;
-
-public enum OnboardingMethod {
- NetworkPackage,
- Manual;
-}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/QuestionnaireDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/QuestionnaireDto.java
new file mode 100644
index 0000000..cb30b50
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/QuestionnaireDto.java
@@ -0,0 +1,30 @@
+package org.openecomp.sdcrests.vendorsoftwareproducts.types;
+
+import java.util.HashMap;
+
+/**
+ * Created by ayalaben on 9/26/2017
+ */
+public class QuestionnaireDto {
+
+ private String id;
+
+ public HashMap<String, String> getQuestionareData() {
+ return questionareData;
+ }
+
+ public void setQuestionareData(HashMap<String, String> questionareData) {
+ this.questionareData = questionareData;
+ }
+
+ private HashMap<String,String> questionareData;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VendorSoftwareProductAction.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VendorSoftwareProductAction.java
index c652c1c..1ec68e4 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VendorSoftwareProductAction.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VendorSoftwareProductAction.java
@@ -21,9 +21,6 @@
package org.openecomp.sdcrests.vendorsoftwareproducts.types;
public enum VendorSoftwareProductAction {
- Checkout,
- Undo_Checkout,
- Checkin,
Submit,
Create_Package;
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VersionSoftwareProductActionRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VersionSoftwareProductActionRequestDto.java
index dbfdf34..f8ea65c 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VersionSoftwareProductActionRequestDto.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VersionSoftwareProductActionRequestDto.java
@@ -20,11 +20,14 @@
package org.openecomp.sdcrests.vendorsoftwareproducts.types;
+import org.openecomp.sdcrests.item.types.SubmitRequestDto;
+
/**
* Created by TALIO on 4/20/2016.
*/
public class VersionSoftwareProductActionRequestDto {
private VendorSoftwareProductAction action;
+ private SubmitRequestDto submitRequest;
public VendorSoftwareProductAction getAction() {
return action;
@@ -33,4 +36,12 @@
public void setAction(VendorSoftwareProductAction action) {
this.action = action;
}
+
+ public SubmitRequestDto getSubmitRequest() {
+ return submitRequest;
+ }
+
+ public void setSubmitRequest(SubmitRequestDto submitRequest) {
+ this.submitRequest = submitRequest;
+ }
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDescriptionDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDescriptionDto.java
index 9062f89..a2358a0 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDescriptionDto.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDescriptionDto.java
@@ -21,7 +21,6 @@
package org.openecomp.sdcrests.vendorsoftwareproducts.types;
import org.openecomp.sdc.vendorsoftwareproduct.types.LicensingData;
-import org.openecomp.sdcrests.common.types.VersionDto;
import javax.validation.constraints.NotNull;
@@ -39,14 +38,9 @@
private String vendorName;
@NotNull
private String vendorId; // this will be populated with vlm id
- private VersionDto licensingVersion; // this will be populated with vlm version
+ private String licensingVersion; // this will be populated with vlm version
private LicensingData licensingData;
- @NotNull
- private String onboardingMethod;
- private String onboardingOrigin;
- private String networkPackageName;
-
public String getName() {
return name;
}
@@ -103,11 +97,11 @@
this.vendorId = vendorId;
}
- public VersionDto getLicensingVersion() {
+ public String getLicensingVersion() {
return licensingVersion;
}
- public void setLicensingVersion(VersionDto licensingVersion) {
+ public void setLicensingVersion(String licensingVersion) {
this.licensingVersion = licensingVersion;
}
@@ -118,28 +112,4 @@
public void setLicensingData(LicensingData licensingData) {
this.licensingData = licensingData;
}
-
- public String getOnboardingMethod() {
- return onboardingMethod;
- }
-
- public void setOnboardingMethod(String onboardingMethod) {
- this.onboardingMethod = onboardingMethod;
- }
-
- public String getOnboardingOrigin() {
- return onboardingOrigin;
- }
-
- public void setOnboardingOrigin(String onboardingOrigin) {
- this.onboardingOrigin = onboardingOrigin;
- }
-
- public String getNetworkPackageName() {
- return networkPackageName;
- }
-
- public void setNetworkPackageName(String networkPackageName) {
- this.networkPackageName = networkPackageName;
- }
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDetailsDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDetailsDto.java
index 28a77f2..5052442 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDetailsDto.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDetailsDto.java
@@ -22,27 +22,20 @@
import io.swagger.annotations.ApiModel;
import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList;
-import org.openecomp.sdc.versioning.dao.types.VersionStatus;
-import org.openecomp.sdcrests.common.types.VersionDto;
-
-import java.util.List;
/**
* Created by TALIO on 4/25/2016.
*/
@ApiModel(value = "VspDetails")
-public class VspDetailsDto extends VspDescriptionDto {
+public class VspDetailsDto extends VspRequestDto {
private String id;
- private VersionDto version;
- private List<VersionDto> viewableVersions;
- private List<VersionDto> finalVersions;
- private VersionStatus status;
- private String lockingUser;
+ private String version;
private ValidationStructureList validationData;
- private String isOldVersion;
+ private String candidateOnboardingOrigin;
private String onboardingOrigin;
private String networkPackageName;
+
public String getId() {
return id;
}
@@ -51,62 +44,30 @@
this.id = id;
}
- public VersionDto getVersion() {
+ public String getVersion() {
return version;
}
- public void setVersion(VersionDto version) {
+ public void setVersion(String version) {
this.version = version;
}
- public List<VersionDto> getViewableVersions() {
- return viewableVersions;
- }
-
- public void setViewableVersions(List<VersionDto> viewableVersions) {
- this.viewableVersions = viewableVersions;
- }
-
- public List<VersionDto> getFinalVersions() {
- return finalVersions;
- }
-
- public void setFinalVersions(List<VersionDto> finalVersions) {
- this.finalVersions = finalVersions;
- }
-
- public VersionStatus getStatus() {
- return status;
- }
-
- public void setStatus(VersionStatus status) {
- this.status = status;
- }
-
- public String getLockingUser() {
- return lockingUser;
- }
-
- public void setLockingUser(String lockingUser) {
- this.lockingUser = lockingUser;
- }
-
public ValidationStructureList getValidationData() {
return validationData;
}
- public String getIsOldVersion() {
- return isOldVersion;
- }
-
- public void setIsOldVersion(String isOldVersion) {
- this.isOldVersion = isOldVersion;
- }
-
public void setValidationData(ValidationStructureList validationData) {
this.validationData = validationData;
}
+ public String getCandidateOnboardingOrigin() {
+ return candidateOnboardingOrigin;
+ }
+
+ public void setCandidateOnboardingOrigin(String candidateOnboardingOrigin) {
+ this.candidateOnboardingOrigin = candidateOnboardingOrigin;
+ }
+
public String getOnboardingOrigin() {
return onboardingOrigin;
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspRequestDto.java
new file mode 100644
index 0000000..19cad86
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspRequestDto.java
@@ -0,0 +1,16 @@
+package org.openecomp.sdcrests.vendorsoftwareproducts.types;
+
+import javax.validation.constraints.NotNull;
+
+public class VspRequestDto extends VspDescriptionDto {
+ @NotNull
+ private String onboardingMethod;
+
+ public String getOnboardingMethod() {
+ return onboardingMethod;
+ }
+
+ public void setOnboardingMethod(String onboardingMethod) {
+ this.onboardingMethod = onboardingMethod;
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/IsValidJson.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/IsValidJson.java
index 5109002..aa8b32c 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/IsValidJson.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/IsValidJson.java
@@ -24,6 +24,14 @@
* @since July 13, 2016
*/
+import org.openecomp.sdcrests.common.RestConstants;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.CONSTRUCTOR;
import static java.lang.annotation.ElementType.FIELD;
@@ -31,14 +39,6 @@
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import org.openecomp.sdcrests.common.RestConstants;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.validation.Constraint;
-import javax.validation.Payload;
-
/**
* The interface Is valid json.
*/
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/StringValidator.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/StringValidator.java
index 0fc2fd7..49b3e91 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/StringValidator.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/StringValidator.java
@@ -1,9 +1,9 @@
package org.openecomp.sdcrests.vendorsoftwareproducts.types.validation;
-import java.util.ArrayList;
-import java.util.List;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
+import java.util.ArrayList;
+import java.util.List;
public class StringValidator implements ConstraintValidator<ValidateString, String> {
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/ValidateString.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/ValidateString.java
index 1218bb1..dab2f25 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/ValidateString.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/ValidateString.java
@@ -1,5 +1,11 @@
package org.openecomp.sdcrests.vendorsoftwareproducts.types.validation;
+import javax.validation.Constraint;
+import javax.validation.Payload;
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.CONSTRUCTOR;
import static java.lang.annotation.ElementType.FIELD;
@@ -7,12 +13,6 @@
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import javax.validation.Constraint;
-import javax.validation.Payload;
-
/**
* The interface Validate string.
*/
diff --git a/openecomp-be/backend/openecomp-sdc-action-manager/src/main/java/org/openecomp/sdc/action/impl/ActionManagerImpl.java b/openecomp-be/backend/openecomp-sdc-action-manager/src/main/java/org/openecomp/sdc/action/impl/ActionManagerImpl.java
index f9b6bfe..492bfef 100644
--- a/openecomp-be/backend/openecomp-sdc-action-manager/src/main/java/org/openecomp/sdc/action/impl/ActionManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-action-manager/src/main/java/org/openecomp/sdc/action/impl/ActionManagerImpl.java
@@ -20,14 +20,61 @@
package org.openecomp.sdc.action.impl;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
+import org.openecomp.core.util.UniqueValueUtil;
+import org.openecomp.core.utilities.CommonMethods;
+import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.sdc.action.ActionConstants;
+import org.openecomp.sdc.action.ActionManager;
+import org.openecomp.sdc.action.dao.ActionArtifactDao;
+import org.openecomp.sdc.action.dao.ActionArtifactDaoFactory;
+import org.openecomp.sdc.action.dao.ActionDao;
+import org.openecomp.sdc.action.dao.ActionDaoFactory;
+import org.openecomp.sdc.action.dao.types.ActionArtifactEntity;
+import org.openecomp.sdc.action.dao.types.ActionEntity;
+import org.openecomp.sdc.action.errors.ActionErrorConstants;
+import org.openecomp.sdc.action.errors.ActionException;
+import org.openecomp.sdc.action.logging.StatusCode;
+import org.openecomp.sdc.action.types.Action;
+import org.openecomp.sdc.action.types.ActionArtifact;
+import org.openecomp.sdc.action.types.ActionArtifactProtection;
+import org.openecomp.sdc.action.types.ActionStatus;
+import org.openecomp.sdc.action.types.ActionSubOperation;
+import org.openecomp.sdc.action.types.OpenEcompComponent;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+import org.openecomp.sdc.versioning.VersioningManager;
+import org.openecomp.sdc.versioning.VersioningManagerFactory;
+import org.openecomp.sdc.versioning.dao.VersionInfoDao;
+import org.openecomp.sdc.versioning.dao.VersionInfoDaoFactory;
+import org.openecomp.sdc.versioning.dao.types.UserCandidateVersion;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.dao.types.VersionInfoEntity;
+import org.openecomp.sdc.versioning.errors.EntityNotExistErrorBuilder;
+import org.openecomp.sdc.versioning.errors.VersioningErrorCodes;
+import org.openecomp.sdc.versioning.types.VersionInfo;
+import org.openecomp.sdc.versioning.types.VersionableEntityAction;
+import org.slf4j.MDC;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
import static org.openecomp.sdc.action.ActionConstants.ACTION_VERSIONABLE_TYPE;
import static org.openecomp.sdc.action.ActionConstants.ARTIFACT_METADATA_ATTR_NAME;
import static org.openecomp.sdc.action.ActionConstants.ARTIFACT_METADATA_ATTR_UUID;
import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_CATEGORY;
-import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_OPEN_ECOMP_COMPONENT;
import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_MODEL;
import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_NAME;
import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_NONE;
+import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_OPEN_ECOMP_COMPONENT;
import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_VENDOR;
import static org.openecomp.sdc.action.ActionConstants.SERVICE_INSTANCE_ID;
import static org.openecomp.sdc.action.ActionConstants.STATUS;
@@ -68,49 +115,6 @@
import static org.openecomp.sdc.action.util.ActionUtil.getCurrentTimeStampUtc;
import static org.openecomp.sdc.versioning.dao.types.Version.VERSION_STRING_VIOLATION_MSG;
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang.StringUtils;
-import org.openecomp.sdc.action.types.*;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-import org.openecomp.core.util.UniqueValueUtil;
-import org.openecomp.core.utilities.CommonMethods;
-import org.openecomp.core.utilities.json.JsonUtil;
-import org.openecomp.sdc.action.ActionConstants;
-import org.openecomp.sdc.action.ActionManager;
-import org.openecomp.sdc.action.dao.ActionArtifactDao;
-import org.openecomp.sdc.action.dao.ActionArtifactDaoFactory;
-import org.openecomp.sdc.action.dao.ActionDao;
-import org.openecomp.sdc.action.dao.ActionDaoFactory;
-import org.openecomp.sdc.action.dao.types.ActionArtifactEntity;
-import org.openecomp.sdc.action.dao.types.ActionEntity;
-import org.openecomp.sdc.action.errors.ActionErrorConstants;
-import org.openecomp.sdc.action.errors.ActionException;
-import org.openecomp.sdc.action.logging.StatusCode;
-import org.openecomp.sdc.action.types.OpenEcompComponent;
-import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.versioning.VersioningManager;
-import org.openecomp.sdc.versioning.VersioningManagerFactory;
-import org.openecomp.sdc.versioning.dao.VersionInfoDao;
-import org.openecomp.sdc.versioning.dao.VersionInfoDaoFactory;
-import org.openecomp.sdc.versioning.dao.types.UserCandidateVersion;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.dao.types.VersionInfoEntity;
-import org.openecomp.sdc.versioning.errors.EntityNotExistErrorBuilder;
-import org.openecomp.sdc.versioning.errors.VersioningErrorCodes;
-import org.openecomp.sdc.versioning.types.VersionInfo;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
-import org.slf4j.MDC;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
/**
* Manager Implementation for {@link ActionManager Action Library Operations} <br> Handles Business
* layer validations and acts as an interface between the REST and DAO layers.
diff --git a/openecomp-be/backend/openecomp-sdc-action-manager/src/test/java/org/openecomp/sdc/action/ActionTest.java b/openecomp-be/backend/openecomp-sdc-action-manager/src/test/java/org/openecomp/sdc/action/ActionTest.java
index a8f7b69..582a4c7 100644
--- a/openecomp-be/backend/openecomp-sdc-action-manager/src/test/java/org/openecomp/sdc/action/ActionTest.java
+++ b/openecomp-be/backend/openecomp-sdc-action-manager/src/test/java/org/openecomp/sdc/action/ActionTest.java
@@ -20,57 +20,6 @@
package org.openecomp.sdc.action;
-import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_NAME;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_ALREADY_EXISTS;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_ALREADY_EXISTS_CODE;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_DEL_LOCKED_OTHER_USER;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_DEL_LOCKED_OTHER_USER_CODE;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST_CODE;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_UPDATE_NAME_INVALID;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_UPDATE_READ_ONLY_MSG;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_DELETE_ON_LOCKED_ENTITY_CODE;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_EDIT_ON_ENTITY_LOCKED_BY_OTHER_USER;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_NOT_EXIST;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_NOT_EXIST_CODE;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_UNIQUE_VALUE_ERROR;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_UNIQUE_VALUE_MSG;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_NOT_LOCKED_CODE;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_NOT_LOCKED_MSG;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_UPDATE_ON_UNLOCKED_ENTITY;
-
-import org.openecomp.core.nosqldb.api.NoSqlDb;
-import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
-import org.openecomp.core.utilities.json.JsonUtil;
-import org.openecomp.sdc.action.dao.ActionDao;
-import org.openecomp.sdc.action.dao.ActionDaoFactory;
-import org.openecomp.sdc.action.dao.types.ActionEntity;
-import org.openecomp.sdc.action.errors.ActionErrorConstants;
-import org.openecomp.sdc.action.errors.ActionException;
-import org.openecomp.sdc.action.impl.ActionManagerImpl;
-import org.openecomp.sdc.action.types.Action;
-import org.openecomp.sdc.action.types.ActionArtifact;
-import org.openecomp.sdc.action.types.ActionArtifactProtection;
-import org.openecomp.sdc.action.types.ActionStatus;
-import org.openecomp.sdc.action.types.OpenEcompComponent;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.testng.Assert;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-
@SuppressWarnings("Duplicates")
public class ActionTest {
diff --git a/openecomp-be/backend/openecomp-sdc-activity-log-manager/pom.xml b/openecomp-be/backend/openecomp-sdc-activity-log-manager/pom.xml
index fc014cd..4b0db49 100644
--- a/openecomp-be/backend/openecomp-sdc-activity-log-manager/pom.xml
+++ b/openecomp-be/backend/openecomp-sdc-activity-log-manager/pom.xml
@@ -46,11 +46,6 @@
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
- <dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>activity-log-rest-types</artifactId>
- <version>${project.version}</version>
- </dependency>
</dependencies>
diff --git a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activityLog/impl/ActivityLogManagerImpl.java b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activityLog/impl/ActivityLogManagerImpl.java
deleted file mode 100644
index 324af20..0000000
--- a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activityLog/impl/ActivityLogManagerImpl.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.activityLog.impl;
-
-import org.openecomp.core.utilities.CommonMethods;
-import org.openecomp.sdc.activityLog.ActivityLogManager;
-import org.openecomp.sdc.activitylog.dao.ActivityLogDao;
-import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
-import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
-import org.openecomp.sdc.versioning.dao.types.Version;
-
-import java.util.Collection;
-
-public class ActivityLogManagerImpl implements ActivityLogManager {
- private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
- private ActivityLogDao activityLogDao;
-
- public ActivityLogManagerImpl(ActivityLogDao activityLogDao) {
- this.activityLogDao = activityLogDao;
- }
-
- @Override
- public void addActionLog(ActivityLogEntity activityLogEntity, String user) {
- mdcDataDebugMessage.debugEntryMessage("ITEM id", activityLogEntity.getItemId());
- activityLogEntity.setId(CommonMethods.nextUuId());
- activityLogDao.create(activityLogEntity);
- }
-
- @Override
- public Collection<ActivityLogEntity> listActivityLogs(String itemId, Version version, String user) {
- mdcDataDebugMessage.debugEntryMessage("ITEM id", itemId);
- String versionId = version.getMinor() == 0 ? String.valueOf(version.getMajor()) : String.valueOf(version.getMajor()+1);
- return activityLogDao.getActivityLogListForItem(itemId, versionId);
- }
-}
diff --git a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activityLog/ActivityLogManager.java b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/ActivityLogManager.java
similarity index 84%
rename from openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activityLog/ActivityLogManager.java
rename to openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/ActivityLogManager.java
index a40e101..06de3e1 100644
--- a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activityLog/ActivityLogManager.java
+++ b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/ActivityLogManager.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.activityLog;
+package org.openecomp.sdc.activitylog;
import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
import org.openecomp.sdc.versioning.dao.types.Version;
@@ -26,6 +26,8 @@
import java.util.Collection;
public interface ActivityLogManager {
- void addActionLog(ActivityLogEntity activityLogEntity, String user);
- Collection<ActivityLogEntity> listActivityLogs(String itemId, Version versionId, String user);
+
+ void logActivity(ActivityLogEntity activityLogEntity);
+
+ Collection<ActivityLogEntity> listLoggedActivities(String itemId, Version versionId);
}
diff --git a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activityLog/ActivityLogManagerFactory.java b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/ActivityLogManagerFactory.java
similarity index 93%
rename from openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activityLog/ActivityLogManagerFactory.java
rename to openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/ActivityLogManagerFactory.java
index 9816b76..93010f6 100644
--- a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activityLog/ActivityLogManagerFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/ActivityLogManagerFactory.java
@@ -17,11 +17,10 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.activityLog;
+package org.openecomp.sdc.activitylog;
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
-import org.openecomp.sdc.activityLog.ActivityLogManager;
public abstract class ActivityLogManagerFactory extends AbstractComponentFactory<ActivityLogManager> {
diff --git a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activityLog/impl/ActivityLogManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerFactoryImpl.java
similarity index 73%
rename from openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activityLog/impl/ActivityLogManagerFactoryImpl.java
rename to openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerFactoryImpl.java
index 4911924..5dc7f84 100644
--- a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activityLog/impl/ActivityLogManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerFactoryImpl.java
@@ -17,17 +17,18 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.activityLog.impl;
+package org.openecomp.sdc.activitylog.impl;
-import org.openecomp.sdc.activityLog.ActivityLogManager;
-import org.openecomp.sdc.activityLog.ActivityLogManagerFactory;
+import org.openecomp.sdc.activitylog.ActivityLogManager;
+import org.openecomp.sdc.activitylog.ActivityLogManagerFactory;
import org.openecomp.sdc.activitylog.dao.ActivityLogDaoFactory;
public class ActivityLogManagerFactoryImpl extends ActivityLogManagerFactory {
- private static final ActivityLogManager INSTANCE = new ActivityLogManagerImpl(
- ActivityLogDaoFactory.getInstance().createInterface()
- );
+ private static final ActivityLogManager INSTANCE =
+ new ActivityLogManagerImpl(ActivityLogDaoFactory.getInstance().createInterface());
- @Override
- public ActivityLogManager createInterface() {return INSTANCE;}
+ @Override
+ public ActivityLogManager createInterface() {
+ return INSTANCE;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerImpl.java b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerImpl.java
new file mode 100644
index 0000000..711fd68
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerImpl.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.activitylog.impl;
+
+import org.openecomp.core.utilities.CommonMethods;
+import org.openecomp.sdc.activitylog.ActivityLogManager;
+import org.openecomp.sdc.activitylog.dao.ActivityLogDao;
+import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.Collection;
+
+public class ActivityLogManagerImpl implements ActivityLogManager {
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private ActivityLogDao activityLogDao;
+
+ public ActivityLogManagerImpl(ActivityLogDao activityLogDao) {
+ this.activityLogDao = activityLogDao;
+ }
+
+ @Override
+ public void logActivity(ActivityLogEntity activityLogEntity) {
+ mdcDataDebugMessage.debugEntryMessage("ITEM id", activityLogEntity.getItemId());
+ activityLogEntity.setId(CommonMethods.nextUuId());
+ activityLogDao.create(activityLogEntity);
+ }
+
+ @Override
+ public Collection<ActivityLogEntity> listLoggedActivities(String itemId, Version version) {
+ mdcDataDebugMessage.debugEntryMessage("ITEM id", itemId);
+ return activityLogDao.list(new ActivityLogEntity(itemId, version));
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/resources/factoryConfiguration.json b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/resources/factoryConfiguration.json
index b4e151d..e4d3dab 100644
--- a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/resources/factoryConfiguration.json
+++ b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/resources/factoryConfiguration.json
@@ -1,3 +1,3 @@
{
- "org.openecomp.sdc.activityLog.ActivityLogManagerFactory": "org.openecomp.sdc.activityLog.impl.ActivityLogManagerFactoryImpl"
+ "org.openecomp.sdc.activitylog.ActivityLogManagerFactory": "org.openecomp.sdc.activitylog.impl.ActivityLogManagerFactoryImpl"
}
\ No newline at end of file
diff --git a/openecomp-be/backend/openecomp-sdc-application-config-manager/src/test/java/org/openecomp/sdc/applicationconfig/ApplicationConfigManagerTest.java b/openecomp-be/backend/openecomp-sdc-application-config-manager/src/test/java/org/openecomp/sdc/applicationconfig/ApplicationConfigManagerTest.java
index 4217025..e58f455 100644
--- a/openecomp-be/backend/openecomp-sdc-application-config-manager/src/test/java/org/openecomp/sdc/applicationconfig/ApplicationConfigManagerTest.java
+++ b/openecomp-be/backend/openecomp-sdc-application-config-manager/src/test/java/org/openecomp/sdc/applicationconfig/ApplicationConfigManagerTest.java
@@ -20,14 +20,7 @@
package org.openecomp.sdc.applicationconfig;
-import org.openecomp.core.utilities.applicationconfig.dao.type.ApplicationConfigEntity;
-import org.openecomp.core.utilities.applicationconfig.type.ConfigurationData;
import org.openecomp.sdc.applicationconfig.impl.ApplicationConfigManagerImpl;
-import org.openecomp.sdc.common.errors.CoreException;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import java.util.Collection;
/**
* Created by Talio on 8/9/2016.
diff --git a/openecomp-be/backend/openecomp-sdc-conflict-manager/pom.xml b/openecomp-be/backend/openecomp-sdc-conflict-manager/pom.xml
new file mode 100644
index 0000000..4fa58b2
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-conflict-manager/pom.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>backend</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>openecomp-sdc-conflict-manager</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-facade-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-conflict-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-conflict-core</artifactId>
+ <version>${project.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/ConflictsManager.java b/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/ConflictsManager.java
new file mode 100644
index 0000000..d7c5c3f
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/ConflictsManager.java
@@ -0,0 +1,20 @@
+package org.openecomp.sdc.conflicts;
+
+import org.openecomp.conflicts.types.Conflict;
+import org.openecomp.conflicts.types.ConflictResolution;
+import org.openecomp.conflicts.types.ItemVersionConflict;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+public interface ConflictsManager {
+
+ boolean isConflicted(String itemId, Version version);
+
+ ItemVersionConflict getConflict(String itemId, Version version);
+
+ void finalizeMerge(String itemId, Version version);
+
+ Conflict getConflict(String itemId, Version version, String conflictId);
+
+ void resolveConflict(String itemId, Version version, String conflictId,
+ ConflictResolution resolution);
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDaoFactory.java b/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/ConflictsManagerFactory.java
similarity index 79%
copy from openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDaoFactory.java
copy to openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/ConflictsManagerFactory.java
index 9654551..7a24cfd 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDaoFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/ConflictsManagerFactory.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,15 +17,14 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
-package org.openecomp.sdc.vendorsoftwareproduct.dao;
+package org.openecomp.sdc.conflicts;
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
-public abstract class UploadDataDaoFactory extends AbstractComponentFactory<UploadDataDao> {
- public static UploadDataDaoFactory getInstance() {
- return AbstractFactory.getInstance(UploadDataDaoFactory.class);
- }
+public abstract class ConflictsManagerFactory extends AbstractComponentFactory<ConflictsManager> {
+ public static ConflictsManagerFactory getInstance() {
+ return AbstractFactory.getInstance(ConflictsManagerFactory.class);
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductDaoFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/impl/ConflictsManagerFactoryImpl.java
similarity index 67%
rename from openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductDaoFactoryImpl.java
rename to openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/impl/ConflictsManagerFactoryImpl.java
index 0a80b2a..2d703c4 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductDaoFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/impl/ConflictsManagerFactoryImpl.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,18 +17,19 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
-package org.openecomp.sdc.vendorsoftwareproduct.dao.impl;
-
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
+package org.openecomp.sdc.conflicts.impl;
-public class VendorSoftwareProductDaoFactoryImpl extends VendorSoftwareProductDaoFactory {
- private static final VendorSoftwareProductDao INSTANCE = new VendorSoftwareProductDaoImpl();
+import org.openecomp.conflicts.dao.ConflictsDaoFactory;
+import org.openecomp.sdc.conflicts.ConflictsManager;
+import org.openecomp.sdc.conflicts.ConflictsManagerFactory;
+
+public class ConflictsManagerFactoryImpl extends ConflictsManagerFactory {
+ private static final ConflictsManager INSTANCE =
+ new ConflictsManagerImpl(ConflictsDaoFactory.getInstance().createInterface());
@Override
- public VendorSoftwareProductDao createInterface() {
+ public ConflictsManager createInterface() {
return INSTANCE;
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/impl/ConflictsManagerImpl.java b/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/impl/ConflictsManagerImpl.java
new file mode 100644
index 0000000..cb4c2dd
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/impl/ConflictsManagerImpl.java
@@ -0,0 +1,112 @@
+package org.openecomp.sdc.conflicts.impl;
+
+import org.openecomp.conflicts.ItemMergeHandler;
+import org.openecomp.conflicts.ItemMergeHandlerFactory;
+import org.openecomp.conflicts.dao.ConflictsDao;
+import org.openecomp.conflicts.types.Conflict;
+import org.openecomp.conflicts.types.ConflictResolution;
+import org.openecomp.conflicts.types.ItemVersionConflict;
+import org.openecomp.conflicts.types.Resolution;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdc.conflicts.ConflictsManager;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.Optional;
+
+public class ConflictsManagerImpl implements ConflictsManager {
+
+ private static final String ELEMENT_CONFLICT_NOT_EXIST_ERR_ID = "ELEMENT_CONFLICT_NOT_EXIST";
+ private static final String ELEMENT_CONFLICT_NOT_EXISTS_MSG =
+ "Item Id %s, version Id %s, element conflict with Id %s does not exists.";
+
+ private final ConflictsDao conflictsDao;
+
+ public ConflictsManagerImpl(ConflictsDao conflictsDao) {
+ this.conflictsDao = conflictsDao;
+ }
+
+ @Override
+ public boolean isConflicted(String itemId, Version version) {
+ Optional<ItemMergeHandler> itemMergeHandler =
+ ItemMergeHandlerFactory.getInstance().createInterface(itemId);
+
+ return conflictsDao.isConflicted(itemId, version) ||
+ (itemMergeHandler.isPresent() &&
+ itemMergeHandler.get().isConflicted(itemId, version));
+ }
+
+ @Override
+ public ItemVersionConflict getConflict(String itemId, Version version) {
+ ItemVersionConflict conflicts = conflictsDao.getConflict(itemId, version);
+
+ ItemMergeHandlerFactory.getInstance().createInterface(itemId)
+ .ifPresent(itemMergeHandler -> itemMergeHandler
+ .postListConflicts(itemId, version, conflicts));
+
+ return conflicts;
+ }
+
+ @Override
+ public void finalizeMerge(String itemId, Version version) {
+ ItemMergeHandlerFactory.getInstance().createInterface(itemId)
+ .ifPresent(mergeHandler -> mergeHandler.finalizeMerge(itemId, version));
+ }
+
+ @Override
+ public Conflict getConflict(String itemId, Version version, String conflictId) {
+ Optional<ItemMergeHandler> itemMergeHandler =
+ ItemMergeHandlerFactory.getInstance().createInterface(itemId);
+ if (itemMergeHandler.isPresent()) {
+ Optional<Conflict> conflict =
+ itemMergeHandler.get().getConflict(itemId, version, conflictId);
+ if (conflict.isPresent()) {
+ return conflict.get();
+ }
+ }
+
+ Conflict conflict = conflictsDao.getConflict(itemId, version, conflictId);
+
+ itemMergeHandler.ifPresent(mergeHandler ->
+ mergeHandler.postGetConflict(itemId, version, conflict));
+
+ if (conflict == null) {
+ throw getConflictNotExistException(itemId, version, conflictId);
+ }
+ return conflict;
+ }
+
+ @Override
+ public void resolveConflict(String itemId, Version version, String conflictId,
+ ConflictResolution resolution) {
+ if (Resolution.OTHER.equals(resolution.getResolution())) {
+ throw new UnsupportedOperationException(
+ "Resolution other than 'THEIRS' or 'YOURS' is not supported.");
+ }
+
+ Optional<ItemMergeHandler> itemMergeHandler =
+ ItemMergeHandlerFactory.getInstance().createInterface(itemId);
+ if (!itemMergeHandler.isPresent() ||
+ !itemMergeHandler.get()
+ .resolveConflict(itemId, version, conflictId, resolution)) {
+
+ getConflict(itemId, version, conflictId); // validate that the conflict exist
+ itemMergeHandler.ifPresent(mergeHandler ->
+ mergeHandler.preResolveConflict(itemId, version, conflictId, resolution));
+
+ conflictsDao.resolveConflict(itemId, version, conflictId, resolution);
+ }
+ }
+
+ private CoreException getConflictNotExistException(String itemId, Version version,
+ String conflictId) {
+ return new CoreException(new ErrorCode.ErrorCodeBuilder()
+ .withCategory(ErrorCategory.APPLICATION)
+ .withId(ELEMENT_CONFLICT_NOT_EXIST_ERR_ID)
+ .withMessage(
+ String.format(ELEMENT_CONFLICT_NOT_EXISTS_MSG, itemId, version.getId(), conflictId))
+ .build());
+ }
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/resources/factoryConfiguration.json b/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/resources/factoryConfiguration.json
new file mode 100644
index 0000000..58e57ab
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/resources/factoryConfiguration.json
@@ -0,0 +1,3 @@
+{
+ "org.openecomp.sdc.conflicts.ConflictsManagerFactory": "org.openecomp.sdc.conflicts.impl.ConflictsManagerFactoryImpl"
+}
\ No newline at end of file
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/pom.xml b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/pom.xml
index 0fd84b8..35777c2 100644
--- a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/pom.xml
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/pom.xml
@@ -35,11 +35,6 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>activity-log-rest-types</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
<groupId>org.openecomp.sdc.core</groupId>
<artifactId>openecomp-zusammen-core</artifactId>
<version>${project.version}</version>
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckManagerFactoryImpl.java
index 1da515f..e5d85a2 100644
--- a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckManagerFactoryImpl.java
@@ -19,7 +19,8 @@
*/
package org.openecomp.sdc.health.impl;
-import org.openecomp.sdc.health.*;
+import org.openecomp.sdc.health.HealthCheckManager;
+import org.openecomp.sdc.health.HealthCheckManagerFactory;
public class HealthCheckManagerFactoryImpl extends HealthCheckManagerFactory {
private static final HealthCheckManager INSTANCE ;
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckManagerImpl.java b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckManagerImpl.java
index 2ee1581..f96b3a3 100644
--- a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckManagerImpl.java
@@ -26,14 +26,14 @@
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.health.HealthCheckDao;
+import org.openecomp.sdc.health.HealthCheckDaoFactory;
import org.openecomp.sdc.health.HealthCheckManager;
import org.openecomp.sdc.health.data.HealthCheckStatus;
import org.openecomp.sdc.health.data.MonitoredModules;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
-import org.openecomp.sdc.health.HealthCheckDao;
-import org.openecomp.sdc.health.HealthCheckDaoFactory;
import java.util.ArrayList;
import java.util.Arrays;
diff --git a/openecomp-be/backend/openecomp-sdc-item-permissions-manager/pom.xml b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/pom.xml
new file mode 100644
index 0000000..3212205
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/pom.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>backend</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+
+ </parent>
+
+ <artifactId>openecomp-sdc-item-permissions-manager</artifactId>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-session-lib</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-facade-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-item-permissions-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-item-permissions-impl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-item-permissions-core</artifactId>
+ <version>${project.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-versioning-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-notification-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>RELEASE</version>
+ </dependency>
+</dependencies>
+
+</project>
\ No newline at end of file
diff --git a/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/ItemPermissionsManager.java b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/ItemPermissionsManager.java
new file mode 100644
index 0000000..74fc3d3
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/ItemPermissionsManager.java
@@ -0,0 +1,23 @@
+package org.openecomp.sdc.itempermissions;
+
+import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity;
+
+import java.util.Collection;
+import java.util.Set;
+
+/**
+ * Created by ayalaben on 6/18/2017.
+ */
+public interface ItemPermissionsManager {
+
+ Collection<ItemPermissionsEntity> listItemPermissions(String itemId);
+
+ void updateItemPermissions(String itemId, String permission, Set<String> addedUsersIds,
+ Set<String> removedUsersIds);
+
+ boolean isAllowed(String itemId,String userId,String action);
+
+ String getUserItemPermiission(String itemId, String userId);
+
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/ItemPermissionsManagerFactory.java b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/ItemPermissionsManagerFactory.java
new file mode 100644
index 0000000..b983314
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/ItemPermissionsManagerFactory.java
@@ -0,0 +1,15 @@
+package org.openecomp.sdc.itempermissions;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+/**
+ * Created by ayalaben on 6/18/2017.
+ */
+public abstract class ItemPermissionsManagerFactory extends
+ AbstractComponentFactory<ItemPermissionsManager> {
+
+ public static ItemPermissionsManagerFactory getInstance() {
+ return AbstractFactory.getInstance(ItemPermissionsManagerFactory.class);
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsManagerFactoryImpl.java
new file mode 100644
index 0000000..2255ad5
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsManagerFactoryImpl.java
@@ -0,0 +1,25 @@
+package org.openecomp.sdc.itempermissions.dao.impl;
+
+import org.openecomp.sdc.itempermissions.ItemPermissionsManager;
+import org.openecomp.sdc.itempermissions.ItemPermissionsManagerFactory;
+import org.openecomp.sdc.itempermissions.PermissionsServicesFactory;
+import org.openecomp.sdc.notification.factories.NotificationPropagationManagerFactory;
+import org.openecomp.sdc.notification.factories.SubscriptionServiceFactory;
+import org.openecomp.sdc.versioning.ItemManagerFactory;
+
+/**
+ * Created by ayalaben on 6/18/2017
+ */
+public class ItemPermissionsManagerFactoryImpl extends ItemPermissionsManagerFactory {
+
+ private static final ItemPermissionsManager INSTANCE =
+ new ItemPermissionsManagerImpl(PermissionsServicesFactory.getInstance().createInterface(),
+ ItemManagerFactory.getInstance().createInterface(),
+ NotificationPropagationManagerFactory.getInstance().createInterface(),
+ SubscriptionServiceFactory.getInstance().createInterface());
+
+ @Override
+ public ItemPermissionsManager createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsManagerImpl.java b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsManagerImpl.java
new file mode 100644
index 0000000..b9fcfcd
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsManagerImpl.java
@@ -0,0 +1,159 @@
+package org.openecomp.sdc.itempermissions.dao.impl;
+
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdc.common.errors.Messages;
+import org.openecomp.sdc.common.session.SessionContextProviderFactory;
+import org.openecomp.sdc.itempermissions.ItemPermissionsManager;
+import org.openecomp.sdc.itempermissions.PermissionsServices;
+import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+import org.openecomp.sdc.notification.dtos.Event;
+import org.openecomp.sdc.notification.services.NotificationPropagationManager;
+import org.openecomp.sdc.notification.services.SubscriptionService;
+import org.openecomp.sdc.versioning.ItemManager;
+import org.openecomp.sdc.versioning.types.Item;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.ITEM_ID_PROP;
+import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.ITEM_NAME_PROP;
+import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_CHANGED;
+import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_GRANTED;
+import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_ITEM;
+import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_USER;
+
+/**
+ * Created by ayalaben on 6/18/2017.
+ */
+public class ItemPermissionsManagerImpl implements ItemPermissionsManager {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ItemPermissionsManagerImpl.class);
+ private static final String CHANGE_PERMISSIONS = "Change_Item_Permissions";
+
+ private PermissionsServices permissionsServices;
+ private ItemManager itemManager;
+ private NotificationPropagationManager notifier;
+ private SubscriptionService subscriptionService;
+
+ public ItemPermissionsManagerImpl(PermissionsServices permissionsServices,
+ ItemManager itemManager,
+ NotificationPropagationManager notificationPropagationManager,
+ SubscriptionService subscriptionService) {
+ this.permissionsServices = permissionsServices;
+ this.itemManager = itemManager;
+ this.notifier = notificationPropagationManager;
+ this.subscriptionService = subscriptionService;
+ }
+
+ @Override
+ public Collection<ItemPermissionsEntity> listItemPermissions(String itemId) {
+
+ return permissionsServices.listItemPermissions(itemId);
+ }
+
+ @Override
+ public void updateItemPermissions(String itemId, String permission, Set<String> addedUsersIds,
+ Set<String> removedUsersIds) {
+
+ String currentUser =
+ SessionContextProviderFactory.getInstance().createInterface().get().getUser().getUserId();
+
+ if (!permissionsServices.isAllowed(itemId, currentUser, CHANGE_PERMISSIONS)) {
+ throw new CoreException(new ErrorCode.ErrorCodeBuilder()
+ .withMessage(Messages.PERMISSIONS_ERROR.getErrorMessage())
+ .withId(Messages.PERMISSIONS_ERROR.getErrorMessage())
+ .withCategory(ErrorCategory.SECURITY).build());
+ }
+
+ permissionsServices
+ .updateItemPermissions(itemId, permission, addedUsersIds, removedUsersIds);
+ sendNotifications(itemId, permission, addedUsersIds, removedUsersIds, currentUser);
+ }
+
+ private void sendNotifications(String itemId, String permission, Set<String> addedUsersIds,
+ Set<String> removedUsersIds, String userName) {
+
+ Item item = itemManager.get(itemId);
+ addedUsersIds.forEach(affectedUser -> {
+ notifyUser(userName, true, item.getName(), itemId, affectedUser, permission);
+ subscriptionService.subscribe(affectedUser, itemId);
+ });
+ removedUsersIds.forEach(affectedUser -> {
+ notifyUser(userName, false, item.getName(), itemId, affectedUser, permission);
+ subscriptionService.unsubscribe(affectedUser, itemId);
+ });
+
+ }
+
+ private void notifyUser(String userName, boolean granted, String itemName, String itemId,
+ String affectedUser, String permission) {
+ Map<String, Object> details = new HashMap<>();
+ details.put(PERMISSION_ITEM, permission);
+ details.put(ITEM_ID_PROP, itemId);
+ details.put(ITEM_NAME_PROP, itemName);
+ details.put(PERMISSION_GRANTED, granted);
+ details.put(PERMISSION_USER, userName);
+ PermissionEvent permissionEvent = new PermissionEvent(PERMISSION_CHANGED, affectedUser,
+ details, affectedUser);
+
+ try {
+ notifier.directNotification(permissionEvent, affectedUser);
+ } catch (Exception e) {
+ LOGGER.error("Failed to send notification on permission changed for user '" +
+ affectedUser + "'");
+ }
+
+ }
+
+ @Override
+ public boolean isAllowed(String itemId, String userId, String action) {
+ return permissionsServices.isAllowed(itemId, userId, action);
+ }
+
+ @Override
+ public String getUserItemPermiission(String itemId, String userId) {
+ return permissionsServices.getUserItemPermiission(itemId, userId);
+ }
+
+ private class PermissionEvent implements Event {
+
+ private String eventType;
+ private String originatorId;
+ private Map<String, Object> attributes;
+ private String entityId;
+
+ private PermissionEvent(String eventType, String originatorId,
+ Map<String, Object> attributes, String entityId) {
+ this.eventType = eventType;
+ this.originatorId = originatorId;
+ this.attributes = attributes;
+ this.entityId = entityId;
+ }
+
+ @Override
+ public String getEventType() {
+ return eventType;
+ }
+
+ @Override
+ public String getOriginatorId() {
+ return originatorId;
+ }
+
+ @Override
+ public Map<String, Object> getAttributes() {
+ return attributes;
+ }
+
+ @Override
+ public String getEntityId() {
+ return entityId;
+ }
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/resources/factoryConfiguration.json b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/resources/factoryConfiguration.json
new file mode 100644
index 0000000..a98f9c0
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/resources/factoryConfiguration.json
@@ -0,0 +1,3 @@
+{
+ "org.openecomp.sdc.itempermissions.ItemPermissionsManagerFactory": "org.openecomp.sdc.itempermissions.dao.impl.ItemPermissionsManagerFactoryImpl"
+}
\ No newline at end of file
diff --git a/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/test/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/test/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsManagerImplTest.java
new file mode 100644
index 0000000..e461824
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/test/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsManagerImplTest.java
@@ -0,0 +1,86 @@
+package org.openecomp.sdc.itempermissions.dao.impl;
+
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.session.SessionContextProviderFactory;
+import org.openecomp.sdc.itempermissions.PermissionsServices;
+import org.openecomp.sdc.notification.services.NotificationPropagationManager;
+import org.openecomp.sdc.notification.services.SubscriptionService;
+import org.openecomp.sdc.versioning.ItemManager;
+import org.openecomp.sdc.versioning.types.Item;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
+
+/**
+ * Created by ayalaben on 7/6/2017
+ */
+public class ItemPermissionsManagerImplTest {
+
+ private static final String ITEM1_ID = "1";
+ private static final String PERMISSION = "Contributor";
+ private static final String ACTION = "Change_Item_Permissions";
+ private static final String USER = "user";
+ private static final String AFFECTED_USER1 = "affected_user1";
+ private static final String AFFECTED_USER2 = "affected_user2";
+ private static final String AFFECTED_USER3 = "affected_user3";
+
+ @Mock
+ private PermissionsServices permissionsServicesMock;
+ @Mock
+ private ItemManager itemManagerMock;
+ @Mock
+ private SubscriptionService subscriptionServiceMock;
+ @Mock
+ private NotificationPropagationManager notifierMock;
+ @InjectMocks
+ private ItemPermissionsManagerImpl permissionsManager;
+
+ @BeforeMethod
+ public void setUp() throws Exception {
+ SessionContextProviderFactory.getInstance().createInterface().create(USER);
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test(expectedExceptions = CoreException.class, expectedExceptionsMessageRegExp = "Permissions " +
+ "Error. The user does not have permission to perform this action.")
+ public void testUpdateItemPermissionsWhenNotAllowed() {
+ doReturn(false).when(permissionsServicesMock).isAllowed(ITEM1_ID, USER, ACTION);
+
+ permissionsManager
+ .updateItemPermissions(ITEM1_ID, PERMISSION, Collections.singleton(AFFECTED_USER1),
+ new HashSet<>());
+ }
+
+ @Test
+ public void testUpdateItemPermissions() {
+ doReturn(true).when(permissionsServicesMock).isAllowed(ITEM1_ID, USER, ACTION);
+ Item item = new Item();
+ item.setName("Item 1 Name");
+ doReturn(item).when(itemManagerMock).get(ITEM1_ID);
+
+ Set<String> addedUsersIds =
+ Stream.of(AFFECTED_USER1, AFFECTED_USER2).collect(Collectors.toSet());
+ Set<String> removedUsersIds = Collections.singleton(AFFECTED_USER3);
+ permissionsManager
+ .updateItemPermissions(ITEM1_ID, PERMISSION, addedUsersIds, removedUsersIds);
+
+ verify(permissionsServicesMock)
+ .updateItemPermissions(ITEM1_ID, PERMISSION, addedUsersIds, removedUsersIds);
+ verify(subscriptionServiceMock).subscribe(AFFECTED_USER1, ITEM1_ID);
+ verify(subscriptionServiceMock).subscribe(AFFECTED_USER2, ITEM1_ID);
+ verify(subscriptionServiceMock).unsubscribe(AFFECTED_USER3, ITEM1_ID);
+
+ // TODO: 12/18/2017 verify notification
+ }
+}
\ No newline at end of file
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/resources/logback.xml b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/test/resources/logback.xml
similarity index 91%
rename from openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/resources/logback.xml
rename to openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/test/resources/logback.xml
index 9c9c06c..c1932e3 100644
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/resources/logback.xml
+++ b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/test/resources/logback.xml
@@ -9,7 +9,7 @@
</appender>
<root level="warn">
- <appender-ref ref="STDOUT"/>
+ <appender-ref ref="STDOUT" />
</root>
</configuration>
\ No newline at end of file
diff --git a/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/impl/UploadValidationManagerImpl.java b/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/impl/UploadValidationManagerImpl.java
index 1d1ce4f..924235d 100644
--- a/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/impl/UploadValidationManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/impl/UploadValidationManagerImpl.java
@@ -25,10 +25,10 @@
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.validation.api.ValidationManager;
-import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
diff --git a/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/util/ValidationManagerUtil.java b/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/util/ValidationManagerUtil.java
index 53b05eb..7a78f09 100644
--- a/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/util/ValidationManagerUtil.java
+++ b/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/util/ValidationManagerUtil.java
@@ -23,8 +23,8 @@
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.validation.api.ValidationManager;
-import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.core.validation.factory.ValidationManagerFactory;
+import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseManager.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseManager.java
index a76b9b8..9184afe 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseManager.java
@@ -28,8 +28,6 @@
import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity;
import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
-import org.openecomp.sdc.vendorlicense.errors.LimitErrorBuilder;
-import org.openecomp.sdc.vendorlicense.types.VersionedVendorLicenseModel;
import org.openecomp.sdc.versioning.dao.types.Version;
import java.util.Collection;
@@ -37,88 +35,71 @@
public interface VendorLicenseManager {
- void checkout(String vendorLicenseModelId, String user);
+ void validate(String vendorLicenseModelId, Version version);
- void undoCheckout(String vendorLicenseModelId, String user);
+ VendorLicenseModelEntity createVendorLicenseModel(VendorLicenseModelEntity licenseModel);
- void checkin(String vendorLicenseModelId, String user);
+ void updateVendorLicenseModel(VendorLicenseModelEntity licenseModel);
- void submit(String vendorLicenseModelId, String user);
+ VendorLicenseModelEntity getVendorLicenseModel(String vlmId, Version version);
- Collection<VersionedVendorLicenseModel> listVendorLicenseModels(String versionFilter,
- String user);
-
- VendorLicenseModelEntity createVendorLicenseModel(VendorLicenseModelEntity licenseModel,
- String user);
-
- void updateVendorLicenseModel(VendorLicenseModelEntity licenseModel, String user);
-
- VersionedVendorLicenseModel getVendorLicenseModel(String vlmId, Version version, String user);
-
- void deleteVendorLicenseModel(String vlmId, String user);
+ void deleteVendorLicenseModel(String vlmId, Version version);
- Collection<LicenseAgreementEntity> listLicenseAgreements(String vlmId, Version version,
- String user);
+ Collection<LicenseAgreementEntity> listLicenseAgreements(String vlmId, Version version);
- LicenseAgreementEntity createLicenseAgreement(LicenseAgreementEntity licenseAgreement,
- String user);
+ LicenseAgreementEntity createLicenseAgreement(LicenseAgreementEntity licenseAgreement);
void updateLicenseAgreement(LicenseAgreementEntity licenseAgreement,
- Set<String> addedFeatureGroupIds, Set<String> removedFeatureGroupIds,
- String user);
+ Set<String> addedFeatureGroupIds, Set<String> removedFeatureGroupIds);
LicenseAgreementModel getLicenseAgreementModel(String vlmId, Version version,
- String licenseAgreementId, String user);
+ String licenseAgreementId);
- void deleteLicenseAgreement(String vlmId, Version version, String licenseAgreementId, String user);
+ void deleteLicenseAgreement(String vlmId, Version version, String licenseAgreementId);
- Collection<FeatureGroupEntity> listFeatureGroups(String vlmId, Version version, String user);
+ Collection<FeatureGroupEntity> listFeatureGroups(String vlmId, Version version);
- FeatureGroupEntity createFeatureGroup(FeatureGroupEntity fg, String user);
+ FeatureGroupEntity createFeatureGroup(FeatureGroupEntity fg);
void updateFeatureGroup(FeatureGroupEntity featureGroup,
Set<String> addedLicenseKeyGroups, Set<String> removedLicenseKeyGroups,
- Set<String> addedEntitlementPools, Set<String> removedEntitlementPools,
- String user);
+ Set<String> addedEntitlementPools, Set<String> removedEntitlementPools);
- FeatureGroupModel getFeatureGroupModel(FeatureGroupEntity featureGroup, String user);
+ FeatureGroupModel getFeatureGroupModel(FeatureGroupEntity featureGroup);
- void deleteFeatureGroup(FeatureGroupEntity featureGroup, String user);
+ void deleteFeatureGroup(FeatureGroupEntity featureGroup);
- Collection<EntitlementPoolEntity> listEntitlementPools(String vlmId, Version version,
- String user);
+ Collection<EntitlementPoolEntity> listEntitlementPools(String vlmId, Version version);
- EntitlementPoolEntity createEntitlementPool(EntitlementPoolEntity entitlementPool, String user);
+ EntitlementPoolEntity createEntitlementPool(EntitlementPoolEntity entitlementPool);
- void updateEntitlementPool(EntitlementPoolEntity entitlementPool, String user);
+ void updateEntitlementPool(EntitlementPoolEntity entitlementPool);
- EntitlementPoolEntity getEntitlementPool(EntitlementPoolEntity entitlementPool, String user);
+ EntitlementPoolEntity getEntitlementPool(EntitlementPoolEntity entitlementPool);
- void deleteEntitlementPool(EntitlementPoolEntity entitlementPool, String user);
+ void deleteEntitlementPool(EntitlementPoolEntity entitlementPool);
- Collection<LicenseKeyGroupEntity> listLicenseKeyGroups(String vlmId, Version version,
- String user);
+ Collection<LicenseKeyGroupEntity> listLicenseKeyGroups(String vlmId, Version version);
- LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user);
+ LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup);
- void updateLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user);
+ void updateLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup);
- LicenseKeyGroupEntity getLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user);
+ LicenseKeyGroupEntity getLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup);
- void deleteLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user);
+ void deleteLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup);
- LimitEntity createLimit(LimitEntity limitEntity, String user);
+ LimitEntity createLimit(LimitEntity limitEntity);
- Collection<LimitEntity> listLimits(String vlmId, Version version, String epLkgId, String user);
+ Collection<LimitEntity> listLimits(String vlmId, Version version, String epLkgId);
- void deleteLimit(LimitEntity limitEntity, String user);
+ void deleteLimit(LimitEntity limitEntity);
- void updateLimit(LimitEntity limitEntity, String user);
+ void updateLimit(LimitEntity limitEntity);
- LimitEntity getLimit(LimitEntity entitlementPool, String user);
-
+ LimitEntity getLimit(LimitEntity entitlementPool);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerFactoryImpl.java
index 152ddd0..472473f 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerFactoryImpl.java
@@ -1,6 +1,5 @@
package org.openecomp.sdc.vendorlicense.impl;
-import org.openecomp.sdc.activityLog.ActivityLogManagerFactory;
import org.openecomp.sdc.vendorlicense.VendorLicenseManager;
import org.openecomp.sdc.vendorlicense.VendorLicenseManagerFactory;
import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDaoFactory;
@@ -10,22 +9,19 @@
import org.openecomp.sdc.vendorlicense.dao.LimitDaoFactory;
import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDaoFactory;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory;
-import org.openecomp.sdc.versioning.VersioningManagerFactory;
/**
* Created by ayalaben on 8/3/2017
*/
-public class VendorLicenseManagerFactoryImpl extends VendorLicenseManagerFactory {
+public class VendorLicenseManagerFactoryImpl extends VendorLicenseManagerFactory {
private static final VendorLicenseManager INSTANCE =
new VendorLicenseManagerImpl(
- VersioningManagerFactory.getInstance().createInterface(),
VendorLicenseFacadeFactory.getInstance().createInterface(),
VendorLicenseModelDaoFactory.getInstance().createInterface(),
LicenseAgreementDaoFactory.getInstance().createInterface(),
FeatureGroupDaoFactory.getInstance().createInterface(),
EntitlementPoolDaoFactory.getInstance().createInterface(),
LicenseKeyGroupDaoFactory.getInstance().createInterface(),
- ActivityLogManagerFactory.getInstance().createInterface(),
LimitDaoFactory.getInstance().createInterface());
@Override
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java
index e07a13c..2489b5a 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java
@@ -20,16 +20,10 @@
package org.openecomp.sdc.vendorlicense.impl;
-import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE;
-
import org.openecomp.core.util.UniqueValueUtil;
-import org.openecomp.sdc.activityLog.ActivityLogManager;
-import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
import org.openecomp.sdc.logging.types.LoggerConstants;
@@ -57,26 +51,16 @@
import org.openecomp.sdc.vendorlicense.errors.InvalidDateErrorBuilder;
import org.openecomp.sdc.vendorlicense.errors.LimitErrorBuilder;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
-import org.openecomp.sdc.vendorlicense.types.VersionedVendorLicenseModel;
-import org.openecomp.sdc.versioning.VersioningManager;
import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.dao.types.VersionStatus;
-import org.openecomp.sdc.versioning.types.VersionInfo;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
-import org.openecomp.sdcrests.activitylog.types.ActivityType;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.List;
-import java.util.Map;
import java.util.Optional;
import java.util.Set;
public class VendorLicenseManagerImpl implements VendorLicenseManager {
- private VersioningManager versioningManager;
private VendorLicenseFacade vendorLicenseFacade;
private VendorLicenseModelDao vendorLicenseModelDao;
private LicenseAgreementDao licenseAgreementDao;
@@ -84,278 +68,134 @@
private EntitlementPoolDao entitlementPoolDao;
private LicenseKeyGroupDao licenseKeyGroupDao;
private LimitDao limitDao;
- private ActivityLogManager activityLogManager;
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
- private static final Logger logger =
- LoggerFactory.getLogger(VendorLicenseManagerImpl.class);
- public VendorLicenseManagerImpl(VersioningManager versioningManager,
- VendorLicenseFacade vendorLicenseFacade,
+ public VendorLicenseManagerImpl(VendorLicenseFacade vendorLicenseFacade,
VendorLicenseModelDao vendorLicenseModelDao,
LicenseAgreementDao licenseAgreementDao,
FeatureGroupDao featureGroupDao,
EntitlementPoolDao entitlementPoolDao,
LicenseKeyGroupDao licenseKeyGroupDao,
- ActivityLogManager activityLogManager,
LimitDao limitDao) {
- this.versioningManager = versioningManager;
this.vendorLicenseFacade = vendorLicenseFacade;
this.vendorLicenseModelDao = vendorLicenseModelDao;
this.licenseAgreementDao = licenseAgreementDao;
this.featureGroupDao = featureGroupDao;
this.entitlementPoolDao = entitlementPoolDao;
this.licenseKeyGroupDao = licenseKeyGroupDao;
- this.activityLogManager = activityLogManager;
this.limitDao = limitDao;
}
- private static void sortVlmListByModificationTimeDescOrder(
- List<VersionedVendorLicenseModel> vendorLicenseModels) {
- vendorLicenseModels.sort((o1, o2) -> o2.getVendorLicenseModel().getWritetimeMicroSeconds()
- .compareTo(o1.getVendorLicenseModel().getWritetimeMicroSeconds()));
- }
-
@Override
- public void checkout(String vendorLicenseModelId, String user) {
-
+ public void validate(String vendorLicenseModelId, Version version) {
mdcDataDebugMessage.debugEntryMessage("VLM id", vendorLicenseModelId);
- Version newVersion = versioningManager
- .checkout(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vendorLicenseModelId, user);
-
- ActivityLogEntity activityLogEntity = new ActivityLogEntity(vendorLicenseModelId, String.valueOf(newVersion.getMajor()+1),
- ActivityType.CHECKOUT.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
-
- newVersion.setStatus(VersionStatus.Locked);
- vendorLicenseFacade.updateVlmLastModificationTime(vendorLicenseModelId, newVersion);
+ vendorLicenseFacade.validate(vendorLicenseModelId, version);
mdcDataDebugMessage.debugExitMessage("VLM id", vendorLicenseModelId);
}
@Override
- public void undoCheckout(String vendorLicenseModelId, String user) {
-
- mdcDataDebugMessage.debugEntryMessage("VLM id", vendorLicenseModelId);
-
- Version newVersion = versioningManager
- .undoCheckout(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vendorLicenseModelId, user);
-
- ActivityLogEntity activityLogEntity =
- new ActivityLogEntity(vendorLicenseModelId, String.valueOf(newVersion.getMajor() + 1),
- ActivityType.UNDO_CHECKOUT.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
-
- vendorLicenseFacade.updateVlmLastModificationTime(vendorLicenseModelId, newVersion);
-
- mdcDataDebugMessage.debugExitMessage("VLM id", vendorLicenseModelId);
- }
-
- @Override
- public void checkin(String vendorLicenseModelId, String user) {
-
- mdcDataDebugMessage.debugEntryMessage("VLM id", vendorLicenseModelId);
-
- Version newVersion = vendorLicenseFacade.checkin(vendorLicenseModelId, user);
-
- ActivityLogEntity activityLogEntity = new ActivityLogEntity(vendorLicenseModelId,
- String.valueOf(newVersion.getMajor()+1), ActivityType.CHECKIN.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
-
- mdcDataDebugMessage.debugExitMessage("VLM id", vendorLicenseModelId);
- }
-
- @Override
- public void submit(String vendorLicenseModelId, String user) {
-
- mdcDataDebugMessage.debugEntryMessage("VLM id", vendorLicenseModelId);
-
- Version newVersion = vendorLicenseFacade.submit(vendorLicenseModelId, user);
-
- ActivityLogEntity activityLogEntity = new ActivityLogEntity(vendorLicenseModelId, String.valueOf(newVersion.getMajor()),
- ActivityType.SUBMIT.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
-
- mdcDataDebugMessage.debugExitMessage("VLM id", vendorLicenseModelId);
- }
-
- @Override
- public Collection<VersionedVendorLicenseModel> listVendorLicenseModels(String versionFilter,
- String user) {
+ public VendorLicenseModelEntity createVendorLicenseModel(
+ VendorLicenseModelEntity vendorLicenseModelEntity) {
mdcDataDebugMessage.debugEntryMessage(null);
- Map<String, VersionInfo> idToVersionsInfo = versioningManager
- .listEntitiesVersionInfo(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, user,
- VersionableEntityAction.Read);
-
- List<VersionedVendorLicenseModel> vendorLicenseModels = new ArrayList<>();
- for (Map.Entry<String, VersionInfo> entry : idToVersionsInfo.entrySet()) {
- VersionInfo versionInfo = entry.getValue();
- if (versionFilter != null && versionFilter.equals(VersionStatus.Final.name())) {
- if (versionInfo.getLatestFinalVersion() == null) {
- continue;
- }
- versionInfo.setActiveVersion(versionInfo.getLatestFinalVersion());
- versionInfo.setStatus(VersionStatus.Final);
- versionInfo.setLockingUser(null);
- }
-
- Version version = versionInfo.getActiveVersion();
- if (user.equals(versionInfo.getLockingUser())) {
- version.setStatus(VersionStatus.Locked);
- }
-
- try {
- VendorLicenseModelEntity vlm =
- vendorLicenseModelDao.get(new VendorLicenseModelEntity(entry.getKey(), version));
- if (vlm != null) {
- VersionedVendorLicenseModel versionedVlm = new VersionedVendorLicenseModel();
- versionedVlm.setVendorLicenseModel(vlm);
- versionedVlm.setVersionInfo(versionInfo);
- vendorLicenseModels.add(versionedVlm);
- }
- }catch(RuntimeException rte){
- logger.error("Error trying to retrieve vlm["+entry.getKey()+"] version["+version.toString
- ()+"] " +
- "message:"+rte
- .getMessage());
- }
- }
-
- sortVlmListByModificationTimeDescOrder(vendorLicenseModels);
-
+ vendorLicenseModelDao.create(vendorLicenseModelEntity);
mdcDataDebugMessage.debugExitMessage(null);
- return vendorLicenseModels;
+
+ return vendorLicenseModelEntity;
}
@Override
- public VendorLicenseModelEntity createVendorLicenseModel(VendorLicenseModelEntity vendorLicenseModelEntity, String user) {
-
- VendorLicenseModelEntity vendorLicenseModelCreated = vendorLicenseFacade.createVendorLicenseModel(vendorLicenseModelEntity, user);
-
- ActivityLogEntity activityLogEntity = new ActivityLogEntity(vendorLicenseModelCreated.getId(),
- String.valueOf(vendorLicenseModelCreated.getVersion().getMajor()+1),
- ActivityType.CREATE_NEW.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
-
- return vendorLicenseModelCreated;
- }
-
- @Override
- public void updateVendorLicenseModel(VendorLicenseModelEntity vendorLicenseModelEntity,
- String user) {
+ public void updateVendorLicenseModel(VendorLicenseModelEntity vendorLicenseModelEntity) {
mdcDataDebugMessage.debugEntryMessage("VLM id", vendorLicenseModelEntity.getId());
- Version version = resloveVersion(vendorLicenseModelEntity.getId(),null,
- getVersionInfo(vendorLicenseModelEntity.getId(), VersionableEntityAction.Write, user),
- user);
- vendorLicenseModelEntity.setVersion(version);
-
String existingVendorName = vendorLicenseModelDao.get(vendorLicenseModelEntity).getVendorName();
updateUniqueName(VendorLicenseConstants.UniqueValues.VENDOR_NAME, existingVendorName,
- vendorLicenseModelEntity.getVendorName());
+ vendorLicenseModelEntity.getVendorName());
vendorLicenseModelDao.update(vendorLicenseModelEntity);
- vendorLicenseFacade
- .updateVlmLastModificationTime(vendorLicenseModelEntity.getId(), version);
-
mdcDataDebugMessage.debugExitMessage("VLM id", vendorLicenseModelEntity.getId());
}
@Override
- public VersionedVendorLicenseModel getVendorLicenseModel(String vlmId, Version version,
- String user) {
- return vendorLicenseFacade.getVendorLicenseModel(vlmId, version, user);
+ public VendorLicenseModelEntity getVendorLicenseModel(String vlmId, Version version) {
+ return vendorLicenseFacade.getVendorLicenseModel(vlmId, version);
}
@Override
- public void deleteVendorLicenseModel(String vlmId, String user) {
+ public void deleteVendorLicenseModel(String vlmId, Version version) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.DELETE_ENTITY, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.UNSUPPORTED_OPERATION);
+ LoggerTragetServiceName.DELETE_ENTITY, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.UNSUPPORTED_OPERATION);
throw new UnsupportedOperationException(VendorLicenseConstants.UNSUPPORTED_OPERATION_ERROR);
}
@Override
- public Collection<LicenseAgreementEntity> listLicenseAgreements(String vlmId, Version version,
- String user) {
+ public Collection<LicenseAgreementEntity> listLicenseAgreements(String vlmId, Version version) {
mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId);
mdcDataDebugMessage.debugExitMessage("VLM id", vlmId);
- LicenseAgreementEntity licenseAgreementEntity = createLicenseAgreementForList(vlmId, version,
- user);
-// return licenseAgreementDao.list(new LicenseAgreementEntity(vlmId, VersioningUtil
-// .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Read, user), user),
-// null));
- return licenseAgreementDao.list(licenseAgreementEntity);
+ return licenseAgreementDao.list(new LicenseAgreementEntity(vlmId, version, null));
}
@Override
- public LicenseAgreementEntity createLicenseAgreement(LicenseAgreementEntity licenseAgreement,
- String user) {
+ public LicenseAgreementEntity createLicenseAgreement(LicenseAgreementEntity licenseAgreement) {
mdcDataDebugMessage
- .debugEntryMessage("VLM id", licenseAgreement.getVendorLicenseModelId());
+ .debugEntryMessage("VLM id", licenseAgreement.getVendorLicenseModelId());
mdcDataDebugMessage
- .debugExitMessage("VLM id", licenseAgreement.getVendorLicenseModelId());
- return vendorLicenseFacade.createLicenseAgreement(licenseAgreement, user);
+ .debugExitMessage("VLM id", licenseAgreement.getVendorLicenseModelId());
+ return vendorLicenseFacade.createLicenseAgreement(licenseAgreement);
}
@Override
public void updateLicenseAgreement(LicenseAgreementEntity licenseAgreement,
Set<String> addedFeatureGroupIds,
- Set<String> removedFeatureGroupIds, String user) {
+ Set<String> removedFeatureGroupIds) {
mdcDataDebugMessage.debugEntryMessage("VLM id, LA id", licenseAgreement
- .getVendorLicenseModelId(), licenseAgreement.getId());
+ .getVendorLicenseModelId(), licenseAgreement.getId());
- Version version = VersioningUtil.resolveVersion(licenseAgreement.getVersion(),
- getVersionInfo(licenseAgreement.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user), user);
- licenseAgreement.setVersion(version);
LicenseAgreementEntity retrieved = licenseAgreementDao.get(licenseAgreement);
VersioningUtil
- .validateEntityExistence(retrieved, licenseAgreement, VendorLicenseModelEntity.ENTITY_TYPE);
+ .validateEntityExistence(retrieved, licenseAgreement, VendorLicenseModelEntity.ENTITY_TYPE);
VersioningUtil.validateContainedEntitiesExistence(new FeatureGroupEntity().getEntityType(),
- removedFeatureGroupIds, retrieved, retrieved.getFeatureGroupIds());
+ removedFeatureGroupIds, retrieved, retrieved.getFeatureGroupIds());
VersioningUtil.validateEntitiesExistence(addedFeatureGroupIds,
- new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(), version, null),
- featureGroupDao, VendorLicenseModelEntity.ENTITY_TYPE);
+ new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(),
+ licenseAgreement.getVersion(),
+ null),
+ featureGroupDao, VendorLicenseModelEntity.ENTITY_TYPE);
updateUniqueName(VendorLicenseConstants.UniqueValues.LICENSE_AGREEMENT_NAME,
- retrieved.getName(), licenseAgreement.getName(), licenseAgreement.getVendorLicenseModelId(),
- licenseAgreement.getVersion().toString());
+ retrieved.getName(), licenseAgreement.getName(), licenseAgreement.getVendorLicenseModelId(),
+ licenseAgreement.getVersion().getId());
licenseAgreementDao.updateColumnsAndDeltaFeatureGroupIds(licenseAgreement, addedFeatureGroupIds,
- removedFeatureGroupIds);
+ removedFeatureGroupIds);
addFeatureGroupsToLicenseAgreementRef(addedFeatureGroupIds, licenseAgreement);
removeFeatureGroupsToLicenseAgreementRef(removedFeatureGroupIds, licenseAgreement);
- vendorLicenseFacade
- .updateVlmLastModificationTime(licenseAgreement.getVendorLicenseModelId(), version);
-
mdcDataDebugMessage.debugExitMessage("VLM id, LA id", licenseAgreement
- .getVendorLicenseModelId(), licenseAgreement.getId());
+ .getVendorLicenseModelId(), licenseAgreement.getId());
}
@Override
public LicenseAgreementModel getLicenseAgreementModel(String vlmId, Version version,
- String licenseAgreementId, String user) {
+ String licenseAgreementId) {
mdcDataDebugMessage.debugEntryMessage("VLM id, LA id", vlmId, licenseAgreementId);
mdcDataDebugMessage.debugExitMessage("VLM id, LA id", vlmId, licenseAgreementId);
- return vendorLicenseFacade.getLicenseAgreementModel(vlmId, version, licenseAgreementId, user);
+ return vendorLicenseFacade.getLicenseAgreementModel(vlmId, version, licenseAgreementId);
}
@Override
- public void deleteLicenseAgreement(String vlmId, Version version, String licenseAgreementId,
- String user) {
+ public void deleteLicenseAgreement(String vlmId, Version version, String licenseAgreementId) {
mdcDataDebugMessage.debugEntryMessage("VLM id, LA id", vlmId, licenseAgreementId);
- version = VersioningUtil
- .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Write, user), user);
LicenseAgreementEntity input =
- new LicenseAgreementEntity(vlmId, version, licenseAgreementId);
+ new LicenseAgreementEntity(vlmId, version, licenseAgreementId);
LicenseAgreementEntity retrieved = licenseAgreementDao.get(input);
VersioningUtil.validateEntityExistence(retrieved, input, VendorLicenseModelEntity.ENTITY_TYPE);
@@ -364,29 +204,25 @@
licenseAgreementDao.delete(retrieved);
deleteUniqueName(VendorLicenseConstants.UniqueValues.LICENSE_AGREEMENT_NAME,
- retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
- retrieved.getName());
-
- vendorLicenseFacade
- .updateVlmLastModificationTime(input.getVendorLicenseModelId(), input.getVersion());
+ retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
+ retrieved.getName());
mdcDataDebugMessage.debugExitMessage("VLM id, LA id", vlmId, licenseAgreementId);
}
@Override
- public Collection<FeatureGroupEntity> listFeatureGroups(String vlmId, Version version,
- String user) {
+ public Collection<FeatureGroupEntity> listFeatureGroups(String vlmId, Version version) {
mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId);
mdcDataDebugMessage.debugExitMessage("VLM id", vlmId);
- return vendorLicenseFacade.listFeatureGroups(vlmId, version, user);
+ return vendorLicenseFacade.listFeatureGroups(vlmId, version);
}
@Override
- public FeatureGroupEntity createFeatureGroup(FeatureGroupEntity featureGroup, String user) {
+ public FeatureGroupEntity createFeatureGroup(FeatureGroupEntity featureGroup) {
mdcDataDebugMessage
- .debugEntryMessage("VLM id", featureGroup.getVendorLicenseModelId());
+ .debugEntryMessage("VLM id", featureGroup.getVendorLicenseModelId());
mdcDataDebugMessage.debugExitMessage("VLM id", featureGroup.getId());
- return vendorLicenseFacade.createFeatureGroup(featureGroup, user);
+ return vendorLicenseFacade.createFeatureGroup(featureGroup);
}
@Override
@@ -394,35 +230,31 @@
Set<String> addedLicenseKeyGroups,
Set<String> removedLicenseKeyGroups,
Set<String> addedEntitlementPools,
- Set<String> removedEntitlementPools,
- String user) {
+ Set<String> removedEntitlementPools) {
mdcDataDebugMessage.debugEntryMessage("VLM id, FG id", featureGroup
- .getVendorLicenseModelId(), featureGroup.getId());
-
- Version version = VersioningUtil.resolveVersion(featureGroup.getVersion(),
- getVersionInfo(featureGroup.getVendorLicenseModelId(), VersionableEntityAction.Write, user),
- user);
- featureGroup.setVersion(version);
+ .getVendorLicenseModelId(), featureGroup.getId());
FeatureGroupEntity retrieved = featureGroupDao.get(featureGroup);
VersioningUtil
- .validateEntityExistence(retrieved, featureGroup, VendorLicenseModelEntity.ENTITY_TYPE);
+ .validateEntityExistence(retrieved, featureGroup, VendorLicenseModelEntity.ENTITY_TYPE);
VersioningUtil.validateContainedEntitiesExistence(new LicenseKeyGroupEntity().getEntityType(),
- removedLicenseKeyGroups, retrieved, retrieved.getLicenseKeyGroupIds());
+ removedLicenseKeyGroups, retrieved, retrieved.getLicenseKeyGroupIds());
VersioningUtil.validateContainedEntitiesExistence(new EntitlementPoolEntity().getEntityType(),
- removedEntitlementPools, retrieved, retrieved.getEntitlementPoolIds());
+ removedEntitlementPools, retrieved, retrieved.getEntitlementPoolIds());
VersioningUtil.validateEntitiesExistence(addedLicenseKeyGroups,
- new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(), version, null),
- licenseKeyGroupDao, VendorLicenseModelEntity.ENTITY_TYPE);
+ new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(), featureGroup.getVersion(),
+ null),
+ licenseKeyGroupDao, VendorLicenseModelEntity.ENTITY_TYPE);
VersioningUtil.validateEntitiesExistence(addedEntitlementPools,
- new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(), version, null),
- entitlementPoolDao, VendorLicenseModelEntity.ENTITY_TYPE);
+ new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(), featureGroup.getVersion(),
+ null),
+ entitlementPoolDao, VendorLicenseModelEntity.ENTITY_TYPE);
updateUniqueName(VendorLicenseConstants.UniqueValues.FEATURE_GROUP_NAME,
- retrieved.getName(), featureGroup.getName(), featureGroup.getVendorLicenseModelId(),
- featureGroup.getVersion().toString());
+ retrieved.getName(), featureGroup.getName(), featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion().getId());
addLicenseKeyGroupsToFeatureGroupsRef(addedLicenseKeyGroups, featureGroup);
removeLicenseKeyGroupsToFeatureGroupsRef(removedLicenseKeyGroups, featureGroup);
@@ -430,413 +262,364 @@
removeEntitlementPoolsToFeatureGroupsRef(removedEntitlementPools, featureGroup);
featureGroupDao.updateFeatureGroup(featureGroup, addedEntitlementPools, removedEntitlementPools,
- addedLicenseKeyGroups, removedLicenseKeyGroups);
-
- vendorLicenseFacade
- .updateVlmLastModificationTime(featureGroup.getVendorLicenseModelId(), version);
+ addedLicenseKeyGroups, removedLicenseKeyGroups);
mdcDataDebugMessage.debugExitMessage("VLM id, FG id", featureGroup
- .getVendorLicenseModelId(), featureGroup.getId());
+ .getVendorLicenseModelId(), featureGroup.getId());
}
@Override
- public FeatureGroupModel getFeatureGroupModel(FeatureGroupEntity featureGroup, String user) {
+ public FeatureGroupModel getFeatureGroupModel(FeatureGroupEntity featureGroup) {
mdcDataDebugMessage.debugEntryMessage("VLM id, FG id",
- featureGroup.getVendorLicenseModelId(), featureGroup.getId());
+ featureGroup.getVendorLicenseModelId(), featureGroup.getId());
mdcDataDebugMessage.debugExitMessage("VLM id, FG id",
- featureGroup.getVendorLicenseModelId(), featureGroup.getId());
- return vendorLicenseFacade.getFeatureGroupModel(featureGroup, user);
+ featureGroup.getVendorLicenseModelId(), featureGroup.getId());
+ return vendorLicenseFacade.getFeatureGroupModel(featureGroup);
}
@Override
- public void deleteFeatureGroup(FeatureGroupEntity featureGroup, String user) {
+ public void deleteFeatureGroup(FeatureGroupEntity featureGroup) {
mdcDataDebugMessage.debugEntryMessage("VLM id, FG id",
- featureGroup.getVendorLicenseModelId(), featureGroup.getId());
+ featureGroup.getVendorLicenseModelId(), featureGroup.getId());
- Version version = VersioningUtil.resolveVersion(featureGroup.getVersion(),
- getVersionInfo(featureGroup.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user), user);
- featureGroup.setVersion(version);
FeatureGroupEntity retrieved = featureGroupDao.get(featureGroup);
VersioningUtil
- .validateEntityExistence(retrieved, featureGroup, VendorLicenseModelEntity.ENTITY_TYPE);
+ .validateEntityExistence(retrieved, featureGroup, VendorLicenseModelEntity.ENTITY_TYPE);
removeLicenseKeyGroupsToFeatureGroupsRef(retrieved.getLicenseKeyGroupIds(), featureGroup);
removeEntitlementPoolsToFeatureGroupsRef(retrieved.getEntitlementPoolIds(), featureGroup);
for (String licenceAgreementId : retrieved.getReferencingLicenseAgreements()) {
licenseAgreementDao.removeFeatureGroup(
- new LicenseAgreementEntity(featureGroup.getVendorLicenseModelId(), version,
- licenceAgreementId), featureGroup.getId());
+ new LicenseAgreementEntity(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion(),
+ licenceAgreementId), featureGroup.getId());
}
featureGroupDao.delete(featureGroup);
deleteUniqueName(VendorLicenseConstants.UniqueValues.FEATURE_GROUP_NAME,
- retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
- retrieved.getName());
-
- vendorLicenseFacade.updateVlmLastModificationTime(featureGroup.getVendorLicenseModelId(),
- featureGroup.getVersion());
+ retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
+ retrieved.getName());
mdcDataDebugMessage
- .debugExitMessage("VLM id, FG id",
- featureGroup.getVendorLicenseModelId(), featureGroup.getId());
+ .debugExitMessage("VLM id, FG id",
+ featureGroup.getVendorLicenseModelId(), featureGroup.getId());
}
@Override
- public Collection<EntitlementPoolEntity> listEntitlementPools(String vlmId, Version version,
- String user) {
+ public Collection<EntitlementPoolEntity> listEntitlementPools(String vlmId, Version version) {
mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId);
mdcDataDebugMessage.debugExitMessage("VLM id", vlmId);
- return vendorLicenseFacade.listEntitlementPools(vlmId, version, user);
+ return vendorLicenseFacade.listEntitlementPools(vlmId, version);
}
@Override
- public EntitlementPoolEntity createEntitlementPool(EntitlementPoolEntity entitlementPool,
- String user) {
+ public EntitlementPoolEntity createEntitlementPool(EntitlementPoolEntity entitlementPool) {
mdcDataDebugMessage
- .debugEntryMessage("VLM id", entitlementPool.getVendorLicenseModelId());
+ .debugEntryMessage("VLM id", entitlementPool.getVendorLicenseModelId());
mdcDataDebugMessage
- .debugExitMessage("VLM id", entitlementPool.getVendorLicenseModelId());
+ .debugExitMessage("VLM id", entitlementPool.getVendorLicenseModelId());
entitlementPool.setStartDate(entitlementPool.getStartDate() != null ? (entitlementPool
- .getStartDate().trim().length() != 0 ? entitlementPool.getStartDate()+"T00:00:00Z"
- : null) : null);
+ .getStartDate().trim().length() != 0 ? entitlementPool.getStartDate() + "T00:00:00Z"
+ : null) : null);
entitlementPool.setExpiryDate(entitlementPool.getExpiryDate() != null ? (entitlementPool
- .getExpiryDate().trim().length() != 0 ? entitlementPool.getExpiryDate()+"T23:59:59Z"
- : null) : null);
+ .getExpiryDate().trim().length() != 0 ? entitlementPool.getExpiryDate() + "T23:59:59Z"
+ : null) : null);
validateCreateDate(entitlementPool.getStartDate(), entitlementPool.getExpiryDate(),
- entitlementPool.getVendorLicenseModelId());
- return vendorLicenseFacade.createEntitlementPool(entitlementPool, user);
+ entitlementPool.getVendorLicenseModelId());
+ return vendorLicenseFacade.createEntitlementPool(entitlementPool);
}
- private void validateCreateDate(String startDate, String expiryDate, String vendorLicenseModelId){
+ private void validateCreateDate(String startDate, String expiryDate,
+ String vendorLicenseModelId) {
mdcDataDebugMessage.debugEntryMessage("Start date and end date", startDate
- +" "+expiryDate);
+ + " " + expiryDate);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy'T'HH:mm:ss'Z'");
- if(startDate != null && expiryDate != null) {
+ if (startDate != null && expiryDate != null) {
if (LocalDate.parse(startDate, formatter).atStartOfDay().isBefore
- (LocalDate.now().atStartOfDay()) || LocalDate.parse(expiryDate, formatter).atStartOfDay()
- .isEqual(LocalDate.parse(startDate, formatter).atStartOfDay()) || LocalDate
- .parse(expiryDate, formatter).isBefore(LocalDate.parse(startDate, formatter))) {
+ (LocalDate.now().atStartOfDay()) || LocalDate.parse(expiryDate, formatter).atStartOfDay()
+ .isEqual(LocalDate.parse(startDate, formatter).atStartOfDay()) || LocalDate
+ .parse(expiryDate, formatter).isBefore(LocalDate.parse(startDate, formatter))) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.VALIDATE_DATE_RANGE,ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_VALUE);
+ LoggerTragetServiceName.VALIDATE_DATE_RANGE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_VALUE);
throw new CoreException(
- new InvalidDateErrorBuilder(vendorLicenseModelId)
- .build());
+ new InvalidDateErrorBuilder(vendorLicenseModelId)
+ .build());
}
}
- if(startDate != null && expiryDate == null) {
+ if (startDate != null && expiryDate == null) {
if (LocalDate.parse(startDate, formatter).atStartOfDay().isBefore
- (LocalDate.now().atStartOfDay())) {
+ (LocalDate.now().atStartOfDay())) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.VALIDATE_DATE_RANGE,ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_VALUE);
+ LoggerTragetServiceName.VALIDATE_DATE_RANGE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_VALUE);
throw new CoreException(
- new InvalidDateErrorBuilder(vendorLicenseModelId)
- .build());
+ new InvalidDateErrorBuilder(vendorLicenseModelId)
+ .build());
}
}
- if(startDate == null && expiryDate != null) {
+ if (startDate == null && expiryDate != null) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.VALIDATE_DATE_RANGE,ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_VALUE);
+ LoggerTragetServiceName.VALIDATE_DATE_RANGE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_VALUE);
throw new CoreException(
- new InvalidDateErrorBuilder(vendorLicenseModelId)
- .build());
+ new InvalidDateErrorBuilder(vendorLicenseModelId)
+ .build());
}
- mdcDataDebugMessage.debugExitMessage(null,null);
+ mdcDataDebugMessage.debugExitMessage(null);
}
- private void validateUpdateDate(String startDate, String expiryDate, String vendorLicenseModelId){
+ private void validateUpdateDate(String startDate, String expiryDate,
+ String vendorLicenseModelId) {
mdcDataDebugMessage.debugEntryMessage("Start date and end date", startDate
- +" "+ expiryDate);
+ + " " + expiryDate);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy'T'HH:mm:ss'Z'");
- if(startDate != null && expiryDate != null) {
+ if (startDate != null && expiryDate != null) {
if (LocalDate.parse(expiryDate, formatter).atStartOfDay()
- .isEqual(LocalDate.parse(startDate, formatter).atStartOfDay()) ||
- LocalDate.parse(expiryDate, formatter).isBefore(LocalDate.parse(startDate, formatter))) {
+ .isEqual(LocalDate.parse(startDate, formatter).atStartOfDay()) ||
+ LocalDate.parse(expiryDate, formatter).isBefore(LocalDate.parse(startDate, formatter))) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.VALIDATE_DATE_RANGE,ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_VALUE);
+ LoggerTragetServiceName.VALIDATE_DATE_RANGE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_VALUE);
throw new CoreException(
- new InvalidDateErrorBuilder(vendorLicenseModelId)
- .build());
+ new InvalidDateErrorBuilder(vendorLicenseModelId)
+ .build());
}
}
- if(startDate == null && expiryDate != null) {
+ if (startDate == null && expiryDate != null) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.VALIDATE_DATE_RANGE,ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_VALUE);
+ LoggerTragetServiceName.VALIDATE_DATE_RANGE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_VALUE);
throw new CoreException(
- new InvalidDateErrorBuilder(vendorLicenseModelId)
- .build());
+ new InvalidDateErrorBuilder(vendorLicenseModelId)
+ .build());
}
- mdcDataDebugMessage.debugExitMessage(null,null);
+ mdcDataDebugMessage.debugExitMessage(null);
}
@Override
- public void updateEntitlementPool(EntitlementPoolEntity entitlementPool, String user) {
+ public void updateEntitlementPool(EntitlementPoolEntity entitlementPool) {
mdcDataDebugMessage.debugEntryMessage("VLM id, EP id", entitlementPool
- .getVendorLicenseModelId(), entitlementPool.getId());
+ .getVendorLicenseModelId(), entitlementPool.getId());
entitlementPool.setStartDate(entitlementPool.getStartDate() != null ? (entitlementPool
- .getStartDate().trim().length() != 0 ? entitlementPool.getStartDate()+"T00:00:00Z"
- : null) : null);
+ .getStartDate().trim().length() != 0 ? entitlementPool.getStartDate() + "T00:00:00Z"
+ : null) : null);
entitlementPool.setExpiryDate(entitlementPool.getExpiryDate() != null ? (entitlementPool
- .getExpiryDate().trim().length() != 0 ? entitlementPool.getExpiryDate()+"T23:59:59Z"
- : null) : null);
+ .getExpiryDate().trim().length() != 0 ? entitlementPool.getExpiryDate() + "T23:59:59Z"
+ : null) : null);
validateUpdateDate(entitlementPool.getStartDate(), entitlementPool.getExpiryDate(),
- entitlementPool.getVendorLicenseModelId());
- Version version = VersioningUtil.resolveVersion(entitlementPool.getVersion(),
- getVersionInfo(entitlementPool.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user), user);
- vendorLicenseFacade
- .updateVlmLastModificationTime(entitlementPool.getVendorLicenseModelId(), version);
- vendorLicenseFacade.updateEntitlementPool(entitlementPool, user);
+ entitlementPool.getVendorLicenseModelId());
+ vendorLicenseFacade.updateEntitlementPool(entitlementPool);
mdcDataDebugMessage.debugExitMessage("VLM id, EP id", entitlementPool
- .getVendorLicenseModelId(), entitlementPool.getId());
+ .getVendorLicenseModelId(), entitlementPool.getId());
}
@Override
- public EntitlementPoolEntity getEntitlementPool(EntitlementPoolEntity entitlementPool,
- String user) {
+ public EntitlementPoolEntity getEntitlementPool(EntitlementPoolEntity entitlementPool) {
mdcDataDebugMessage.debugEntryMessage("VLM id, EP id", entitlementPool
- .getVendorLicenseModelId(), entitlementPool.getId());
-
- entitlementPool.setVersion(VersioningUtil.resolveVersion(entitlementPool.getVersion(),
- getVersionInfo(entitlementPool.getVendorLicenseModelId(), VersionableEntityAction.Read,
- user), user));
+ .getVendorLicenseModelId(), entitlementPool.getId());
EntitlementPoolEntity retrieved = entitlementPoolDao.get(entitlementPool);
VersioningUtil
- .validateEntityExistence(retrieved, entitlementPool, VendorLicenseModelEntity.ENTITY_TYPE);
+ .validateEntityExistence(retrieved, entitlementPool, VendorLicenseModelEntity.ENTITY_TYPE);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy'T'HH:mm:ss'Z'");
DateTimeFormatter targetFormatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
- if(retrieved.getStartDate() != null){
- retrieved.setStartDate(LocalDate.parse(retrieved.getStartDate(),formatter).format
- (targetFormatter));
+ if (retrieved.getStartDate() != null) {
+ retrieved.setStartDate(LocalDate.parse(retrieved.getStartDate(), formatter).format
+ (targetFormatter));
}
- if(retrieved.getExpiryDate() != null){
- retrieved.setExpiryDate(LocalDate.parse(retrieved.getExpiryDate(),formatter).format
- (targetFormatter));
+ if (retrieved.getExpiryDate() != null) {
+ retrieved.setExpiryDate(LocalDate.parse(retrieved.getExpiryDate(), formatter).format
+ (targetFormatter));
}
mdcDataDebugMessage.debugExitMessage("VLM id, EP id", entitlementPool
- .getVendorLicenseModelId(), entitlementPool.getId());
+ .getVendorLicenseModelId(), entitlementPool.getId());
return retrieved;
}
@Override
- public void deleteEntitlementPool(EntitlementPoolEntity entitlementPool, String user) {
+ public void deleteEntitlementPool(EntitlementPoolEntity entitlementPool) {
mdcDataDebugMessage.debugEntryMessage("VLM id, EP id", entitlementPool
- .getVendorLicenseModelId(), entitlementPool.getId());
-
- Version version = VersioningUtil.resolveVersion(entitlementPool.getVersion(),
- getVersionInfo(entitlementPool.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user), user);
- entitlementPool.setVersion(version);
+ .getVendorLicenseModelId(), entitlementPool.getId());
EntitlementPoolEntity retrieved = entitlementPoolDao.get(entitlementPool);
VersioningUtil
- .validateEntityExistence(retrieved, entitlementPool, VendorLicenseModelEntity.ENTITY_TYPE);
+ .validateEntityExistence(retrieved, entitlementPool, VendorLicenseModelEntity.ENTITY_TYPE);
for (String referencingFeatureGroupId : retrieved.getReferencingFeatureGroups()) {
featureGroupDao.removeEntitlementPool(
- new FeatureGroupEntity(entitlementPool.getVendorLicenseModelId(), version,
- referencingFeatureGroupId), entitlementPool.getId());
+ new FeatureGroupEntity(entitlementPool.getVendorLicenseModelId(),
+ entitlementPool.getVersion(),
+ referencingFeatureGroupId), entitlementPool.getId());
}
- deleteChildLimits(entitlementPool.getVendorLicenseModelId(), entitlementPool.getVersion(), entitlementPool.getId(), user);
+ deleteChildLimits(entitlementPool.getVendorLicenseModelId(), entitlementPool.getVersion(),
+ entitlementPool.getId());
entitlementPoolDao.delete(entitlementPool);
deleteUniqueName(VendorLicenseConstants.UniqueValues.ENTITLEMENT_POOL_NAME,
- retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
- retrieved.getName());
-
- vendorLicenseFacade.updateVlmLastModificationTime(entitlementPool.getVendorLicenseModelId(),
- entitlementPool.getVersion());
+ retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
+ retrieved.getName());
mdcDataDebugMessage.debugExitMessage("VLM id, EP id", entitlementPool
- .getVendorLicenseModelId(), entitlementPool.getId());
+ .getVendorLicenseModelId(), entitlementPool.getId());
}
- protected void deleteChildLimits(String vlmId, Version version, String epLkgId, String user) {
+ protected void deleteChildLimits(String vlmId, Version version, String epLkgId) {
Optional<Collection<LimitEntity>> limitEntities = Optional.ofNullable(
- listLimits(vlmId, version, epLkgId, user));
- limitEntities.ifPresent(entities->
- entities.forEach(entity->
- deleteLimit(entity, user)));
+ listLimits(vlmId, version, epLkgId));
+ limitEntities.ifPresent(entities -> entities.forEach(this::deleteLimit));
}
@Override
- public Collection<LicenseKeyGroupEntity> listLicenseKeyGroups(String vlmId, Version version,
- String user) {
+ public Collection<LicenseKeyGroupEntity> listLicenseKeyGroups(String vlmId, Version version) {
mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId);
mdcDataDebugMessage.debugExitMessage("VLM id", vlmId);
- return vendorLicenseFacade.listLicenseKeyGroups(vlmId, version, user);
+ return vendorLicenseFacade.listLicenseKeyGroups(vlmId, version);
}
@Override
- public LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup,
- String user) {
+ public LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup) {
mdcDataDebugMessage
- .debugEntryMessage("VLM id", licenseKeyGroup.getVendorLicenseModelId());
+ .debugEntryMessage("VLM id", licenseKeyGroup.getVendorLicenseModelId());
mdcDataDebugMessage.debugExitMessage("VLM id", licenseKeyGroup
- .getVendorLicenseModelId());
+ .getVendorLicenseModelId());
licenseKeyGroup.setStartDate(licenseKeyGroup.getStartDate() != null ? (licenseKeyGroup
- .getStartDate().trim().length() != 0 ? licenseKeyGroup.getStartDate()+"T00:00:00Z"
- : null) : null);
+ .getStartDate().trim().length() != 0 ? licenseKeyGroup.getStartDate() + "T00:00:00Z"
+ : null) : null);
licenseKeyGroup.setExpiryDate(licenseKeyGroup.getExpiryDate() != null ? (licenseKeyGroup
- .getExpiryDate().trim().length() != 0 ? licenseKeyGroup.getExpiryDate()+"T23:59:59Z"
- : null) : null);
+ .getExpiryDate().trim().length() != 0 ? licenseKeyGroup.getExpiryDate() + "T23:59:59Z"
+ : null) : null);
validateCreateDate(licenseKeyGroup.getStartDate(), licenseKeyGroup.getExpiryDate(),
- licenseKeyGroup.getVendorLicenseModelId());
- return vendorLicenseFacade.createLicenseKeyGroup(licenseKeyGroup, user);
+ licenseKeyGroup.getVendorLicenseModelId());
+ return vendorLicenseFacade.createLicenseKeyGroup(licenseKeyGroup);
}
@Override
- public void updateLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user) {
+ public void updateLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup) {
mdcDataDebugMessage.debugEntryMessage("VLM id, LKG id", licenseKeyGroup
- .getVendorLicenseModelId(), licenseKeyGroup.getId());
+ .getVendorLicenseModelId(), licenseKeyGroup.getId());
licenseKeyGroup.setStartDate(licenseKeyGroup.getStartDate() != null ? (licenseKeyGroup
- .getStartDate().trim().length() != 0 ? licenseKeyGroup.getStartDate()+"T00:00:00Z"
- : null) : null);
+ .getStartDate().trim().length() != 0 ? licenseKeyGroup.getStartDate() + "T00:00:00Z"
+ : null) : null);
licenseKeyGroup.setExpiryDate(licenseKeyGroup.getExpiryDate() != null ? (licenseKeyGroup
- .getExpiryDate().trim().length() != 0 ? licenseKeyGroup.getExpiryDate()+"T23:59:59Z"
- : null) : null);
+ .getExpiryDate().trim().length() != 0 ? licenseKeyGroup.getExpiryDate() + "T23:59:59Z"
+ : null) : null);
validateUpdateDate(licenseKeyGroup.getStartDate(), licenseKeyGroup.getExpiryDate(),
- licenseKeyGroup.getVendorLicenseModelId());
-
- Version version = VersioningUtil.resolveVersion(licenseKeyGroup.getVersion(),
- getVersionInfo(licenseKeyGroup.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user), user);
- vendorLicenseFacade
- .updateVlmLastModificationTime(licenseKeyGroup.getVendorLicenseModelId(), version);
-
- vendorLicenseFacade.updateLicenseKeyGroup(licenseKeyGroup, user);
+ licenseKeyGroup.getVendorLicenseModelId());
+ vendorLicenseFacade.updateLicenseKeyGroup(licenseKeyGroup);
mdcDataDebugMessage.debugExitMessage("VLM id, LKG id", licenseKeyGroup
- .getVendorLicenseModelId(), licenseKeyGroup.getId());
+ .getVendorLicenseModelId(), licenseKeyGroup.getId());
}
@Override
- public LicenseKeyGroupEntity getLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup,
- String user) {
+ public LicenseKeyGroupEntity getLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup) {
mdcDataDebugMessage.debugEntryMessage("VLM id, LKG id", licenseKeyGroup
- .getVendorLicenseModelId(), licenseKeyGroup.getId());
-
- licenseKeyGroup.setVersion(VersioningUtil.resolveVersion(licenseKeyGroup.getVersion(),
- getVersionInfo(licenseKeyGroup.getVendorLicenseModelId(), VersionableEntityAction.Read,
- user), user));
+ .getVendorLicenseModelId(), licenseKeyGroup.getId());
LicenseKeyGroupEntity retrieved = licenseKeyGroupDao.get(licenseKeyGroup);
VersioningUtil
- .validateEntityExistence(retrieved, licenseKeyGroup, VendorLicenseModelEntity.ENTITY_TYPE);
+ .validateEntityExistence(retrieved, licenseKeyGroup, VendorLicenseModelEntity.ENTITY_TYPE);
mdcDataDebugMessage.debugExitMessage("VLM id, LKG id", licenseKeyGroup
- .getVendorLicenseModelId(), licenseKeyGroup.getId());
+ .getVendorLicenseModelId(), licenseKeyGroup.getId());
return retrieved;
}
@Override
- public void deleteLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user) {
+ public void deleteLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup) {
mdcDataDebugMessage.debugEntryMessage("VLM id, LKG id", licenseKeyGroup
- .getVendorLicenseModelId(), licenseKeyGroup.getId());
-
- Version version = VersioningUtil.resolveVersion(licenseKeyGroup.getVersion(),
- getVersionInfo(licenseKeyGroup.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user), user);
- licenseKeyGroup.setVersion(version);
+ .getVendorLicenseModelId(), licenseKeyGroup.getId());
LicenseKeyGroupEntity retrieved = licenseKeyGroupDao.get(licenseKeyGroup);
VersioningUtil
- .validateEntityExistence(retrieved, licenseKeyGroup, VendorLicenseModelEntity.ENTITY_TYPE);
+ .validateEntityExistence(retrieved, licenseKeyGroup, VendorLicenseModelEntity.ENTITY_TYPE);
for (String referencingFeatureGroupId : retrieved.getReferencingFeatureGroups()) {
featureGroupDao.removeLicenseKeyGroup(
- new FeatureGroupEntity(licenseKeyGroup.getVendorLicenseModelId(), version,
- referencingFeatureGroupId), licenseKeyGroup.getId());
+ new FeatureGroupEntity(licenseKeyGroup.getVendorLicenseModelId(),
+ licenseKeyGroup.getVersion(),
+ referencingFeatureGroupId), licenseKeyGroup.getId());
}
- deleteChildLimits(licenseKeyGroup.getVendorLicenseModelId(), licenseKeyGroup.getVersion(), licenseKeyGroup.getId(), user);
+ deleteChildLimits(licenseKeyGroup.getVendorLicenseModelId(), licenseKeyGroup.getVersion(),
+ licenseKeyGroup.getId());
licenseKeyGroupDao.delete(licenseKeyGroup);
deleteUniqueName(VendorLicenseConstants.UniqueValues.LICENSE_KEY_GROUP_NAME,
- retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
- retrieved.getName());
-
- vendorLicenseFacade.updateVlmLastModificationTime(licenseKeyGroup.getVendorLicenseModelId(),
- licenseKeyGroup.getVersion());
+ retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
+ retrieved.getName());
mdcDataDebugMessage.debugExitMessage("VLM id, LKG id", licenseKeyGroup
- .getVendorLicenseModelId(), licenseKeyGroup.getId());
+ .getVendorLicenseModelId(), licenseKeyGroup.getId());
}
@Override
- public LimitEntity createLimit(LimitEntity limit, String user) {
+ public LimitEntity createLimit(LimitEntity limit) {
mdcDataDebugMessage
- .debugEntryMessage("VLM id", limit.getVendorLicenseModelId(), "EP/LKGId", limit
- .getEpLkgId());
+ .debugEntryMessage("VLM id", limit.getVendorLicenseModelId(), "EP/LKGId", limit
+ .getEpLkgId());
mdcDataDebugMessage
- .debugExitMessage("VLM id", limit.getVendorLicenseModelId(), "EP/LKGId", limit
- .getEpLkgId());
- validateLimit(limit, user);
- LimitEntity createdLimit = vendorLicenseFacade.createLimit(limit, user);
- updateParentForLimit(limit,user);
+ .debugExitMessage("VLM id", limit.getVendorLicenseModelId(), "EP/LKGId", limit
+ .getEpLkgId());
+ validateLimit(limit);
+ LimitEntity createdLimit = vendorLicenseFacade.createLimit(limit);
+ updateParentForLimit(limit);
return createdLimit;
}
- private void validateLimit(LimitEntity limit, String user) {
- Version version = VersioningUtil.resolveVersion(limit.getVersion(),
- getVersionInfo(limit.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user), user);
- Collection<LimitEntity> limitList = listLimits(limit.getVendorLicenseModelId(),version
- ,limit.getEpLkgId(), user);
+ private void validateLimit(LimitEntity limit) {
+ Collection<LimitEntity> limitList =
+ listLimits(limit.getVendorLicenseModelId(), limit.getVersion()
+ , limit.getEpLkgId());
- if (!isLimitNameUnique(limitList,limit.getName(), limit.getType(), limit.getId())) {
+ if (!isLimitNameUnique(limitList, limit.getName(), limit.getType(), limit.getId())) {
final ErrorCode duplicateLimitNameErrorBuilder =
- LimitErrorBuilder.getDuplicateNameErrorbuilder(limit.getName(), limit.getType().name());
+ LimitErrorBuilder.getDuplicateNameErrorbuilder(limit.getName(), limit.getType().name());
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerServiceName.Create_LIMIT.toString(), ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(),
- duplicateLimitNameErrorBuilder.message());
+ LoggerServiceName.Create_LIMIT.toString(), ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(),
+ duplicateLimitNameErrorBuilder.message());
throw new CoreException(duplicateLimitNameErrorBuilder);
}
}
private boolean isLimitNameUnique(Collection<LimitEntity> limitList, String name, LimitType
- type, String id) {
+ type, String id) {
for (LimitEntity limit : limitList) {
- if(limit.getName().equalsIgnoreCase(name) &&
- limit.getType().name().equalsIgnoreCase(type.name())) {
- if(id != null && limit.getId().equals(id)){
+ if (limit.getName().equalsIgnoreCase(name) &&
+ limit.getType().name().equalsIgnoreCase(type.name())) {
+ if (id != null && limit.getId().equals(id)) {
continue;
}
return false;
@@ -846,54 +629,45 @@
}
@Override
- public Collection<LimitEntity> listLimits(String vlmId, Version version, String epLkgId,
- String user) {
+ public Collection<LimitEntity> listLimits(String vlmId, Version version, String epLkgId) {
mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId, "EP/LKGId", epLkgId);
mdcDataDebugMessage.debugExitMessage("VLM id", vlmId, "EP/LKGId", epLkgId);
- return vendorLicenseFacade.listLimits(vlmId, version, epLkgId, user);
+ return vendorLicenseFacade.listLimits(vlmId, version, epLkgId);
}
@Override
- public void deleteLimit(LimitEntity limitEntity, String user) {
+ public void deleteLimit(LimitEntity limitEntity) {
mdcDataDebugMessage.debugEntryMessage("VLM id, EP id, Limit Id", limitEntity
- .getVendorLicenseModelId(), limitEntity.getEpLkgId(), limitEntity.getId());
+ .getVendorLicenseModelId(), limitEntity.getEpLkgId(), limitEntity.getId());
- Version version = VersioningUtil.resolveVersion(limitEntity.getVersion(),
- getVersionInfo(limitEntity.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user), user);
- limitEntity.setVersion(version);
-
- if ( !isLimitPresent(limitEntity)) {
+ if (!isLimitPresent(limitEntity)) {
VersioningUtil
- .validateEntityExistence(null, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
+ .validateEntityExistence(null, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
}
LimitEntity retrieved = limitDao.get(limitEntity);
VersioningUtil
- .validateEntityExistence(retrieved, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
+ .validateEntityExistence(retrieved, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
limitDao.delete(limitEntity);
- vendorLicenseFacade.updateVlmLastModificationTime(limitEntity.getVendorLicenseModelId(),
- limitEntity.getVersion());
-
- updateParentForLimit(limitEntity,user);
+ updateParentForLimit(limitEntity);
mdcDataDebugMessage.debugExitMessage("VLM id, EP id, Limit Id", limitEntity
- .getVendorLicenseModelId(), limitEntity.getEpLkgId(), limitEntity.getId());
+ .getVendorLicenseModelId(), limitEntity.getEpLkgId(), limitEntity.getId());
}
@Override
- public void updateLimit(LimitEntity limit, String user) {
+ public void updateLimit(LimitEntity limit) {
mdcDataDebugMessage
- .debugEntryMessage("VLM id", limit.getVendorLicenseModelId(), "EP/LKGId", limit
- .getEpLkgId());
- getLimit(limit,user);
- validateLimit(limit, user);
- vendorLicenseFacade.updateLimit(limit, user);
- updateParentForLimit(limit,user);
+ .debugEntryMessage("VLM id", limit.getVendorLicenseModelId(), "EP/LKGId", limit
+ .getEpLkgId());
+ getLimit(limit);
+ validateLimit(limit);
+ vendorLicenseFacade.updateLimit(limit);
+ updateParentForLimit(limit);
mdcDataDebugMessage
- .debugExitMessage("VLM id", limit.getVendorLicenseModelId(), "EP/LKGId", limit
- .getEpLkgId());
+ .debugExitMessage("VLM id", limit.getVendorLicenseModelId(), "EP/LKGId", limit
+ .getEpLkgId());
}
private boolean isLimitPresent(LimitEntity limit) {
@@ -901,52 +675,46 @@
}
@Override
- public LimitEntity getLimit(LimitEntity limitEntity,
- String user) {
+ public LimitEntity getLimit(LimitEntity limitEntity) {
mdcDataDebugMessage.debugEntryMessage("VLM id", limitEntity.getVendorLicenseModelId(),
- "EP/LKGId", limitEntity.getEpLkgId());
+ "EP/LKGId", limitEntity.getEpLkgId());
- limitEntity.setVersion(VersioningUtil.resolveVersion(limitEntity.getVersion(),
- getVersionInfo(limitEntity.getVendorLicenseModelId(), VersionableEntityAction.Read,
- user), user));
- if(!isLimitPresent(limitEntity)){
+ if (!isLimitPresent(limitEntity)) {
VersioningUtil
- .validateEntityExistence(null, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
+ .validateEntityExistence(null, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
}
LimitEntity retrieved = limitDao.get(limitEntity);
VersioningUtil
- .validateEntityExistence(retrieved, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
+ .validateEntityExistence(retrieved, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
mdcDataDebugMessage.debugExitMessage("VLM id", limitEntity.getVendorLicenseModelId(),
- "EP/LKGId", limitEntity.getEpLkgId());
+ "EP/LKGId", limitEntity.getEpLkgId());
return retrieved;
}
/**
* update Parent of limit (EP/LKG) versionuuid when limit is modified so that limit updates are
* captured in VLM XML
- * @param limit
- * @param user
*/
- private void updateParentForLimit(LimitEntity limit, String user) {
+ private void updateParentForLimit(LimitEntity limit) {
mdcDataDebugMessage.debugEntryMessage("VLM id", limit.getVendorLicenseModelId(),
- "EP/LKGId", limit.getEpLkgId(), "Limit Parent ", limit.getParent());
- if ("EntitlementPool".equals(limit.getParent()) ) {
+ "EP/LKGId", limit.getEpLkgId(), "Limit Parent ", limit.getParent());
+ if ("EntitlementPool".equals(limit.getParent())) {
EntitlementPoolEntity entitlementPoolEntity =
- entitlementPoolDao.get(new EntitlementPoolEntity(limit.getVendorLicenseModelId(),
- limit.getVersion(), limit.getEpLkgId()));
- vendorLicenseFacade.updateEntitlementPool(entitlementPoolEntity, user);
+ entitlementPoolDao.get(new EntitlementPoolEntity(limit.getVendorLicenseModelId(),
+ limit.getVersion(), limit.getEpLkgId()));
+ vendorLicenseFacade.updateEntitlementPool(entitlementPoolEntity);
}
if ("LicenseKeyGroup".equals(limit.getParent())) {
LicenseKeyGroupEntity licenseKeyGroupEntity = licenseKeyGroupDao.get(
- new LicenseKeyGroupEntity(limit.getVendorLicenseModelId(), limit.getVersion(),
- limit.getEpLkgId()));
- vendorLicenseFacade.updateLicenseKeyGroup(licenseKeyGroupEntity, user);
+ new LicenseKeyGroupEntity(limit.getVendorLicenseModelId(), limit.getVersion(),
+ limit.getEpLkgId()));
+ vendorLicenseFacade.updateLicenseKeyGroup(licenseKeyGroupEntity);
}
mdcDataDebugMessage.debugEntryMessage("VLM id", limit.getVendorLicenseModelId(),
- "EP/LKGId", limit.getEpLkgId(), "Limit Parent ", limit.getParent());
+ "EP/LKGId", limit.getEpLkgId(), "Limit Parent ", limit.getParent());
}
protected void addFeatureGroupsToLicenseAgreementRef(Set<String> featureGroupIds,
@@ -954,8 +722,8 @@
if (featureGroupIds != null) {
for (String featureGroupId : featureGroupIds) {
featureGroupDao.addReferencingLicenseAgreement(
- new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(),
- licenseAgreement.getVersion(), featureGroupId), licenseAgreement.getId());
+ new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(),
+ licenseAgreement.getVersion(), featureGroupId), licenseAgreement.getId());
}
}
}
@@ -965,8 +733,8 @@
if (featureGroupIds != null) {
for (String featureGroupId : featureGroupIds) {
featureGroupDao.removeReferencingLicenseAgreement(
- new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(),
- licenseAgreement.getVersion(), featureGroupId), licenseAgreement.getId());
+ new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(),
+ licenseAgreement.getVersion(), featureGroupId), licenseAgreement.getId());
}
}
}
@@ -976,8 +744,8 @@
if (licenseKeyGroupIds != null) {
for (String licenseKeyGroupId : licenseKeyGroupIds) {
licenseKeyGroupDao.addReferencingFeatureGroup(
- new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(),
- featureGroup.getVersion(), licenseKeyGroupId), featureGroup.getId());
+ new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion(), licenseKeyGroupId), featureGroup.getId());
}
}
}
@@ -987,8 +755,8 @@
if (licenseKeyGroupIds != null) {
for (String licenseKeyGroupId : licenseKeyGroupIds) {
licenseKeyGroupDao.removeReferencingFeatureGroup(
- new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(),
- featureGroup.getVersion(), licenseKeyGroupId), featureGroup.getId());
+ new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion(), licenseKeyGroupId), featureGroup.getId());
}
}
}
@@ -998,8 +766,8 @@
if (entitlementPoolIds != null) {
for (String entitlementPoolId : entitlementPoolIds) {
entitlementPoolDao.addReferencingFeatureGroup(
- new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(),
- featureGroup.getVersion(), entitlementPoolId), featureGroup.getId());
+ new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion(), entitlementPoolId), featureGroup.getId());
}
}
}
@@ -1009,38 +777,19 @@
if (entitlementPoolIds != null) {
for (String entitlementPoolId : entitlementPoolIds) {
entitlementPoolDao.removeReferencingFeatureGroup(
- new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(),
- featureGroup.getVersion(), entitlementPoolId), featureGroup.getId());
+ new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion(), entitlementPoolId), featureGroup.getId());
}
}
}
- protected VersionInfo getVersionInfo(String vendorLicenseModelId, VersionableEntityAction action,
- String user) {
- return vendorLicenseFacade.getVersionInfo(vendorLicenseModelId, action, user);
- }
-
- protected LicenseAgreementEntity createLicenseAgreementForList(String vlmId, Version version,
- String user) {
- return new LicenseAgreementEntity(vlmId, VersioningUtil
- .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Read, user), user),
- null);
- }
-
- protected void updateUniqueName(String uniqueValueType ,String oldName, String newName,String ...
- context) {
+ protected void updateUniqueName(String uniqueValueType, String oldName, String newName, String...
+ context) {
UniqueValueUtil
- .updateUniqueValue(uniqueValueType, oldName, newName,context);
+ .updateUniqueValue(uniqueValueType, oldName, newName, context);
}
- protected void deleteUniqueName(String uniqueValueType,String ... uniqueCombination) {
+ protected void deleteUniqueName(String uniqueValueType, String... uniqueCombination) {
UniqueValueUtil.deleteUniqueValue(uniqueValueType, uniqueCombination);
}
-
- protected Version resloveVersion(String vlmId,Version requestedVersion, VersionInfo versionInfo,
- String user){
- return VersioningUtil.resolveVersion(null,
- getVersionInfo(vlmId, VersionableEntityAction.Write, user), user);
- }
-
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/ArtifactTestUtils.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/ArtifactTestUtils.java
index 5d9729d..c005e96 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/ArtifactTestUtils.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/ArtifactTestUtils.java
@@ -20,41 +20,6 @@
package org.openecomp.sdc.vendorlicense;
-import org.openecomp.core.utilities.CommonMethods;
-import org.openecomp.sdc.vendorlicense.dao.types.AggregationFunction;
-import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther;
-import org.openecomp.sdc.vendorlicense.dao.types.EntitlementMetric;
-import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.EntitlementTime;
-import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyType;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseTerm;
-import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther;
-import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope;
-import org.openecomp.sdc.vendorlicense.dao.types.ThresholdUnit;
-import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
-import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory;
-import org.openecomp.sdc.vendorlicense.impl.VendorLicenseManagerImpl;
-import org.openecomp.sdc.vendorlicense.licenseartifacts.VendorLicenseArtifactsService;
-import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
-import org.openecomp.sdc.vendorsoftwareproduct.impl.VendorSoftwareProductManagerImpl;
-import org.openecomp.sdc.versioning.VersioningManager;
-import org.openecomp.sdc.versioning.VersioningManagerFactory;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.VersionInfo;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
-import org.testng.annotations.BeforeMethod;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE;
-
/**
* Created by Katyr on 29-May-16
*/
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/LimitTest.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/LimitTest.java
index 07fdeee..0197dd9 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/LimitTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/LimitTest.java
@@ -20,17 +20,11 @@
package org.openecomp.sdc.vendorlicense;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.verify;
-
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.vendorlicense.dao.LimitDao;
import org.openecomp.sdc.vendorlicense.dao.types.AggregationFunction;
import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity;
@@ -45,19 +39,19 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
+
public class LimitTest {
- private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
-
- private final String USER1 = "limitTestUser1";
- private final String LT1_NAME = "LT1 name";
+ private final String USER1 = "limitTestUser1";
+ private final String LT1_NAME = "LT1 name";
private static final String VLM_ID = "VLM_ID";
private static final Version VERSION = new Version(0, 1);
@@ -76,8 +70,8 @@
private VendorLicenseManagerImpl vendorLicenseManagerImpl;
public static LimitEntity createLimitEntity(String name, LimitType type, String description,
- Version version, String metric,
- AggregationFunction aggregationFunction, int unit,
+ Version version, String metric,
+ AggregationFunction aggregationFunction, int unit,
String time) {
LimitEntity limitEntity = new LimitEntity();
limitEntity.setName(name);
@@ -92,22 +86,22 @@
}
@BeforeMethod
- public void setUp() {
+ public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
}
@Test
public void testUpdateLimit() {
Version version = new Version();
- LimitEntity limitEntity1 = createLimitEntity(LT1_NAME,LimitType.Vendor,"string",version,
- "Core",AggregationFunction.Average,10,"Hour");
- LimitEntity limitEntity2 = createLimitEntity(LT1_NAME,LimitType.Vendor,"string",version,
- "Tokens",AggregationFunction.Peak,12,"Month");
+ LimitEntity limitEntity1 = createLimitEntity(LT1_NAME, LimitType.Vendor, "string", version,
+ "Core", AggregationFunction.Average, 10, "Hour");
+ LimitEntity limitEntity2 = createLimitEntity(LT1_NAME, LimitType.Vendor, "string", version,
+ "Tokens", AggregationFunction.Peak, 12, "Month");
VersionInfo info = new VersionInfo();
info.getViewableVersions().add(version);
info.setActiveVersion(version);
- doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(),anyObject(),anyObject());
+ /*doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(), anyObject(), anyObject());*/
doReturn(true).when(limitDao).isLimitPresent(anyObject());
doReturn(limitEntity1).when(limitDao).get(anyObject());
@@ -116,27 +110,28 @@
limitEntityList.add(limitEntity2);
limitEntity1.setId("1234");
limitEntity2.setId("1234");
- doReturn(limitEntityList).when(vendorLicenseFacade).listLimits(anyObject(),anyObject(),
- anyObject(),anyObject());
+ doReturn(limitEntityList).when(vendorLicenseFacade)
+ .listLimits(anyObject(), anyObject(), anyObject());
- vendorLicenseManagerImpl.updateLimit(limitEntity2,USER1);
+ vendorLicenseManagerImpl.updateLimit(limitEntity2);
- verify(vendorLicenseFacade).updateLimit(anyObject(), anyObject());
+ verify(vendorLicenseFacade).updateLimit(anyObject());
}
@Test
public void testUpdateLimitErrorWithSameNameType() {
try {
Version version = new Version();
- LimitEntity limitEntity1 = createLimitEntity(LT1_NAME,LimitType.Vendor,"string",version,
- "Core",AggregationFunction.Average,10,"Hour");
- LimitEntity limitEntity2 = createLimitEntity(LT1_NAME,LimitType.Vendor,"string",version,
- "Tokens",AggregationFunction.Peak,12,"Month");
+ LimitEntity limitEntity1 = createLimitEntity(LT1_NAME, LimitType.Vendor, "string", version,
+ "Core", AggregationFunction.Average, 10, "Hour");
+ LimitEntity limitEntity2 = createLimitEntity(LT1_NAME, LimitType.Vendor, "string", version,
+ "Tokens", AggregationFunction.Peak, 12, "Month");
VersionInfo info = new VersionInfo();
info.getViewableVersions().add(version);
info.setActiveVersion(version);
- doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(),anyObject(),anyObject());
+/* doReturn(info).when(vendorLicenseFacade)
+ .getVersionInfo(anyObject(), anyObject(), anyObject());*/
doReturn(limitEntity1).when(limitDao).get(anyObject());
List<LimitEntity> limitEntityList = new ArrayList<>();
@@ -144,13 +139,12 @@
limitEntityList.add(limitEntity2);
limitEntity1.setId("1234");
limitEntity2.setId("9632");
- doReturn(limitEntityList).when(vendorLicenseFacade).listLimits(anyObject(),anyObject(),
- anyObject(),anyObject());
+ doReturn(limitEntityList).when(vendorLicenseFacade)
+ .listLimits(anyObject(), anyObject(), anyObject());
- vendorLicenseManagerImpl.updateLimit(limitEntity2,USER1);
+ vendorLicenseManagerImpl.updateLimit(limitEntity2);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(),
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
@@ -159,13 +153,13 @@
@Test
public void testDeleteLimit() {
Version version = new Version();
- LimitEntity limitEntity = createLimitEntity(LT1_NAME,LimitType.Vendor,"string",version,
- "Core",AggregationFunction.Average,10,"Hour");
+ LimitEntity limitEntity = createLimitEntity(LT1_NAME, LimitType.Vendor, "string", version,
+ "Core", AggregationFunction.Average, 10, "Hour");
VersionInfo info = new VersionInfo();
info.getViewableVersions().add(version);
info.setActiveVersion(version);
- doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(),anyObject(),anyObject());
+ /*doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(), anyObject(), anyObject());*/
doReturn(true).when(limitDao).isLimitPresent(anyObject());
doReturn(limitEntity).when(limitDao).get(anyObject());
@@ -173,27 +167,28 @@
limitEntityList.add(limitEntity);
limitEntity.setId("1234");
- vendorLicenseManagerImpl.deleteLimit(limitEntity,LT1_NAME);
+ vendorLicenseManagerImpl.deleteLimit(limitEntity);
- verify(vendorLicenseManagerImpl).deleteLimit(anyObject(), anyObject());
+ verify(vendorLicenseManagerImpl).deleteLimit(anyObject());
}
@Test
public void testUpdateLimitErrorWithInvalidId() {
try {
Version version = new Version();
- LimitEntity limitEntity1 = createLimitEntity(LT1_NAME,LimitType.Vendor,"string",version,
- "Core",AggregationFunction.Average,10,"Hour");
- LimitEntity limitEntity2 = createLimitEntity(LT1_NAME,LimitType.Vendor,"string",version,
- "Tokens",AggregationFunction.Peak,12,"Month");
+ LimitEntity limitEntity1 = createLimitEntity(LT1_NAME, LimitType.Vendor, "string", version,
+ "Core", AggregationFunction.Average, 10, "Hour");
+ LimitEntity limitEntity2 = createLimitEntity(LT1_NAME, LimitType.Vendor, "string", version,
+ "Tokens", AggregationFunction.Peak, 12, "Month");
VersionInfo info = new VersionInfo();
info.getViewableVersions().add(version);
info.setActiveVersion(version);
- doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(),anyObject(),anyObject());
+/* doReturn(info).when(vendorLicenseFacade)
+ .getVersionInfo(anyObject(), anyObject(), anyObject());*/
doReturn(null).when(limitDao).get(anyObject());
- vendorLicenseManagerImpl.updateLimit(limitEntity2,USER1);
+ vendorLicenseManagerImpl.updateLimit(limitEntity2);
Assert.fail();
} catch (CoreException exception) {
Assert.assertEquals(exception.code().id(),
@@ -206,14 +201,14 @@
doReturn(Arrays.asList(
createLimit(VLM_ID, VERSION, EPLKG_ID, LIMIT1_ID),
createLimit(VLM_ID, VERSION, EPLKG_ID, LIMIT2_ID)))
- .when(vendorLicenseFacade).listLimits(VLM_ID, VERSION, EPLKG_ID, USER1);
+ .when(vendorLicenseFacade).listLimits(VLM_ID, VERSION, EPLKG_ID);
final Collection<LimitEntity> limits =
- vendorLicenseManagerImpl.listLimits(VLM_ID, VERSION, EPLKG_ID, USER1);
+ vendorLicenseManagerImpl.listLimits(VLM_ID, VERSION, EPLKG_ID);
Assert.assertEquals(limits.size(), 2);
for (LimitEntity limit : limits) {
Assert.assertEquals(limit.getName(),
- LIMIT1_ID.equals(limit.getId()) ? LIMIT1_ID+" name" : LIMIT2_ID+" name" );
+ LIMIT1_ID.equals(limit.getId()) ? LIMIT1_ID + " name" : LIMIT2_ID + " name");
}
}
@@ -224,10 +219,10 @@
info.getViewableVersions().add(VERSION);
info.setActiveVersion(VERSION);
- doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(),anyObject(),anyObject());
+ /*doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(), anyObject(), anyObject());*/
- vendorLicenseManagerImpl.createLimit(expected, USER1);
- verify(vendorLicenseFacade).createLimit(expected,USER1);
+ vendorLicenseManagerImpl.createLimit(expected);
+ verify(vendorLicenseFacade).createLimit(expected);
}
@Test
@@ -241,20 +236,19 @@
List<LimitEntity> vfcImageList = new ArrayList<LimitEntity>();
vfcImageList.add(expectedDiffName);
- doReturn(vfcImageList).when(vendorLicenseFacade).listLimits(anyObject(), anyObject(), anyObject(),
- anyObject());
+ doReturn(vfcImageList).when(vendorLicenseFacade)
+ .listLimits(anyObject(), anyObject(), anyObject());
VersionInfo info = new VersionInfo();
info.getViewableVersions().add(VERSION);
info.setActiveVersion(VERSION);
- doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(),anyObject(),anyObject());
+/* doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(), anyObject(), anyObject());*/
try {
- vendorLicenseManagerImpl.createLimit(expected, USER1);
+ vendorLicenseManagerImpl.createLimit(expected);
Assert.fail();
- }
- catch (CoreException ex) {
+ } catch (CoreException ex) {
Assert.assertEquals(ex.code().id(),
VendorLicenseErrorCodes.DUPLICATE_LIMIT_NAME_NOT_ALLOWED);
}
@@ -267,13 +261,14 @@
info.getViewableVersions().add(VERSION);
info.setActiveVersion(VERSION);
- doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(),anyObject(),anyObject());
+ /*doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(), anyObject(), anyObject());*/
try {
- vendorLicenseManagerImpl.getLimit(limit , USER1);
+ vendorLicenseManagerImpl.getLimit(limit);
Assert.fail();
} catch (CoreException exception) {
- Assert.assertEquals(exception.code().id(), VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ Assert.assertEquals(exception.code().id(),
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
}
@@ -293,10 +288,10 @@
info.getViewableVersions().add(VERSION);
info.setActiveVersion(VERSION);
- doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(),anyObject(),anyObject());
+ /*doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(), anyObject(), anyObject());*/
LimitEntity actual = createLimit(VLM_ID, VERSION, EPLKG_ID, LIMIT1_ID);
- vendorLicenseManagerImpl.getLimit(actual, USER1);
+ vendorLicenseManagerImpl.getLimit(actual);
Assert.assertEquals(actual.getId(), expected.getId());
Assert.assertEquals(actual.getName(), expected.getName());
Assert.assertEquals(actual.getUnit(), expected.getUnit());
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/VendorLicenseFacadeImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/VendorLicenseFacadeImplTest.java
index ab6262d..e3719ab 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/VendorLicenseFacadeImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/VendorLicenseFacadeImplTest.java
@@ -1,39 +1,5 @@
package org.openecomp.sdc.vendorlicense;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.mockito.Spy;
-import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDao;
-import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDao;
-import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDao;
-import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDao;
-import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDao;
-import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity;
-import org.openecomp.sdc.vendorlicense.facade.impl.VendorLicenseFacadeImpl;
-import org.openecomp.sdc.versioning.VersioningManager;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.VersionInfo;
-import org.testng.Assert;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.doReturn;
-import static org.openecomp.sdc.vendorlicense.errors.UncompletedVendorLicenseModelErrorType.SUBMIT_UNCOMPLETED_VLM_MSG_FG_MISSING_EP;
-import static org.openecomp.sdc.vendorlicense.errors.UncompletedVendorLicenseModelErrorType.SUBMIT_UNCOMPLETED_VLM_MSG_LA_MISSING_FG;
-
/**
* This test just verifies Feature Group Get and List APIs.
*/
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/EntitlementPoolTest.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/EntitlementPoolTest.java
index 178d05e..57d2254 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/EntitlementPoolTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/EntitlementPoolTest.java
@@ -28,12 +28,16 @@
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDao;
import org.openecomp.sdc.vendorlicense.dao.LimitDao;
-import org.openecomp.sdc.vendorlicense.dao.types.*;
+import org.openecomp.sdc.vendorlicense.dao.types.AggregationFunction;
+import org.openecomp.sdc.vendorlicense.dao.types.EntitlementMetric;
+import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.EntitlementTime;
+import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther;
+import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope;
+import org.openecomp.sdc.vendorlicense.dao.types.ThresholdUnit;
import org.openecomp.sdc.vendorlicense.errors.VendorLicenseErrorCodes;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.VersionInfo;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -41,7 +45,6 @@
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
@@ -54,353 +57,323 @@
public class EntitlementPoolTest {
- //JUnit Test Cases using Mockito
- private final String USER1 = "epTestUser1";
- private final String EP1_NAME = "EP1 name";
- private final String EP2_NAME = "EP2 name";
- private final String LT1_NAME = "LT1 name";
- private static String vlm1_id = "vlm1_id";
- private static String ep1_id = "ep1_id";
- private static String ep2_id = "ep2_id";
- public static final Version VERSION01 = new Version(0, 1);
+ //JUnit Test Cases using Mockito
+ private final String USER1 = "epTestUser1";
+ private final String EP1_NAME = "EP1 name";
+ private final String EP2_NAME = "EP2 name";
+ private final String LT1_NAME = "LT1 name";
+ private static String vlm1_id = "vlm1_id";
+ private static String ep1_id = "ep1_id";
+ private static String ep2_id = "ep2_id";
+ public static final Version VERSION01 = new Version(0, 1);
- @Mock
- private VendorLicenseFacade vendorLicenseFacade;
+ @Mock
+ private VendorLicenseFacade vendorLicenseFacade;
- @Mock
- private EntitlementPoolDao entitlementPoolDao;
- @Mock
- private LimitDao limitDao;
+ @Mock
+ private EntitlementPoolDao entitlementPoolDao;
+ @Mock
+ private LimitDao limitDao;
- @InjectMocks
- @Spy
- private VendorLicenseManagerImpl vendorLicenseManagerImpl;
+ @InjectMocks
+ @Spy
+ private VendorLicenseManagerImpl vendorLicenseManagerImpl;
- public EntitlementPoolEntity createEntitlementPool(String vlmId, Version version,String id,
- String name, String desc, int threshold,
- ThresholdUnit thresholdUnit,
- EntitlementMetric entitlementMetricChoice,
- String entitlementMetricOther,
- String increments,
- AggregationFunction aggregationFunctionChoice,
- String aggregationFunctionOther,
- Set<OperationalScope> operationalScopeChoices,
- String operationalScopeOther,
- EntitlementTime timeChoice,
- String timeOther, String sku) {
- EntitlementPoolEntity entitlementPool = new EntitlementPoolEntity();
- entitlementPool.setVendorLicenseModelId(vlmId);
- entitlementPool.setId(id);
- entitlementPool.setVersion(version);
- entitlementPool.setName(name);
- entitlementPool.setDescription(desc);
- entitlementPool.setThresholdValue(threshold);
- entitlementPool.setThresholdUnit(thresholdUnit);
- entitlementPool.setIncrements(increments);
- entitlementPool.setOperationalScope(
- new MultiChoiceOrOther<>(operationalScopeChoices, operationalScopeOther));
- return entitlementPool;
+ public EntitlementPoolEntity createEntitlementPool(String vlmId, Version version, String id,
+ String name, String desc, int threshold,
+ ThresholdUnit thresholdUnit,
+ EntitlementMetric entitlementMetricChoice,
+ String entitlementMetricOther,
+ String increments,
+ AggregationFunction aggregationFunctionChoice,
+ String aggregationFunctionOther,
+ Set<OperationalScope> operationalScopeChoices,
+ String operationalScopeOther,
+ EntitlementTime timeChoice,
+ String timeOther, String sku) {
+ EntitlementPoolEntity entitlementPool = new EntitlementPoolEntity();
+ entitlementPool.setVendorLicenseModelId(vlmId);
+ entitlementPool.setId(id);
+ entitlementPool.setVersion(version);
+ entitlementPool.setName(name);
+ entitlementPool.setDescription(desc);
+ entitlementPool.setThresholdValue(threshold);
+ entitlementPool.setThresholdUnit(thresholdUnit);
+ entitlementPool.setIncrements(increments);
+ entitlementPool.setOperationalScope(
+ new MultiChoiceOrOther<>(operationalScopeChoices, operationalScopeOther));
+ return entitlementPool;
+ }
+
+ @BeforeMethod
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void createTest() {
+ Set<OperationalScope> opScopeChoices;
+ opScopeChoices = new HashSet<>();
+ opScopeChoices.add(OperationalScope.Core);
+ opScopeChoices.add(OperationalScope.CPU);
+ opScopeChoices.add(OperationalScope.Network_Wide);
+ EntitlementPoolEntity ep2 =
+ createEntitlementPool("vlm1Id", null, ep1_id, EP1_NAME, "EP2 dec", 70, ThresholdUnit
+ .Absolute,
+ EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average, null,
+ opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
+ ep2.setStartDate(LocalDate.now().format(formatter));
+ ep2.setExpiryDate(LocalDate.now().plusDays(1L).format(formatter));
+
+ vendorLicenseManagerImpl.createEntitlementPool(ep2);
+ verify(vendorLicenseFacade).createEntitlementPool(ep2);
+
+ }
+
+ @Test(expectedExceptions = CoreException.class, expectedExceptionsMessageRegExp = "Vendor " +
+ "license model with id vlm1_id has invalid date range.")
+ public void createWithInvalidStartExpiryDateTest() {
+
+ Set<OperationalScope> opScopeChoices;
+ opScopeChoices = new HashSet<>();
+ opScopeChoices.add(OperationalScope.Core);
+ opScopeChoices.add(OperationalScope.CPU);
+ opScopeChoices.add(OperationalScope.Network_Wide);
+ EntitlementPoolEntity ep2 =
+ createEntitlementPool("vlm2Id", null, ep1_id, EP1_NAME, "EP2 dec", 70,
+ ThresholdUnit.Absolute,
+ EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average, null,
+ opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
+ ep2.setStartDate(LocalDate.now().format(formatter));
+ ep2.setExpiryDate(LocalDate.now().minusDays(2L).format(formatter));
+ ep2.setVendorLicenseModelId(vlm1_id);
+ vendorLicenseManagerImpl.createEntitlementPool(ep2).getId();
+ Assert.fail();
+
+ }
+
+ @Test(expectedExceptions = CoreException.class, expectedExceptionsMessageRegExp = "Vendor " +
+ "license model with id vlm1_id has invalid date range.")
+ public void createWithoutStartDateTest() {
+
+ Set<OperationalScope> opScopeChoices;
+ opScopeChoices = new HashSet<>();
+ opScopeChoices.add(OperationalScope.Core);
+ opScopeChoices.add(OperationalScope.CPU);
+ opScopeChoices.add(OperationalScope.Network_Wide);
+ EntitlementPoolEntity ep2 =
+ createEntitlementPool("vlm3Id", null, ep1_id, EP1_NAME, "EP2 dec", 70,
+ ThresholdUnit.Absolute,
+ EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average, null,
+ opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
+ ep2.setExpiryDate(LocalDate.now().plusDays(2L).format(formatter));
+ ep2.setVendorLicenseModelId(vlm1_id);
+ vendorLicenseManagerImpl.createEntitlementPool(ep2).getId();
+ Assert.fail();
+
+ }
+
+ @Test(expectedExceptions = CoreException.class, expectedExceptionsMessageRegExp = "Vendor " +
+ "license model with id vlm1_id has invalid date range.")
+ public void createWithSameStartExpiryDateTest() {
+
+ Set<OperationalScope> opScopeChoices;
+ opScopeChoices = new HashSet<>();
+ opScopeChoices.add(OperationalScope.Core);
+ opScopeChoices.add(OperationalScope.CPU);
+ opScopeChoices.add(OperationalScope.Network_Wide);
+ EntitlementPoolEntity ep2 =
+ createEntitlementPool("vlm4Id", null, ep1_id, EP1_NAME, "EP2 dec", 70,
+ ThresholdUnit.Absolute,
+ EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average, null,
+ opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
+ ep2.setStartDate(LocalDate.now().format(formatter));
+ ep2.setExpiryDate(LocalDate.now().format(formatter));
+ ep2.setVendorLicenseModelId(vlm1_id);
+ vendorLicenseManagerImpl.createEntitlementPool(ep2).getId();
+ Assert.fail();
+ }
+
+ @Test
+ public void testUpdate() {
+ Set<OperationalScope> opScopeChoices;
+ opScopeChoices = new HashSet<>();
+ opScopeChoices.add(OperationalScope.Core);
+ opScopeChoices.add(OperationalScope.CPU);
+ opScopeChoices.add(OperationalScope.Network_Wide);
+ EntitlementPoolEntity ep2 =
+ createEntitlementPool(vlm1_id, VERSION01, ep1_id, EP1_NAME, "EP2 dec", 70,
+ ThresholdUnit
+ .Absolute,
+ EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average, null,
+ opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
+ ep2.setStartDate(LocalDate.now().minusDays(3L).format(formatter));
+ ep2.setExpiryDate(LocalDate.now().minusDays(2L).format(formatter));
+
+ vendorLicenseManagerImpl.updateEntitlementPool(ep2);
+ }
+
+ @Test(expectedExceptions = CoreException.class, expectedExceptionsMessageRegExp = "Vendor " +
+ "license model with id vlm1_id has invalid date range.")
+ public void updateWithInvalidStartExpiryDateTest() {
+
+ Set<OperationalScope> opScopeChoices;
+ opScopeChoices = new HashSet<>();
+ opScopeChoices.add(OperationalScope.Core);
+ opScopeChoices.add(OperationalScope.CPU);
+ opScopeChoices.add(OperationalScope.Network_Wide);
+ EntitlementPoolEntity ep2 =
+ createEntitlementPool("vlm2Id", null, ep1_id, EP1_NAME, "EP2 dec", 70,
+ ThresholdUnit.Absolute,
+ EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average, null,
+ opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
+ ep2.setStartDate(LocalDate.now().format(formatter));
+ ep2.setExpiryDate(LocalDate.now().minusDays(2L).format(formatter));
+ ep2.setVendorLicenseModelId(vlm1_id);
+ vendorLicenseManagerImpl.updateEntitlementPool(ep2);
+ Assert.fail();
+
+ }
+
+ @Test
+ public void updateWithoutStartDateTest() {
+ try {
+
+ Set<OperationalScope> opScopeChoices;
+ opScopeChoices = new HashSet<>();
+ opScopeChoices.add(OperationalScope.Core);
+ opScopeChoices.add(OperationalScope.CPU);
+ opScopeChoices.add(OperationalScope.Network_Wide);
+ EntitlementPoolEntity ep2 =
+ createEntitlementPool("vlm3Id", null, ep1_id, EP1_NAME, "EP2 dec", 70,
+ ThresholdUnit.Absolute,
+ EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average,
+ null,
+ opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
+ ep2.setExpiryDate(LocalDate.now().plusDays(2L).format(formatter));
+ vendorLicenseManagerImpl.updateEntitlementPool(ep2);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), VendorLicenseErrorCodes.DATE_RANGE_INVALID);
}
+ }
- @BeforeMethod
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
+ @Test
+ public void updateWithSameStartExpiryDateTest() {
+ try {
+
+ Set<OperationalScope> opScopeChoices;
+ opScopeChoices = new HashSet<>();
+ opScopeChoices.add(OperationalScope.Core);
+ opScopeChoices.add(OperationalScope.CPU);
+ opScopeChoices.add(OperationalScope.Network_Wide);
+ EntitlementPoolEntity ep2 =
+ createEntitlementPool("vlm4Id", null, ep1_id, EP1_NAME, "EP2 dec", 70,
+ ThresholdUnit.Absolute,
+ EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average,
+ null,
+ opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
+ ep2.setStartDate(LocalDate.now().format(formatter));
+ ep2.setExpiryDate(LocalDate.now().format(formatter));
+ vendorLicenseManagerImpl.updateEntitlementPool(ep2);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), VendorLicenseErrorCodes.DATE_RANGE_INVALID);
}
+ }
- @Test
- public void createTest() {
- Set<OperationalScope> opScopeChoices;
- opScopeChoices = new HashSet<>();
- opScopeChoices.add(OperationalScope.Core);
- opScopeChoices.add(OperationalScope.CPU);
- opScopeChoices.add(OperationalScope.Network_Wide);
- EntitlementPoolEntity ep2 =
- createEntitlementPool("vlm1Id", null, ep1_id,EP1_NAME, "EP2 dec", 70, ThresholdUnit
- .Absolute,
- EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average, null,
- opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
- ep2.setStartDate(LocalDate.now().format(formatter));
- ep2.setExpiryDate(LocalDate.now().plusDays(1L).format(formatter));
+ @Test
+ public void deleteEntitlementPoolTest() {
+ Set<OperationalScope> opScopeChoices;
+ opScopeChoices = new HashSet<>();
+ opScopeChoices.add(OperationalScope.Core);
+ opScopeChoices.add(OperationalScope.CPU);
+ opScopeChoices.add(OperationalScope.Network_Wide);
- vendorLicenseManagerImpl.createEntitlementPool(ep2, USER1);
- verify(vendorLicenseFacade).createEntitlementPool(ep2,USER1);
+ EntitlementPoolEntity entitlementPool =
+ createEntitlementPool(vlm1_id, VERSION01, ep1_id, EP1_NAME, "EP2 dec", 70,
+ ThresholdUnit.Absolute, EntitlementMetric.Other, "exception metric2", "inc2",
+ AggregationFunction.Average, null,
+ opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
+ entitlementPool.setStartDate(LocalDate.now().format(formatter));
+ entitlementPool.setExpiryDate(LocalDate.now().plusDays(1L).format(formatter));
- }
+ doReturn(entitlementPool).when(entitlementPoolDao).get(anyObject());
- @Test(expectedExceptions = CoreException.class, expectedExceptionsMessageRegExp = "Vendor " +
- "license model with id vlm1_id has invalid date range.")
- public void createWithInvalidStartExpiryDateTest() {
+ doNothing().when(vendorLicenseManagerImpl).deleteChildLimits(vlm1_id, VERSION01, ep1_id);
- Set<OperationalScope> opScopeChoices;
- opScopeChoices = new HashSet<>();
- opScopeChoices.add(OperationalScope.Core);
- opScopeChoices.add(OperationalScope.CPU);
- opScopeChoices.add(OperationalScope.Network_Wide);
- EntitlementPoolEntity ep2 =
- createEntitlementPool("vlm2Id", null, ep1_id,EP1_NAME, "EP2 dec", 70,
- ThresholdUnit.Absolute,
- EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average, null,
- opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
- ep2.setStartDate(LocalDate.now().format(formatter));
- ep2.setExpiryDate(LocalDate.now().minusDays(2L).format(formatter));
- ep2.setVendorLicenseModelId(vlm1_id);
- vendorLicenseManagerImpl.createEntitlementPool(ep2, USER1).getId();
- Assert.fail();
+ doNothing().when(vendorLicenseManagerImpl).deleteUniqueName(anyObject(), anyObject(),
+ anyObject(), anyObject());
- }
+ vendorLicenseManagerImpl.deleteEntitlementPool(entitlementPool);
- @Test(expectedExceptions = CoreException.class, expectedExceptionsMessageRegExp = "Vendor " +
- "license model with id vlm1_id has invalid date range.")
- public void createWithoutStartDateTest() {
+ verify(entitlementPoolDao).delete(entitlementPool);
+ }
- Set<OperationalScope> opScopeChoices;
- opScopeChoices = new HashSet<>();
- opScopeChoices.add(OperationalScope.Core);
- opScopeChoices.add(OperationalScope.CPU);
- opScopeChoices.add(OperationalScope.Network_Wide);
- EntitlementPoolEntity ep2 =
- createEntitlementPool("vlm3Id", null, ep1_id,EP1_NAME, "EP2 dec", 70,
- ThresholdUnit.Absolute,
- EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average, null,
- opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
- ep2.setExpiryDate(LocalDate.now().plusDays(2L).format(formatter));
- ep2.setVendorLicenseModelId(vlm1_id);
- vendorLicenseManagerImpl.createEntitlementPool(ep2, USER1).getId();
- Assert.fail();
+ @Test
+ public void testGetEntitlementPool() {
+ Set<OperationalScope> opScopeChoices;
+ opScopeChoices = new HashSet<>();
+ opScopeChoices.add(OperationalScope.Core);
+ opScopeChoices.add(OperationalScope.CPU);
+ opScopeChoices.add(OperationalScope.Network_Wide);
- }
+ EntitlementPoolEntity entitlementPool =
+ createEntitlementPool(vlm1_id, VERSION01, ep1_id, EP1_NAME, "EP2 dec", 70,
+ ThresholdUnit.Absolute, EntitlementMetric.Other, "exception metric2", "inc2",
+ AggregationFunction.Average, null,
+ opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy'T'HH:mm:ss'Z'");
- @Test(expectedExceptions = CoreException.class, expectedExceptionsMessageRegExp = "Vendor " +
- "license model with id vlm1_id has invalid date range.")
- public void createWithSameStartExpiryDateTest() {
+ entitlementPool.setStartDate(LocalDateTime.now().format(formatter));
+ entitlementPool.setExpiryDate(LocalDateTime.now().plusDays(1L).format(formatter));
- Set<OperationalScope> opScopeChoices;
- opScopeChoices = new HashSet<>();
- opScopeChoices.add(OperationalScope.Core);
- opScopeChoices.add(OperationalScope.CPU);
- opScopeChoices.add(OperationalScope.Network_Wide);
- EntitlementPoolEntity ep2 =
- createEntitlementPool("vlm4Id", null, ep1_id,EP1_NAME, "EP2 dec", 70,
- ThresholdUnit.Absolute,
- EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average, null,
- opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
- ep2.setStartDate(LocalDate.now().format(formatter));
- ep2.setExpiryDate(LocalDate.now().format(formatter));
- ep2.setVendorLicenseModelId(vlm1_id);
- vendorLicenseManagerImpl.createEntitlementPool(ep2, USER1).getId();
- Assert.fail();
- }
+ doReturn(entitlementPool).when(entitlementPoolDao).get(anyObject());
- @Test
- public void testUpdate() {
- Set<OperationalScope> opScopeChoices;
- opScopeChoices = new HashSet<>();
- opScopeChoices.add(OperationalScope.Core);
- opScopeChoices.add(OperationalScope.CPU);
- opScopeChoices.add(OperationalScope.Network_Wide);
- EntitlementPoolEntity ep2 =
- createEntitlementPool(vlm1_id, VERSION01, ep1_id,EP1_NAME, "EP2 dec", 70,
- ThresholdUnit
- .Absolute,
- EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average, null,
- opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
- ep2.setStartDate(LocalDate.now().minusDays(3L).format(formatter));
- ep2.setExpiryDate(LocalDate.now().minusDays(2L).format(formatter));
+ EntitlementPoolEntity retrived = vendorLicenseManagerImpl.getEntitlementPool(entitlementPool);
- VersionInfo info = new VersionInfo();
- info.getViewableVersions().add(VERSION01);
- info.setActiveVersion(VERSION01);
- doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(),anyObject(),anyObject());
+ Assert.assertEquals(retrived.getId(), entitlementPool.getId());
+ Assert.assertEquals(retrived.getVendorLicenseModelId(),
+ entitlementPool.getVendorLicenseModelId());
+ Assert.assertEquals(retrived.getVersion(), entitlementPool.getVersion());
+ }
- vendorLicenseManagerImpl.updateEntitlementPool(ep2, USER1);
- verify(vendorLicenseFacade).updateEntitlementPool(ep2,USER1);
- verify(vendorLicenseFacade).updateVlmLastModificationTime(vlm1_id,VERSION01);
- }
+ @Test
+ public void testListEntitlmentPool() {
- @Test(expectedExceptions = CoreException.class, expectedExceptionsMessageRegExp = "Vendor " +
- "license model with id vlm1_id has invalid date range.")
- public void updateWithInvalidStartExpiryDateTest() {
+ Set<OperationalScope> opScopeChoices;
+ opScopeChoices = new HashSet<>();
+ opScopeChoices.add(OperationalScope.Core);
+ opScopeChoices.add(OperationalScope.CPU);
+ opScopeChoices.add(OperationalScope.Network_Wide);
- Set<OperationalScope> opScopeChoices;
- opScopeChoices = new HashSet<>();
- opScopeChoices.add(OperationalScope.Core);
- opScopeChoices.add(OperationalScope.CPU);
- opScopeChoices.add(OperationalScope.Network_Wide);
- EntitlementPoolEntity ep2 =
- createEntitlementPool("vlm2Id", null, ep1_id,EP1_NAME, "EP2 dec", 70,
- ThresholdUnit.Absolute,
- EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average, null,
- opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
- ep2.setStartDate(LocalDate.now().format(formatter));
- ep2.setExpiryDate(LocalDate.now().minusDays(2L).format(formatter));
- ep2.setVendorLicenseModelId(vlm1_id);
- vendorLicenseManagerImpl.updateEntitlementPool(ep2, USER1);
- Assert.fail();
+ doReturn(Arrays.asList(
+ createEntitlementPool(vlm1_id, VERSION01, ep1_id, EP1_NAME, "EP1 dec", 70,
+ ThresholdUnit.Absolute, EntitlementMetric.Other, "exception metric1",
+ "inc1", AggregationFunction.Average, null,
+ opScopeChoices, null, EntitlementTime.Other, "time1", "sku1"),
+ createEntitlementPool(vlm1_id, VERSION01, ep2_id, EP2_NAME, "EP2 dec", 70,
+ ThresholdUnit.Absolute, EntitlementMetric.Other, "exception metric2",
+ "inc2", AggregationFunction.Average, null,
+ opScopeChoices, null, EntitlementTime.Other, "time2", "sku2")))
+ .when(vendorLicenseFacade).listEntitlementPools(vlm1_id, VERSION01);
- }
+ Collection<EntitlementPoolEntity> EPs =
+ vendorLicenseManagerImpl.listEntitlementPools(vlm1_id, VERSION01);
- @Test
- public void updateWithoutStartDateTest() {
- try {
-
- Set<OperationalScope> opScopeChoices;
- opScopeChoices = new HashSet<>();
- opScopeChoices.add(OperationalScope.Core);
- opScopeChoices.add(OperationalScope.CPU);
- opScopeChoices.add(OperationalScope.Network_Wide);
- EntitlementPoolEntity ep2 =
- createEntitlementPool("vlm3Id", null, ep1_id,EP1_NAME, "EP2 dec", 70,
- ThresholdUnit.Absolute,
- EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average, null,
- opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
- ep2.setExpiryDate(LocalDate.now().plusDays(2L).format(formatter));
- vendorLicenseManagerImpl.updateEntitlementPool(ep2, USER1);
- Assert.fail();
- } catch (CoreException exception) {
- Assert.assertEquals(exception.code().id(), VendorLicenseErrorCodes.DATE_RANGE_INVALID);
- }
- }
-
- @Test
- public void updateWithSameStartExpiryDateTest() {
- try {
-
- Set<OperationalScope> opScopeChoices;
- opScopeChoices = new HashSet<>();
- opScopeChoices.add(OperationalScope.Core);
- opScopeChoices.add(OperationalScope.CPU);
- opScopeChoices.add(OperationalScope.Network_Wide);
- EntitlementPoolEntity ep2 =
- createEntitlementPool("vlm4Id", null, ep1_id,EP1_NAME, "EP2 dec", 70,
- ThresholdUnit.Absolute,
- EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average, null,
- opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
- ep2.setStartDate(LocalDate.now().format(formatter));
- ep2.setExpiryDate(LocalDate.now().format(formatter));
- vendorLicenseManagerImpl.updateEntitlementPool(ep2, USER1);
- Assert.fail();
- } catch (CoreException exception) {
- Assert.assertEquals(exception.code().id(), VendorLicenseErrorCodes.DATE_RANGE_INVALID);
- }
- }
-
- @Test
- public void deleteEntitlementPoolTest() {
-
- VersionInfo versionInfo = new VersionInfo();
- versionInfo.setActiveVersion(VERSION01);
- versionInfo.setLockingUser(USER1);
- ArrayList<Version> viewable = new ArrayList<Version>();
- viewable.add(VERSION01);
- versionInfo.setViewableVersions(viewable);
-
- doReturn(versionInfo).when(vendorLicenseManagerImpl).getVersionInfo(vlm1_id,
- VersionableEntityAction.Write, USER1);
-
- Set<OperationalScope> opScopeChoices;
- opScopeChoices = new HashSet<>();
- opScopeChoices.add(OperationalScope.Core);
- opScopeChoices.add(OperationalScope.CPU);
- opScopeChoices.add(OperationalScope.Network_Wide);
-
- EntitlementPoolEntity entitlementPool =
- createEntitlementPool(vlm1_id,VERSION01, ep1_id,EP1_NAME, "EP2 dec", 70,
- ThresholdUnit.Absolute,EntitlementMetric.Other, "exception metric2", "inc2",
- AggregationFunction.Average, null,
- opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
- entitlementPool.setStartDate(LocalDate.now().format(formatter));
- entitlementPool.setExpiryDate(LocalDate.now().plusDays(1L).format(formatter));
-
- doReturn(entitlementPool).when(entitlementPoolDao).get(anyObject());
-
- doNothing().when(vendorLicenseManagerImpl).deleteChildLimits(vlm1_id,VERSION01,ep1_id,USER1);
-
- doNothing().when(vendorLicenseManagerImpl).deleteUniqueName(anyObject(),anyObject(),
- anyObject(),anyObject());
-
- vendorLicenseManagerImpl.deleteEntitlementPool(entitlementPool, USER1);
-
- verify(entitlementPoolDao).delete(entitlementPool);
- verify(vendorLicenseFacade).updateVlmLastModificationTime(vlm1_id,VERSION01);
-
- }
-
- @Test
- public void testGetEntitlementPool(){
-
- VersionInfo versionInfo = new VersionInfo();
- versionInfo.setActiveVersion(VERSION01);
- versionInfo.setLockingUser(USER1);
- ArrayList<Version> viewable = new ArrayList<Version>();
- viewable.add(VERSION01);
- versionInfo.setViewableVersions(viewable);
- versionInfo.setActiveVersion(VERSION01);
-
- doReturn(versionInfo).when(vendorLicenseManagerImpl).getVersionInfo(vlm1_id,
- VersionableEntityAction.Read, USER1);
-
- Set<OperationalScope> opScopeChoices;
- opScopeChoices = new HashSet<>();
- opScopeChoices.add(OperationalScope.Core);
- opScopeChoices.add(OperationalScope.CPU);
- opScopeChoices.add(OperationalScope.Network_Wide);
-
- EntitlementPoolEntity entitlementPool =
- createEntitlementPool(vlm1_id,VERSION01, ep1_id,EP1_NAME, "EP2 dec", 70,
- ThresholdUnit.Absolute,EntitlementMetric.Other, "exception metric2", "inc2",
- AggregationFunction.Average, null,
- opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy'T'HH:mm:ss'Z'");
-
- entitlementPool.setStartDate(LocalDateTime.now().format(formatter));
- entitlementPool.setExpiryDate(LocalDateTime.now().plusDays(1L).format(formatter));
-
- doReturn(entitlementPool).when(entitlementPoolDao).get(anyObject());
-
- EntitlementPoolEntity retrived = vendorLicenseManagerImpl.getEntitlementPool
- (entitlementPool,USER1);
-
- Assert.assertEquals(retrived.getId(),entitlementPool.getId());
- Assert.assertEquals(retrived.getVendorLicenseModelId(),entitlementPool.getVendorLicenseModelId());
- Assert.assertEquals(retrived.getVersion(),entitlementPool.getVersion());
- }
-
- @Test
- public void testListEntitlmentPool(){
-
- Set<OperationalScope> opScopeChoices;
- opScopeChoices = new HashSet<>();
- opScopeChoices.add(OperationalScope.Core);
- opScopeChoices.add(OperationalScope.CPU);
- opScopeChoices.add(OperationalScope.Network_Wide);
-
- doReturn(Arrays.asList(
- createEntitlementPool(vlm1_id,VERSION01, ep1_id, EP1_NAME,"EP1 dec", 70,
- ThresholdUnit.Absolute,EntitlementMetric.Other, "exception metric1",
- "inc1", AggregationFunction.Average, null,
- opScopeChoices, null, EntitlementTime.Other, "time1", "sku1"),
- createEntitlementPool(vlm1_id,VERSION01, ep2_id, EP2_NAME,"EP2 dec", 70,
- ThresholdUnit.Absolute,EntitlementMetric.Other, "exception metric2",
- "inc2", AggregationFunction.Average, null,
- opScopeChoices, null, EntitlementTime.Other, "time2", "sku2")))
- .when(vendorLicenseFacade).listEntitlementPools(vlm1_id, VERSION01, USER1);
-
- Collection<EntitlementPoolEntity> EPs =
- vendorLicenseManagerImpl.listEntitlementPools(vlm1_id, VERSION01, USER1);
-
- verify(vendorLicenseFacade).listEntitlementPools(vlm1_id, VERSION01, USER1);
- Assert.assertEquals(EPs.size(), 2);
- EPs.forEach(ep -> Assert.assertTrue(ep.getId().matches(ep1_id + "|" + ep2_id)));
- }
+ verify(vendorLicenseFacade).listEntitlementPools(vlm1_id, VERSION01);
+ Assert.assertEquals(EPs.size(), 2);
+ EPs.forEach(ep -> Assert.assertTrue(ep.getId().matches(ep1_id + "|" + ep2_id)));
+ }
/* @Test
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/FeatureGroupTest.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/FeatureGroupTest.java
index dd35606..b9eacc3 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/FeatureGroupTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/FeatureGroupTest.java
@@ -21,35 +21,27 @@
package org.openecomp.sdc.vendorlicense.impl;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.doReturn;
-
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
-import org.openecomp.sdc.activityLog.ActivityLogManager;
import org.openecomp.sdc.vendorlicense.VendorLicenseConstants;
-import org.openecomp.sdc.vendorlicense.dao.*;
-import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther;
+import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDao;
+import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDao;
+import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDao;
+import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDao;
+import org.openecomp.sdc.vendorlicense.dao.LimitDao;
+import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDao;
import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity;
import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseTerm;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
-import org.openecomp.sdc.vendorlicense.facade.impl.VendorLicenseFacadeImpl;
-import org.openecomp.sdc.vendorlicense.impl.VendorLicenseManagerImpl;
import org.openecomp.sdc.versioning.VersioningManager;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.VersionInfo;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
import org.testng.Assert;
-import org.testng.AssertJUnit.*;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
@@ -58,7 +50,6 @@
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
/**
@@ -66,272 +57,254 @@
*/
public class FeatureGroupTest {
- //JUnit Test Cases using Mockito
- private static final Version VERSION01 = new Version(0, 1);
- private static final Version VERSION10 = new Version(1, 0);
- private final String FG1_NAME = "FG1 name";
- private static final String USER1 = "TestUser1";
- private static final String USER2 = "TestUser2";
+ //JUnit Test Cases using Mockito
+ private static final Version VERSION01 = new Version(0, 1);
+ private static final Version VERSION10 = new Version(1, 0);
+ private final String FG1_NAME = "FG1 name";
+ private static final String USER1 = "TestUser1";
+ private static final String USER2 = "TestUser2";
- private static String vlm1_id = "vlm1_id";
- private static String vlm2_id = "vlm2_id";
- private static String lkg1_id = "lkg1_id";
- private static String lkg2_id = "lkg2_id";
- private static String fg1_id = "fg1_id";
- private static String fg2_id = "fg2_id";
- private static String ep1_id = "ep1_id";
- private static String ep2_id = "ep2_id";
+ private static String vlm1_id = "vlm1_id";
+ private static String vlm2_id = "vlm2_id";
+ private static String lkg1_id = "lkg1_id";
+ private static String lkg2_id = "lkg2_id";
+ private static String fg1_id = "fg1_id";
+ private static String fg2_id = "fg2_id";
+ private static String ep1_id = "ep1_id";
+ private static String ep2_id = "ep2_id";
- @Mock
- private VendorLicenseFacade vendorLicenseFacadeMcok;
+ @Mock
+ private VendorLicenseFacade vendorLicenseFacadeMcok;
- @Mock
- private LimitDao limitDaoMcok;
- @Mock
- private ActivityLogManager activityLogManagerMcok;
+ @Mock
+ private LimitDao limitDaoMcok;
- @Mock
- private VendorLicenseModelDao vendorLicenseModelDao;
+ @Mock
+ private VendorLicenseModelDao vendorLicenseModelDao;
- @Mock
- private LicenseAgreementDao licenseAgreementDao;
+ @Mock
+ private LicenseAgreementDao licenseAgreementDao;
- @Mock
- private FeatureGroupDao featureGroupDao;
+ @Mock
+ private FeatureGroupDao featureGroupDao;
- @Mock
- private EntitlementPoolDao entitlementPoolDao;
+ @Mock
+ private EntitlementPoolDao entitlementPoolDao;
- @Mock
- private LicenseKeyGroupDao licenseKeyGroupDao;
+ @Mock
+ private LicenseKeyGroupDao licenseKeyGroupDao;
- @Mock
- private VersioningManager versioningManager;
+ @Mock
+ private VersioningManager versioningManager;
- @InjectMocks
- @Spy
- private VendorLicenseManagerImpl vendorLicenseManagerImpl;
+ @InjectMocks
+ @Spy
+ private VendorLicenseManagerImpl vendorLicenseManagerImpl;
- public FeatureGroupEntity updateFeatureGroup(String vlmId, Version version, String id, String name, String desc,
- String partNumber, String manufacturerReferenceNumber, Set<String>
- licenseKeyGroupIds, Set<String> entitlementPoolIds, Set<String>
- referencingLicenseAgreements){
- FeatureGroupEntity featureGroup = new FeatureGroupEntity(vlmId, version, id);
- featureGroup.setVendorLicenseModelId(vlmId);
- featureGroup.setVersion(version);
- featureGroup.setId(id);
- featureGroup.setName(name);
- featureGroup.setDescription(desc);
- featureGroup.setPartNumber(partNumber);
- //featureGroup.setManufacturerReferenceNumber(manufacturerReferenceNumber);
- featureGroup.setLicenseKeyGroupIds(licenseKeyGroupIds);
- featureGroup.setEntitlementPoolIds(entitlementPoolIds);
- featureGroup.setReferencingLicenseAgreements(referencingLicenseAgreements);
+ public FeatureGroupEntity updateFeatureGroup(String vlmId, Version version, String id,
+ String name, String desc,
+ String partNumber,
+ String manufacturerReferenceNumber, Set<String>
+ licenseKeyGroupIds,
+ Set<String> entitlementPoolIds, Set<String>
+ referencingLicenseAgreements) {
+ FeatureGroupEntity featureGroup = new FeatureGroupEntity(vlmId, version, id);
+ featureGroup.setVendorLicenseModelId(vlmId);
+ featureGroup.setVersion(version);
+ featureGroup.setId(id);
+ featureGroup.setName(name);
+ featureGroup.setDescription(desc);
+ featureGroup.setPartNumber(partNumber);
+ //featureGroup.setManufacturerReferenceNumber(manufacturerReferenceNumber);
+ featureGroup.setLicenseKeyGroupIds(licenseKeyGroupIds);
+ featureGroup.setEntitlementPoolIds(entitlementPoolIds);
+ featureGroup.setReferencingLicenseAgreements(referencingLicenseAgreements);
- return featureGroup;
- }
+ return featureGroup;
+ }
- @BeforeMethod
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- }
+ @BeforeMethod
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
- @Test
- public void testUpdate(){
- Set<String> licenseKeyGroupIds;
- licenseKeyGroupIds = new HashSet<>();
- licenseKeyGroupIds.add("lkg1");
+ @Test
+ public void testUpdate() {
+ Set<String> licenseKeyGroupIds;
+ licenseKeyGroupIds = new HashSet<>();
+ licenseKeyGroupIds.add("lkg1");
- Set<String> entitlementPoolIds;
- entitlementPoolIds = new HashSet<>();
- entitlementPoolIds.add("ep1");
+ Set<String> entitlementPoolIds;
+ entitlementPoolIds = new HashSet<>();
+ entitlementPoolIds.add("ep1");
- Set<String> referencingLicenseAgreements;
- referencingLicenseAgreements = new HashSet<>();
- referencingLicenseAgreements.add("la1");
+ Set<String> referencingLicenseAgreements;
+ referencingLicenseAgreements = new HashSet<>();
+ referencingLicenseAgreements.add("la1");
- FeatureGroupEntity featureGroupEntity = updateFeatureGroup("vlmId", VERSION01, "fgId", FG1_NAME, "fg1 desc",
+ FeatureGroupEntity featureGroupEntity =
+ updateFeatureGroup("vlmId", VERSION01, "fgId", FG1_NAME, "fg1 desc",
"partNumber", "MRN", licenseKeyGroupIds, entitlementPoolIds,
referencingLicenseAgreements);
- doReturn(featureGroupEntity).when(featureGroupDao).get(anyObject());
+ doReturn(featureGroupEntity).when(featureGroupDao).get(anyObject());
/*if(featureGroupEntity.getManufacturerReferenceNumber() != null)
featureGroupDao.update(featureGroupEntity);
verify(featureGroupDao).update(anyObject());*/
- }
+ }
- @Test
- public void testUpdateWithoutManufacturingReferenceNumber(){
- Set<String> licenseKeyGroupIds;
- licenseKeyGroupIds = new HashSet<>();
- licenseKeyGroupIds.add("lkg1");
+ @Test
+ public void testUpdateWithoutManufacturingReferenceNumber() {
+ Set<String> licenseKeyGroupIds;
+ licenseKeyGroupIds = new HashSet<>();
+ licenseKeyGroupIds.add("lkg1");
- Set<String> entitlementPoolIds;
- entitlementPoolIds = new HashSet<>();
- entitlementPoolIds.add("ep1");
+ Set<String> entitlementPoolIds;
+ entitlementPoolIds = new HashSet<>();
+ entitlementPoolIds.add("ep1");
- Set<String> referencingLicenseAgreements;
- referencingLicenseAgreements = new HashSet<>();
- referencingLicenseAgreements.add("la1");
+ Set<String> referencingLicenseAgreements;
+ referencingLicenseAgreements = new HashSet<>();
+ referencingLicenseAgreements.add("la1");
- FeatureGroupEntity featureGroupEntity = updateFeatureGroup("vlmId", VERSION01, "fgId", FG1_NAME, "fg1 desc",
+ FeatureGroupEntity featureGroupEntity =
+ updateFeatureGroup("vlmId", VERSION01, "fgId", FG1_NAME, "fg1 desc",
"partNumber", null, licenseKeyGroupIds, entitlementPoolIds,
referencingLicenseAgreements);
- doReturn(featureGroupEntity).when(featureGroupDao).get(anyObject());
+ doReturn(featureGroupEntity).when(featureGroupDao).get(anyObject());
/*if(featureGroupEntity.getManufacturerReferenceNumber() != null)
featureGroupDao.update(featureGroupEntity);
verify(featureGroupDao, never()).update(anyObject());*/
- }
+ }
- @Test
- public void testListFeatureGroups() {
- doReturn(Arrays.asList(
- createFeatureGroup(vlm1_id, VERSION01, fg1_id, "FG1", "FG1 desc", new HashSet<String>(),
- new HashSet<String>()),
- createFeatureGroup(vlm1_id, VERSION01, fg2_id, "FG2", "FG2 desc", new HashSet<String>(),
- new HashSet<String>())))
- .when(vendorLicenseFacadeMcok).listFeatureGroups(vlm1_id, VERSION01, USER1);
+ @Test
+ public void testListFeatureGroups() {
+ doReturn(Arrays.asList(
+ createFeatureGroup(vlm1_id, VERSION01, fg1_id, "FG1", "FG1 desc", new HashSet<String>(),
+ new HashSet<String>()),
+ createFeatureGroup(vlm1_id, VERSION01, fg2_id, "FG2", "FG2 desc", new HashSet<String>(),
+ new HashSet<String>())))
+ .when(vendorLicenseFacadeMcok).listFeatureGroups(vlm1_id, VERSION01);
- Collection<FeatureGroupEntity> FGs =
- vendorLicenseManagerImpl.listFeatureGroups(vlm1_id, VERSION01, USER1);
+ Collection<FeatureGroupEntity> FGs =
+ vendorLicenseManagerImpl.listFeatureGroups(vlm1_id, VERSION01);
- verify(vendorLicenseFacadeMcok).listFeatureGroups(vlm1_id, VERSION01, USER1);
- Assert.assertEquals(FGs.size(), 2);
- FGs.forEach(fg -> Assert.assertTrue(fg.getId().matches(fg1_id + "|" + fg2_id)));
- }
+ verify(vendorLicenseFacadeMcok).listFeatureGroups(vlm1_id, VERSION01);
+ Assert.assertEquals(FGs.size(), 2);
+ FGs.forEach(fg -> Assert.assertTrue(fg.getId().matches(fg1_id + "|" + fg2_id)));
+ }
- @Test
- public void testCreateFeatureGroup() {
- FeatureGroupEntity featureGroupEntity = new FeatureGroupEntity(vlm1_id,VERSION01,
- fg1_id);
+ @Test
+ public void testCreateFeatureGroup() {
+ FeatureGroupEntity featureGroupEntity = new FeatureGroupEntity(vlm1_id, VERSION01,
+ fg1_id);
- doReturn(featureGroupEntity).when(vendorLicenseFacadeMcok).createFeatureGroup
- (featureGroupEntity,USER1);
+ doReturn(featureGroupEntity).when(vendorLicenseFacadeMcok).createFeatureGroup
+ (featureGroupEntity);
- vendorLicenseManagerImpl.createFeatureGroup(featureGroupEntity,USER1);
+ vendorLicenseManagerImpl.createFeatureGroup(featureGroupEntity);
- verify(vendorLicenseFacadeMcok).createFeatureGroup(featureGroupEntity,USER1);
- }
+ verify(vendorLicenseFacadeMcok).createFeatureGroup(featureGroupEntity);
+ }
- @Test
- public void testUpdateFeatureGroup(){
- VersionInfo versionInfo = new VersionInfo();
- versionInfo.setActiveVersion(VERSION01);
- versionInfo.setLockingUser(USER1);
- ArrayList<Version> viewable = new ArrayList<Version>();
- viewable.add(VERSION01);
- versionInfo.setViewableVersions(viewable);
+ @Test
+ public void testUpdateFeatureGroup() {
+ FeatureGroupEntity existingFG = new FeatureGroupEntity(vlm1_id, VERSION01, fg1_id);
- doReturn(versionInfo).when(vendorLicenseManagerImpl).getVersionInfo(vlm1_id,
- VersionableEntityAction.Write, USER1);
- FeatureGroupEntity existingFG = new FeatureGroupEntity(vlm1_id, VERSION01, fg1_id);
+ existingFG.setEntitlementPoolIds(new HashSet<String>());
+ existingFG.setLicenseKeyGroupIds(new HashSet<String>());
- existingFG.setEntitlementPoolIds(new HashSet<String>());
- existingFG.setLicenseKeyGroupIds(new HashSet<String>());
+ doReturn(existingFG).when(featureGroupDao).get(existingFG);
- doReturn(existingFG).when(featureGroupDao).get(existingFG);
+ Set<String> removedEPs = new HashSet<>();
+ Set<String> addedEPs = new HashSet<>();
- Set<String> removedEPs = new HashSet<>();
- Set<String> addedEPs = new HashSet<>();
+ addedEPs.add(ep1_id);
+ addedEPs.add(ep2_id);
+ EntitlementPoolEntity ep1 = new EntitlementPoolEntity(vlm1_id, VERSION01, ep1_id);
+ EntitlementPoolEntity ep2 = new EntitlementPoolEntity(vlm1_id, VERSION01, ep2_id);
+ doReturn(ep1).when(entitlementPoolDao).get(ep1);
+ doReturn(ep2).when(entitlementPoolDao).get(ep2);
- addedEPs.add(ep1_id);
- addedEPs.add(ep2_id);
- EntitlementPoolEntity ep1 = new EntitlementPoolEntity(vlm1_id, VERSION01, ep1_id);
- EntitlementPoolEntity ep2 = new EntitlementPoolEntity(vlm1_id, VERSION01, ep2_id);
- doReturn(ep1).when(entitlementPoolDao).get(ep1);
- doReturn(ep2).when(entitlementPoolDao).get(ep2);
+ Set<String> removedLKGs = new HashSet<>();
+ Set<String> addedLKGs = new HashSet<>();
- Set<String> removedLKGs = new HashSet<>();
- Set<String> addedLKGs = new HashSet<>();
+ addedLKGs.add(lkg1_id);
+ addedLKGs.add(lkg2_id);
+ LicenseKeyGroupEntity lkg1 = new LicenseKeyGroupEntity(vlm1_id, VERSION01, lkg1_id);
+ LicenseKeyGroupEntity lkg2 = new LicenseKeyGroupEntity(vlm1_id, VERSION01, lkg2_id);
+ doReturn(lkg1).when(licenseKeyGroupDao).get(lkg1);
+ doReturn(lkg2).when(licenseKeyGroupDao).get(lkg2);
- addedLKGs.add(lkg1_id);
- addedLKGs.add(lkg2_id);
- LicenseKeyGroupEntity lkg1 = new LicenseKeyGroupEntity(vlm1_id, VERSION01, lkg1_id);
- LicenseKeyGroupEntity lkg2 = new LicenseKeyGroupEntity(vlm1_id, VERSION01, lkg2_id);
- doReturn(lkg1).when(licenseKeyGroupDao).get(lkg1);
- doReturn(lkg2).when(licenseKeyGroupDao).get(lkg2);
+ doNothing().when(vendorLicenseManagerImpl).updateUniqueName(anyObject(), anyObject(),
+ anyObject(), anyObject(), anyObject());
- doNothing().when(vendorLicenseManagerImpl).updateUniqueName(anyObject(), anyObject(),
- anyObject(),anyObject(), anyObject());
+ vendorLicenseManagerImpl.updateFeatureGroup(existingFG, addedLKGs, removedLKGs, addedEPs,
+ removedEPs);
- vendorLicenseManagerImpl.updateFeatureGroup(existingFG,addedLKGs,removedLKGs, addedEPs,
- removedEPs, USER1);
+ verify(vendorLicenseManagerImpl).addLicenseKeyGroupsToFeatureGroupsRef(addedLKGs,
+ existingFG);
+ verify(vendorLicenseManagerImpl).removeLicenseKeyGroupsToFeatureGroupsRef(removedLKGs,
+ existingFG);
+ verify(vendorLicenseManagerImpl).addEntitlementPoolsToFeatureGroupsRef(addedEPs, existingFG);
+ verify(vendorLicenseManagerImpl).removeEntitlementPoolsToFeatureGroupsRef(removedEPs,
+ existingFG);
- verify(vendorLicenseManagerImpl).addLicenseKeyGroupsToFeatureGroupsRef(addedLKGs,
- existingFG);
- verify(vendorLicenseManagerImpl).removeLicenseKeyGroupsToFeatureGroupsRef(removedLKGs,
- existingFG);
- verify(vendorLicenseManagerImpl).addEntitlementPoolsToFeatureGroupsRef(addedEPs,existingFG);
- verify(vendorLicenseManagerImpl).removeEntitlementPoolsToFeatureGroupsRef(removedEPs,
- existingFG);
-
- verify(featureGroupDao)
- .updateFeatureGroup(existingFG,addedEPs,removedEPs, addedLKGs, removedLKGs);
- verify(vendorLicenseFacadeMcok).updateVlmLastModificationTime(vlm1_id,VERSION01);
- }
+ verify(featureGroupDao)
+ .updateFeatureGroup(existingFG, addedEPs, removedEPs, addedLKGs, removedLKGs);
+ }
- @Test
- public void testGetFeatureGroup(){
- FeatureGroupEntity featureGroupEntity = new FeatureGroupEntity(vlm1_id,VERSION01,fg1_id);
- vendorLicenseManagerImpl.getFeatureGroupModel(featureGroupEntity,USER1);
- verify(vendorLicenseFacadeMcok).getFeatureGroupModel(featureGroupEntity,USER1);
- }
+ @Test
+ public void testGetFeatureGroup() {
+ FeatureGroupEntity featureGroupEntity = new FeatureGroupEntity(vlm1_id, VERSION01, fg1_id);
+ vendorLicenseManagerImpl.getFeatureGroupModel(featureGroupEntity);
+ verify(vendorLicenseFacadeMcok).getFeatureGroupModel(featureGroupEntity);
+ }
- @Test
- public void deleteFeatureGroupTest() {
+ @Test
+ public void deleteFeatureGroupTest() {
- VersionInfo versionInfo = new VersionInfo();
- versionInfo.setActiveVersion(VERSION01);
- versionInfo.setLockingUser(USER1);
- ArrayList<Version> viewable = new ArrayList<Version>();
- viewable.add(VERSION01);
- versionInfo.setViewableVersions(viewable);
+ FeatureGroupEntity existingFG = new FeatureGroupEntity(vlm1_id, VERSION01, fg1_id);
+ existingFG.setName("FG_name");
+ existingFG.setLicenseKeyGroupIds(new HashSet<String>());
+ existingFG.setEntitlementPoolIds(new HashSet<String>());
+ existingFG.setLicenseKeyGroupIds(new HashSet<String>());
- doReturn(versionInfo).when(vendorLicenseManagerImpl).getVersionInfo(vlm1_id,
- VersionableEntityAction.Write, USER1);
+ doReturn(existingFG).when(featureGroupDao).get(anyObject());
- FeatureGroupEntity existingFG = new FeatureGroupEntity(vlm1_id, VERSION01, fg1_id);
- existingFG.setName("FG_name");
- existingFG.setLicenseKeyGroupIds(new HashSet<String>());
- existingFG.setEntitlementPoolIds(new HashSet<String>());
- existingFG.setLicenseKeyGroupIds(new HashSet<String>());
+ doNothing().when(vendorLicenseManagerImpl).deleteUniqueName(VendorLicenseConstants
+ .UniqueValues.FEATURE_GROUP_NAME, vlm1_id, VERSION01.toString(), existingFG.getName());
- doReturn(existingFG).when(featureGroupDao).get(anyObject());
+ vendorLicenseManagerImpl.deleteFeatureGroup(existingFG);
- doNothing().when(vendorLicenseManagerImpl).deleteUniqueName(VendorLicenseConstants
- .UniqueValues.FEATURE_GROUP_NAME,vlm1_id,VERSION01.toString(),existingFG.getName());
+ verify(featureGroupDao).delete(existingFG);
- vendorLicenseManagerImpl.deleteFeatureGroup(existingFG, USER1);
+ verify(vendorLicenseManagerImpl).removeLicenseKeyGroupsToFeatureGroupsRef(existingFG
+ .getLicenseKeyGroupIds(), existingFG);
+ verify(vendorLicenseManagerImpl).removeEntitlementPoolsToFeatureGroupsRef(existingFG
+ .getEntitlementPoolIds(), existingFG);
+ verify(vendorLicenseManagerImpl).deleteUniqueName(VendorLicenseConstants
+ .UniqueValues.FEATURE_GROUP_NAME, vlm1_id, VERSION01.toString(), existingFG.getName());
+ }
- verify(featureGroupDao).delete(existingFG);
- verify(vendorLicenseFacadeMcok).updateVlmLastModificationTime(vlm1_id,VERSION01);
-
- verify(vendorLicenseManagerImpl).removeLicenseKeyGroupsToFeatureGroupsRef(existingFG
- .getLicenseKeyGroupIds(),existingFG);
- verify(vendorLicenseManagerImpl).removeEntitlementPoolsToFeatureGroupsRef(existingFG
- .getEntitlementPoolIds(),existingFG);
- verify(vendorLicenseManagerImpl).deleteUniqueName(VendorLicenseConstants
- .UniqueValues.FEATURE_GROUP_NAME,vlm1_id,VERSION01.toString(),existingFG.getName());
- }
-
- private FeatureGroupEntity createFeatureGroup(String vendorId, Version version, String id,
- String name, String description,
- Set<String> entitlementPoolIds,
- Set<String> licenseKeyGroupIds) {
- FeatureGroupEntity featureGroup = new FeatureGroupEntity();
- featureGroup.setVendorLicenseModelId(vendorId);
- featureGroup.setVersion(version);
- featureGroup.setId(id);
- featureGroup.setName(name);
- featureGroup.setDescription(description);
- featureGroup.setEntitlementPoolIds(entitlementPoolIds);
- featureGroup.setLicenseKeyGroupIds(licenseKeyGroupIds);
- return featureGroup;
- }
+ private FeatureGroupEntity createFeatureGroup(String vendorId, Version version, String id,
+ String name, String description,
+ Set<String> entitlementPoolIds,
+ Set<String> licenseKeyGroupIds) {
+ FeatureGroupEntity featureGroup = new FeatureGroupEntity();
+ featureGroup.setVendorLicenseModelId(vendorId);
+ featureGroup.setVersion(version);
+ featureGroup.setId(id);
+ featureGroup.setName(name);
+ featureGroup.setDescription(description);
+ featureGroup.setEntitlementPoolIds(entitlementPoolIds);
+ featureGroup.setLicenseKeyGroupIds(licenseKeyGroupIds);
+ return featureGroup;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/LicenseAgreementTest.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/LicenseAgreementTest.java
index b0b5953..91435e8 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/LicenseAgreementTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/LicenseAgreementTest.java
@@ -26,17 +26,11 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
-import org.openecomp.core.util.UniqueValueUtil;
-import org.openecomp.core.utilities.CommonMethods;
-import org.openecomp.sdc.activityLog.ActivityLogManager;
import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
-import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.vendorlicense.VendorLicenseConstants;
import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDao;
import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDao;
-import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDaoFactory;
import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDao;
-import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDaoFactory;
import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDao;
import org.openecomp.sdc.vendorlicense.dao.LimitDao;
import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDao;
@@ -44,36 +38,24 @@
import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity;
import org.openecomp.sdc.vendorlicense.dao.types.LicenseTerm;
-import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
-import org.openecomp.sdc.vendorlicense.impl.VendorLicenseManagerImpl;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
import org.openecomp.sdc.versioning.VersioningManager;
-import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.VersionInfo;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.verify;
-import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE;
-import static org.testng.AssertJUnit.assertEquals;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
+
public class LicenseAgreementTest {
private static final String USER1 = "TestUser1";
@@ -104,8 +86,6 @@
private LicenseKeyGroupDao licenseKeyGroupDaoMcok;
@Mock
private LimitDao limitDaoMcok;
- @Mock
- private ActivityLogManager activityLogManagerMcok;
@Spy
@@ -160,12 +140,12 @@
@Test
public void listLicenseAgreementsTest() {
- LicenseAgreementEntity la = new LicenseAgreementEntity(vlm1_id,VERSION01,USER1);
- doReturn(la).when(vendorLicenseManager).createLicenseAgreementForList(vlm1_id,VERSION01, USER1);
+ LicenseAgreementEntity la =
+ new LicenseAgreementEntity(vlm1_id, VERSION01, null); // TODO: 8/13/2017
doReturn(Arrays.asList(
createLicenseAgreement(vlm1_id, VERSION01, la1_id, "LA1", "LA1 " +
- "desc","RequirementsAndConstrains2", new ChoiceOrOther<>(LicenseTerm.Unlimited, null),
+ "desc", "RequirementsAndConstrains2", new ChoiceOrOther<>(LicenseTerm.Unlimited, null),
"fg1"),
createLicenseAgreement(vlm1_id, VERSION01, la2_id, "LA2", "LA2 desc",
"RequirementsAndConstrains2", new ChoiceOrOther<>(LicenseTerm.Unlimited, null),
@@ -173,23 +153,23 @@
.when(licenseAgreementDaoMcok).list(la);
Collection<LicenseAgreementEntity> LAs =
- vendorLicenseManager.listLicenseAgreements(vlm1_id, VERSION01, USER1);
+ vendorLicenseManager.listLicenseAgreements(vlm1_id, VERSION01);
Assert.assertEquals(LAs.size(), 2);
- LAs.forEach(licseAgreement-> Assert.assertTrue(licseAgreement.getId().matches(la1_id + "|" + la2_id)));
+ LAs.forEach(
+ licseAgreement -> Assert.assertTrue(licseAgreement.getId().matches(la1_id + "|" + la2_id)));
}
@Test
public void testListLicenseAgreementsWhenNone() {
- LicenseAgreementEntity la = new LicenseAgreementEntity(vlm1_id,VERSION01,USER1);
- doReturn(la).when(vendorLicenseManager).createLicenseAgreementForList(vlm1_id,VERSION01,
- USER1);
+ LicenseAgreementEntity la =
+ new LicenseAgreementEntity(vlm1_id, VERSION01, null); // TODO: 8/13/2017
doReturn(new ArrayList<LicenseAgreementEntity>())
.when(licenseAgreementDaoMcok).list(la);
Collection<LicenseAgreementEntity> LAs =
- vendorLicenseManager.listLicenseAgreements(vlm1_id, VERSION01, USER1);
+ vendorLicenseManager.listLicenseAgreements(vlm1_id, VERSION01);
verify(licenseAgreementDaoMcok).list(la);
Assert.assertEquals(LAs.size(), 0);
@@ -199,29 +179,19 @@
@Test
public void testCreateLicenseAgreement() {
- LicenseAgreementEntity licenseAgreementEntity = new LicenseAgreementEntity(vlm1_id,VERSION01,
+ LicenseAgreementEntity licenseAgreementEntity = new LicenseAgreementEntity(vlm1_id, VERSION01,
la2_id);
doReturn(licenseAgreementEntity).when(vendorLicenseFacadeMcok).createLicenseAgreement
- (licenseAgreementEntity,USER1);
+ (licenseAgreementEntity);
- vendorLicenseManager.createLicenseAgreement(licenseAgreementEntity,USER1);
+ vendorLicenseManager.createLicenseAgreement(licenseAgreementEntity);
- verify(vendorLicenseFacadeMcok).createLicenseAgreement(licenseAgreementEntity,USER1);
+ verify(vendorLicenseFacadeMcok).createLicenseAgreement(licenseAgreementEntity);
}
@Test
public void testUpdateLicenseAgreement() {
-
- VersionInfo versionInfo = new VersionInfo();
- versionInfo.setActiveVersion(VERSION01);
- versionInfo.setLockingUser(USER1);
- ArrayList<Version> viewable = new ArrayList<Version>();
- viewable.add(VERSION01);
- versionInfo.setViewableVersions(viewable);
-
- doReturn(versionInfo).when(vendorLicenseManager).getVersionInfo(vlm1_id,
- VersionableEntityAction.Write, USER1);
LicenseAgreementEntity existingLA = new LicenseAgreementEntity(vlm1_id, VERSION01, la1_id);
existingLA.setFeatureGroupIds(new HashSet<String>());
@@ -236,34 +206,20 @@
FeatureGroupEntity fg2 = new FeatureGroupEntity(vlm1_id, VERSION01, fg2_id);
doReturn(fg1).when(featureGroupDaoMcok).get(fg1);
doReturn(fg2).when(featureGroupDaoMcok).get(fg2);
- doReturn(existingLA).when(vendorLicenseManager).createLicenseAgreementForList(vlm1_id,VERSION01,
- USER1);
doNothing().when(vendorLicenseManager).updateUniqueName(anyObject(), anyObject(), anyObject(),
anyObject(), anyObject());
- vendorLicenseManager.updateLicenseAgreement(existingLA, addedFGs, removedFGs, USER1);
+ vendorLicenseManager.updateLicenseAgreement(existingLA, addedFGs, removedFGs);
verify(licenseAgreementDaoMcok)
.updateColumnsAndDeltaFeatureGroupIds(existingLA, addedFGs, removedFGs);
- verify(vendorLicenseManager).addFeatureGroupsToLicenseAgreementRef(addedFGs,existingLA);
- verify(vendorLicenseManager).removeFeatureGroupsToLicenseAgreementRef(removedFGs,existingLA);
- verify(vendorLicenseFacadeMcok).updateVlmLastModificationTime(vlm1_id,VERSION01);
+ verify(vendorLicenseManager).addFeatureGroupsToLicenseAgreementRef(addedFGs, existingLA);
+ verify(vendorLicenseManager).removeFeatureGroupsToLicenseAgreementRef(removedFGs, existingLA);
}
@Test
public void deleteLicenseAgreementsTest() {
-
- VersionInfo versionInfo = new VersionInfo();
- versionInfo.setActiveVersion(VERSION01);
- versionInfo.setLockingUser(USER1);
- ArrayList<Version> viewable = new ArrayList<Version>();
- viewable.add(VERSION01);
- versionInfo.setViewableVersions(viewable);
-
- doReturn(versionInfo).when(vendorLicenseManager).getVersionInfo(vlm1_id,
- VersionableEntityAction.Write, USER1);
-
LicenseAgreementEntity existingLA = new LicenseAgreementEntity(vlm1_id, VERSION01, la1_id);
existingLA.setName("LA");
existingLA.setFeatureGroupIds(new HashSet<>());
@@ -271,20 +227,19 @@
doReturn(existingLA).when(licenseAgreementDaoMcok).get(anyObject());
doNothing().when(vendorLicenseManager).deleteUniqueName(VendorLicenseConstants.UniqueValues
- .LICENSE_AGREEMENT_NAME,vlm1_id,VERSION01.toString(),existingLA.getName());
+ .LICENSE_AGREEMENT_NAME, vlm1_id, VERSION01.toString(), existingLA.getName());
- vendorLicenseManager.deleteLicenseAgreement(vlm1_id, VERSION01, la1_id, USER1);
+ vendorLicenseManager.deleteLicenseAgreement(vlm1_id, VERSION01, la1_id);
verify(licenseAgreementDaoMcok).delete(existingLA);
- verify(vendorLicenseFacadeMcok).updateVlmLastModificationTime(vlm1_id,VERSION01);
verify(vendorLicenseManager).removeFeatureGroupsToLicenseAgreementRef(existingLA
- .getFeatureGroupIds(),existingLA);
+ .getFeatureGroupIds(), existingLA);
}
@Test
- public void testGetLicenseAgreement(){
- vendorLicenseManager.getLicenseAgreementModel(vlm1_id,VERSION01,la1_id,USER1);
- verify(vendorLicenseFacadeMcok).getLicenseAgreementModel(vlm1_id,VERSION01,la1_id,USER1);
+ public void testGetLicenseAgreement() {
+ vendorLicenseManager.getLicenseAgreementModel(vlm1_id, VERSION01, la1_id);
+ verify(vendorLicenseFacadeMcok).getLicenseAgreementModel(vlm1_id, VERSION01, la1_id);
}
/*
@@ -300,7 +255,7 @@
featureGroupDao.create(created);
featureGroupDao.addReferencingLicenseAgreement(created, licenseAgreement.getId());
- vendorLicenseManager.deleteFeatureGroup(created, USER1);
+ vendorLicenseManager.deleteFeatureGroup(created);
LicenseAgreementEntity afterDeletingFG = licenseAgreementDao.get(licenseAgreement);
Assert.assertEquals(afterDeletingFG.getFeatureGroupIds().size(), 1);
Assert.assertTrue(afterDeletingFG.getFeatureGroupIds().contains("fg2"));
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/LicenseKeyGroupTest.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/LicenseKeyGroupTest.java
index f0dd383..dc376ee 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/LicenseKeyGroupTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/LicenseKeyGroupTest.java
@@ -26,21 +26,19 @@
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDao;
import org.openecomp.sdc.vendorlicense.dao.LimitDao;
-import org.openecomp.sdc.vendorlicense.dao.types.*;
+import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyType;
+import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther;
+import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope;
import org.openecomp.sdc.vendorlicense.errors.VendorLicenseErrorCodes;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.VersionInfo;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.util.ArrayList;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
@@ -56,10 +54,10 @@
public class LicenseKeyGroupTest {
//JUnit Test Cases using Mockito
- private final String USER = "lkgTestUser";
- private final String LKG_NAME = "LKG name";
- private final String LKG2_NAME = "LKG2 name";
- private final String LT_NAME = "LT name";
+ private final String USER = "lkgTestUser";
+ private final String LKG_NAME = "LKG name";
+ private final String LKG2_NAME = "LKG2 name";
+ private final String LT_NAME = "LT name";
private final String LKG1_NAME = "LKG1 name";
private final String USER1 = "user1";
private static String lkg1_id = "lkg1_id";
@@ -85,15 +83,16 @@
MockitoAnnotations.initMocks(this);
}
- private LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyType type, Set<OperationalScope> operationalScopeChoices,
- String operationalScopeOther)
- {
+ private LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyType type,
+ Set<OperationalScope> operationalScopeChoices,
+ String operationalScopeOther) {
LicenseKeyGroupEntity licenseKeyGroupEntity = new LicenseKeyGroupEntity();
licenseKeyGroupEntity.setType(type);
licenseKeyGroupEntity.setOperationalScope(
new MultiChoiceOrOther<>(operationalScopeChoices, operationalScopeOther));
return licenseKeyGroupEntity;
}
+
/*
@Test
public void deleteLicenseKeyGroupTest() {
@@ -207,14 +206,14 @@
opScopeChoices.add(OperationalScope.CPU);
opScopeChoices.add(OperationalScope.Network_Wide);
LicenseKeyGroupEntity lkg =
- createLicenseKeyGroup("vlm1Id", null,lkg1_id, LKG1_NAME, "LKG1 dec",LicenseKeyType.Unique,
+ createLicenseKeyGroup("vlm1Id", null, lkg1_id, LKG1_NAME, "LKG1 dec", LicenseKeyType.Unique,
new MultiChoiceOrOther<>(opScopeChoices, null));
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
lkg.setStartDate(LocalDate.now().format(formatter));
lkg.setExpiryDate(LocalDate.now().plusDays(1L).format(formatter));
- vendorLicenseManagerImpl.createLicenseKeyGroup(lkg, USER1);
- verify(vendorLicenseFacade).createLicenseKeyGroup(lkg,USER1);
+ vendorLicenseManagerImpl.createLicenseKeyGroup(lkg);
+ verify(vendorLicenseFacade).createLicenseKeyGroup(lkg);
}
@Test
@@ -227,12 +226,13 @@
opScopeChoices.add(OperationalScope.CPU);
opScopeChoices.add(OperationalScope.Network_Wide);
LicenseKeyGroupEntity lkg =
- createLicenseKeyGroup("vlm1Id", null, lkg1_id,LKG1_NAME, "LKG1 dec",LicenseKeyType.Unique,
+ createLicenseKeyGroup("vlm1Id", null, lkg1_id, LKG1_NAME, "LKG1 dec",
+ LicenseKeyType.Unique,
new MultiChoiceOrOther<>(opScopeChoices, null));
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
lkg.setStartDate(LocalDate.now().format(formatter));
lkg.setExpiryDate(LocalDate.now().minusDays(2L).format(formatter));
- vendorLicenseManagerImpl.createLicenseKeyGroup(lkg, USER1);
+ vendorLicenseManagerImpl.createLicenseKeyGroup(lkg);
Assert.fail();
} catch (CoreException exception) {
Assert.assertEquals(exception.code().id(), VendorLicenseErrorCodes.DATE_RANGE_INVALID);
@@ -249,11 +249,12 @@
opScopeChoices.add(OperationalScope.CPU);
opScopeChoices.add(OperationalScope.Network_Wide);
LicenseKeyGroupEntity lkg =
- createLicenseKeyGroup("vlm1Id", null, lkg1_id,LKG1_NAME, "LKG1 dec",LicenseKeyType.Unique,
+ createLicenseKeyGroup("vlm1Id", null, lkg1_id, LKG1_NAME, "LKG1 dec",
+ LicenseKeyType.Unique,
new MultiChoiceOrOther<>(opScopeChoices, null));
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
lkg.setExpiryDate(LocalDate.now().plusDays(2L).format(formatter));
- vendorLicenseManagerImpl.createLicenseKeyGroup(lkg, USER1).getId();
+ vendorLicenseManagerImpl.createLicenseKeyGroup(lkg).getId();
Assert.fail();
} catch (CoreException exception) {
Assert.assertEquals(exception.code().id(), VendorLicenseErrorCodes.DATE_RANGE_INVALID);
@@ -270,12 +271,13 @@
opScopeChoices.add(OperationalScope.CPU);
opScopeChoices.add(OperationalScope.Network_Wide);
LicenseKeyGroupEntity lkg =
- createLicenseKeyGroup("vlm1Id", null, lkg1_id,LKG1_NAME, "LKG1 dec",LicenseKeyType.Unique,
+ createLicenseKeyGroup("vlm1Id", null, lkg1_id, LKG1_NAME, "LKG1 dec",
+ LicenseKeyType.Unique,
new MultiChoiceOrOther<>(opScopeChoices, null));
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
lkg.setStartDate(LocalDate.now().plusDays(2L).format(formatter));
lkg.setExpiryDate(LocalDate.now().plusDays(2L).format(formatter));
- vendorLicenseManagerImpl.createLicenseKeyGroup(lkg, USER1).getId();
+ vendorLicenseManagerImpl.createLicenseKeyGroup(lkg).getId();
Assert.fail();
} catch (CoreException exception) {
Assert.assertEquals(exception.code().id(), VendorLicenseErrorCodes.DATE_RANGE_INVALID);
@@ -290,19 +292,14 @@
opScopeChoices.add(OperationalScope.CPU);
opScopeChoices.add(OperationalScope.Network_Wide);
LicenseKeyGroupEntity lkg =
- createLicenseKeyGroup(vlm1_id, null,lkg1_id, LKG1_NAME, "LKG1 dec",LicenseKeyType.Unique,
+ createLicenseKeyGroup(vlm1_id, null, lkg1_id, LKG1_NAME, "LKG1 dec", LicenseKeyType.Unique,
new MultiChoiceOrOther<>(opScopeChoices, null));
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
lkg.setStartDate(LocalDate.now().minusDays(3L).format(formatter));
lkg.setExpiryDate(LocalDate.now().minusDays(2L).format(formatter));
- VersionInfo info = new VersionInfo();
- info.getViewableVersions().add(VERSION01);
- info.setActiveVersion(VERSION01);
- doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(),anyObject(),anyObject());
- vendorLicenseManagerImpl.updateLicenseKeyGroup(lkg, USER1);
- verify(vendorLicenseFacade).updateLicenseKeyGroup(lkg,USER1);
- verify(vendorLicenseFacade).updateVlmLastModificationTime(vlm1_id,VERSION01);
+ vendorLicenseManagerImpl.updateLicenseKeyGroup(lkg);
+ verify(vendorLicenseFacade).updateLicenseKeyGroup(lkg);
}
@Test
@@ -315,12 +312,13 @@
opScopeChoices.add(OperationalScope.CPU);
opScopeChoices.add(OperationalScope.Network_Wide);
LicenseKeyGroupEntity lkg =
- createLicenseKeyGroup("vlm1Id", null, lkg1_id,LKG1_NAME, "LKG1 dec",LicenseKeyType.Unique,
+ createLicenseKeyGroup("vlm1Id", null, lkg1_id, LKG1_NAME, "LKG1 dec",
+ LicenseKeyType.Unique,
new MultiChoiceOrOther<>(opScopeChoices, null));
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
lkg.setStartDate(LocalDate.now().format(formatter));
lkg.setExpiryDate(LocalDate.now().minusDays(2L).format(formatter));
- vendorLicenseManagerImpl.updateLicenseKeyGroup(lkg, USER1);
+ vendorLicenseManagerImpl.updateLicenseKeyGroup(lkg);
Assert.fail();
} catch (CoreException exception) {
Assert.assertEquals(exception.code().id(), VendorLicenseErrorCodes.DATE_RANGE_INVALID);
@@ -337,11 +335,12 @@
opScopeChoices.add(OperationalScope.CPU);
opScopeChoices.add(OperationalScope.Network_Wide);
LicenseKeyGroupEntity lkg =
- createLicenseKeyGroup("vlm1Id", null, lkg1_id,LKG1_NAME, "LKG1 dec",LicenseKeyType.Unique,
+ createLicenseKeyGroup("vlm1Id", null, lkg1_id, LKG1_NAME, "LKG1 dec",
+ LicenseKeyType.Unique,
new MultiChoiceOrOther<>(opScopeChoices, null));
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
lkg.setExpiryDate(LocalDate.now().plusDays(2L).format(formatter));
- vendorLicenseManagerImpl.updateLicenseKeyGroup(lkg, USER1);
+ vendorLicenseManagerImpl.updateLicenseKeyGroup(lkg);
Assert.fail();
} catch (CoreException exception) {
Assert.assertEquals(exception.code().id(), VendorLicenseErrorCodes.DATE_RANGE_INVALID);
@@ -358,12 +357,13 @@
opScopeChoices.add(OperationalScope.CPU);
opScopeChoices.add(OperationalScope.Network_Wide);
LicenseKeyGroupEntity lkg =
- createLicenseKeyGroup("vlm1Id", null,lkg1_id, LKG1_NAME, "LKG1 dec",LicenseKeyType.Unique,
+ createLicenseKeyGroup("vlm1Id", null, lkg1_id, LKG1_NAME, "LKG1 dec",
+ LicenseKeyType.Unique,
new MultiChoiceOrOther<>(opScopeChoices, null));
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
lkg.setStartDate(LocalDate.now().format(formatter));
lkg.setExpiryDate(LocalDate.now().format(formatter));
- vendorLicenseManagerImpl.updateLicenseKeyGroup(lkg, USER1);
+ vendorLicenseManagerImpl.updateLicenseKeyGroup(lkg);
Assert.fail();
} catch (CoreException exception) {
Assert.assertEquals(exception.code().id(), VendorLicenseErrorCodes.DATE_RANGE_INVALID);
@@ -371,9 +371,10 @@
}
@Test
- public void testListlistLicenseKeyGroups(){
+ public void testListlistLicenseKeyGroups() {
- MultiChoiceOrOther<OperationalScope> multiChoiceOrOther = new MultiChoiceOrOther<OperationalScope>();
+ MultiChoiceOrOther<OperationalScope> multiChoiceOrOther =
+ new MultiChoiceOrOther<OperationalScope>();
Set<OperationalScope> opScopeChoices = new HashSet<>();
opScopeChoices.add(OperationalScope.Core);
opScopeChoices.add(OperationalScope.CPU);
@@ -382,34 +383,25 @@
multiChoiceOrOther.setOther("Other");
doReturn(Arrays.asList(
- createLicenseKeyGroup(vlm1_id,VERSION01, lkg1_id, LKG1_NAME,"LKG1 dec", LicenseKeyType.Universal,
+ createLicenseKeyGroup(vlm1_id, VERSION01, lkg1_id, LKG1_NAME, "LKG1 dec",
+ LicenseKeyType.Universal,
multiChoiceOrOther),
- createLicenseKeyGroup(vlm1_id,VERSION01, lkg2_id, LKG2_NAME,"LKG2 dec", LicenseKeyType
+ createLicenseKeyGroup(vlm1_id, VERSION01, lkg2_id, LKG2_NAME, "LKG2 dec", LicenseKeyType
.Universal, multiChoiceOrOther)))
- .when(vendorLicenseFacade).listLicenseKeyGroups(vlm1_id, VERSION01, USER1);
+ .when(vendorLicenseFacade).listLicenseKeyGroups(vlm1_id, VERSION01);
Collection<LicenseKeyGroupEntity> LKGs =
- vendorLicenseManagerImpl.listLicenseKeyGroups(vlm1_id, VERSION01, USER1);
+ vendorLicenseManagerImpl.listLicenseKeyGroups(vlm1_id, VERSION01);
- verify(vendorLicenseFacade).listLicenseKeyGroups(vlm1_id, VERSION01, USER1);
+ verify(vendorLicenseFacade).listLicenseKeyGroups(vlm1_id, VERSION01);
Assert.assertEquals(LKGs.size(), 2);
LKGs.forEach(lkg -> Assert.assertTrue(lkg.getId().matches(lkg1_id + "|" + lkg2_id)));
}
@Test
- public void testGetLicenseKeyGroup(){
- VersionInfo versionInfo = new VersionInfo();
- versionInfo.setActiveVersion(VERSION01);
- versionInfo.setLockingUser(USER1);
- ArrayList<Version> viewable = new ArrayList<Version>();
- viewable.add(VERSION01);
- versionInfo.setViewableVersions(viewable);
- versionInfo.setActiveVersion(VERSION01);
-
- doReturn(versionInfo).when(vendorLicenseManagerImpl).getVersionInfo(vlm1_id,
- VersionableEntityAction.Read, USER1);
-
- MultiChoiceOrOther<OperationalScope> multiChoiceOrOther = new MultiChoiceOrOther<OperationalScope>();
+ public void testGetLicenseKeyGroup() {
+ MultiChoiceOrOther<OperationalScope> multiChoiceOrOther =
+ new MultiChoiceOrOther<OperationalScope>();
Set<OperationalScope> opScopeChoices = new HashSet<>();
opScopeChoices.add(OperationalScope.Core);
opScopeChoices.add(OperationalScope.CPU);
@@ -417,35 +409,24 @@
multiChoiceOrOther.setChoices(opScopeChoices);
multiChoiceOrOther.setOther("Other");
- LicenseKeyGroupEntity lkg = createLicenseKeyGroup(vlm1_id,VERSION01, lkg1_id, LKG1_NAME,
+ LicenseKeyGroupEntity lkg = createLicenseKeyGroup(vlm1_id, VERSION01, lkg1_id, LKG1_NAME,
"LKG1 dec", LicenseKeyType.Universal, multiChoiceOrOther);
doReturn(lkg).when(licenseKeyGroupDao).get(anyObject());
- LicenseKeyGroupEntity lkgRetrived = vendorLicenseManagerImpl.getLicenseKeyGroup(lkg,USER1);
+ LicenseKeyGroupEntity lkgRetrived = vendorLicenseManagerImpl.getLicenseKeyGroup(lkg);
verify(licenseKeyGroupDao).get(lkg);
- Assert.assertEquals(lkgRetrived.getId(),lkg.getId());
- Assert.assertEquals(lkgRetrived.getVendorLicenseModelId(),lkg.getVendorLicenseModelId());
- Assert.assertEquals(lkgRetrived.getVersion(),lkg.getVersion());
+ Assert.assertEquals(lkgRetrived.getId(), lkg.getId());
+ Assert.assertEquals(lkgRetrived.getVendorLicenseModelId(), lkg.getVendorLicenseModelId());
+ Assert.assertEquals(lkgRetrived.getVersion(), lkg.getVersion());
}
@Test
public void testDeleteLicenseKeyGroup() {
-
- VersionInfo versionInfo = new VersionInfo();
- versionInfo.setActiveVersion(VERSION01);
- versionInfo.setLockingUser(USER1);
- ArrayList<Version> viewable = new ArrayList<Version>();
- viewable.add(VERSION01);
- versionInfo.setViewableVersions(viewable);
-
- doReturn(versionInfo).when(vendorLicenseManagerImpl).getVersionInfo(vlm1_id,
- VersionableEntityAction.Write, USER1);
-
-
- MultiChoiceOrOther<OperationalScope> multiChoiceOrOther = new MultiChoiceOrOther<OperationalScope>();
+ MultiChoiceOrOther<OperationalScope> multiChoiceOrOther =
+ new MultiChoiceOrOther<OperationalScope>();
Set<OperationalScope> opScopeChoices = new HashSet<>();
opScopeChoices.add(OperationalScope.Core);
opScopeChoices.add(OperationalScope.CPU);
@@ -453,26 +434,26 @@
multiChoiceOrOther.setChoices(opScopeChoices);
multiChoiceOrOther.setOther("Other");
- LicenseKeyGroupEntity lkg = createLicenseKeyGroup(vlm1_id,VERSION01, lkg1_id, LKG1_NAME,
+ LicenseKeyGroupEntity lkg = createLicenseKeyGroup(vlm1_id, VERSION01, lkg1_id, LKG1_NAME,
"LKG1 dec", LicenseKeyType.Universal, multiChoiceOrOther);
lkg.setReferencingFeatureGroups(new HashSet<>());
doReturn(lkg).when(licenseKeyGroupDao).get(anyObject());
- doNothing().when(vendorLicenseManagerImpl).deleteChildLimits(vlm1_id,VERSION01,lkg1_id,USER1);
+ doNothing().when(vendorLicenseManagerImpl).deleteChildLimits(vlm1_id, VERSION01, lkg1_id);
- doNothing().when(vendorLicenseManagerImpl).deleteUniqueName(anyObject(),anyObject(),
- anyObject(),anyObject());
+ doNothing().when(vendorLicenseManagerImpl).deleteUniqueName(anyObject(), anyObject(),
+ anyObject(), anyObject());
- vendorLicenseManagerImpl.deleteLicenseKeyGroup(lkg, USER1);
+ vendorLicenseManagerImpl.deleteLicenseKeyGroup(lkg);
verify(licenseKeyGroupDao).delete(lkg);
- verify(vendorLicenseFacade).updateVlmLastModificationTime(vlm1_id,VERSION01);
}
- public static LicenseKeyGroupEntity createLicenseKeyGroup(String vlmId, Version version,String id,
+ public static LicenseKeyGroupEntity createLicenseKeyGroup(String vlmId, Version version,
+ String id,
String name, String desc,
LicenseKeyType type,
MultiChoiceOrOther<OperationalScope> operationalScope) {
@@ -525,7 +506,7 @@
vlm1Id = vendorLicenseManager.createVendorLicenseModel(VendorLicenseModelTest
.createVendorLicenseModel("vendor1 name " + CommonMethods.nextUuId(), "vlm1Id dec",
- "icon1"), USER1).getId();
+ "icon1")1).getId();
vlm2Id = vendorLicenseManager.createVendorLicenseModel(VendorLicenseModelTest
.createVendorLicenseModel("vendor2 name " + CommonMethods.nextUuId(), "vlm2 dec", "icon2"),
USER1).getId();
@@ -545,7 +526,7 @@
LicenseKeyGroupEntity
lkg1 = createLicenseKeyGroup(vlmId, VERSION01, name, "LKG1 dec", LicenseKeyType.One_Time,
new MultiChoiceOrOther<>(opScopeChoices, null));
- String lkg1Id = vendorLicenseManager.createLicenseKeyGroup(lkg1, USER1).getId();
+ String lkg1Id = vendorLicenseManager.createLicenseKeyGroup(lkg11).getId();
lkg1.setId(lkg1Id);
LicenseKeyGroupEntity loadedLkg1 = licenseKeyGroupDao.get(lkg1);
@@ -560,7 +541,7 @@
createLicenseKeyGroup(vlm1Id, VERSION01, LKG1_NAME, "LKG1 dec", LicenseKeyType.One_Time,
new MultiChoiceOrOther<>(Collections.singleton(OperationalScope.Other),
"other op scope"));
- vendorLicenseManager.createLicenseKeyGroup(lkg1, USER1).getId();
+ vendorLicenseManager.createLicenseKeyGroup(lkg11).getId();
Assert.fail();
} catch (CoreException exception) {
Assert.assertEquals(exception.code().id(), UniqueValueUtil.UNIQUE_VALUE_VIOLATION);
@@ -581,9 +562,9 @@
lkg1.setOperationalScope(new MultiChoiceOrOther<>(opScopeChoices, "op scope1 updated"));
lkg1.setDescription("LKG1 dec updated");
- vendorLicenseManager.updateLicenseKeyGroup(lkg1, USER1);
+ vendorLicenseManager.updateLicenseKeyGroup(lkg11);
- LicenseKeyGroupEntity loadedLkg1 = vendorLicenseManager.getLicenseKeyGroup(lkg1, USER1);
+ LicenseKeyGroupEntity loadedLkg1 = vendorLicenseManager.getLicenseKeyGroup(lkg11);
Assert.assertTrue(loadedLkg1.equals(lkg1));
}
@@ -595,11 +576,11 @@
LicenseKeyGroupEntity lkg2 =
createLicenseKeyGroup(vlm1Id, VERSION01, "LKG2", "LKG2 dec", LicenseKeyType.Universal,
new MultiChoiceOrOther<>(opScopeChoices, null));
- lkg2Id = vendorLicenseManager.createLicenseKeyGroup(lkg2, USER1).getId();
+ lkg2Id = vendorLicenseManager.createLicenseKeyGroup(lkg21).getId();
lkg2.setId(lkg2Id);
Collection<LicenseKeyGroupEntity> loadedLkgs =
- vendorLicenseManager.listLicenseKeyGroups(vlm1Id, null, USER1);
+ vendorLicenseManager.listLicenseKeyGroups(vlm1Id, null1);
Assert.assertEquals(loadedLkgs.size(), 2);
for (LicenseKeyGroupEntity loadedLkg : loadedLkgs) {
if (lkg2Id.equals(loadedLkg.getId())) {
@@ -611,7 +592,7 @@
@Test(dependsOnMethods = {"listTest"})
public void deleteTest() {
vendorLicenseManager
- .deleteLicenseKeyGroup(new LicenseKeyGroupEntity(vlm1Id, VERSION01, lkg1Id), USER1);
+ .deleteLicenseKeyGroup(new LicenseKeyGroupEntity(vlm1Id, VERSION01, lkg1Id)1);
LicenseKeyGroupEntity loadedLkg1 =
licenseKeyGroupDao.get(new LicenseKeyGroupEntity(vlm1Id, VERSION01, lkg1Id));
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseModelTest.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseModelTest.java
index 195fa5d..d1df147 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseModelTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseModelTest.java
@@ -1,12 +1,12 @@
package org.openecomp.sdc.vendorlicense.impl;
-import org.junit.rules.ExpectedException;
-import org.openecomp.core.util.UniqueValueUtil;
-import org.openecomp.sdc.activityLog.ActivityLogManager;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.mockito.Spy;
import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
-import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.common.errors.ErrorCategory;
-import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.vendorlicense.VendorLicenseConstants;
import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDao;
import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDao;
@@ -14,50 +14,17 @@
import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDao;
import org.openecomp.sdc.vendorlicense.dao.LimitDao;
import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDao;
-import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther;
-import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseTerm;
import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
-import org.openecomp.sdc.vendorlicense.types.VersionedVendorLicenseModel;
-import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
-import org.openecomp.sdc.vendorsoftwareproduct.types.VersionedVendorSoftwareProductInfo;
import org.openecomp.sdc.versioning.VersioningManager;
-import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.dao.types.VersionStatus;
-import org.openecomp.sdc.versioning.types.VersionInfo;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
-import org.testng.annotations.BeforeMethod;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Captor;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.mockito.Spy;
-import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.verify;
-import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE;
/**
@@ -93,9 +60,6 @@
private LicenseKeyGroupDao licenseKeyGroupDaoMcok;
@Mock
private LimitDao limitDaoMcok;
- @Mock
- private ActivityLogManager activityLogManagerMcok;
-
@Spy
@InjectMocks
@@ -112,159 +76,19 @@
}
@Test
- public void testCheckout() {
-
- doReturn(VERSION01).when(versioningManagerMcok)
- .checkout(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vlm1_id, USER1);
-
- vendorLicenseManager.checkout(vlm1_id, USER1);
-
- Assert.assertEquals(VERSION01.getStatus(), VersionStatus.Locked);
- verify(vendorLicenseFacadeMcok).updateVlmLastModificationTime(vlm1_id, VERSION01);
-
- verify(versioningManagerMcok)
- .checkout(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vlm1_id, USER1);
-
- verify(activityLogManagerMcok).addActionLog(activityLogEntityArg.capture(), eq(USER1));
- ActivityLogEntity activityLogEntity = activityLogEntityArg.getValue();
- Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION01.getMajor() + 1));
- Assert.assertTrue(activityLogEntity.isSuccess());
- }
-
- @Test
- public void testUndoCheckout() {
- Version existingVersion = new Version(0, 2);
- doReturn(existingVersion).when(versioningManagerMcok).undoCheckout(
- VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vlm1_id, USER1);
-
- vendorLicenseManager.undoCheckout(vlm1_id, USER1);
-
- verify(vendorLicenseFacadeMcok).updateVlmLastModificationTime(vlm1_id, existingVersion);
- }
-
- @Test
- public void testCheckin() {
-
- doReturn(VERSION10).when(vendorLicenseFacadeMcok).checkin(vlm1_id, USER1);
-
- vendorLicenseManager.checkin(vlm1_id, USER1);
- verify(activityLogManagerMcok).addActionLog(activityLogEntityArg.capture(), eq(USER1));
- ActivityLogEntity activityLogEntity = activityLogEntityArg.getValue();
- Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION10.getMajor() + 1));
- verify(vendorLicenseFacadeMcok).checkin(vlm1_id, USER1);
-
- }
-
- @Test
- public void testSubmit() {
-
- doReturn(VERSION10).when(vendorLicenseFacadeMcok).submit(vlm1_id, USER1);
-
- vendorLicenseManager.submit(vlm1_id, USER1);
- verify(activityLogManagerMcok).addActionLog(activityLogEntityArg.capture(), eq(USER1));
- ActivityLogEntity activityLogEntity = activityLogEntityArg.getValue();
- Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION10.getMajor()));
- verify(vendorLicenseFacadeMcok).submit(vlm1_id, USER1);
-
- }
-
- @Test
- public void testListWhenNone() {
- doReturn(new HashMap<>()).when(versioningManagerMcok).listEntitiesVersionInfo
- (VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, USER1, VersionableEntityAction.Read);
- Collection<VersionedVendorLicenseModel> vlms = vendorLicenseManager.listVendorLicenseModels
- (null, USER1);
- Assert.assertEquals(vlms.size(), 0);
- }
-
- @Test
- public void testList() {
-
- Map<String, VersionInfo> vlmsTobeReturned = new HashMap<>();
-
- VersionInfo versionInfo1 = new VersionInfo();
- versionInfo1.setActiveVersion(VERSION01);
- vlmsTobeReturned.put(vlm1_id, versionInfo1);
-
- VersionInfo versionInfo2 = new VersionInfo();
- versionInfo2.setActiveVersion(VERSION10);
- vlmsTobeReturned.put(vlm2_id, versionInfo2);
-
- doReturn(vlmsTobeReturned).when(versioningManagerMcok).listEntitiesVersionInfo
- (VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, USER1, VersionableEntityAction.Read);
-
- VendorLicenseModelEntity vlm1 = new VendorLicenseModelEntity(vlm1_id, VERSION01);
- vlm1.setWritetimeMicroSeconds(8L);
- doReturn(vlm1).when(vendorLicenseModelDaoMcok).get(any(VendorLicenseModelEntity.class));
-
- Collection<VersionedVendorLicenseModel> vlms = vendorLicenseManager.listVendorLicenseModels
- (null, USER1);
- Assert.assertEquals(vlms.size(), 2);
- }
-
- @Test
- public void testListFinalsWhenNone() {
-
- Map<String, VersionInfo> vspsTobeReturned = new HashMap<>();
-
- VersionInfo versionInfo1 = new VersionInfo();
- versionInfo1.setActiveVersion(VERSION01);
- vspsTobeReturned.put(vlm1_id, versionInfo1);
-
- VersionInfo versionInfo2 = new VersionInfo();
- versionInfo2.setActiveVersion(VERSION10);
- vspsTobeReturned.put(vlm2_id, versionInfo2);
-
- doReturn(vspsTobeReturned).when(versioningManagerMcok).listEntitiesVersionInfo
- (VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, USER1, VersionableEntityAction.Read);
-
- Collection<VersionedVendorLicenseModel> vlms = vendorLicenseManager.listVendorLicenseModels
- (VersionStatus.Final.name(), USER1);
- Assert.assertEquals(vlms.size(), 0);
- }
-
- @Test
- public void testListFinals() {
- Map<String, VersionInfo> vlmsTobeReturned = new HashMap<>();
-
- VersionInfo versionInfo1 = new VersionInfo();
- versionInfo1.setActiveVersion(VERSION01);
- vlmsTobeReturned.put(vlm1_id, versionInfo1);
-
- VersionInfo versionInfo2 = new VersionInfo();
-
- versionInfo2.setActiveVersion(new Version(1, 3));
- versionInfo2.setLatestFinalVersion(VERSION10);
- vlmsTobeReturned.put(vlm2_id, versionInfo2);
-
- doReturn(vlmsTobeReturned).when(versioningManagerMcok).listEntitiesVersionInfo
- (VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, USER1, VersionableEntityAction.Read);
-
- VendorLicenseModelEntity vlm1 = new VendorLicenseModelEntity(vlm1_id, VERSION01);
- vlm1.setWritetimeMicroSeconds(8L);
- doReturn(vlm1).when(vendorLicenseModelDaoMcok).get(any(VendorLicenseModelEntity.class));
-
- Collection<VersionedVendorLicenseModel> vlms = vendorLicenseManager.listVendorLicenseModels
- (VersionStatus.Final.name(), USER1);
-
- Assert.assertEquals(vlms.size(), 1);
+ public void testValidate() {
+ // TODO: 8/13/2017
+ vendorLicenseManager.validate(vlm1_id, null);
+ verify(vendorLicenseFacadeMcok).validate(vlm1_id, null);
}
@Test
public void testCreate() {
-
VendorLicenseModelEntity vlmEntity = new VendorLicenseModelEntity(vlm1_id, VERSION01);
- doReturn(vlmEntity).when(vendorLicenseFacadeMcok).createVendorLicenseModel(vlmEntity, USER1);
+ vendorLicenseManager.createVendorLicenseModel(vlmEntity);
- vendorLicenseManager.createVendorLicenseModel(vlmEntity, USER1);
-
- verify(vendorLicenseFacadeMcok).createVendorLicenseModel(vlmEntity, USER1);
- verify(activityLogManagerMcok).addActionLog(activityLogEntityArg.capture(), eq(USER1));
- ActivityLogEntity activityLogEntity = activityLogEntityArg.getValue();
- Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION01.getMajor() + 1));
- Assert.assertTrue(activityLogEntity.isSuccess());
-
+ verify(vendorLicenseModelDaoMcok).create(vlmEntity);
}
@Test
@@ -277,14 +101,6 @@
existingVlm.setVendorName("VLM1");
existingVlm.setDescription("decription");
- VersionInfo versionInfo = new VersionInfo();
- versionInfo.setActiveVersion(VERSION01);
-
- doReturn(versionInfo).when(vendorLicenseManager).getVersionInfo(existingVlm.getId(),
- VersionableEntityAction.Write, USER1);
-
- doReturn(VERSION01).when(vendorLicenseManager).resloveVersion(vlm1_id,null, versionInfo, USER1);
-
doReturn("VLM1").when(vendorLicenseModelDaoMcok).get(existingVlm);
VendorLicenseModelEntity updatedVlm = new VendorLicenseModelEntity();
@@ -302,21 +118,20 @@
doReturn(existingVlm).when(vendorLicenseModelDaoMcok).get(any(VendorLicenseModelEntity.class));
- vendorLicenseManager.updateVendorLicenseModel(updatedVlm, USER1);
+ vendorLicenseManager.updateVendorLicenseModel(updatedVlm);
verify(vendorLicenseModelDaoMcok).update(updatedVlm);
- verify(vendorLicenseFacadeMcok).updateVlmLastModificationTime(vlm1_id, VERSION01);
}
@Test
- public void testGetVendorLicenseModel(){
- vendorLicenseManager.getVendorLicenseModel(vlm1_id,VERSION01,USER1);
- verify(vendorLicenseFacadeMcok).getVendorLicenseModel(vlm1_id,VERSION01,USER1);
+ public void testGetVendorLicenseModel() {
+ vendorLicenseManager.getVendorLicenseModel(vlm1_id, VERSION01);
+ verify(vendorLicenseFacadeMcok).getVendorLicenseModel(vlm1_id, VERSION01);
}
@Test(expectedExceptions = UnsupportedOperationException.class)
public void testDeleteVLMUnsupportedOperation() {
- vendorLicenseManager.deleteVendorLicenseModel(vlm1_id, USER1);
+ vendorLicenseManager.deleteVendorLicenseModel(vlm1_id, null); // TODO: 8/13/2017
}
@@ -324,7 +139,7 @@
// public void testGetNonExistingVersion_negative() {
// Version notExistversion = new Version(43, 8);
// doReturn(null).when(vspInfoDaoMock).get(any(VspDetails.class));
-// vendorSoftwareProductManager.getVsp(VSP_ID, notExistversion, USER1);
+// vendorSoftwareProductManager.getVsp(VSP_ID, notExistversion);
// }
}
\ No newline at end of file
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/VendorLicenseArtifactsServiceTest.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/VendorLicenseArtifactsServiceTest.java
index ec50c96..c20d96a 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/VendorLicenseArtifactsServiceTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/VendorLicenseArtifactsServiceTest.java
@@ -20,22 +20,8 @@
package org.openecomp.sdc.vendorlicense.licenseartifacts.impl;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.StringUtils;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.sdc.vendorlicense.ArtifactTestUtils;
-import org.openecomp.sdc.vendorlicense.VendorLicenseConstants;
-import org.openecomp.sdc.vendorlicense.dao.types.EntitlementMetric;
-import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
public class VendorLicenseArtifactsServiceTest extends ArtifactTestUtils {
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentDependencyModelManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentDependencyModelManager.java
index a651b0b..869628e 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentDependencyModelManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentDependencyModelManager.java
@@ -4,12 +4,17 @@
import org.openecomp.sdc.versioning.dao.types.Version;
import java.util.Collection;
-import java.util.List;
public interface ComponentDependencyModelManager {
- void createComponentDependencyModel(List<ComponentDependencyModelEntity> entities, String
- vspId, Version version, String user);
+ Collection<ComponentDependencyModelEntity> list(String vspId, Version version);
- Collection<ComponentDependencyModelEntity> list(String vspId, Version version, String user);
+ ComponentDependencyModelEntity createComponentDependency(ComponentDependencyModelEntity entity,
+ String vspId, Version version);
+
+ void delete(String vspId, Version version, String dependencyId);
+
+ void update(ComponentDependencyModelEntity entity);
+
+ ComponentDependencyModelEntity get(String vspId, Version version, String dependencyId);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManager.java
index b895f55..4135298 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManager.java
@@ -31,24 +31,23 @@
public interface ComponentManager {
- Collection<ComponentEntity> listComponents(String vspId, Version version, String user);
+ Collection<ComponentEntity> listComponents(String vspId, Version version);
- void deleteComponents(String vspId, Version version, String user);
+ void deleteComponents(String vspId, Version version);
- ComponentEntity createComponent(ComponentEntity componentEntity, String user);
+ ComponentEntity createComponent(ComponentEntity componentEntity);
- CompositionEntityValidationData updateComponent(ComponentEntity componentEntity, String user);
+ CompositionEntityValidationData updateComponent(ComponentEntity componentEntity);
CompositionEntityResponse<ComponentData> getComponent(String vspId, Version version,
- String componentId, String user);
+ String componentId);
- void deleteComponent(String vspId, Version version, String componentId, String user);
+ void deleteComponent(String vspId, Version version, String componentId);
- QuestionnaireResponse getQuestionnaire(String vspId, Version version, String componentId,
- String user);
+ QuestionnaireResponse getQuestionnaire(String vspId, Version version, String componentId);
void updateQuestionnaire(String vspId, Version version, String componentId,
- String questionnaireData, String user);
+ String questionnaireData);
- void validateComponentExistence(String vspId, Version version, String componentId, String user);
+ void validateComponentExistence(String vspId, Version version, String componentId);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManager.java
index 65bceb9..7ddd4e2 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManager.java
@@ -12,23 +12,20 @@
public interface ComputeManager {
- Collection<ListComputeResponse> listCompute(String vspId, Version version, String
- componentId, String user);
+ Collection<ListComputeResponse> listComputes(String vspId, Version version, String componentId);
- ComputeEntity createCompute(ComputeEntity compute, String user);
+ ComputeEntity createCompute(ComputeEntity compute);
- CompositionEntityResponse<ComputeData> getCompute(String vspId, Version version, String
- componentId, String computeFlavorId, String user);
+ CompositionEntityResponse<ComputeData> getCompute(String vspId, Version version,
+ String componentId, String computeFlavorId);
- QuestionnaireResponse getComputeQuestionnaire(String vspId, Version version, String
- componentId, String computeFlavorId, String user);
+ QuestionnaireResponse getComputeQuestionnaire(String vspId, Version version, String componentId,
+ String computeFlavorId);
- void updateComputeQuestionnaire(String vspId, Version version, String componentId, String
- computeId, String
- questionnaireData, String user);
+ void updateComputeQuestionnaire(String vspId, Version version, String componentId,
+ String computeId, String questionnaireData);
- CompositionEntityValidationData updateCompute(ComputeEntity compute, String user);
+ CompositionEntityValidationData updateCompute(ComputeEntity compute);
- void deleteCompute(String vspId, Version version,String componentId, String computeFlavorId,
- String user);
+ void deleteCompute(String vspId, Version version, String componentId, String computeFlavorId);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManager.java
index 51ba2f4..88d399a 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManager.java
@@ -12,23 +12,19 @@
public interface DeploymentFlavorManager {
- DeploymentFlavorEntity createDeploymentFlavor(DeploymentFlavorEntity deploymentFlavorEntity,
- String user);
+ DeploymentFlavorEntity createDeploymentFlavor(DeploymentFlavorEntity deploymentFlavorEntity);
- Collection<DeploymentFlavorEntity> listDeploymentFlavors(String vspId, Version version,
- String user);
+ Collection<DeploymentFlavorEntity> listDeploymentFlavors(String vspId, Version version);
CompositionEntityResponse<DeploymentFlavor> getDeploymentFlavor(String vspId, Version version,
- String deploymentFlavorId,
- String user);
+ String deploymentFlavorId);
- CompositionEntityResponse<DeploymentFlavor> getDeploymentFlavorSchema(String vspId, Version
- version, String user);
+ CompositionEntityResponse<DeploymentFlavor> getDeploymentFlavorSchema(String vspId,
+ Version version);
- void deleteDeploymentFlavor(String vspId, Version version, String deploymentFlavorId, String
- user);
+ void deleteDeploymentFlavor(String vspId, Version version, String deploymentFlavorId);
- CompositionEntityValidationData updateDeploymentFlavor(DeploymentFlavorEntity
- deploymentFlavorEntity, String user);
+ CompositionEntityValidationData updateDeploymentFlavor(
+ DeploymentFlavorEntity deploymentFlavorEntity);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManager.java
index 6bbfc0b..1a53221 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManager.java
@@ -10,24 +10,22 @@
import java.util.Collection;
public interface ImageManager {
- ImageEntity createImage(ImageEntity imageEntity, String user);
+ ImageEntity createImage(ImageEntity imageEntity);
- CompositionEntityResponse<Image> getImageSchema(String vspId, String user);
+ CompositionEntityResponse<Image> getImageSchema(String vspId);
- Collection<ImageEntity> listImages(String vspId, Version version, String componentId,
- String user);
+ Collection<ImageEntity> listImages(String vspId, Version version, String componentId);
CompositionEntityResponse<Image> getImage(String vspId, Version version, String componentId,
- String imageId, String user);
+ String imageId);
- QuestionnaireResponse getImageQuestionnaire(String vspId, Version version, String
- componentId, String imageId, String user);
+ QuestionnaireResponse getImageQuestionnaire(String vspId, Version version, String componentId,
+ String imageId);
- void deleteImage(String vspId, Version version, String componentId, String imageId, String user);
+ void deleteImage(String vspId, Version version, String componentId, String imageId);
- CompositionEntityValidationData updateImage(ImageEntity imageEntity, String user);
+ CompositionEntityValidationData updateImage(ImageEntity imageEntity);
void updateImageQuestionnaire(String vspId, Version version, String componentId, String imageId,
- String
- questionnaireData, String user);
+ String questionnaireData);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ManualVspToscaManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ManualVspToscaManager.java
index c9a5206..621374a 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ManualVspToscaManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ManualVspToscaManager.java
@@ -6,7 +6,7 @@
public interface ManualVspToscaManager {
- public VspModelInfo gatherVspInformation(String vspId, Version version, String user);
+ VspModelInfo gatherVspInformation(String vspId, Version version);
- public ToscaServiceModel generateToscaModel(VspModelInfo vspModelInfo);
+ ToscaServiceModel generateToscaModel(VspModelInfo vspModelInfo);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MonitoringUploadsManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MonitoringUploadsManager.java
index f5e34a0..36f0650 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MonitoringUploadsManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MonitoringUploadsManager.java
@@ -28,11 +28,10 @@
public interface MonitoringUploadsManager {
void delete(String vspId, Version version, String componentId,
- MonitoringUploadType monitoringUploadType, String user);
+ MonitoringUploadType monitoringUploadType);
void upload(InputStream object, String filename, String vspId, Version version,
- String componentId, MonitoringUploadType monitoringUploadType, String user);
+ String componentId, MonitoringUploadType monitoringUploadType);
- MonitoringUploadStatus listFilenames(String vspId, Version version, String componentId,
- String user);
+ MonitoringUploadStatus listFilenames(String vspId, Version version, String componentId);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NetworkManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NetworkManager.java
index b647735..fa74069 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NetworkManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NetworkManager.java
@@ -29,14 +29,13 @@
import java.util.Collection;
public interface NetworkManager {
- Collection<NetworkEntity> listNetworks(String vspId, Version version, String user);
+ Collection<NetworkEntity> listNetworks(String vspId, Version version);
- NetworkEntity createNetwork(NetworkEntity network, String user);
+ NetworkEntity createNetwork(NetworkEntity network);
- CompositionEntityValidationData updateNetwork(NetworkEntity networkEntity, String user);
+ CompositionEntityValidationData updateNetwork(NetworkEntity networkEntity);
- CompositionEntityResponse<Network> getNetwork(String vspId, Version version, String networkId,
- String user);
+ CompositionEntityResponse<Network> getNetwork(String vspId, Version version, String networkId);
- void deleteNetwork(String vspId, Version version, String networkId, String user);
+ void deleteNetwork(String vspId, Version version, String networkId);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NicManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NicManager.java
index 466583e..b055d97 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NicManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NicManager.java
@@ -31,20 +31,20 @@
public interface NicManager {
- Collection<NicEntity> listNics(String vspId, Version version, String componentId, String user);
+ Collection<NicEntity> listNics(String vspId, Version version, String componentId);
- NicEntity createNic(NicEntity nic, String user);
+ NicEntity createNic(NicEntity nic);
- CompositionEntityValidationData updateNic(NicEntity nicEntity, String user);
+ CompositionEntityValidationData updateNic(NicEntity nicEntity);
CompositionEntityResponse<Nic> getNic(String vspId, Version version, String componentId,
- String nicId, String user);
+ String nicId);
- void deleteNic(String vspId, Version version, String componentId, String nicId, String user);
+ void deleteNic(String vspId, Version version, String componentId, String nicId);
QuestionnaireResponse getNicQuestionnaire(String vspId, Version version, String componentId,
- String nicId, String user);
+ String nicId);
void updateNicQuestionnaire(String vspId, Version version, String componentId, String nicId,
- String questionnaireData, String user);
+ String questionnaireData);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManager.java
index e2ef861..84318db 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManager.java
@@ -21,6 +21,7 @@
package org.openecomp.sdc.vendorsoftwareproduct;
import org.apache.commons.lang3.tuple.Pair;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse;
@@ -33,14 +34,16 @@
public interface OrchestrationTemplateCandidateManager {
UploadFileResponse upload(String vspId, Version version, InputStream heatFileToUpload,
- String user, String filePrefix, String networkPackageName);
+ String fileSuffix, String networkPackageName);
- OrchestrationTemplateActionResponse process(String vspId, Version version, String user);
+ OrchestrationTemplateActionResponse process(String vspId, Version version);
- Optional<FilesDataStructure> getFilesDataStructure(String vspId, Version version, String user);
+ Optional<FilesDataStructure> getFilesDataStructure(String vspId, Version version);
- ValidationResponse updateFilesDataStructure(String vspId, Version version, String user,
+ ValidationResponse updateFilesDataStructure(String vspId, Version version,
FilesDataStructure fileDataStructure);
- Optional<Pair<String, byte[]>> get(String vspId, Version version, String user) throws IOException;
+ Optional<Pair<String, byte[]>> get(String vspId, Version version) throws IOException;
+
+ OrchestrationTemplateCandidateData getInfo(String vspId, Version version);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ProcessManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ProcessManager.java
index afe88d2..979eea0 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ProcessManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ProcessManager.java
@@ -28,27 +28,22 @@
import java.util.Collection;
public interface ProcessManager {
- Collection<ProcessEntity> listProcesses(String vspId, Version version, String componentId,
- String user);
+ Collection<ProcessEntity> listProcesses(String vspId, Version version, String componentId);
- void deleteProcesses(String vspId, Version version, String componentId, String user);
+ void deleteProcesses(String vspId, Version version, String componentId);
- ProcessEntity createProcess(ProcessEntity processEntity, String user);
+ ProcessEntity createProcess(ProcessEntity processEntity);
- ProcessEntity getProcess(String vspId, Version version, String componentId, String processId,
- String user);
+ ProcessEntity getProcess(String vspId, Version version, String componentId, String processId);
- void updateProcess(ProcessEntity processEntity, String user);
+ void updateProcess(ProcessEntity processEntity);
- void deleteProcess(String vspId, Version version, String componentId, String processId,
- String user);
+ void deleteProcess(String vspId, Version version, String componentId, String processId);
- File getProcessArtifact(String vspId, Version version, String componentId, String processId,
- String user);
+ File getProcessArtifact(String vspId, Version version, String componentId, String processId);
- void deleteProcessArtifact(String vspId, Version version, String componentId, String processId,
- String user);
+ void deleteProcessArtifact(String vspId, Version version, String componentId, String processId);
void uploadProcessArtifact(InputStream uploadFile, String fileName, String vspId,
- Version version, String componentId, String processId, String user);
+ Version version, String componentId, String processId);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java
index 0adca1c..2e38122 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java
@@ -20,65 +20,55 @@
package org.openecomp.sdc.vendorsoftwareproduct;
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse;
-import org.openecomp.sdc.vendorsoftwareproduct.types.VersionedVendorSoftwareProductInfo;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.VersionInfo;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
+import java.util.Map;
public interface VendorSoftwareProductManager {
- Version checkout(String vendorSoftwareProductId, String user);
+ VspDetails createVsp(VspDetails vspDetails);
- Version undoCheckout(String vendorSoftwareProductId, String user);
+ void updateVsp(VspDetails vspDetails);
- Version checkin(String vendorSoftwareProductId, String user);
+ VspDetails getVsp(String vspId, Version version);
- ValidationResponse submit(String vendorSoftwareProductId, String user) throws IOException;
+ void deleteVsp(String vspIdToDelete);
+
+ ValidationResponse validate(String vspId, Version version) throws IOException;
+
+ Map<String, List<ErrorMessage>> compile(String vspId, Version version);
- List<VersionedVendorSoftwareProductInfo> listVsps(String versionFilter, String user);
+ QuestionnaireResponse getVspQuestionnaire(String vspId, Version version);
- VspDetails createVsp(VspDetails vspDetails, String user);
-
- void updateVsp(VspDetails vspDetails, String user);
-
- VspDetails getVsp(String vspId, Version version, String user);
-
- Version callAutoHeal(String vspId, VersionInfo versionInfo,
- VspDetails vendorSoftwareProductInfo, String user) throws Exception;
-
- void deleteVsp(String vspIdToDelete, String user);
-
- QuestionnaireResponse getVspQuestionnaire(String vspId, Version version, String user);
-
- void updateVspQuestionnaire(String vspId, Version version, String questionnaireData, String user);
+ void updateVspQuestionnaire(String vspId, Version version, String questionnaireData);
- byte[] getOrchestrationTemplateFile(String vspId, Version version, String user);
+ byte[] getOrchestrationTemplateFile(String vspId, Version version);
- PackageInfo createPackage(String vspId, Version version, String user) throws IOException;
+ OrchestrationTemplateEntity getOrchestrationTemplateInfo(String vspId, Version version);
+
+
+ PackageInfo createPackage(String vspId, Version version) throws IOException;
List<PackageInfo> listPackages(String category, String subCategory);
- File getTranslatedFile(String vspId, Version version, String user);
- void heal(String vspId, Version version, String user);
+ File getTranslatedFile(String vspId, Version version);
- File getInformationArtifact(String vspId, Version version, String user);
+ File getInformationArtifact(String vspId, Version version);
- String fetchValidationVsp(String user);
- Collection<ComputeEntity> getComputeByVsp(String vspId, Version version, String user);
-
- Version healAndAdvanceFinalVersion(String vspId, VspDetails vendorSoftwareProductInfo,
- String user) throws IOException;
+ Collection<ComputeEntity> getComputeByVsp(String vspId, Version version);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentDependencyModelErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentDependencyModelErrorBuilder.java
index 78605c8..53ad74b 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentDependencyModelErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentDependencyModelErrorBuilder.java
@@ -1,18 +1,14 @@
package org.openecomp.sdc.vendorsoftwareproduct.errors;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes
- .CYCLIC_DEPENDENCY_IN_COMPONENTS;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes
- .INVALID_COMPONENT_RELATION_TYPE;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes
- .NO_SOURCE_COMPONENT;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes
- .SAME_SOURCE_TARGET_COMPONENT;
-
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.CYCLIC_DEPENDENCY_IN_COMPONENTS;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.INVALID_COMPONENT_RELATION_TYPE;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.NO_SOURCE_COMPONENT;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.SAME_SOURCE_TARGET_COMPONENT;
+
public class ComponentDependencyModelErrorBuilder {
private static final String CYCLIC_DEPENDENCY_COMPONENT_MSG = "Cyclic dependency exists between"
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateComputeInComponentErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateComputeInComponentErrorBuilder.java
index b242b71..5d58f5c 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateComputeInComponentErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateComputeInComponentErrorBuilder.java
@@ -2,41 +2,16 @@
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
+
import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.UPDATE_COMPUTE_NOT_ALLOWED;
public class DuplicateComputeInComponentErrorBuilder {
-
- private static final String DUPLICATE_COMPUTE_NAME_NOT_ALLOWED_MSG =
- "Invalid request, Compute with name %s already exists for component with ID %s.";
- private static final String COMPUTE_HEAT_READONLY_ATTR_MSG = "Update of attribute %s not allowed "
- + "for VSP onboarded via HEAT.";
- private static final String COMPUTE_MANUAL_READONLY_ATTR_MSG = "Update of attribute %s not allowed "
- + "for VSP onboarded manually.";
-
+ private static final String COMPUTE_HEAT_READONLY_ATTR_MSG =
+ "Update of attribute %s not allowed for VSP onboarded via HEAT.";
private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- public DuplicateComputeInComponentErrorBuilder(String computeName, String componentId ){
- builder.withId(VendorSoftwareProductErrorCodes.DUPLICATE_COMPUTE_NAME_NOT_ALLOWED);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format(DUPLICATE_COMPUTE_NAME_NOT_ALLOWED_MSG,computeName,
- componentId));
- }
-
- /**
- * Gets duplicate compute name error builder.
- *
- * @return the duplicate compute name error builder
- */
- public static ErrorCode getDuplicateComputeNameErrorBuilder(String computeName, String componenetId) {
- ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- builder.withId(VendorSoftwareProductErrorCodes.DUPLICATE_COMPUTE_NAME_NOT_ALLOWED);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format(DUPLICATE_COMPUTE_NAME_NOT_ALLOWED_MSG, computeName, componenetId ));
- return builder.build();
- }
-
public static ErrorCode getComputeHeatReadOnlyErrorBuilder(String name) {
ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
builder.withId(UPDATE_COMPUTE_NOT_ALLOWED);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ImageErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ImageErrorBuilder.java
index 9ac6e1b..2d22d01 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ImageErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ImageErrorBuilder.java
@@ -3,7 +3,11 @@
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.*;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.DUPLICATE_IMAGE_NAME_NOT_ALLOWED;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.DUPLICATE_IMAGE_VERSION_NOT_ALLOWED;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.IMAGE_NAME_FORMAT_NOT_ALLOWED;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.UPDATE_IMAGE_NOT_ALLOWED;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.VFC_IMAGE_INVALID_FORMAT;
/**
* The Image error builder.
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MonitoringUploadErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MonitoringUploadErrorBuilder.java
index 5fc29d5..eed56e1 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MonitoringUploadErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MonitoringUploadErrorBuilder.java
@@ -28,8 +28,7 @@
public class MonitoringUploadErrorBuilder extends BaseErrorBuilder {
private static final String UPLOAD_INVALID_DETAILED_MSG =
- "Monitoring file uploaded for vendor software product with Id %s and version %s is invalid:" +
- " %s";
+ "Monitoring file uploaded for vendor software product with Id %s and version %s is invalid: %s";
/**
@@ -44,7 +43,7 @@
getErrorCodeBuilder().withId(MONITORING_UPLOAD_INVALID);
getErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION);
getErrorCodeBuilder().withMessage(String.format(UPLOAD_INVALID_DETAILED_MSG,
- vendorSoftwareProductId, version == null ? null : version.toString(), error));
+ vendorSoftwareProductId, version == null ? null : version.getId(), error));
}
/**
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicInternalNetworkErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicInternalNetworkErrorBuilder.java
index 0850d2e..2acfde4 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicInternalNetworkErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicInternalNetworkErrorBuilder.java
@@ -1,11 +1,11 @@
package org.openecomp.sdc.vendorsoftwareproduct.errors;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.NETWORK_DESCRIPTION_NOT_ALLOWED_FOR_INTERNAL_NETWORK;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.NETWORK_TYPE_UPDATE_NOT_ALLOWED;
-
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.NETWORK_DESCRIPTION_NOT_ALLOWED_FOR_INTERNAL_NETWORK;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.NETWORK_TYPE_UPDATE_NOT_ALLOWED;
+
public class NicInternalNetworkErrorBuilder {
private static final String NULL_NETWORKID_NOT_ALLOWED_MSG =
"Internal Networks are currently not supported for VSP created Manually, so please fix all the NIC to be of Type External and re-submit the VSP.";
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NotSupportedHeatOnboardMethodErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NotSupportedHeatOnboardMethodErrorBuilder.java
index 7801df8..1b68962 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NotSupportedHeatOnboardMethodErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NotSupportedHeatOnboardMethodErrorBuilder.java
@@ -1,5 +1,8 @@
package org.openecomp.sdc.vendorsoftwareproduct.errors;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.ADD_COMPUTE_NOT_ALLOWED_IN_HEAT_ONBOARDING;
import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.ADD_IMAGE_NOT_ALLOWED_IN_HEAT_ONBOARDING;
import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.ADD_NIC_NOT_ALLOWED_IN_HEAT_ONBOARDING;
@@ -7,9 +10,6 @@
import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.DELETE_IMAGE_NOT_ALLOWED;
import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.EDIT_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING;
-import org.openecomp.sdc.common.errors.ErrorCategory;
-import org.openecomp.sdc.common.errors.ErrorCode;
-
public class NotSupportedHeatOnboardMethodErrorBuilder {
private static final String ADD_NIC_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG =
"NIC cannot be added for VSPs onboarded with HEAT.";
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/OnboardingMethodErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/OnboardingMethodErrorBuilder.java
index 8aad900..49785a3 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/OnboardingMethodErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/OnboardingMethodErrorBuilder.java
@@ -1,37 +1,19 @@
package org.openecomp.sdc.vendorsoftwareproduct.errors;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes
- .VSP_INVALID_ONBOARDING_METHOD;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes
- .VSP_ONBOARD_METHOD_UPDATE_NOT_ALLOWED;
-
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.VSP_INVALID_ONBOARDING_METHOD;
+
/**
* The type Onboarding method error builder.
*/
public class OnboardingMethodErrorBuilder {
- private static final String VSP_ONBOARD_METHOD_UPDATE_NOT_ALLOWED_MSG =
- "onboardingMethod update is not allowed.";
private static final String VSP_INVALID_ONBOARDING_METHOD_MSG =
"The onboardingMethod value doesn't meet the expected attribute value.";
/**
- * Gets onboarding update error.
- *
- * @return the onboarding update error
- */
- public static ErrorCode getOnboardingUpdateError() {
- ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- builder.withId(VSP_ONBOARD_METHOD_UPDATE_NOT_ALLOWED);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format(VSP_ONBOARD_METHOD_UPDATE_NOT_ALLOWED_MSG));
- return builder.build();
- }
-
- /**
* Get invalid onboarding method error builder error code.
*
* @return the error code
@@ -40,7 +22,7 @@
ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
builder.withId(VSP_INVALID_ONBOARDING_METHOD);
builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format(VSP_INVALID_ONBOARDING_METHOD_MSG));
+ builder.withMessage(VSP_INVALID_ONBOARDING_METHOD_MSG);
return builder.build();
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/TranslationFileCreationErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/TranslationFileCreationErrorBuilder.java
index 1ec3af3..fd8acd1 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/TranslationFileCreationErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/TranslationFileCreationErrorBuilder.java
@@ -20,12 +20,12 @@
package org.openecomp.sdc.vendorsoftwareproduct.errors;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.TRANSLATION_FILE_CREATION;
-
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.versioning.dao.types.Version;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.TRANSLATION_FILE_CREATION;
+
public class TranslationFileCreationErrorBuilder {
private static final String TRANSLATION_FILE_CREATION_ERROR_MSG =
"Error while trying to create translation file from the package of vendor software product "
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductInvalidErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductInvalidErrorBuilder.java
index 4a84c83..4fc0b6e 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductInvalidErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductInvalidErrorBuilder.java
@@ -28,7 +28,7 @@
private static final String VSP_INVALID_MSG =
"Vendor software product with Id %s and version %s is invalid - does not contain "
+ "service model.";
- private static final String VSP_INVALID_MISSING_DEPLOYMENT_FLAVOR_MSG ="VSP has to have a " +
+ private static final String VSP_INVALID_MISSING_DEPLOYMENT_FLAVOR_MSG = "VSP has to have a " +
"minimum of one Deployment Flavor defined for being able to be instantiated.Please add a Deployment Flavor and re-submit the VSP.";
private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
@@ -39,13 +39,13 @@
* @param version the version
*/
public static ErrorCode VendorSoftwareProductMissingServiceModelErrorBuilder(String
- vendorSoftwareProductId,
- Version version) {
+ vendorSoftwareProductId,
+ Version version) {
ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
builder.withId(VendorSoftwareProductErrorCodes.VSP_INVALID);
builder.withCategory(ErrorCategory.APPLICATION);
builder
- .withMessage(String.format(VSP_INVALID_MSG, vendorSoftwareProductId, version.toString()));
+ .withMessage(String.format(VSP_INVALID_MSG, vendorSoftwareProductId, version.getId()));
return builder.build();
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerFactoryImpl.java
index b4513de..1f9a35c 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerFactoryImpl.java
@@ -3,13 +3,16 @@
import org.openecomp.sdc.vendorsoftwareproduct.ComponentDependencyModelManager;
import org.openecomp.sdc.vendorsoftwareproduct.ComponentDependencyModelManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDaoFactory;
public class ComponentDependencyModelManagerFactoryImpl extends
ComponentDependencyModelManagerFactory {
+
private static final ComponentDependencyModelManager INSTANCE =
- new ComponentDependencyModelManagerImpl(VendorSoftwareProductDaoFactory.getInstance()
- .createInterface(), ComponentManagerFactory.getInstance().createInterface());
+ new ComponentDependencyModelManagerImpl(
+ ComponentManagerFactory.getInstance().createInterface(),
+ ComponentDependencyModelDaoFactory.getInstance().createInterface()
+ );
@Override
public ComponentDependencyModelManager createInterface() {
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerImpl.java
index 5dc1446..17d1833 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerImpl.java
@@ -1,6 +1,7 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
import org.apache.commons.lang3.StringUtils;
+import org.openecomp.core.utilities.CommonMethods;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
@@ -12,57 +13,28 @@
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
import org.openecomp.sdc.vendorsoftwareproduct.ComponentDependencyModelManager;
import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.errors.ComponentDependencyModelErrorBuilder;
+import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
import java.util.Collection;
-import java.util.List;
public class ComponentDependencyModelManagerImpl implements ComponentDependencyModelManager {
- private VendorSoftwareProductDao vendorSoftwareProductDao;
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
protected static final Logger logger =
LoggerFactory.getLogger(ComponentDependencyModelManagerImpl.class);
private ComponentManager componentManager;
+ private ComponentDependencyModelDao componentDependencyModelDao;
- public ComponentDependencyModelManagerImpl(VendorSoftwareProductDao vendorSoftwareProductDao, ComponentManager componentManager) {
- this.vendorSoftwareProductDao = vendorSoftwareProductDao;
+ public ComponentDependencyModelManagerImpl(
+ ComponentManager componentManager, ComponentDependencyModelDao componentDependencyModelDao) {
this.componentManager = componentManager;
- }
-
- @Override
- public void createComponentDependencyModel(List<ComponentDependencyModelEntity> entities,
- String vspId, Version version, String user) {
-
- mdcDataDebugMessage.debugEntryMessage("createComponentDependencyModel");
- for(ComponentDependencyModelEntity entity : entities) {
- if (!StringUtils.isEmpty(entity.getSourceComponentId())) {
- componentManager.validateComponentExistence(entity.getVspId(), entity.getVersion(),
- entity.getSourceComponentId(), user);
- if (entity.getSourceComponentId().equals(entity.getTargetComponentId())) {
- ErrorCode errorCode =
- ComponentDependencyModelErrorBuilder.getSourceTargetComponentEqualErrorBuilder();
- raiseException(errorCode);
- }
- } else {
- ErrorCode errorCode = ComponentDependencyModelErrorBuilder
- .getNoSourceComponentErrorBuilder();
- raiseException(errorCode);
- }
-
- if (!StringUtils.isEmpty(entity.getTargetComponentId())) {
- componentManager.validateComponentExistence(entity.getVspId(), entity.getVersion(),
- entity.getTargetComponentId(), user);
- }
- }
-
- vendorSoftwareProductDao.createComponentDependencyModel(entities, vspId, version );
-
- mdcDataDebugMessage.debugExitMessage("createComponentDependencyModel");
+ this.componentDependencyModelDao = componentDependencyModelDao;
}
private void raiseException(ErrorCode errorCode) {
@@ -73,11 +45,82 @@
}
@Override
- public Collection<ComponentDependencyModelEntity> list(String vspId, Version version, String
- user) {
+ public Collection<ComponentDependencyModelEntity> list(String vspId, Version version) {
mdcDataDebugMessage.debugExitMessage("VSP id, version", vspId, version.toString());
- return vendorSoftwareProductDao.listComponentDependencies(vspId, version);
+ return componentDependencyModelDao
+ .list(new ComponentDependencyModelEntity(vspId, version, null));
+ }
+
+ @Override
+ public ComponentDependencyModelEntity createComponentDependency(ComponentDependencyModelEntity
+ entity, String vspId,
+ Version version) {
+
+ validateComponentDependency(entity);
+ entity.setId(CommonMethods.nextUuId());
+ componentDependencyModelDao.create(entity);
+ return entity;
+ }
+
+ private void validateComponentDependency(ComponentDependencyModelEntity entity) {
+ if (!StringUtils.isEmpty(entity.getSourceComponentId())) {
+ componentManager.validateComponentExistence(entity.getVspId(), entity.getVersion(),
+ entity.getSourceComponentId());
+ if (entity.getSourceComponentId().equals(entity.getTargetComponentId())) {
+ ErrorCode errorCode =
+ ComponentDependencyModelErrorBuilder.getSourceTargetComponentEqualErrorBuilder();
+ raiseException(errorCode);
+ }
+ } else {
+ ErrorCode errorCode = ComponentDependencyModelErrorBuilder
+ .getNoSourceComponentErrorBuilder();
+ raiseException(errorCode);
+ }
+
+ if (!StringUtils.isEmpty(entity.getTargetComponentId())) {
+ componentManager.validateComponentExistence(entity.getVspId(), entity.getVersion(),
+ entity.getTargetComponentId());
+ }
+ }
+
+ @Override
+ public void delete(String vspId, Version version, String dependencyId) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, dependencyId", vspId, dependencyId);
+ ComponentDependencyModelEntity componentDependencyEntity = getComponentDependency(vspId,
+ version, dependencyId);
+ if (componentDependencyEntity != null) {
+ componentDependencyModelDao.delete(componentDependencyEntity);
+ }
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, dependencyId", vspId, dependencyId);
+ }
+
+ @Override
+ public void update(ComponentDependencyModelEntity entity) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, dependencyId", entity.getVspId(),
+ entity.getId());
+ ComponentDependencyModelEntity componentDependencyEntity = getComponentDependency(
+ entity.getVspId(), entity.getVersion(), entity.getId());
+ validateComponentDependency(entity);
+ componentDependencyModelDao.update(entity);
+ }
+
+ @Override
+ public ComponentDependencyModelEntity get(String vspId, Version version, String dependencyId) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, dependencyId", vspId, dependencyId);
+ ComponentDependencyModelEntity componentDependency =
+ getComponentDependency(vspId, version, dependencyId);
+ return componentDependency;
+ }
+
+ private ComponentDependencyModelEntity getComponentDependency(String vspId, Version version,
+ String dependencyId) {
+ ComponentDependencyModelEntity retrieved = componentDependencyModelDao.get(
+ new ComponentDependencyModelEntity(vspId, version, dependencyId));
+ VersioningUtil.validateEntityExistence(retrieved, new ComponentDependencyModelEntity(
+ vspId, version, dependencyId), VspDetails.ENTITY_TYPE);
+ return retrieved;
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java
index 72a38bb..1834bf0 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java
@@ -67,10 +67,10 @@
private NicManager nicManager;
private VendorSoftwareProductInfoDao vspInfoDao;
- public ComponentManagerImpl(
- ComponentDao componentDao,
- CompositionEntityDataManager compositionEntityDataManager,
- NicManager nicManager, VendorSoftwareProductInfoDao vspInfoDao) {
+ public ComponentManagerImpl(ComponentDao componentDao,
+ CompositionEntityDataManager compositionEntityDataManager,
+ NicManager nicManager,
+ VendorSoftwareProductInfoDao vspInfoDao) {
this.componentDao = componentDao;
this.compositionEntityDataManager = compositionEntityDataManager;
this.nicManager = nicManager;
@@ -78,14 +78,14 @@
}
@Override
- public Collection<ComponentEntity> listComponents(String vspId, Version version, String user) {
+ public Collection<ComponentEntity> listComponents(String vspId, Version version) {
mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
return componentDao.list(new ComponentEntity(vspId, version, null));
}
@Override
- public void deleteComponents(String vspId, Version version, String user) {
+ public void deleteComponents(String vspId, Version version) {
mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
if (!vspInfoDao.isManual(vspId, version)) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
@@ -95,12 +95,11 @@
new CompositionEditNotAllowedErrorBuilder(vspId, version).build());
}
- //componentDao.updateVspLatestModificationTime(vspId, version);
mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
}
/*@Override
- public ComponentEntity createComponent(ComponentEntity component, String user) {
+ public ComponentEntity createComponent(ComponentEntity component) {
mdcDataDebugMessage.debugEntryMessage("VSP id", component.getId());
if (!isManual(component.getVspId(), component.getVersion())) {
@@ -112,24 +111,18 @@
.build());
}
- //componentDao.updateVspLatestModificationTime(component.getVspId(), component.getVersion());
mdcDataDebugMessage.debugExitMessage("VSP id", component.getId());
return null;
}*/
@Override
- public ComponentEntity createComponent(ComponentEntity component, String user) {
+ public ComponentEntity createComponent(ComponentEntity component) {
mdcDataDebugMessage.debugEntryMessage("VSP id", component.getId());
- /*Version activeVersion =
- getVersionInfo(component.getVspId(), VersionableEntityAction.Write, user)
- .getActiveVersion();
- component.setVersion(activeVersion);*/
final String VFC_ADD_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG =
"VFCs cannot be added for VSPs onboarded with HEAT.";
- ComponentEntity createdComponent = null;
-
+ ComponentEntity createdComponent;
if (!vspInfoDao.isManual(component.getVspId(), component.getVersion())) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.CREATE_COMPONENT, ErrorLevel.ERROR.name(),
@@ -141,7 +134,7 @@
} else {
validateComponentManual(component);
updateComponentName(component);
- createdComponent = createComponent(component);
+ createdComponent = compositionEntityDataManager.createComponent(component);
}
mdcDataDebugMessage.debugExitMessage("VSP id", component.getId());
@@ -149,10 +142,6 @@
return createdComponent;
}
- private ComponentEntity createComponent(ComponentEntity component) {
- return compositionEntityDataManager.createComponent(component);
- }
-
private void updateComponentName(ComponentEntity component) {
ComponentData data = component.getComponentCompositionData();
data.setName(COMPUTE_TYPE_PREFIX + data.getDisplayName());
@@ -166,8 +155,8 @@
final String VSP_VFC_DUPLICATE_NAME_MSG = "VFC with specified name "
+ "already present in given VSP.";
- Collection<ComponentEntity> vspComponentList = listComponents(component.getVspId()
- , component.getVersion(), null);
+ Collection<ComponentEntity> vspComponentList =
+ listComponents(component.getVspId(), component.getVersion());
if (vspComponentList.size() >= 1) //1707 release only supports 1 VFC in VSP (manual creation)
{
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
@@ -202,18 +191,17 @@
}
@Override
- public CompositionEntityValidationData updateComponent(ComponentEntity component, String user) {
+ public CompositionEntityValidationData updateComponent(ComponentEntity component) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id", component
.getVspId(), component.getId());
ComponentEntity retrieved =
- getComponent(component.getVspId(), component.getVersion(), component.getId());
+ getValidatedComponent(component.getVspId(), component.getVersion(), component.getId());
boolean isManual = vspInfoDao.isManual(component.getVspId(), component.getVersion());
if (isManual) {
- validateComponentUpdateManual(component, retrieved, user);
+ validateComponentUpdateManual(retrieved);
}
-
ComponentCompositionSchemaInput schemaInput = new ComponentCompositionSchemaInput();
schemaInput.setManual(isManual);
schemaInput.setComponent(retrieved.getComponentCompositionData());
@@ -232,19 +220,18 @@
return validationData;
}
- private void validateComponentUpdateManual(ComponentEntity component, ComponentEntity
- retrieved, String user) {
+ private void validateComponentUpdateManual(ComponentEntity component) {
Collection<ComponentEntity> vspComponentList =
- listComponents(component.getVspId(), component.getVersion(), user);
+ listComponents(component.getVspId(), component.getVersion());
//VFC name should be unique within VSP
//Removing VFC with same ID from list to avoid self compare
- for(ComponentEntity ce : vspComponentList) {
+ for (ComponentEntity ce : vspComponentList) {
if (ce.getId().equals(component.getId())) {
vspComponentList.remove(ce);
break;
}
}
- if (!isVfcNameUnique(vspComponentList, component.getComponentCompositionData()
+ if (!isVfcNameUnique(vspComponentList, component.getComponentCompositionData()
.getDisplayName())) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.UPDATE_COMPONENT, ErrorLevel.ERROR.name(),
@@ -259,9 +246,9 @@
}
public CompositionEntityResponse<ComponentData> getComponent(String vspId, Version version,
- String componentId, String user) {
+ String componentId) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
- ComponentEntity componentEntity = getComponent(vspId, version, componentId);
+ ComponentEntity componentEntity = getValidatedComponent(vspId, version, componentId);
ComponentData component = componentEntity.getComponentCompositionData();
ComponentCompositionSchemaInput schemaInput = new ComponentCompositionSchemaInput();
@@ -278,7 +265,7 @@
}
@Override
- public void deleteComponent(String vspId, Version version, String componentId, String user) {
+ public void deleteComponent(String vspId, Version version, String componentId) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
if (!vspInfoDao.isManual(vspId, version)) {
@@ -289,14 +276,12 @@
new CompositionEditNotAllowedErrorBuilder(vspId, version).build());
}
- //componentDao.updateVspLatestModificationTime(vspId, version);
-
mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
}
@Override
public QuestionnaireResponse getQuestionnaire(String vspId, Version version,
- String componentId, String user) {
+ String componentId) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
@@ -306,7 +291,7 @@
VspDetails.ENTITY_TYPE);
questionnaireResponse.setData(component.getQuestionnaireData());
- List<String> nicNames = nicManager.listNics(vspId, version, componentId, user).stream()
+ List<String> nicNames = nicManager.listNics(vspId, version, componentId).stream()
.map(nic -> nic.getNicCompositionData().getName()).collect(Collectors.toList());
questionnaireResponse.setSchema(getComponentQuestionnaireSchema(
new ComponentQuestionnaireSchemaInput(nicNames, questionnaireResponse.getData() == null
@@ -319,23 +304,21 @@
@Override
public void updateQuestionnaire(String vspId, Version version, String componentId,
- String questionnaireData, String user) {
+ String questionnaireData) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
- validateComponentExistence(vspId, version, componentId, user);
+ validateComponentExistence(vspId, version, componentId);
componentDao.updateQuestionnaireData(vspId, version, componentId, questionnaireData);
- //componentDao.updateVspLatestModificationTime(vspId, version);
mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
}
@Override
- public void validateComponentExistence(String vspId, Version version, String componentId,
- String user) {
- getComponent(vspId, version, componentId);
+ public void validateComponentExistence(String vspId, Version version, String componentId) {
+ getValidatedComponent(vspId, version, componentId);
}
- private ComponentEntity getComponent(String vspId, Version version, String componentId) {
+ private ComponentEntity getValidatedComponent(String vspId, Version version, String componentId) {
ComponentEntity retrieved = componentDao.get(new ComponentEntity(vspId, version, componentId));
VersioningUtil
.validateEntityExistence(retrieved, new ComponentEntity(vspId, version, componentId),
@@ -353,8 +336,4 @@
.generate(SchemaTemplateContext.questionnaire, CompositionEntityType.component,
schemaInput);
}
-
- /*private boolean isManual(String vspId, Version version) {
- return false;
- }*/
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerFactoryImpl.java
index 71985fa..598c45f 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerFactoryImpl.java
@@ -2,7 +2,6 @@
import org.openecomp.sdc.vendorsoftwareproduct.ComputeManager;
import org.openecomp.sdc.vendorsoftwareproduct.ComputeManagerFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
@@ -15,10 +14,7 @@
VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(),
ComputeDaoFactory.getInstance().createInterface(),
CompositionEntityDataManagerFactory.getInstance().createInterface(),
- DeploymentFlavorDaoFactory.getInstance().createInterface(),
- ComponentDaoFactory.getInstance().createInterface()
-
- );
+ DeploymentFlavorDaoFactory.getInstance().createInterface());
@Override
public ComputeManager createInterface() {
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImpl.java
index be90b08..0fc0aaf 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImpl.java
@@ -2,6 +2,8 @@
import org.apache.commons.collections4.CollectionUtils;
+import org.openecomp.core.util.UniqueValueUtil;
+import org.openecomp.core.utilities.json.JsonSchemaDataGenerator;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
@@ -12,7 +14,7 @@
import org.openecomp.sdc.logging.types.LoggerErrorCode;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
import org.openecomp.sdc.vendorsoftwareproduct.ComputeManager;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
+import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
@@ -51,33 +53,22 @@
private CompositionEntityDataManager compositionEntityDataManager;
private VendorSoftwareProductInfoDao vspInfoDao;
private DeploymentFlavorDao deploymentFlavorDao;
- private ComponentDao componentDao;
- private static final String MANUAL = "Manual";
- public ComputeManagerImpl(
- VendorSoftwareProductInfoDao vspInfoDao,
- ComputeDao computeDao,
- CompositionEntityDataManager compositionEntityDataManager,
- DeploymentFlavorDao deploymentFlavorDao,
- ComponentDao componentDao
- ) {
+ public ComputeManagerImpl(VendorSoftwareProductInfoDao vspInfoDao,
+ ComputeDao computeDao,
+ CompositionEntityDataManager compositionEntityDataManager,
+ DeploymentFlavorDao deploymentFlavorDao) {
this.computeDao = computeDao;
this.compositionEntityDataManager = compositionEntityDataManager;
this.vspInfoDao = vspInfoDao;
this.deploymentFlavorDao = deploymentFlavorDao;
- this.componentDao = componentDao;
}
@Override
- public ComputeEntity createCompute(ComputeEntity compute, String user) {
- ComputeEntity createdCompute = null;
- mdcDataDebugMessage.debugEntryMessage("VSP id, component id", compute.getVspId(),
- compute.getComponentId());
+ public ComputeEntity createCompute(ComputeEntity compute) {
+ mdcDataDebugMessage
+ .debugEntryMessage("VSP id, component id", compute.getVspId(), compute.getComponentId());
- /*Version activeVersion =
- getVersionInfo(compute.getVspId(), VersionableEntityAction.Write, user).getActiveVersion();
- compute.setVersion(activeVersion);*/
- //if (!isManual(compute.getVspId(), activeVersion)) {
if (!vspInfoDao.isManual(compute.getVspId(), compute.getVersion())) {
ErrorCode onboardingMethodUpdateErrorCode = NotSupportedHeatOnboardMethodErrorBuilder
.getAddComputeNotSupportedHeatOnboardMethodErrorBuilder();
@@ -87,92 +78,45 @@
onboardingMethodUpdateErrorCode.message());
throw new CoreException(onboardingMethodUpdateErrorCode);
} else {
+ validateUniqueName(compute.getVspId(), compute.getVersion(), compute.getComponentId(),
+ compute.getComputeCompositionData().getName());
- //validateComponentId(compute.getVspId(),compute.getVersion(),compute.getComponentId());
- Collection<ComputeEntity> vfcComputeList = listCompute(compute.getVspId(),compute.getVersion
- (),compute.getComponentId());
-
- validateVfcCompute(compute, vfcComputeList, LoggerTragetServiceName.CREATE_COMPUTE);
- createdCompute = createCompute(compute);
+ compute.setQuestionnaireData(
+ new JsonSchemaDataGenerator(getComputeQuestionnaireSchema(null)).generateData());
+ computeDao.create(compute);
+ createUniqueName(compute.getVspId(), compute.getVersion(), compute.getComponentId(),
+ compute.getComputeCompositionData().getName());
}
mdcDataDebugMessage
.debugExitMessage("VSP id, component id", compute.getVspId(), compute.getComponentId());
- return createdCompute;
+ return compute;
}
- private ComputeEntity createCompute(ComputeEntity compute) {
-
- return compositionEntityDataManager.createCompute(compute);
- }
-
- /*private void validateCompute(ComputeEntity compute) {
- Collection<ComputeEntity> vfcComputeList = listCompute(compute.getVspId(),compute.getVersion
- (),compute.getComponentId());
-
- if (!isComputeNameUnique(vfcComputeList,compute.getComputeCompositionData().getName())) {
- final ErrorCode duplicateComputeInComponentErrorBuilder =
- new DuplicateComputeInComponentErrorBuilder(compute.getComputeCompositionData().getName(),
- compute.getComponentId()).build();
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.CREATE_COMPUTE, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(),
- duplicateComputeInComponentErrorBuilder.message());
- throw new CoreException(duplicateComputeInComponentErrorBuilder);
- }
-
- }*/
-
- private void validateComputeUpdate(ComputeEntity compute) {
- Collection<ComputeEntity> vfcComputeList = listCompute(compute.getVspId(),compute.getVersion
- (),compute.getComponentId());
-
- for (ComputeEntity ce : vfcComputeList) {
- if (ce.getId().equals(compute.getId())) {
- vfcComputeList.remove(ce);
- break;
- }
- }
-
- if (!isComputeNameUnique(vfcComputeList,compute.getComputeCompositionData().getName())) {
- final ErrorCode duplicateComputeInComponentErrorBuilder =
- new DuplicateComputeInComponentErrorBuilder(compute.getComputeCompositionData().getName(),
- compute.getComponentId()).build();
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.UPDATE_COMPUTE, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(),
- duplicateComputeInComponentErrorBuilder.message());
- throw new CoreException(duplicateComputeInComponentErrorBuilder);
- }
-
- }
@Override
- public Collection<ListComputeResponse> listCompute(String vspId, Version version,
- String componentId, String user) {
-
+ public Collection<ListComputeResponse> listComputes(String vspId, Version version,
+ String componentId) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
- //validateComponentId(vspId, version, componentId);
- ComputeEntity entity = new ComputeEntity(vspId, version, componentId, null);
- Collection<ComputeEntity> computes = computeDao.list(entity);
+ Collection<ComputeEntity> computes =
+ computeDao.list(new ComputeEntity(vspId, version, componentId, null));
Collection<ListComputeResponse> computeResponse =
- getListComputeResponse(vspId, version, user, computes);
+ getListComputeResponse(vspId, version, computes);
mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
return computeResponse;
}
private Collection<ListComputeResponse> getListComputeResponse(String vspId, Version version,
- String user,
Collection<ComputeEntity> computes) {
- Set<String> vspComputes = getComputeAssociatedWithDepFlavors(vspId, version, user);
- Collection<ListComputeResponse> computeResponse = new ArrayList<ListComputeResponse>();
- for(ComputeEntity computeEntity : computes) {
+ Set<String> vspComputes = getComputeAssociatedWithDepFlavors(vspId, version);
+ Collection<ListComputeResponse> computeResponse = new ArrayList<>();
+ for (ComputeEntity computeEntity : computes) {
ListComputeResponse response = new ListComputeResponse();
response.setComputeEntity(computeEntity);
- if(vspComputes.contains(computeEntity.getId())) {
+ if (vspComputes.contains(computeEntity.getId())) {
response.setAssociatedWithDeploymentFlavor(true);
} else {
response.setAssociatedWithDeploymentFlavor(false);
@@ -182,16 +126,15 @@
return computeResponse;
}
- private Set<String> getComputeAssociatedWithDepFlavors(String vspId, Version version,
- String user) {
+ private Set<String> getComputeAssociatedWithDepFlavors(String vspId, Version version) {
final Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null));
- Set<String> vspComputes = new HashSet<String>();
- for(DeploymentFlavorEntity entity : deploymentFlavorEntities) {
+ Set<String> vspComputes = new HashSet<>();
+ for (DeploymentFlavorEntity entity : deploymentFlavorEntities) {
final List<ComponentComputeAssociation> componentComputeAssociations =
entity.getDeploymentFlavorCompositionData().getComponentComputeAssociations();
- if(componentComputeAssociations != null && !componentComputeAssociations.isEmpty()) {
- for(ComponentComputeAssociation association : componentComputeAssociations) {
+ if (componentComputeAssociations != null && !componentComputeAssociations.isEmpty()) {
+ for (ComponentComputeAssociation association : componentComputeAssociations) {
vspComputes.add(association.getComputeFlavorId());
}
}
@@ -199,32 +142,14 @@
return vspComputes;
}
- private boolean isComputeNameUnique(Collection<ComputeEntity> vfcComputeList, String name) {
- for (ComputeEntity compute : vfcComputeList) {
- if (compute.getComputeCompositionData().getName().equalsIgnoreCase(name)) {
- return false;
- }
- }
- return true;
- }
-
- private Collection<ComputeEntity> listCompute(String vspId, Version version,String componentId) {
- Collection<ComputeEntity> computeEntities =
- computeDao.list(new ComputeEntity(vspId, version, componentId, null));
-
- return computeEntities;
- }
-
@Override
public CompositionEntityResponse<ComputeData> getCompute(String vspId, Version version,
String componentId,
- String computeFlavorId, String user) {
+ String computeFlavorId) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id, compute id", vspId,
componentId, computeFlavorId);
- /*version = VersioningUtil
- .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));*/
- ComputeEntity computeEntity = getCompute(vspId, version, componentId, computeFlavorId);
+ ComputeEntity computeEntity = getValidatedCompute(vspId, version, componentId, computeFlavorId);
ComputeData compute = computeEntity.getComputeCompositionData();
ComputeCompositionSchemaInput schemaInput = new ComputeCompositionSchemaInput();
@@ -242,9 +167,8 @@
return response;
}
- private ComputeEntity getCompute(String vspId, Version version, String componentId, String
- computeFlavorId) {
- //validateComponentId(vspId,version,componentId);
+ private ComputeEntity getValidatedCompute(String vspId, Version version, String componentId,
+ String computeFlavorId) {
ComputeEntity retrieved = computeDao.get(new ComputeEntity(vspId, version, componentId,
computeFlavorId));
VersioningUtil
@@ -253,186 +177,113 @@
return retrieved;
}
- /*private void validateComponentId(String vspId, Version version, String componentId) {
- ComponentEntity retrivedComponent = componentDao.get(new ComponentEntity(vspId, version,
- componentId));
- VersioningUtil
- .validateEntityExistence(retrivedComponent, new ComponentEntity(vspId, version,
- componentId),VspDetails.ENTITY_TYPE);
- }*/
-
@Override
public QuestionnaireResponse getComputeQuestionnaire(String vspId, Version version, String
- componentId, String computeId, String user) {
+ componentId, String computeId) {
mdcDataDebugMessage.debugEntryMessage("VSP id, componentId", vspId, componentId, computeId);
- /*version = VersioningUtil
- .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));*/
- //validateComponentId(vspId,version,componentId);
QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
- //validateComponentId(vspId,version,componentId);
- ComputeEntity computeQuestionnaire = computeDao.getQuestionnaireData(vspId, version, componentId, computeId);
+ ComputeEntity computeQuestionnaire =
+ computeDao.getQuestionnaireData(vspId, version, componentId, computeId);
VersioningUtil
- .validateEntityExistence(computeQuestionnaire, new ComputeEntity(vspId, version, componentId,
- computeId), VspDetails.ENTITY_TYPE);
+ .validateEntityExistence(computeQuestionnaire,
+ new ComputeEntity(vspId, version, componentId, computeId), VspDetails.ENTITY_TYPE);
questionnaireResponse.setData(computeQuestionnaire.getQuestionnaireData());
questionnaireResponse.setSchema(getComputeQuestionnaireSchema(null));
- mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId,
- componentId, computeId);
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId, computeId);
return questionnaireResponse;
}
- protected String getComputeQuestionnaireSchema(SchemaTemplateInput schemaInput) {
- mdcDataDebugMessage.debugEntryMessage(null, null);
-
- mdcDataDebugMessage.debugExitMessage(null, null);
- return SchemaGenerator
- .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.compute,
- schemaInput);
- }
-
-
@Override
- public void updateComputeQuestionnaire(String vspId, Version version, String componentId, String
- computeId,
- String questionnaireData, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id, component id, compute id", vspId,
- componentId, computeId);
+ public void updateComputeQuestionnaire(String vspId, Version version, String componentId,
+ String computeId, String questionnaireData) {
+ mdcDataDebugMessage
+ .debugEntryMessage("VSP id, component id, compute id", vspId, componentId, computeId);
- /*Version activeVersion =
- getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();
- getComponent(vspId, activeVersion, componentId);*/
- ComputeEntity retrieved = computeDao.get(new ComputeEntity(vspId,version,componentId,
+ ComputeEntity retrieved = computeDao.get(new ComputeEntity(vspId, version, componentId,
computeId));
VersioningUtil.validateEntityExistence(retrieved, new ComputeEntity(vspId, version,
componentId, computeId), VspDetails.ENTITY_TYPE);
computeDao.updateQuestionnaireData(vspId, version, componentId, computeId, questionnaireData);
- mdcDataDebugMessage.debugExitMessage("VSP id, component id, compute id", vspId,
- componentId, computeId);
+ mdcDataDebugMessage
+ .debugExitMessage("VSP id, component id, compute id", vspId, componentId, computeId);
}
@Override
- public CompositionEntityValidationData updateCompute(ComputeEntity compute, String user) {
+ public CompositionEntityValidationData updateCompute(ComputeEntity compute) {
mdcDataDebugMessage
- .debugEntryMessage("VSP id, component id", compute.getVspId(), compute.getComponentId(),
- compute.getId());
-
- /*Version activeVersion =
- getVersionInfo(image.getVspId(), VersionableEntityAction.Write, user).getActiveVersion();
- image.setVersion(activeVersion);*/
-
- ComputeEntity retrieved = getComputeEntity(compute.getVspId(), compute.getVersion(), compute.getComponentId(),
+ .debugEntryMessage("VSP id, component id", compute.getVspId(), compute.getComponentId(),
compute.getId());
- if(!vspInfoDao.isManual(compute.getVspId(), compute.getVersion())) {
- final ComputeData computeCompositionData = compute.getComputeCompositionData();
- final String name = computeCompositionData.getName();
- //final String format = computeCompositionData.getFormat();
- validateHeatVspComputeUpdate("Name", name, retrieved.getComputeCompositionData()
- .getName());
- /*validateHeatVspComputeUpdate("format", format, retrieved.getComputeCompositionData()
- .getFormat());*/
+ ComputeEntity retrieved =
+ getComputeEntity(compute.getVspId(), compute.getVersion(), compute.getComponentId(),
+ compute.getId());
+
+ boolean manual = vspInfoDao.isManual(compute.getVspId(), compute.getVersion());
+ if (!manual) {
+ validateHeatVspComputeUpdate("Name",
+ compute.getComputeCompositionData().getName(),
+ retrieved.getComputeCompositionData().getName());
}
- Collection<ComputeEntity> vfcComputeList = listComputes(compute.getVspId() ,
- compute.getVersion(), compute.getComponentId());
-
- //Set to null so that retrieved object is equal to one in list and gets removed.
- retrieved.setQuestionnaireData(null);
- vfcComputeList.remove(retrieved);
- if(vspInfoDao.isManual(compute.getVspId(), compute.getVersion()))
- validateVfcCompute(compute, vfcComputeList, LoggerTragetServiceName.UPDATE_COMPUTE);
-
- //Set format to default value in order to handle FTL validation when compute format is null
- /*if(compute.getComputeCompositionData().getFormat() == null)
- compute.getComputeCompositionData().setFormat(ComputeFormat.qcow2.name());*/
-
ComputeCompositionSchemaInput schemaInput = new ComputeCompositionSchemaInput();
schemaInput.setCompute(compute.getComputeCompositionData());
CompositionEntityValidationData validationData = compositionEntityDataManager
- .validateEntity(compute, SchemaTemplateContext.composition, schemaInput);
+ .validateEntity(compute, SchemaTemplateContext.composition, schemaInput);
if (CollectionUtils.isEmpty(validationData.getErrors())) {
+ updateUniqueName(compute.getVspId(), compute.getVersion(), compute.getComponentId(),
+ retrieved.getComputeCompositionData().getName(),
+ compute.getComputeCompositionData().getName());
computeDao.update(compute);
}
mdcDataDebugMessage
- .debugExitMessage("VSP id, component id", compute.getVspId(), compute.getComponentId(),
- compute.getId());
+ .debugExitMessage("VSP id, component id", compute.getVspId(), compute.getComponentId(),
+ compute.getId());
return validationData;
}
private void validateHeatVspComputeUpdate(String name, String value, String retrivedValue) {
- if(value != null && !value.equals(retrivedValue)) {
+ if (value != null && !value.equals(retrivedValue)) {
final ErrorCode updateHeatComputeErrorBuilder =
- DuplicateComputeInComponentErrorBuilder.getComputeHeatReadOnlyErrorBuilder(name);
+ DuplicateComputeInComponentErrorBuilder.getComputeHeatReadOnlyErrorBuilder(name);
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.UPDATE_COMPUTE, ErrorLevel.ERROR.name(),
- LoggerErrorCode.PERMISSION_ERROR.getErrorCode(),
- updateHeatComputeErrorBuilder.message());
+ LoggerTragetServiceName.UPDATE_COMPUTE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(),
+ updateHeatComputeErrorBuilder.message());
throw new CoreException(updateHeatComputeErrorBuilder);
}
}
- private void validateVfcCompute(ComputeEntity compute, Collection<ComputeEntity> vfcComputeList,
- String event) {
- if (isComputeNameDuplicate(vfcComputeList,compute.getComputeCompositionData().getName(),
- compute.getId())) {
- ErrorCode errorCode = DuplicateComputeInComponentErrorBuilder
- .getDuplicateComputeNameErrorBuilder(compute.getComputeCompositionData().getName(),
- compute.getComponentId());
-
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- event, ErrorLevel.ERROR.name(),
- errorCode.id(),errorCode.message());
-
- throw new CoreException(errorCode);
- }
- }
-
- private boolean isComputeNameDuplicate(Collection<ComputeEntity> computes, String name, String computeId) {
- for (ComputeEntity compute : computes) {
- if (compute.getComputeCompositionData().getName().equalsIgnoreCase(name) && !compute.getId().equals(computeId)) {
- return true;
- }
- }
- return false;
- }
-
-
private ComputeEntity getComputeEntity(String vspId, Version version, String componentId,
- String computeId) {
- //validateComponentId(vspId,version,componentId);
- ComputeEntity computeEntity = computeDao.get(new ComputeEntity(vspId, version, componentId, computeId));
- VersioningUtil.validateEntityExistence(computeEntity, new ComputeEntity(vspId, version, componentId,
- computeId), VspDetails.ENTITY_TYPE);
- return computeEntity;
- }
-
- private Collection<ComputeEntity> listComputes(String vspId, Version version, String componentId) {
- return computeDao.list(new ComputeEntity(vspId, version, componentId, null));
+ String computeId) {
+ ComputeEntity computeEntity =
+ computeDao.get(new ComputeEntity(vspId, version, componentId, computeId));
+ VersioningUtil
+ .validateEntityExistence(computeEntity, new ComputeEntity(vspId, version, componentId,
+ computeId), VspDetails.ENTITY_TYPE);
+ return computeEntity;
}
@Override
- public void deleteCompute(String vspId, Version version, String componentId, String
- computeFlavorId, String user) {
+ public void deleteCompute(String vspId, Version version, String componentId,
+ String computeFlavorId) {
final String VSP_COMPOSITION_EDIT_NOT_ALLOWED_MSG =
"Composition entities may not be created / deleted for Vendor Software Product "
+ "whose entities were uploaded";
mdcDataDebugMessage.debugEntryMessage("VSP id, component id, compute id", vspId,
componentId, computeFlavorId);
- /*Version activeVersion =
- getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();*/
if (!vspInfoDao.isManual(vspId, version)) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.DELETE_COMPUTE, ErrorLevel.ERROR.name(),
@@ -442,30 +293,32 @@
.withId(VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED)
.withMessage(VSP_COMPOSITION_EDIT_NOT_ALLOWED_MSG).build());
}
- ComputeEntity retrived = getCompute(vspId,version,componentId,computeFlavorId);
- if (retrived != null){
- deleteComputeFromDeploymentFlavors(vspId,version,computeFlavorId);
+ ComputeEntity retrieved = getValidatedCompute(vspId, version, componentId, computeFlavorId);
+ if (retrieved != null) {
+ deleteComputeFromDeploymentFlavors(vspId, version, computeFlavorId);
computeDao.delete(new ComputeEntity(vspId, version, componentId, computeFlavorId));
+ deleteUniqueValue(retrieved.getVspId(), retrieved.getVersion(), retrieved.getComponentId(),
+ retrieved.getComputeCompositionData().getName());
}
mdcDataDebugMessage.debugExitMessage("VSP id, component id, compute id", vspId,
componentId, computeFlavorId);
}
- private void deleteComputeFromDeploymentFlavors(String vspId, Version activeVersion,
+ private void deleteComputeFromDeploymentFlavors(String vspId, Version version,
String computeFlavorId) {
- //Collection<DeploymentFlavorEntity> listDF = listDeploymentFlavors(vspId, activeVersion);
- Collection<DeploymentFlavorEntity> listDF = deploymentFlavorDao.list(new DeploymentFlavorEntity
- (vspId, activeVersion, null));
- for(DeploymentFlavorEntity df : listDF) {
- DeploymentFlavorEntity deploymentFlavorEntity=removeComputeFromDF(df, computeFlavorId);
- if(deploymentFlavorEntity!=null)
+ Collection<DeploymentFlavorEntity> listDF =
+ deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null));
+ for (DeploymentFlavorEntity df : listDF) {
+ DeploymentFlavorEntity deploymentFlavorEntity = removeComputeFromDF(df, computeFlavorId);
+ if (deploymentFlavorEntity != null) {
deploymentFlavorDao.update(deploymentFlavorEntity);
+ }
}
}
- private DeploymentFlavorEntity removeComputeFromDF(DeploymentFlavorEntity df, String
- computeFlavorId) {
+ private DeploymentFlavorEntity removeComputeFromDF(DeploymentFlavorEntity df,
+ String computeFlavorId) {
DeploymentFlavor flavor = df.getDeploymentFlavorCompositionData();
List<ComponentComputeAssociation> associations = flavor.getComponentComputeAssociations();
if (associations != null) {
@@ -486,20 +339,47 @@
return null;
}
- protected String getComputeCompositionSchema(SchemaTemplateInput schemaInput){
- mdcDataDebugMessage.debugEntryMessage(null, null);
- mdcDataDebugMessage.debugExitMessage(null, null);
- return SchemaGenerator.generate(SchemaTemplateContext.composition, CompositionEntityType.compute, schemaInput);
+ protected String getComputeCompositionSchema(SchemaTemplateInput schemaInput) {
+ mdcDataDebugMessage.debugEntryMessage(null);
+ mdcDataDebugMessage.debugExitMessage(null);
+ return SchemaGenerator
+ .generate(SchemaTemplateContext.composition, CompositionEntityType.compute, schemaInput);
}
- /*boolean isManual(String vspId, Version version) {
+ protected String getComputeQuestionnaireSchema(SchemaTemplateInput schemaInput) {
+ mdcDataDebugMessage.debugEntryMessage(null);
+ mdcDataDebugMessage.debugExitMessage(null);
+ return SchemaGenerator
+ .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.compute, schemaInput);
+ }
- VspDetails vsp = vspInfoDao.get(new VspDetails(vspId, version));
- String onboardingMethod = vsp.getOnboardingMethod();
- if (MANUAL.equals(onboardingMethod)) {
- return true;
+ protected void validateUniqueName(String vspId, Version version, String componentId,
+ String name) {
+ UniqueValueUtil.validateUniqueValue(VendorSoftwareProductConstants.UniqueValues.COMPUTE_NAME,
+ vspId, version.getId(), componentId, name);
+ }
+
+ protected void createUniqueName(String vspId, Version version, String componentId, String name) {
+ UniqueValueUtil
+ .createUniqueValue(VendorSoftwareProductConstants.UniqueValues.COMPUTE_NAME, vspId,
+ version.getId(), componentId, name);
+ }
+
+ protected void updateUniqueName(String vspId, Version version, String componentId,
+ String oldName, String newName) {
+ UniqueValueUtil
+ .updateUniqueValue(VendorSoftwareProductConstants.UniqueValues.COMPUTE_NAME, oldName,
+ newName, vspId, version.getId(), componentId);
+ }
+
+ protected void deleteUniqueValue(String vspId, Version version, String componentId, String name) {
+ if (componentId == null) {
+ UniqueValueUtil
+ .deleteUniqueValue(VendorSoftwareProductConstants.UniqueValues.COMPUTE_NAME, vspId,
+ version.getId(), name);
}
- return false;
- }*/
-
+ UniqueValueUtil
+ .deleteUniqueValue(VendorSoftwareProductConstants.UniqueValues.COMPUTE_NAME, vspId,
+ version.getId(), componentId, name);
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImpl.java
index 0873eaf..f1acaae 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImpl.java
@@ -44,18 +44,14 @@
private VendorSoftwareProductInfoDao vspInfoDao;
private DeploymentFlavorDao deploymentFlavorDao;
private CompositionEntityDataManager compositionEntityDataManager;
- private ComponentDao componentDao;
+ private ComponentDao componentDao;
private ComputeDao computeDao;
- public DeploymentFlavorManagerImpl(
- VendorSoftwareProductInfoDao vspInfoDao,
- DeploymentFlavorDao deploymentFlavorDao,
- CompositionEntityDataManager compositionEntityDataManager,
- ComponentDao componentDao,
- ComputeDao computeDao
-
- ) {
-
+ public DeploymentFlavorManagerImpl(VendorSoftwareProductInfoDao vspInfoDao,
+ DeploymentFlavorDao deploymentFlavorDao,
+ CompositionEntityDataManager compositionEntityDataManager,
+ ComponentDao componentDao,
+ ComputeDao computeDao) {
this.vspInfoDao = vspInfoDao;
this.deploymentFlavorDao = deploymentFlavorDao;
this.compositionEntityDataManager = compositionEntityDataManager;
@@ -65,31 +61,17 @@
}
@Override
- public Collection<DeploymentFlavorEntity> listDeploymentFlavors(String vspId, Version version,
- String user) {
+ public Collection<DeploymentFlavorEntity> listDeploymentFlavors(String vspId, Version version) {
mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
- /*version = VersioningUtil
- .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));*/
-
mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
- return listDeploymentFlavors(vspId, version);
- }
-
- private Collection<DeploymentFlavorEntity> listDeploymentFlavors(String vspId, Version version) {
- Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
- deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null));
- return deploymentFlavorEntities;
+ return deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null));
}
@Override
public DeploymentFlavorEntity createDeploymentFlavor(
- DeploymentFlavorEntity deploymentFlavorEntity, String user) {
- DeploymentFlavorEntity createDeploymentFlavor = null;
+ DeploymentFlavorEntity deploymentFlavorEntity) {
+ DeploymentFlavorEntity createDeploymentFlavor;
mdcDataDebugMessage.debugEntryMessage("VSP id ", deploymentFlavorEntity.getVspId());
- /*Version activeVersion =
- getVersionInfo(deploymentFlavorEntity.getVspId(), VersionableEntityAction.Write, user)
- .getActiveVersion();
- deploymentFlavorEntity.setVersion(activeVersion);*/
if (!vspInfoDao.isManual(deploymentFlavorEntity.getVspId(),
deploymentFlavorEntity.getVersion())) {
@@ -100,31 +82,30 @@
LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), deploymentFlavorErrorBuilder.message());
throw new CoreException(deploymentFlavorErrorBuilder);
} else {
- validateDeploymentFlavor(deploymentFlavorEntity, user, deploymentFlavorEntity.getVersion());
+ validateDeploymentFlavor(deploymentFlavorEntity, deploymentFlavorEntity.getVersion());
createDeploymentFlavor =
compositionEntityDataManager.createDeploymentFlavor(deploymentFlavorEntity);
}
return createDeploymentFlavor;
}
- private void validateDeploymentFlavor(DeploymentFlavorEntity deploymentFlavorEntity, String
- user, Version activeVersion) {
-
+ private void validateDeploymentFlavor(DeploymentFlavorEntity deploymentFlavorEntity,
+ Version version) {
//Validation for unique model.
Collection<DeploymentFlavorEntity> listDeploymentFlavors =
listDeploymentFlavors(deploymentFlavorEntity.getVspId(),
- activeVersion);
+ version);
isDeploymentFlavorModelDuplicate(deploymentFlavorEntity, listDeploymentFlavors);
List<String> featureGroups =
- getFeatureGroupListForVsp(deploymentFlavorEntity.getVspId(), user, activeVersion);
+ getFeatureGroupListForVsp(deploymentFlavorEntity.getVspId(), version);
String featureGroup = deploymentFlavorEntity.getDeploymentFlavorCompositionData()
.getFeatureGroupId();
- if (featureGroup != null && featureGroup.trim().length()>0) {
+ if (featureGroup != null && featureGroup.trim().length() > 0) {
if (isEmpty(featureGroups) || (!(validFeatureGroup(featureGroups, featureGroup)))) {
ErrorCode deploymentFlavorErrorBuilder = DeploymentFlavorErrorBuilder
.getFeatureGroupNotexistErrorBuilder(featureGroup, deploymentFlavorEntity.getVspId(),
- activeVersion);
+ version);
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.CREATE_DEPLOYMENT_FLAVOR, ErrorLevel.ERROR.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), deploymentFlavorErrorBuilder.message());
@@ -132,7 +113,7 @@
}
}
- validateComponentComputeAssociation(deploymentFlavorEntity, activeVersion);
+ validateComponentComputeAssociation(deploymentFlavorEntity, version);
}
private void isDeploymentFlavorModelDuplicate(DeploymentFlavorEntity deploymentFlavorEntity,
@@ -152,14 +133,8 @@
});
}
- private List<String> getFeatureGroupListForVsp(String vspId,
- String user, Version activeVersion) {
- /*VersionedVendorSoftwareProductInfo versionedVendorSoftwareProductInfo = getVspDetails(
- vspId,activeVersion, user);
- return versionedVendorSoftwareProductInfo.getVspDetails()
- .getFeatureGroups();*/
-
- final VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, activeVersion));
+ private List<String> getFeatureGroupListForVsp(String vspId, Version version) {
+ final VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));
return vspDetails.getFeatureGroups();
}
@@ -183,7 +158,7 @@
}
private void validateComponentComputeAssociation(DeploymentFlavorEntity deploymentFlavorEntity,
- Version activeVersion) {
+ Version version) {
List<ComponentComputeAssociation> componentComputeAssociationList = deploymentFlavorEntity
.getDeploymentFlavorCompositionData().getComponentComputeAssociations();
List<String> vfcList = new ArrayList<>();
@@ -201,14 +176,14 @@
LoggerErrorCode.DATA_ERROR.getErrorCode(), invalidAssociationErrorBuilder.message());
throw new CoreException(invalidAssociationErrorBuilder);
} else if (componentComputeAssociation.getComponentId() != null &&
- componentComputeAssociation.getComponentId().trim().length() > 0 ) {
- ComponentEntity component = getComponent(deploymentFlavorEntity.getVspId(), activeVersion,
+ componentComputeAssociation.getComponentId().trim().length() > 0) {
+ ComponentEntity component = getComponent(deploymentFlavorEntity.getVspId(), version,
componentComputeAssociation.getComponentId());
if (componentComputeAssociation
.getComputeFlavorId() != null && componentComputeAssociation
- .getComputeFlavorId().trim().length() > 0 ) {
+ .getComputeFlavorId().trim().length() > 0) {
ComputeEntity computeFlavor = computeDao.get(new ComputeEntity(deploymentFlavorEntity
- .getVspId(), activeVersion, componentComputeAssociation.getComponentId(),
+ .getVspId(), version, componentComputeAssociation.getComponentId(),
componentComputeAssociation.getComputeFlavorId()));
if (computeFlavor == null) {
ErrorCode invalidComputeIdErrorBuilder = DeploymentFlavorErrorBuilder
@@ -251,22 +226,19 @@
@Override
public CompositionEntityResponse<DeploymentFlavor> getDeploymentFlavor(String vspId,
Version version,
- String deploymentFlavorId,
- String user) {
+ String deploymentFlavorId) {
mdcDataDebugMessage
.debugEntryMessage("VSP id, deployment flavor id", vspId, deploymentFlavorId);
- /*version = VersioningUtil
- .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));*/
- DeploymentFlavorEntity deploymentFlavorEntity = getDeploymentFlavor(vspId,version,
- deploymentFlavorId);
+ DeploymentFlavorEntity deploymentFlavorEntity =
+ getValidatedDeploymentFlavor(vspId, version, deploymentFlavorId);
DeploymentFlavor deploymentFlavor = deploymentFlavorEntity.getDeploymentFlavorCompositionData();
DeploymentFlavorCompositionSchemaInput schemaInput = new
DeploymentFlavorCompositionSchemaInput();
schemaInput.setManual(vspInfoDao.isManual(vspId, version));
schemaInput.setDeploymentFlavor(deploymentFlavor);
List<String> featureGroups =
- getFeatureGroupListForVsp(vspId, user, version);
+ getFeatureGroupListForVsp(vspId, version);
schemaInput.setFeatureGroupIds(featureGroups);
CompositionEntityResponse<DeploymentFlavor> response = new CompositionEntityResponse<>();
response.setId(deploymentFlavorId);
@@ -280,27 +252,24 @@
return response;
}
- private DeploymentFlavorEntity getDeploymentFlavor(String vspId, Version version, String
+ private DeploymentFlavorEntity getValidatedDeploymentFlavor(String vspId, Version version, String
deploymentFlavorId) {
DeploymentFlavorEntity retrieved = deploymentFlavorDao.get(new DeploymentFlavorEntity(vspId,
version, deploymentFlavorId));
VersioningUtil
.validateEntityExistence(retrieved, new DeploymentFlavorEntity(vspId, version,
- deploymentFlavorId ), VspDetails.ENTITY_TYPE);
+ deploymentFlavorId), VspDetails.ENTITY_TYPE);
return retrieved;
}
@Override
public CompositionEntityResponse<DeploymentFlavor> getDeploymentFlavorSchema(String vspId,
- Version version,
- String user) {
- /*version = VersioningUtil
- .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));*/
- DeploymentFlavorCompositionSchemaInput schemaInput= new
- DeploymentFlavorCompositionSchemaInput();
+ Version version) {
+ DeploymentFlavorCompositionSchemaInput schemaInput =
+ new DeploymentFlavorCompositionSchemaInput();
schemaInput.setManual(vspInfoDao.isManual(vspId, version));
List<String> featureGroups =
- getFeatureGroupListForVsp(vspId, user, version);
+ getFeatureGroupListForVsp(vspId, version);
schemaInput.setFeatureGroupIds(featureGroups);
CompositionEntityResponse<DeploymentFlavor> response = new CompositionEntityResponse<>();
response.setSchema((SchemaGenerator
@@ -310,14 +279,13 @@
}
@Override
- public void deleteDeploymentFlavor(String vspId, Version version, String deploymentFlavorId,
- String user) {
+ public void deleteDeploymentFlavor(String vspId, Version version, String deploymentFlavorId) {
mdcDataDebugMessage
.debugEntryMessage("VSP id, deployment flavor id", vspId, deploymentFlavorId);
/*Version activeVersion =
getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();*/
- DeploymentFlavorEntity deploymentFlavorEntity = getDeploymentFlavor(vspId,version,
- deploymentFlavorId);
+ DeploymentFlavorEntity deploymentFlavorEntity =
+ getValidatedDeploymentFlavor(vspId, version, deploymentFlavorId);
if (!vspInfoDao.isManual(vspId, version)) {
final ErrorCode deleteDeploymentFlavorErrorBuilder =
NotSupportedHeatOnboardMethodErrorBuilder
@@ -328,7 +296,7 @@
deleteDeploymentFlavorErrorBuilder.message());
throw new CoreException(deleteDeploymentFlavorErrorBuilder);
}
- if(deploymentFlavorEntity != null) {
+ if (deploymentFlavorEntity != null) {
deploymentFlavorDao.delete(new DeploymentFlavorEntity(vspId, version, deploymentFlavorId));
}
@@ -336,8 +304,8 @@
.debugExitMessage("VSP id, deployment flavor id", vspId, deploymentFlavorId);
}
- public CompositionEntityValidationData updateDeploymentFlavor(DeploymentFlavorEntity
- deploymentFlavorEntity, String user) {
+ public CompositionEntityValidationData updateDeploymentFlavor(
+ DeploymentFlavorEntity deploymentFlavorEntity) {
mdcDataDebugMessage.debugEntryMessage("VSP id, deploymentFlavor id", deploymentFlavorEntity
.getVspId(), deploymentFlavorEntity.getId());
/*Version activeVersion =
@@ -355,9 +323,9 @@
updateDeploymentFlavorErrorBuilder.message());
throw new CoreException(updateDeploymentFlavorErrorBuilder);
}
- //deploymentFlavorEntity.setVersion(activeVersion);
DeploymentFlavorEntity retrieved =
- getDeploymentFlavor(deploymentFlavorEntity.getVspId(), deploymentFlavorEntity.getVersion(),
+ getValidatedDeploymentFlavor(deploymentFlavorEntity.getVspId(),
+ deploymentFlavorEntity.getVersion(),
deploymentFlavorEntity.getId());
@@ -367,7 +335,8 @@
isDeploymentFlavorModelDuplicate(deploymentFlavorEntity, listDeploymentFlavors);
//validateComponentComputeAssociation(deploymentFlavorEntity, activeVersion);
- validateComponentComputeAssociation(deploymentFlavorEntity, deploymentFlavorEntity.getVersion());
+ validateComponentComputeAssociation(deploymentFlavorEntity,
+ deploymentFlavorEntity.getVersion());
DeploymentFlavorCompositionSchemaInput schemaInput = new
DeploymentFlavorCompositionSchemaInput();
@@ -376,7 +345,7 @@
schemaInput.setDeploymentFlavor(retrieved.getDeploymentFlavorCompositionData());
List<String> featureGroups =
- getFeatureGroupListForVsp(deploymentFlavorEntity.getVspId(), user,
+ getFeatureGroupListForVsp(deploymentFlavorEntity.getVspId(),
deploymentFlavorEntity.getVersion());
schemaInput.setFeatureGroupIds(featureGroups);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImpl.java
index 82b7139..0429ba4 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImpl.java
@@ -37,72 +37,49 @@
import java.util.Collection;
import java.util.stream.Collectors;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-
public class ImageManagerImpl implements ImageManager {
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
private VendorSoftwareProductInfoDao vspInfoDao;
private ImageDao imageDao;
private CompositionEntityDataManager compositionEntityDataManager;
- private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
-
- public ImageManagerImpl(
- VendorSoftwareProductInfoDao vspInfoDao,
- ImageDao imageDao,
- CompositionEntityDataManager compositionEntityDataManager
-
- ) {
-
+ public ImageManagerImpl(VendorSoftwareProductInfoDao vspInfoDao,
+ ImageDao imageDao,
+ CompositionEntityDataManager compositionEntityDataManager) {
this.vspInfoDao = vspInfoDao;
this.imageDao = imageDao;
this.compositionEntityDataManager = compositionEntityDataManager;
-
}
@Override
- public ImageEntity createImage(ImageEntity imageEntity, String user) {
- /*Version activeVersion = getVersionInfo(imageEntity.getVspId(),
- VersionableEntityAction.Write, user).getActiveVersion();
-
- imageEntity.setVersion(activeVersion);*/
+ public ImageEntity createImage(ImageEntity imageEntity) {
boolean isManual = vspInfoDao.isManual(imageEntity.getVspId(), imageEntity.getVersion());
if (!isManual) {
-
ErrorCode errorCode = NotSupportedHeatOnboardMethodErrorBuilder
- .getAddImageNotSupportedHeatOnboardMethodErrorBuilder();
+ .getAddImageNotSupportedHeatOnboardMethodErrorBuilder();
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.CREATE_IMAGE, ErrorLevel.ERROR.name(),
- errorCode.id(), errorCode.message());
+ LoggerTragetServiceName.CREATE_IMAGE, ErrorLevel.ERROR.name(),
+ errorCode.id(), errorCode.message());
throw new CoreException(errorCode);
}
-
- /*Collection<ImageEntity> vfcImageList = listImages(imageEntity.getVspId() ,
- imageEntity.getVersion(), imageEntity.getComponentId());*/
compositionEntityDataManager.createImage(imageEntity);
return imageEntity;
}
@Override
- public Collection<ImageEntity> listImages(String vspId, Version version, String componentId,
- String user) {
+ public Collection<ImageEntity> listImages(String vspId, Version version, String componentId) {
mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
- Collection<ImageEntity> imageEntities = listImages(vspId, version, componentId);
+ Collection<ImageEntity> imageEntities =
+ imageDao.list(new ImageEntity(vspId, version, componentId, null));
mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
-
return imageEntities;
}
- private Collection<ImageEntity> listImages(String vspId, Version version, String componentId) {
- return imageDao.list(new ImageEntity(vspId, version, componentId, null));
- }
-
@Override
- public CompositionEntityResponse getImageSchema(String vspId, String user) {
+ public CompositionEntityResponse<Image> getImageSchema(String vspId) {
mdcDataDebugMessage.debugEntryMessage("VSP id, image id", vspId);
CompositionEntityResponse<Image> response = new CompositionEntityResponse<>();
@@ -118,14 +95,10 @@
@Override
public CompositionEntityResponse<Image> getImage(String vspId, Version version, String
- componentId, String imageId, String user) {
+ componentId, String imageId) {
mdcDataDebugMessage.debugEntryMessage("VSP id, componentId, image id", vspId, componentId,
- imageId);
-
- /*version = VersioningUtil
- .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));*/
-
+ imageId);
ImageEntity imageEntity = getImageEntity(vspId, version, componentId, imageId);
Image image = imageEntity.getImageCompositionData();
@@ -142,25 +115,21 @@
response.setSchema(getImageCompositionSchema(schemaInput));
mdcDataDebugMessage.debugExitMessage("VSP id, componentId, image id", vspId, componentId,
- imageId);
+ imageId);
return response;
}
@Override
public QuestionnaireResponse getImageQuestionnaire(String vspId, Version version, String
- componentId, String imageId, String user) {
+ componentId, String imageId) {
mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
-
- /*version = VersioningUtil
- .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));
- validateComponentId(vspId,version,componentId);*/
QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
//validateComponentId(vspId,version,componentId);
ImageEntity retrieved = imageDao.getQuestionnaireData(vspId, version, componentId, imageId);
VersioningUtil.validateEntityExistence(retrieved, new ImageEntity(vspId, version, componentId,
- imageId), ComponentEntity.ENTITY_TYPE);
+ imageId), ComponentEntity.ENTITY_TYPE);
questionnaireResponse.setData(retrieved.getQuestionnaireData());
questionnaireResponse.setSchema(getImageQuestionnaireSchema(null));
@@ -170,72 +139,63 @@
}
@Override
- public void deleteImage(String vspId, Version version, String componentId, String imageId, String
- user) {
+ public void deleteImage(String vspId, Version version, String componentId, String imageId) {
mdcDataDebugMessage
- .debugEntryMessage("VSP id, component id", vspId, componentId, imageId);
-
- /*Version activeVersion =
- getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();
- ComponentEntity component = getComponent(vspId, activeVersion, componentId);*/
+ .debugEntryMessage("VSP id, component id", vspId, componentId, imageId);
ImageEntity imageEntity = getImageEntity(vspId, version, componentId, imageId);
if (!vspInfoDao.isManual(vspId, version)) {
final ErrorCode deleteImageErrorBuilder =
- NotSupportedHeatOnboardMethodErrorBuilder
- .getDelImageNotSupportedHeatOnboardMethodErrorBuilder();
+ NotSupportedHeatOnboardMethodErrorBuilder
+ .getDelImageNotSupportedHeatOnboardMethodErrorBuilder();
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.DELETE_IMAGE, ErrorLevel.ERROR.name(),
- LoggerErrorCode.PERMISSION_ERROR.getErrorCode(),
- deleteImageErrorBuilder.message());
+ LoggerTragetServiceName.DELETE_IMAGE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(),
+ deleteImageErrorBuilder.message());
throw new CoreException(deleteImageErrorBuilder);
}
if (imageEntity != null) {
imageDao.delete(new ImageEntity(vspId, version, componentId, imageId));
}
mdcDataDebugMessage
- .debugExitMessage("VSP id, component id", vspId, componentId, imageId);
+ .debugExitMessage("VSP id, component id", vspId, componentId, imageId);
}
private void validateHeatVspImageUpdate(String name, String value, String retrivedValue) {
-
- if(value != null && !value.equals(retrivedValue)) {
-
+ if (value != null && !value.equals(retrivedValue)) {
final ErrorCode updateHeatImageErrorBuilder =
- ImageErrorBuilder.getImageHeatReadOnlyErrorBuilder(name);
+ ImageErrorBuilder.getImageHeatReadOnlyErrorBuilder(name);
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.UPDATE_IMAGE, ErrorLevel.ERROR.name(),
- LoggerErrorCode.PERMISSION_ERROR.getErrorCode(),
- updateHeatImageErrorBuilder.message());
+ LoggerTragetServiceName.UPDATE_IMAGE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(),
+ updateHeatImageErrorBuilder.message());
throw new CoreException(updateHeatImageErrorBuilder);
}
}
@Override
- public CompositionEntityValidationData updateImage(ImageEntity image, String user) {
+ public CompositionEntityValidationData updateImage(ImageEntity image) {
mdcDataDebugMessage
- .debugEntryMessage("VSP id, component id", image.getVspId(), image.getComponentId(),
- image.getId());
-
- /*Version activeVersion =
- getVersionInfo(image.getVspId(), VersionableEntityAction.Write, user).getActiveVersion();
- image.setVersion(activeVersion);*/
- boolean isManual = vspInfoDao.isManual(image.getVspId(), image.getVersion());
- ImageEntity retrieved = getImageEntity(image.getVspId(), image.getVersion(), image.getComponentId(),
+ .debugEntryMessage("VSP id, component id", image.getVspId(), image.getComponentId(),
image.getId());
- if(!isManual) {
+ boolean isManual = vspInfoDao.isManual(image.getVspId(), image.getVersion());
+ ImageEntity retrieved =
+ getImageEntity(image.getVspId(), image.getVersion(), image.getComponentId(),
+ image.getId());
+
+ if (!isManual) {
final Image imageCompositionData = image.getImageCompositionData();
final String fileName = imageCompositionData.getFileName();
//final String format = imageCompositionData.getFormat();
validateHeatVspImageUpdate("fileName", fileName, retrieved.getImageCompositionData()
- .getFileName());
+ .getFileName());
/*validateHeatVspImageUpdate("format", format, retrieved.getImageCompositionData()
.getFormat());*/
}
- Collection<ImageEntity> vfcImageList = listImages(image.getVspId() ,
- image.getVersion(), image.getComponentId());
+ Collection<ImageEntity> vfcImageList = listImages(image.getVspId(),
+ image.getVersion(), image.getComponentId());
//Set to null so that retrieved object is equal to one in list and gets removed.
retrieved.setQuestionnaireData(null);
@@ -249,50 +209,45 @@
schemaInput.setImage(image.getImageCompositionData());
CompositionEntityValidationData validationData = compositionEntityDataManager
- .validateEntity(image, SchemaTemplateContext.composition, schemaInput);
+ .validateEntity(image, SchemaTemplateContext.composition, schemaInput);
if (CollectionUtils.isEmpty(validationData.getErrors())) {
imageDao.update(image);
}
mdcDataDebugMessage
- .debugExitMessage("VSP id, component id", image.getVspId(), image.getComponentId(),
- image.getId());
+ .debugExitMessage("VSP id, component id", image.getVspId(), image.getComponentId(),
+ image.getId());
return validationData;
}
@Override
public void updateImageQuestionnaire(String vspId, Version version, String componentId, String
- imageId, String questionnaireData, String user) {
+ imageId, String questionnaireData) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id, imageId", vspId, componentId,
- imageId);
+ imageId);
getImageEntity(vspId, version, componentId, imageId);
- /*Version activeVersion =
- getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();
-
- getComponent(vspId, activeVersion, componentId);*/
final ImageDetails image = JsonUtil.json2Object(questionnaireData, ImageDetails.class);
final String format = image.getFormat();
try {
if (format != null) {
- final ImageFormat imageFormat = ImageFormat.valueOf(format);
+ ImageFormat.valueOf(format);
}
} catch (IllegalArgumentException exception) {
- log.debug("", exception);
ErrorCode errorCode = ImageErrorBuilder.getInvalidImageFormatErrorBuilder();
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.UPDATE_IMAGE, ErrorLevel.ERROR.name(),
- errorCode.id(), errorCode.message() );
+ LoggerTragetServiceName.UPDATE_IMAGE, ErrorLevel.ERROR.name(),
+ errorCode.id(), errorCode.message());
throw new CoreException(errorCode);
}
//Validate Format is read only for HEAT Onboarding
if (!vspInfoDao.isManual(vspId, version)) {
final QuestionnaireResponse imageQuestionnaire = getImageQuestionnaire(vspId, version,
- componentId, imageId, user);
+ componentId, imageId);
final String data = imageQuestionnaire.getData();
if (data != null) {
String retrivedFormat = JsonUtil.json2Object(data, ImageDetails.class).getFormat();
@@ -300,34 +255,33 @@
}
}
- if(!isImageVersionUnique(vspId, version, componentId, imageId, image, user))
- {
+ if (!isImageVersionUnique(vspId, version, componentId, imageId, image)) {
ErrorCode errorCode = ImageErrorBuilder.getDuplicateImageVersionErrorBuilder(image
- .getVersion(), componentId);
+ .getVersion(), componentId);
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.UPDATE_IMAGE, ErrorLevel.ERROR.name(),
- errorCode.id(),errorCode.message());
+ LoggerTragetServiceName.UPDATE_IMAGE, ErrorLevel.ERROR.name(),
+ errorCode.id(), errorCode.message());
throw new CoreException(errorCode);
}
imageDao.updateQuestionnaireData(vspId, version, componentId, imageId, questionnaireData);
mdcDataDebugMessage.debugExitMessage("VSP id, component id, imageId", vspId, componentId,
- imageId);
+ imageId);
}
- private boolean isImageVersionUnique(String vspId, Version version, String componentId, String imageId,
- ImageDetails image, String user)
- {
+ private boolean isImageVersionUnique(String vspId, Version version, String componentId,
+ String imageId,
+ ImageDetails image) {
boolean isPresent = true;
- if(image!=null && image.getVersion()!=null)
- {
- Collection<ImageEntity> imageEntities = imageDao.list(new ImageEntity(vspId, version, componentId, null));
- if(CollectionUtils.isNotEmpty(imageEntities))
- {
- imageEntities = imageEntities.stream().filter(imageEntity -> image.getVersion().trim().equalsIgnoreCase(
- getImageVersion(vspId, version, componentId, imageEntity, user))
+ if (image != null && image.getVersion() != null) {
+ Collection<ImageEntity> imageEntities =
+ imageDao.list(new ImageEntity(vspId, version, componentId, null));
+ if (CollectionUtils.isNotEmpty(imageEntities)) {
+ imageEntities =
+ imageEntities.stream().filter(imageEntity -> image.getVersion().trim().equalsIgnoreCase(
+ getImageVersion(vspId, version, componentId, imageEntity))
&& !imageEntity.getId().equals(imageId)).collect(Collectors.toList());
isPresent = CollectionUtils.isEmpty(imageEntities);
@@ -337,14 +291,17 @@
return isPresent;
}
- private String getImageVersion(String vspId, Version version, String componentId, ImageEntity imageEntity, String user)
- {
+ private String getImageVersion(String vspId, Version version, String componentId,
+ ImageEntity imageEntity) {
QuestionnaireResponse imageQuestionnaire = getImageQuestionnaire(vspId, version,
- componentId, imageEntity.getId(), user);
- ImageDetails imageDetails = JsonUtil.json2Object(imageQuestionnaire.getData(), ImageDetails.class);
+ componentId, imageEntity.getId());
+ ImageDetails imageDetails =
+ JsonUtil.json2Object(imageQuestionnaire.getData(), ImageDetails.class);
- return imageDetails==null?null:imageDetails.getVersion()!=null?imageDetails.getVersion().trim():null;
+ return imageDetails == null ? null
+ : imageDetails.getVersion() != null ? imageDetails.getVersion().trim() : null;
}
+
private ImageEntity getImageEntity(String vspId, Version version, String componentId,
String imageId) {
//validateComponentId(vspId,version,componentId);
@@ -352,34 +309,24 @@
ImageEntity imageEntity = imageDao.get(new ImageEntity(vspId, version, componentId, imageId));
VersioningUtil.validateEntityExistence(imageEntity, new ImageEntity(vspId, version, componentId,
- imageId), VspDetails.ENTITY_TYPE);
+ imageId), VspDetails.ENTITY_TYPE);
return imageEntity;
}
-
- private boolean isImageNameDuplicate(Collection<ImageEntity> images, String fileName) {
- for (ImageEntity image : images) {
- if (image.getImageCompositionData().getFileName().equalsIgnoreCase(fileName)) {
- return true;
- }
- }
- return false;
- }
-
protected String getImageCompositionSchema(SchemaTemplateInput schemaInput) {
- mdcDataDebugMessage.debugEntryMessage(null, null);
- mdcDataDebugMessage.debugExitMessage(null, null);
+ mdcDataDebugMessage.debugEntryMessage(null);
+ mdcDataDebugMessage.debugExitMessage(null);
return SchemaGenerator
- .generate(SchemaTemplateContext.composition, CompositionEntityType.image,
- schemaInput);
+ .generate(SchemaTemplateContext.composition, CompositionEntityType.image,
+ schemaInput);
}
protected String getImageQuestionnaireSchema(SchemaTemplateInput schemaInput) {
- mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugEntryMessage(null);
- mdcDataDebugMessage.debugExitMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null);
return SchemaGenerator
- .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.image,
- schemaInput);
+ .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.image,
+ schemaInput);
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java
index 8bdc7fd..fdb9621 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java
@@ -6,8 +6,6 @@
import org.openecomp.sdc.generator.datatypes.tosca.DeploymentFlavorModel;
import org.openecomp.sdc.generator.datatypes.tosca.MultiFlavorVfcImage;
import org.openecomp.sdc.generator.datatypes.tosca.VspModelInfo;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
import org.openecomp.sdc.logging.types.LoggerConstants;
@@ -29,18 +27,15 @@
private ManualVspDataCollectionService
manualVspDataCollectionService = new ManualVspDataCollectionService();
- private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
-
@Override
- public VspModelInfo gatherVspInformation(String vspId, Version version, String user) {
+ public VspModelInfo gatherVspInformation(String vspId, Version version) {
mdcDataDebugMessage.debugEntryMessage(null, null);
VspModelInfo vspModelInfo = new VspModelInfo();
//Get Release Vendor Name
Optional<String> releaseVendor;
try {
- releaseVendor = manualVspDataCollectionService.getReleaseVendor(vspId, version, user);
+ releaseVendor = manualVspDataCollectionService.getReleaseVendor(vspId, version);
} catch (Exception ex) {
- log.debug("", ex);
releaseVendor = Optional.empty();
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
LoggerTragetServiceName.COLLECT_MANUAL_VSP_TOSCA_DATA, ErrorLevel.INFO.name(),
@@ -52,9 +47,8 @@
//Get Allowed Deployment flavors information
Map<String, DeploymentFlavorModel> allowedFlavors;
try {
- allowedFlavors = manualVspDataCollectionService.getAllowedFlavors(vspId, version, user);
+ allowedFlavors = manualVspDataCollectionService.getAllowedFlavors(vspId, version);
} catch (Exception ex) {
- log.debug("", ex);
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
LoggerTragetServiceName.COLLECT_MANUAL_VSP_TOSCA_DATA, ErrorLevel.INFO.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), "Unable to collect allowed flavors : "
@@ -69,9 +63,8 @@
Map<String, List<MultiFlavorVfcImage>> vspComponentImages;
try {
vspComponentImages =
- manualVspDataCollectionService.getVspComponentImages(vspId, version, user);
+ manualVspDataCollectionService.getVspComponentImages(vspId, version);
} catch (Exception ex) {
- log.debug("", ex);
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
LoggerTragetServiceName.COLLECT_MANUAL_VSP_TOSCA_DATA, ErrorLevel.INFO.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), "Unable to collect vsp component images : "
@@ -85,9 +78,8 @@
//Get VFC component information
Map<String, String> vspComponents;
try {
- vspComponents = manualVspDataCollectionService.getVspComponents(vspId, version, user);
+ vspComponents = manualVspDataCollectionService.getVspComponents(vspId, version);
} catch (Exception ex) {
- log.debug("", ex);
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
LoggerTragetServiceName.COLLECT_MANUAL_VSP_TOSCA_DATA, ErrorLevel.INFO.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), "Unable to collect vsp components : "
@@ -101,9 +93,8 @@
//Get VSP component nic information
Map<String, List<Nic>> vspComponentNics;
try {
- vspComponentNics = manualVspDataCollectionService.getVspComponentNics(vspId, version, user);
+ vspComponentNics = manualVspDataCollectionService.getVspComponentNics(vspId, version);
} catch (Exception ex) {
- log.debug("", ex);
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
LoggerTragetServiceName.COLLECT_MANUAL_VSP_TOSCA_DATA, ErrorLevel.INFO.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), "Unable to collect vsp component nics : "
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerFactoryImpl.java
index 6569312..eed566d 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerFactoryImpl.java
@@ -20,15 +20,13 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
-import org.openecomp.sdc.activityLog.ActivityLogManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.MonitoringUploadsManager;
import org.openecomp.sdc.vendorsoftwareproduct.MonitoringUploadsManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.MonitoringUploadDaoFactory;
public class MonitoringUploadsManagerFactoryImpl extends MonitoringUploadsManagerFactory {
private static final MonitoringUploadsManager INSTANCE =
- new MonitoringUploadsManagerImpl(MonitoringUploadDaoFactory.getInstance().createInterface(),
- ActivityLogManagerFactory.getInstance().createInterface());
+ new MonitoringUploadsManagerImpl(MonitoringUploadDaoFactory.getInstance().createInterface());
@Override
public MonitoringUploadsManager createInterface() {
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImpl.java
index 0f4d73f..bcfdefb 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImpl.java
@@ -26,8 +26,6 @@
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
-import org.openecomp.sdc.activityLog.ActivityLogManager;
-import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.common.utils.CommonUtil;
@@ -45,7 +43,6 @@
import org.openecomp.sdc.vendorsoftwareproduct.MonitoringUploadsManager;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentArtifactDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.errors.MonitoringUploadErrorBuilder;
@@ -53,7 +50,6 @@
import org.openecomp.sdc.vendorsoftwareproduct.utils.VendorSoftwareProductUtils;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdc.versioning.errors.VersionableSubEntityNotFoundErrorBuilder;
-import org.openecomp.sdcrests.activitylog.types.ActivityType;
import java.io.IOException;
import java.io.InputStream;
@@ -67,26 +63,20 @@
public class MonitoringUploadsManagerImpl implements MonitoringUploadsManager {
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
- private ActivityLogManager activityLogManager;
private ComponentArtifactDao componentArtifactDao;
- private VendorSoftwareProductDao vendorSoftwareProductDao;
private static final Logger logger =
LoggerFactory.getLogger(VendorSoftwareProductManagerImpl.class);
- private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
-
- MonitoringUploadsManagerImpl(ComponentArtifactDao componentArtifactDao,
- ActivityLogManager activityLogManager) {
+ MonitoringUploadsManagerImpl(ComponentArtifactDao componentArtifactDao) {
this.componentArtifactDao = componentArtifactDao;
- this.activityLogManager = activityLogManager;
componentArtifactDao.registerVersioning(
VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
}
@Override
public void delete(String vspId, Version version, String componentId,
- MonitoringUploadType monitoringUploadType, String user) {
+ MonitoringUploadType monitoringUploadType) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
ComponentMonitoringUploadEntity componentMonitoringUploadEntity =
@@ -112,8 +102,7 @@
@Override
public void upload(InputStream object, String filename, String vspId,
Version version, String componentId,
- MonitoringUploadType type,
- String user) {
+ MonitoringUploadType type) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
if (object == null) {
@@ -130,7 +119,7 @@
final FileContentHandler upload =
validateZip(vspId, version, uploadedFileData, errors);
if (type.equals(MonitoringUploadType.VES_EVENTS)) {
- validateVesEventUpload(upload, errors, vspId, version);
+ validateVesEventUpload(upload, errors);
}
if (MapUtils.isNotEmpty(errors)) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
@@ -147,27 +136,18 @@
uploadedFileData);
} catch (Exception exception) {
- log.debug("", exception);
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.UPLOAD_MONITORING_FILE, ErrorLevel.ERROR.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), "Invalid " + type.toString() + "zip file");
throw new CoreException(new MonitoringUploadErrorBuilder(exception.getMessage()).build());
}
}
-
- ActivityLogEntity activityLogEntity =
- new ActivityLogEntity(vspId, String.valueOf(version.getMajor() + 1),
- ActivityType.UPLOAD_MONITORING_FILE.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
logger.audit("Uploaded Monitoring File for component id:" + componentId + " ,vspId:" + vspId);
-
-
mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
}
private void validateVesEventUpload(FileContentHandler upload,
- Map<String, List<ErrorMessage>> errors, String vspId,
- Version version) {
+ Map<String, List<ErrorMessage>> errors) {
if (!CommonUtil.validateAllFilesYml(upload)) {
ErrorMessage.ErrorMessageUtil.addMessage(SdcCommon.UPLOAD_FILE, errors)
.add(new ErrorMessage(ErrorLevel.ERROR,
@@ -194,8 +174,7 @@
}
@Override
- public MonitoringUploadStatus listFilenames(String vspId, Version version, String componentId,
- String user) {
+ public MonitoringUploadStatus listFilenames(String vspId, Version version, String componentId) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
ComponentMonitoringUploadEntity current =
@@ -259,10 +238,10 @@
Map<String, List<ErrorMessage>> errors) {
FileContentHandler contentMap;
try {
- contentMap = CommonUtil.validateAndUploadFileContent(OnboardingTypesEnum.ZIP, uploadedFileData);
+ contentMap =
+ CommonUtil.validateAndUploadFileContent(OnboardingTypesEnum.ZIP, uploadedFileData);
VendorSoftwareProductUtils.validateContentZipData(contentMap, errors);
} catch (IOException exception) {
- log.debug("", exception);
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.VALIDATE_MONITORING_FILE, ErrorLevel.ERROR.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), "Invalid Monitoring zip file");
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImpl.java
index 77b6b00..e6233bb 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImpl.java
@@ -59,7 +59,7 @@
}
@Override
- public Collection<NetworkEntity> listNetworks(String vspId, Version version, String user) {
+ public Collection<NetworkEntity> listNetworks(String vspId, Version version) {
mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
@@ -67,7 +67,7 @@
}
@Override
- public NetworkEntity createNetwork(NetworkEntity network, String user) {
+ public NetworkEntity createNetwork(NetworkEntity network) {
mdcDataDebugMessage.debugEntryMessage("VSP id", network.getVspId());
if (!isManual(network.getVspId(), network.getVersion())) {
@@ -87,16 +87,12 @@
return null;
}
- private NetworkEntity createNetwork(NetworkEntity network) {
- return compositionEntityDataManager.createNetwork(network);
- }
-
@Override
- public CompositionEntityValidationData updateNetwork(NetworkEntity network, String user) {
+ public CompositionEntityValidationData updateNetwork(NetworkEntity network) {
mdcDataDebugMessage
.debugEntryMessage("VSP id, network id", network.getVspId(), network.getId());
- NetworkEntity retrieved = getNetwork(network.getVspId(), network.getVersion(), network.getId());
+ NetworkEntity retrieved = getValidatedNetwork(network.getVspId(), network.getVersion(), network.getId());
NetworkCompositionSchemaInput schemaInput = new NetworkCompositionSchemaInput();
schemaInput.setManual(isManual(network.getVspId(), network.getVersion()));
@@ -119,10 +115,10 @@
@Override
public CompositionEntityResponse<Network> getNetwork(String vspId, Version version,
- String networkId, String user) {
+ String networkId) {
mdcDataDebugMessage.debugEntryMessage("VSP id, network id", vspId, networkId);
- NetworkEntity networkEntity = getNetwork(vspId, version, networkId);
+ NetworkEntity networkEntity = getValidatedNetwork(vspId, version, networkId);
Network network = networkEntity.getNetworkCompositionData();
NetworkCompositionSchemaInput schemaInput = new NetworkCompositionSchemaInput();
@@ -140,7 +136,7 @@
}
- private NetworkEntity getNetwork(String vspId, Version version, String networkId) {
+ private NetworkEntity getValidatedNetwork(String vspId, Version version, String networkId) {
NetworkEntity retrieved = networkDao.get(new NetworkEntity(vspId, version, networkId));
VersioningUtil.validateEntityExistence(retrieved, new NetworkEntity(vspId, version, networkId),
VspDetails.ENTITY_TYPE);
@@ -148,7 +144,7 @@
}
@Override
- public void deleteNetwork(String vspId, Version version, String networkId, String user) {
+ public void deleteNetwork(String vspId, Version version, String networkId) {
mdcDataDebugMessage.debugEntryMessage("VSP id, network id", vspId, networkId);
if (!isManual(vspId, version)) {
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImpl.java
index 0304353..f2bb0ba 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImpl.java
@@ -37,7 +37,12 @@
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
-import org.openecomp.sdc.vendorsoftwareproduct.errors.*;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.DeleteNicErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.DuplicateNicInComponentErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.NicErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.NicInternalNetworkErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.NicNetworkIdNotAllowedExternalNetworkErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.NotSupportedHeatOnboardMethodErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGenerator;
import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
@@ -63,7 +68,7 @@
private NicDao nicDao;
private CompositionEntityDataManager compositionEntityDataManager;
private NetworkManager networkManager;
- private VendorSoftwareProductInfoDao vspInfoDao;
+ private VendorSoftwareProductInfoDao vspInfoDao;
public NicManagerImpl(NicDao nicDao,
CompositionEntityDataManager compositionEntityDataManager,
@@ -76,14 +81,13 @@
}
@Override
- public Collection<NicEntity> listNics(String vspId, Version version, String componentId,
- String user) {
+ public Collection<NicEntity> listNics(String vspId, Version version, String componentId) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
Collection<NicEntity> nics = nicDao.list(new NicEntity(vspId, version, componentId, null));
if (!nics.isEmpty()) {
- Map<String, String> networksNameById = listNetworksNameById(vspId, version, user);
+ Map<String, String> networksNameById = listNetworksNameById(vspId, version);
nics.forEach(nicEntity -> {
Nic nic = nicEntity.getNicCompositionData();
nic.setNetworkName(networksNameById.get(nic.getNetworkId()));
@@ -96,18 +100,18 @@
return nics;
}
- private Map<String, String> listNetworksNameById(String vspId, Version version, String user) {
- Collection<NetworkEntity> networks = networkManager.listNetworks(vspId, version, user);
+ private Map<String, String> listNetworksNameById(String vspId, Version version) {
+ Collection<NetworkEntity> networks = networkManager.listNetworks(vspId, version);
return networks.stream().collect(Collectors.toMap(NetworkEntity::getId,
networkEntity -> networkEntity.getNetworkCompositionData().getName()));
}
@Override
- public NicEntity createNic(NicEntity nic, String user) {
- NicEntity createdNic = null;
+ public NicEntity createNic(NicEntity nic) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id", nic.getVspId(),
nic.getComponentId());
+ NicEntity createdNic;
if (!vspInfoDao.isManual(nic.getVspId(), nic.getVersion())) {
ErrorCode onboardingMethodUpdateErrorCode = NotSupportedHeatOnboardMethodErrorBuilder
.getAddNicNotSupportedHeatOnboardMethodErrorBuilder();
@@ -117,25 +121,20 @@
onboardingMethodUpdateErrorCode.message());
throw new CoreException(onboardingMethodUpdateErrorCode);
} else {
- validateNic(nic, user);
- createdNic = createNic(nic);
+ validateNic(nic);
+ createdNic = compositionEntityDataManager.createNic(nic);
}
- //nicDao.updateVspLatestModificationTime(nic.getVspId(), nic.getVersion());
-
mdcDataDebugMessage
.debugExitMessage("VSP id, component id", nic.getVspId(), nic.getComponentId());
return createdNic;
}
- private NicEntity createNic(NicEntity nic) {
- return compositionEntityDataManager.createNic(nic);
- }
- private void validateNic(NicEntity nic, String user) {
+ private void validateNic(NicEntity nic) {
Collection<NicEntity> listNics = listNics(nic.getVspId(), nic.getVersion(), nic
- .getComponentId(), user);
+ .getComponentId());
String networkId = nic.getNicCompositionData().getNetworkId();
NetworkType networkType = nic.getNicCompositionData().getNetworkType();
String networkDescription = nic.getNicCompositionData().getNetworkDescription();
@@ -171,14 +170,12 @@
if (!(networkId == null || networkId.equals(""))) {
//NetworkEntity ne = getNetwork(nic.getVspId(), activeVersion, networkId);
final CompositionEntityResponse<Network> network =
- networkManager.getNetwork(nic.getVspId(), nic.getVersion(), networkId,
- user);
+ networkManager.getNetwork(nic.getVspId(), nic.getVersion(), networkId);
}
if (!(networkDescription == null || networkDescription.equals(""))) {
final ErrorCode nicNetworkDescriptionErrorBuilder =
- new NicInternalNetworkErrorBuilder()
- .getNetworkDescriptionInternalNetworkErrorBuilder();
+ NicInternalNetworkErrorBuilder.getNetworkDescriptionInternalNetworkErrorBuilder();
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.CREATE_NIC, ErrorLevel.ERROR.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), nicNetworkDescriptionErrorBuilder.message());
@@ -200,17 +197,17 @@
@Override
public CompositionEntityResponse<Nic> getNic(String vspId, Version version, String componentId,
- String nicId, String user) {
+ String nicId) {
mdcDataDebugMessage
.debugEntryMessage("VSP id, component id, nic id", vspId, componentId, nicId);
- NicEntity nicEntity = getNic(vspId, version, componentId, nicId);
+ NicEntity nicEntity = getValidatedNic(vspId, version, componentId, nicId);
Nic nic = nicEntity.getNicCompositionData();
NicCompositionSchemaInput schemaInput = new NicCompositionSchemaInput();
schemaInput.setManual(vspInfoDao.isManual(vspId, version));
schemaInput.setNic(nic);
- Map<String, String> networksNameById = listNetworksNameById(vspId, version, user);
+ Map<String, String> networksNameById = listNetworksNameById(vspId, version);
nic.setNetworkName(networksNameById.get(nic.getNetworkId()));
schemaInput.setNetworkIds(networksNameById.keySet());
@@ -226,7 +223,8 @@
}
- private NicEntity getNic(String vspId, Version version, String componentId, String nicId) {
+ private NicEntity getValidatedNic(String vspId, Version version, String componentId,
+ String nicId) {
NicEntity retrieved = nicDao.get(new NicEntity(vspId, version, componentId, nicId));
VersioningUtil
.validateEntityExistence(retrieved, new NicEntity(vspId, version, componentId, nicId),
@@ -235,14 +233,13 @@
}
@Override
- public void deleteNic(String vspId, Version version, String componentId, String nicId,
- String user) {
+ public void deleteNic(String vspId, Version version, String componentId, String nicId) {
mdcDataDebugMessage
.debugEntryMessage("VSP id, component id", vspId, componentId, nicId);
if (!vspInfoDao.isManual(vspId, version)) {
final ErrorCode deleteNicErrorBuilder =
- new DeleteNicErrorBuilder().getDeleteNicForHeatOnboardedVspErrorBuilder();
+ DeleteNicErrorBuilder.getDeleteNicForHeatOnboardedVspErrorBuilder();
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.DELETE_NIC, ErrorLevel.ERROR.name(),
LoggerErrorCode.PERMISSION_ERROR.getErrorCode(),
@@ -250,23 +247,21 @@
throw new CoreException(deleteNicErrorBuilder);
}
- NicEntity nicEntity = getNic(vspId, version, componentId, nicId);
- if (nicEntity != null) {
- nicDao.delete(nicEntity);
- }
+ NicEntity nicEntity = getValidatedNic(vspId, version, componentId, nicId);
+ nicDao.delete(nicEntity);
mdcDataDebugMessage
.debugExitMessage("VSP id, component id", vspId, componentId, nicId);
}
@Override
- public CompositionEntityValidationData updateNic(NicEntity nic, String user) {
+ public CompositionEntityValidationData updateNic(NicEntity nic) {
mdcDataDebugMessage
.debugEntryMessage("VSP id, component id", nic.getVspId(), nic.getComponentId(),
nic.getId());
NicEntity retrieved =
- getNic(nic.getVspId(), nic.getVersion(), nic.getComponentId(), nic.getId());
+ getValidatedNic(nic.getVspId(), nic.getVersion(), nic.getComponentId(), nic.getId());
NicCompositionSchemaInput schemaInput = new NicCompositionSchemaInput();
schemaInput.setManual(vspInfoDao.isManual(nic.getVspId(), nic.getVersion()));
@@ -289,9 +284,6 @@
if (CollectionUtils.isEmpty(validationData.getErrors())) {
nicDao.update(nic);
}
-
- //nicDao.updateVspLatestModificationTime(nic.getVspId(), nic.getVersion());
-
mdcDataDebugMessage
.debugExitMessage("VSP id, component id", nic.getVspId(), nic.getComponentId(),
nic.getId());
@@ -301,7 +293,7 @@
@Override
public QuestionnaireResponse getNicQuestionnaire(String vspId, Version version,
- String componentId, String nicId, String user) {
+ String componentId, String nicId) {
mdcDataDebugMessage
.debugEntryMessage("VSP id, component id", vspId, componentId, nicId);
@@ -321,15 +313,13 @@
@Override
public void updateNicQuestionnaire(String vspId, Version version, String componentId,
- String nicId, String questionnaireData, String user) {
+ String nicId, String questionnaireData) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId, nicId);
getNic(vspId, version, componentId, nicId);
nicDao.updateQuestionnaireData(vspId, version, componentId, nicId, questionnaireData);
- //nicDao.updateVspLatestModificationTime(vspId, version);
-
mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId, nicId);
}
@@ -342,9 +332,4 @@
return SchemaGenerator
.generate(SchemaTemplateContext.composition, CompositionEntityType.nic, schemaInput);
}
- // todo *************************** move to reusable place! *************************
-
- /*private boolean isManual(String vspId, Version version) {
- return false;
- }*/
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerFactoryImpl.java
index b5464e5..b8fddcd 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerFactoryImpl.java
@@ -20,40 +20,21 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
-import org.openecomp.core.model.dao.ServiceModelDaoFactory;
-import org.openecomp.sdc.activityLog.ActivityLogManagerFactory;
import org.openecomp.sdc.healing.factory.HealingManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManager;
import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManagerFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.MonitoringUploadDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.factory.CandidateServiceFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionDataExtractorFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionEntityDataManagerFactory;
public class OrchestrationTemplateCandidateManagerFactoryImpl extends
OrchestrationTemplateCandidateManagerFactory {
+
private static final OrchestrationTemplateCandidateManager INSTANCE =
new OrchestrationTemplateCandidateManagerImpl(
- VendorSoftwareProductDaoFactory.getInstance().createInterface(),
VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(),
- OrchestrationTemplateDaoFactory.getInstance().createInterface(),
CandidateServiceFactory.getInstance().createInterface(),
- HealingManagerFactory.getInstance().createInterface(),
- CompositionDataExtractorFactory.getInstance().createInterface(),
- ServiceModelDaoFactory.getInstance().createInterface(),
- CompositionEntityDataManagerFactory.getInstance().createInterface(),
- NicDaoFactory.getInstance().createInterface(),
- ComponentDaoFactory.getInstance().createInterface(),
- MonitoringUploadDaoFactory.getInstance().createInterface(),
- ProcessDaoFactory.getInstance().createInterface(),
- ActivityLogManagerFactory.getInstance().createInterface());
-
+ HealingManagerFactory.getInstance().createInterface()
+ );
@Override
public OrchestrationTemplateCandidateManager createInterface() {
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java
index 07a3fa7..f613dbb 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java
@@ -23,11 +23,8 @@
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
-import org.openecomp.core.model.dao.ServiceModelDao;
-import org.openecomp.core.model.types.ServiceElement;
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
-import org.openecomp.sdc.activityLog.ActivityLogManager;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.common.utils.CommonUtil;
@@ -35,7 +32,6 @@
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.healing.api.HealingManager;
-import org.openecomp.sdc.healing.types.HealCode;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.api.annotations.Metrics;
@@ -43,14 +39,7 @@
import org.openecomp.sdc.logging.messages.AuditMessages;
import org.openecomp.sdc.logging.types.LoggerServiceName;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
-import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManager;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentArtifactDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
@@ -58,9 +47,6 @@
import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationTemplateFileHandler;
import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationUploadFactory;
import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.process.OrchestrationProcessFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.process.OrchestrationTemplateProcessHandler;
-import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionDataExtractor;
-import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService;
import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
@@ -80,114 +66,52 @@
private static final Logger logger =
LoggerFactory.getLogger(OrchestrationTemplateCandidateManagerImpl.class);
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
- private VendorSoftwareProductDao vendorSoftwareProductDao;
+
private VendorSoftwareProductInfoDao vspInfoDao;
- private OrchestrationTemplateDao orchestrationTemplateDataDao;
private CandidateService candidateService;
private HealingManager healingManager;
- private CompositionDataExtractor compositionDataExtractor;
- private ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao;
- private CompositionEntityDataManager compositionEntityDataManager;
- private NicDao nicDao;
- private ComponentDao componentDao;
- private ComponentArtifactDao componentArtifactDao;
- private ActivityLogManager activityLogManager;
- private ProcessDao processDao;
- /**
- * Instantiates a new Orchestration template candidate manager.
- *
- * @param vendorSoftwareProductDao the vendor software product dao
- * @param vspInfoDao the vsp info dao
- * @param orchestrationTemplateDataDao the orchestration template data dao
- * @param candidateService the candidate service
- * @param healingManager the healing manager
- * @param compositionDataExtractor the composition data extractor
- * @param serviceModelDao the service model dao
- * @param compositionEntityDataManager the composition entity data manager
- * @param nicDao the nic dao
- * @param componentDao the component dao
- * @param componentArtifactDao the mib dao
- * @param processDao the process dao
- * @param activityLogManager the activity log manager
- */
- public OrchestrationTemplateCandidateManagerImpl(
- VendorSoftwareProductDao vendorSoftwareProductDao, VendorSoftwareProductInfoDao
- vspInfoDao,
- OrchestrationTemplateDao orchestrationTemplateDataDao,
- CandidateService candidateService, HealingManager healingManager,
- CompositionDataExtractor compositionDataExtractor,
- ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao,
- CompositionEntityDataManager compositionEntityDataManager,
- NicDao nicDao,
- ComponentDao componentDao,
- ComponentArtifactDao componentArtifactDao,
- ProcessDao processDao,
- ActivityLogManager activityLogManager) {
- this.vendorSoftwareProductDao = vendorSoftwareProductDao;
+ public OrchestrationTemplateCandidateManagerImpl(VendorSoftwareProductInfoDao vspInfoDao,
+ CandidateService candidateService,
+ HealingManager healingManager) {
this.vspInfoDao = vspInfoDao;
- this.orchestrationTemplateDataDao = orchestrationTemplateDataDao;
this.candidateService = candidateService;
this.healingManager = healingManager;
- this.compositionDataExtractor = compositionDataExtractor;
- this.serviceModelDao = serviceModelDao;
- this.compositionEntityDataManager = compositionEntityDataManager;
- this.nicDao = nicDao;
- this.componentDao = componentDao;
- this.componentArtifactDao = componentArtifactDao;
- this.processDao = processDao;
- this.activityLogManager = activityLogManager;
}
@Override
@Metrics
public UploadFileResponse upload(String vspId, Version version, InputStream fileToUpload,
- String user, String filePrefix,
- String networkPackageName) {
+ String fileSuffix, String networkPackageName) {
mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+
OrchestrationTemplateFileHandler orchestrationTemplateFileHandler =
- OrchestrationUploadFactory.createOrchestrationTemplateFileHandler(filePrefix);
+ OrchestrationUploadFactory.createOrchestrationTemplateFileHandler(fileSuffix);
+
VspDetails vspDetails = getVspDetails(vspId, version);
+
UploadFileResponse uploadResponse = orchestrationTemplateFileHandler
- .upload(vspId, version, fileToUpload, user, candidateService,
- vspDetails);
- vspDetails.setOnboardingOrigin(filePrefix);
- vspDetails.setNetworkPackageName(networkPackageName);
- vspInfoDao.update(vspDetails);
+ .upload(vspDetails, fileToUpload, fileSuffix, networkPackageName, candidateService);
uploadResponse.setNetworkPackageName(networkPackageName);
return uploadResponse;
}
-
-
@Override
- public OrchestrationTemplateActionResponse process(String vspId,
- Version version, String user) {
+ public OrchestrationTemplateActionResponse process(String vspId, Version version) {
mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
- OrchestrationTemplateActionResponse response = new OrchestrationTemplateActionResponse();
- Optional<OrchestrationTemplateCandidateData> candidate =
- fetchCandidateDataEntity(vspId, version);
- if (!candidate.isPresent()) {
- throw new CoreException(new OrchestrationTemplateNotFoundErrorBuilder(vspId).build());
- }
+ OrchestrationTemplateCandidateData candidate = fetchCandidateDataEntity(vspId, version)
+ .orElseThrow(
+ () -> new CoreException(new OrchestrationTemplateNotFoundErrorBuilder(vspId).build()));
- VspDetails vspDetails =
- getVspDetails(vspId, version);
- Optional<OrchestrationTemplateProcessHandler> processInstance =
- OrchestrationProcessFactory.getInstance(vspDetails.getOnboardingOrigin());
-
- if(processInstance.isPresent()){
- response = processInstance.get().process(vspDetails, candidate.get(), user);
- }
-
- return response;
+ return OrchestrationProcessFactory.getInstance(candidate.getFileSuffix())
+ .map(processor -> processor.process(getVspDetails(vspId, version), candidate))
+ .orElse(new OrchestrationTemplateActionResponse());
}
@Override
- public Optional<FilesDataStructure> getFilesDataStructure(
- String vspId, Version version, String user) {
+ public Optional<FilesDataStructure> getFilesDataStructure(String vspId, Version version) {
mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
Optional<FilesDataStructure> candidateFileDataStructure =
@@ -195,19 +119,13 @@
if (candidateFileDataStructure.isPresent()) {
return candidateFileDataStructure;
} else {
- Map<String, Object> healingParams = getHealingParamsAsMap(vspId, version, user);
-
- mdcDataDebugMessage
- .debugExitMessage("VSP id", vspId);
- return (Optional<FilesDataStructure>) healingManager
- .heal(HealCode.FILE_DATA_STRUCTURE_HEALER, healingParams);
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ return Optional.empty();
}
}
@Override
-
- public ValidationResponse updateFilesDataStructure(String vspId,
- Version version, String user,
+ public ValidationResponse updateFilesDataStructure(String vspId, Version version,
FilesDataStructure fileDataStructure) {
mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
@@ -222,27 +140,23 @@
response.setUploadDataErrors(errorsMap, LoggerServiceName.Update_Manifest,
LoggerTragetServiceName.VALIDATE_FILE_DATA_STRUCTURE);
- mdcDataDebugMessage
- .debugExitMessage("VSP id", vspId);
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
return response;
}
}
- candidateService.updateOrchestrationTemplateCandidateFileDataStructure(vspId, version,
- fileDataStructure);
+ candidateService
+ .updateOrchestrationTemplateCandidateFileDataStructure(vspId, version, fileDataStructure);
- mdcDataDebugMessage
- .debugExitMessage("VSP id", vspId);
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
return response;
}
@Override
- public Optional<Pair<String, byte[]>> get(String vspId, Version version, String user)
- throws IOException {
+ public Optional<Pair<String, byte[]>> get(String vspId, Version version) throws IOException {
mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
- VspDetails vspDetails =
- getVspDetails(vspId, version);
+ VspDetails vspDetails = getVspDetails(vspId, version);
Optional<OrchestrationTemplateCandidateData> candidateDataEntity =
fetchCandidateDataEntity(vspId, version);
@@ -252,31 +166,34 @@
Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage());
logger.error(errorMessage.getMessage());
- mdcDataDebugMessage
- .debugExitMessage("VSP id", vspId);
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
return Optional.empty();
}
OnboardingTypesEnum type =
- OnboardingTypesEnum.getOnboardingTypesEnum(vspDetails.getOnboardingOrigin());
+ OnboardingTypesEnum.getOnboardingTypesEnum(candidateDataEntity.get().getFileSuffix());
- if(CommonUtil.isFileOriginFromZip(vspDetails.getOnboardingOrigin())) {
+ if (CommonUtil.isFileOriginFromZip(candidateDataEntity.get().getFileSuffix())) {
FilesDataStructure structure = JsonUtil
.json2Object(candidateDataEntity.get().getFilesDataStructure(), FilesDataStructure.class);
String manifest = candidateService.createManifest(vspDetails, structure);
- mdcDataDebugMessage
- .debugExitMessage("VSP id", vspId);
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
return Optional.of(
- new ImmutablePair<>(OnboardingTypesEnum.ZIP.toString(),candidateService
+ new ImmutablePair<>(OnboardingTypesEnum.ZIP.toString(), candidateService
.replaceManifestInZip(candidateDataEntity.get().getContentData(),
- manifest, vspId, type)));
+ manifest, vspId, type)));
}
return Optional.of(
- new ImmutablePair<>(vspDetails.getOnboardingOrigin(),candidateDataEntity.get()
+ new ImmutablePair<>(candidateDataEntity.get().getFileSuffix(), candidateDataEntity.get()
.getContentData().array()));
}
+ @Override
+ public OrchestrationTemplateCandidateData getInfo(String vspId, Version version) {
+ return candidateService.getOrchestrationTemplateCandidateInfo(vspId, version);
+ }
+
private Optional<OrchestrationTemplateCandidateData> fetchCandidateDataEntity(
String vspId, Version version) {
return Optional
@@ -286,19 +203,22 @@
// todo *************************** move to reusable place! *************************
- private Map<String, Object> getHealingParamsAsMap(String vspId, Version version, String user) {
+ private Map<String, Object> getHealingParamsAsMap(String vspId, Version version) {
Map<String, Object> healingParams = new HashMap<>();
healingParams.put(SdcCommon.VSP_ID, vspId);
healingParams.put(SdcCommon.VERSION, version);
- healingParams.put(SdcCommon.USER, user);
return healingParams;
}
private VspDetails getVspDetails(String vspId, Version version) {
VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));
- vspDetails.setValidationData(orchestrationTemplateDataDao.getValidationData(vspId, version));
+/* OrchestrationTemplateEntity orchestrationTemplateInfo =
+ orchestrationTemplateDao.getInfo(vspId, version);
+ vspDetails.setValidationData(orchestrationTemplateInfo.getValidationData());
+ vspDetails.setNetworkPackageName(orchestrationTemplateInfo.getFileName());
+ vspDetails.setOnboardingOrigin(orchestrationTemplateInfo.getFileSuffix());*/
return vspDetails;
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerFactoryImpl.java
index d870454..7a4e487 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerFactoryImpl.java
@@ -20,16 +20,13 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
-import org.openecomp.sdc.activityLog.ActivityLogManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.ProcessManager;
import org.openecomp.sdc.vendorsoftwareproduct.ProcessManagerFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDaoFactory;
public class ProcessManagerFactoryImpl extends ProcessManagerFactory {
private static final ProcessManager INSTANCE =
- new ProcessManagerImpl(
- VendorSoftwareProductDaoFactory.getInstance().createInterface(),
- ActivityLogManagerFactory.getInstance().createInterface());
+ new ProcessManagerImpl(ProcessDaoFactory.getInstance().createInterface());
@Override
public ProcessManager createInterface() {
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImpl.java
index a3d0286..121abda 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImpl.java
@@ -22,12 +22,10 @@
import org.openecomp.core.util.UniqueValueUtil;
import org.openecomp.core.utilities.file.FileUtils;
-import org.openecomp.sdc.activityLog.ActivityLogManager;
-import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
import org.openecomp.sdc.logging.types.LoggerConstants;
@@ -35,138 +33,133 @@
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
import org.openecomp.sdc.vendorsoftwareproduct.ProcessManager;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.errors.UploadInvalidErrorBuilder;
import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdcrests.activitylog.types.ActivityType;
+import org.openecomp.sdc.versioning.errors.VersioningErrorCodes;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.ByteBuffer;
import java.util.Collection;
public class ProcessManagerImpl implements ProcessManager {
- private static final MdcDataDebugMessage MDC_DATA_DEBUG_MESSAGE = new MdcDataDebugMessage();
- private final ActivityLogManager activityLogManager;
+ private static final String PROCESS_ARTIFACT_NOT_EXIST_MSG =
+ "Process artifact for process with Id %s does not exist for %s with Id %s and version %s";
- private final VendorSoftwareProductDao vendorSoftwareProductDao;
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
- private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
+ private ProcessDao processDao;
- public ProcessManagerImpl(VendorSoftwareProductDao vendorSoftwareProductDao, ActivityLogManager activityLogManager) {
- this.vendorSoftwareProductDao = vendorSoftwareProductDao;
- this.activityLogManager = activityLogManager;
+ public ProcessManagerImpl(ProcessDao processDao) {
+ this.processDao = processDao;
}
@Override
public Collection<ProcessEntity> listProcesses(String vspId, Version version,
- String componentId,
- String user) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id", vspId, componentId);
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id", vspId, componentId);
+ String componentId) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
- return vendorSoftwareProductDao.listProcesses(vspId, version, componentId);
+ return processDao.list(new ProcessEntity(vspId, version, componentId, null));
}
@Override
- public void deleteProcesses(String vspId, Version version, String componentId, String user) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id", vspId, componentId);
+ public void deleteProcesses(String vspId, Version version, String componentId) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
- Collection<ProcessEntity> processes =
- vendorSoftwareProductDao.listProcesses(vspId, version, componentId);
+ ProcessEntity allProcesses = new ProcessEntity(vspId, version, componentId, null);
+ Collection<ProcessEntity> processes = processDao.list(allProcesses);
if (!processes.isEmpty()) {
for (ProcessEntity process : processes) {
deleteUniqueValue(process.getVspId(), process.getVersion(), process.getComponentId(),
process.getName());
}
-
- vendorSoftwareProductDao.deleteProcesses(vspId, version, componentId);
}
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id", vspId, componentId);
+
+ if (componentId == null) {
+ processDao.deleteVspAll(vspId,version);
+ } else {
+ processDao.deleteAll(allProcesses);
+ }
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
}
@Override
- public ProcessEntity createProcess(ProcessEntity process, String user) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id", process.getId(),
+ public ProcessEntity createProcess(ProcessEntity process) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", process.getId(),
process.getComponentId());
validateUniqueName(process.getVspId(), process.getVersion(), process.getComponentId(),
process.getName());
- //process.setId(CommonMethods.nextUuId());
- vendorSoftwareProductDao.createProcess(process);
+ processDao.create(process);
createUniqueName(process.getVspId(), process.getVersion(), process.getComponentId(),
process.getName());
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id", process.getId(),
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", process.getId(),
process.getComponentId());
return process;
}
-
@Override
public ProcessEntity getProcess(String vspId, Version version, String componentId,
- String processId, String user) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id", vspId, componentId);
+ String processId) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
ProcessEntity retrieved =
- vendorSoftwareProductDao.getProcess(vspId, version, componentId, processId);
+ processDao.get(new ProcessEntity(vspId, version, componentId, processId));
validateProcessExistence(vspId, version, componentId, processId, retrieved);
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id", vspId, componentId);
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
return retrieved;
}
@Override
- public void updateProcess(ProcessEntity process, String user) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id", process.getId(),
+ public void updateProcess(ProcessEntity process) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", process.getId(),
process.getComponentId());
- ProcessEntity retrieved = vendorSoftwareProductDao
- .getProcess(process.getVspId(), process.getVersion(), process.getComponentId(),
- process.getId());
+ ProcessEntity retrieved = processDao.get(process);
validateProcessExistence(process.getVspId(), process.getVersion(), process.getComponentId(),
process.getId(), retrieved);
updateUniqueName(process.getVspId(), process.getVersion(), process.getComponentId(),
retrieved.getName(), process.getName());
- vendorSoftwareProductDao.updateProcess(process);
+ processDao.update(process);
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id", process.getId(),
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", process.getId(),
process.getComponentId());
}
@Override
- public void deleteProcess(String vspId, Version version, String componentId, String processId,
- String user) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id", vspId, componentId);
+ public void deleteProcess(String vspId, Version version, String componentId, String processId) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
- ProcessEntity retrieved =
- vendorSoftwareProductDao.getProcess(vspId, version, componentId, processId);
- validateProcessExistence(vspId, version, componentId, processId, retrieved);
+ ProcessEntity retrieved = getProcess(vspId, version, componentId, processId);
- vendorSoftwareProductDao.deleteProcess(vspId, version, componentId, processId);
+ processDao.delete(retrieved);
deleteUniqueValue(retrieved.getVspId(), retrieved.getVersion(), retrieved.getComponentId(),
retrieved.getName());
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id", vspId, componentId);
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
}
@Override
public File getProcessArtifact(String vspId, Version version, String componentId,
- String processId, String user) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id", vspId, componentId);
+ String processId) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
- ProcessEntity retrieved =
- vendorSoftwareProductDao.getProcessArtifact(vspId, version, componentId, processId);
- validateProcessArtifactExistence(vspId, version, componentId, processId, retrieved);
+ ProcessEntity retrieved = getValidatedProcessArtifact(vspId, version, componentId, processId);
File file = new File(String.format("%s_%s_%s", vspId, componentId, processId));
try (FileOutputStream fos = new FileOutputStream(file)) {
@@ -175,125 +168,115 @@
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.GET_PROCESS_ARTIFACT, ErrorLevel.ERROR.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), "Can't get process artifact");
- throw new CoreException(new UploadInvalidErrorBuilder().build(), exception);
+ throw new CoreException(new UploadInvalidErrorBuilder().build());
}
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id", vspId, componentId);
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
return file;
}
@Override
public void deleteProcessArtifact(String vspId, Version version, String componentId,
- String processId, String user) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id", vspId, componentId);
+ String processId) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
- ProcessEntity retrieved =
- vendorSoftwareProductDao.getProcessArtifact(vspId, version, componentId, processId);
- validateProcessArtifactExistence(vspId, version, componentId, processId, retrieved);
+ ProcessEntity retrieved = getValidatedProcessArtifact(vspId, version, componentId, processId);
- vendorSoftwareProductDao.deleteProcessArtifact(vspId, version, componentId, processId);
+ processDao.deleteArtifact(retrieved);
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id", vspId, componentId);
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
}
@Override
public void uploadProcessArtifact(InputStream artifactFile, String artifactFileName, String vspId,
- Version version, String componentId, String processId,
- String user) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id", vspId, componentId);
+ Version version, String componentId, String processId) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
+ ProcessEntity process = getProcess(vspId, version, componentId, processId);
+ process.setArtifactName(artifactFileName);
+ process.setArtifact(readArtifact(artifactFile));
+ processDao.uploadArtifact(process);
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
+ }
+
+ private ProcessEntity getValidatedProcessArtifact(String vspId, Version version,
+ String componentId, String processId) {
ProcessEntity retrieved =
- vendorSoftwareProductDao.getProcess(vspId, version, componentId, processId);
- validateProcessExistence(vspId, version, componentId, processId, retrieved);
+ processDao.getArtifact(new ProcessEntity(vspId, version, componentId, processId));
+ validateProcessArtifactExistence(vspId, version, componentId, processId, retrieved);
+ return retrieved;
+ }
- if (artifactFile == null) {
+ private ByteBuffer readArtifact(InputStream artifactInputStream) {
+ if (artifactInputStream == null) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.UPLOAD_PROCESS_ARTIFACT, ErrorLevel.ERROR.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), "Can't upload process artifact");
throw new CoreException(new UploadInvalidErrorBuilder().build());
}
-
- byte[] artifact;
try {
- artifact = FileUtils.toByteArray(artifactFile);
+ return ByteBuffer.wrap(FileUtils.toByteArray(artifactInputStream));
} catch (RuntimeException exception) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.UPLOAD_PROCESS_ARTIFACT, ErrorLevel.ERROR.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), "Can't upload process artifact");
- throw new CoreException(new UploadInvalidErrorBuilder().build(), exception);
+ throw new CoreException(new UploadInvalidErrorBuilder().build());
}
-
- vendorSoftwareProductDao.uploadProcessArtifact(vspId, version, componentId, processId, artifact,
- artifactFileName);
- ActivityLogEntity activityLogEntity = new ActivityLogEntity(vspId, String.valueOf(version.getMajor()+1),
- ActivityType.UPLOAD_MONITORING_FILE.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
-
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id", vspId, componentId);
}
private void validateProcessExistence(String vspId, Version version, String componentId,
String processId, ProcessEntity retrieved) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id, process id", vspId, componentId,
- processId);
-
- if (retrieved != null) {
- return;
- }
VersioningUtil.validateEntityExistence(retrieved,
new ProcessEntity(vspId, version, componentId, processId),
- VspDetails.ENTITY_TYPE);//todo retrieved is always null ??
-
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id, process id", vspId, componentId,
- processId);
+ VspDetails.ENTITY_TYPE);
}
private void validateProcessArtifactExistence(String vspId, Version version, String componentId,
String processId, ProcessEntity retrieved) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id, process id", vspId, componentId,
- processId);
-
- if (retrieved != null) {
- VersioningUtil.validateEntityExistence(retrieved.getArtifact(),
- new ProcessEntity(vspId, version, componentId, processId),
- VspDetails.ENTITY_TYPE);
- } else {
- VersioningUtil.validateEntityExistence(retrieved,
- new ProcessEntity(vspId, version, componentId, processId),
- VspDetails.ENTITY_TYPE); //todo retrieved is always null ??
+ ProcessEntity inputProcess = new ProcessEntity(vspId, version, componentId, processId);
+ VersioningUtil.validateEntityExistence(retrieved, inputProcess, VspDetails.ENTITY_TYPE);
+ if (retrieved.getArtifact() == null) {
+ throw new CoreException(new ErrorCode.ErrorCodeBuilder()
+ .withCategory(ErrorCategory.APPLICATION)
+ .withId(VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND)
+ .withMessage(String.format(PROCESS_ARTIFACT_NOT_EXIST_MSG,
+ processId, VspDetails.ENTITY_TYPE, vspId, version)).build());
}
-
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id, process id", vspId, componentId,
- processId);
}
protected void validateUniqueName(String vspId, Version version, String componentId,
String processName) {
UniqueValueUtil.validateUniqueValue(VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME,
- vspId, version.toString(), componentId, processName);
+ vspId, version.getId(), componentId, processName);
}
protected void createUniqueName(String vspId, Version version, String componentId,
String processName) {
UniqueValueUtil
.createUniqueValue(VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME, vspId,
- version.toString(), componentId, processName);
+ version.getId(), componentId, processName);
}
protected void updateUniqueName(String vspId, Version version, String componentId,
String oldProcessName, String newProcessName) {
UniqueValueUtil
.updateUniqueValue(VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME, oldProcessName,
- newProcessName, vspId, version.toString(), componentId);
+ newProcessName, vspId, version.getId(), componentId);
}
protected void deleteUniqueValue(String vspId, Version version, String componentId,
String processName) {
+ if (componentId == null) {
+ UniqueValueUtil
+ .deleteUniqueValue(VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME, vspId,
+ version.getId(), processName);
+ }
UniqueValueUtil
.deleteUniqueValue(VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME, vspId,
- version.toString(), componentId, processName);
+ version.getId(), componentId, processName);
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
index d4879da..640d5c0 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
@@ -34,18 +34,12 @@
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.core.validation.api.ValidationManager;
import org.openecomp.core.validation.util.MessageContainerUtil;
-import org.openecomp.sdc.activityLog.ActivityLogManager;
-import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.common.errors.ValidationErrorBuilder;
import org.openecomp.sdc.common.utils.CommonUtil;
-import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
-import org.openecomp.sdc.generator.datatypes.tosca.VspModelInfo;
-import org.openecomp.sdc.healing.api.HealingManager;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
@@ -63,11 +57,14 @@
import org.openecomp.sdc.vendorsoftwareproduct.ManualVspToscaManager;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.errors.VendorSoftwareProductNotFoundErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
@@ -76,18 +73,17 @@
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OnboardingMethod;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadDataEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspQuestionnaireEntity;
import org.openecomp.sdc.vendorsoftwareproduct.errors.ComponentDependencyModelErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.ComponentErrorBuilder;
-import org.openecomp.sdc.vendorsoftwareproduct.errors.CreatePackageForNonFinalVendorSoftwareProductErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.DeploymentFlavorErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.FileCreationErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.InformationArtifactCreationErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.NicInternalNetworkErrorBuilder;
-import org.openecomp.sdc.vendorsoftwareproduct.errors.OnboardingMethodErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.PackageInvalidErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.PackageNotFoundErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.TranslationFileCreationErrorBuilder;
@@ -99,7 +95,6 @@
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireValidationResult;
import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse;
-import org.openecomp.sdc.vendorsoftwareproduct.types.VersionedVendorSoftwareProductInfo;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
@@ -111,15 +106,8 @@
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext;
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateInput;
import org.openecomp.sdc.vendorsoftwareproduct.utils.ComponentDependencyTracker;
-import org.openecomp.sdc.versioning.VersioningManager;
import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.dao.types.VersionStatus;
-import org.openecomp.sdc.versioning.errors.RequestedVersionInvalidErrorBuilder;
-import org.openecomp.sdc.versioning.types.VersionInfo;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
-import org.openecomp.sdcrests.activitylog.types.ActivityType;
-import org.slf4j.MDC;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
@@ -136,276 +124,178 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;
-import java.util.Optional;
import java.util.Set;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductManager {
- private String VALIDATION_VSP_ID = "validationOnlyVspId";
- private static final String VALIDATION_VSP_NAME = "validationOnlyVspName";
- //private static final String VALIDATION_VSP_USER = "validationOnlyVspUser";
-
- private static final MdcDataDebugMessage MDC_DATA_DEBUG_MESSAGE = new MdcDataDebugMessage();
+ private static MdcDataDebugMessage MDC_DATA_DEBUG_MESSAGE = new MdcDataDebugMessage();
private static final Logger LOGGER =
LoggerFactory.getLogger(VendorSoftwareProductManagerImpl.class);
- private final OrchestrationTemplateDao orchestrationTemplateDao;
- private final VendorSoftwareProductInfoDao vspInfoDao;
- private final VersioningManager versioningManager;
- private final VendorSoftwareProductDao vendorSoftwareProductDao;
- private final VendorLicenseFacade vendorLicenseFacade;
- private final ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao;
- private final EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> enrichedServiceModelDao;
- private final HealingManager healingManager;
- private final VendorLicenseArtifactsService licenseArtifactsService;
- private final InformationArtifactGenerator informationArtifactGenerator;
- private final PackageInfoDao packageInfoDao;
- private final ActivityLogManager activityLogManager;
- private final DeploymentFlavorDao deploymentFlavorDao;
- private final NicDao nicDao;
- private final ManualVspToscaManager manualVspToscaManager;
+ private OrchestrationTemplateDao orchestrationTemplateDao;
+ private VendorSoftwareProductInfoDao vspInfoDao;
+ private VendorLicenseFacade vendorLicenseFacade;
+ private ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao;
+ private EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> enrichedServiceModelDao;
+ private VendorLicenseArtifactsService licenseArtifactsService;
+ private InformationArtifactGenerator informationArtifactGenerator;
+ private PackageInfoDao packageInfoDao;
+ private DeploymentFlavorDao deploymentFlavorDao;
+ private ComponentDao componentDao;
+ private ComponentDependencyModelDao componentDependencyModelDao;
+ private NicDao nicDao;
+ private ComputeDao computeDao;
+ private ImageDao imageDao;
+ private ManualVspToscaManager manualVspToscaManager;
- /**
- * Instantiates a new Vendor software product manager.
- *
- * @param versioningManager the versioning manager
- * @param vendorSoftwareProductDao the vendor software product dao
- * @param orchestrationTemplateDataDao the orchestration template data dao
- * @param vspInfoDao the vsp info dao
- * @param vendorLicenseFacade the vendor license facade
- * @param serviceModelDao the service model dao
- * @param enrichedServiceModelDao the enriched service model dao
- * @param healingManager the healing manager
- * @param licenseArtifactsService the license artifacts service
- * @param informationArtifactGenerator the information artifact generator
- * @param packageInfoDao the package info dao
- * @param activityLogManager the activity log manager
- * @param deploymentFlavorDao the deployment flavor dao
- * @param nicDao the nic dao
- */
public VendorSoftwareProductManagerImpl(
- VersioningManager versioningManager,
- VendorSoftwareProductDao vendorSoftwareProductDao,
OrchestrationTemplateDao orchestrationTemplateDataDao,
VendorSoftwareProductInfoDao vspInfoDao,
VendorLicenseFacade vendorLicenseFacade,
ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao,
EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> enrichedServiceModelDao,
- HealingManager healingManager,
VendorLicenseArtifactsService licenseArtifactsService,
InformationArtifactGenerator informationArtifactGenerator,
PackageInfoDao packageInfoDao,
- ActivityLogManager activityLogManager,
DeploymentFlavorDao deploymentFlavorDao,
+ ComponentDao componentDao,
+ ComponentDependencyModelDao componentDependencyModelDao,
NicDao nicDao,
+ ComputeDao computeDao,
+ ImageDao imageDao,
ManualVspToscaManager manualVspToscaManager) {
- this.versioningManager = versioningManager;
- this.vendorSoftwareProductDao = vendorSoftwareProductDao;
this.orchestrationTemplateDao = orchestrationTemplateDataDao;
this.vspInfoDao = vspInfoDao;
this.vendorLicenseFacade = vendorLicenseFacade;
this.serviceModelDao = serviceModelDao;
this.enrichedServiceModelDao = enrichedServiceModelDao;
- this.healingManager = healingManager;
this.licenseArtifactsService = licenseArtifactsService;
this.informationArtifactGenerator = informationArtifactGenerator;
this.packageInfoDao = packageInfoDao;
- this.activityLogManager = activityLogManager;
this.deploymentFlavorDao = deploymentFlavorDao;
+ this.componentDao = componentDao;
+ this.componentDependencyModelDao = componentDependencyModelDao;
this.nicDao = nicDao;
+ this.computeDao = computeDao;
+ this.imageDao = imageDao;
this.manualVspToscaManager = manualVspToscaManager;
registerToVersioning();
}
private void registerToVersioning() {
- vendorSoftwareProductDao.registerVersioning(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
serviceModelDao.registerVersioning(
VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
enrichedServiceModelDao.registerVersioning(
VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
}
- @Override
- public Version checkout(String vendorSoftwareProductId, String user) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vendorSoftwareProductId);
- MDC.put(LoggerConstants.SERVICE_NAME, LoggerServiceName.Checkout_Entity.toString());
-
- Version newVersion = versioningManager
- .checkout(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
- vendorSoftwareProductId, user);
-
- if (newVersion != null) {
- ActivityLogEntity activityLogEntity =
- new ActivityLogEntity(vendorSoftwareProductId, String.valueOf(newVersion.getMajor() + 1),
- ActivityType.CHECKOUT.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
- }
-
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vendorSoftwareProductId);
- return newVersion;
- }
-
@Override
- public Version undoCheckout(String vendorSoftwareProductId, String user) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vendorSoftwareProductId);
-
- Version version =
- getVersionInfo(vendorSoftwareProductId, VersionableEntityAction.Read, user)
- .getActiveVersion();
-
- ActivityLogEntity activityLogEntity =
- new ActivityLogEntity(vendorSoftwareProductId, String.valueOf(version.getMajor() + 1),
- ActivityType.UNDO_CHECKOUT.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
-
- String preVspName = vspInfoDao
- .get(new VspDetails(vendorSoftwareProductId, version)).getName();
-
- Version newVersion = versioningManager.undoCheckout(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
- vendorSoftwareProductId, user);
-
- String postVspName = vspInfoDao
- .get(new VspDetails(vendorSoftwareProductId, newVersion))
- .getName();
-
- updateUniqueName(preVspName, postVspName);
-
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vendorSoftwareProductId);
-
- return newVersion;
- }
-
- @Override
- public Version checkin(String vendorSoftwareProductId, String user) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vendorSoftwareProductId);
-
- Version newVersion = versioningManager.checkin(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
- vendorSoftwareProductId, user, null);
-
- if (newVersion != null) {
- ActivityLogEntity activityLogEntity =
- new ActivityLogEntity(vendorSoftwareProductId, String.valueOf(newVersion.getMajor() + 1),
- ActivityType.CHECKIN.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
- }
-
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vendorSoftwareProductId);
-
- return newVersion;
- }
-
- @Override
- public ValidationResponse submit(String vspId, String user) throws IOException {
+ public ValidationResponse validate(String vspId, Version version) throws IOException {
MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
- Version version = getVersionInfo(vspId, VersionableEntityAction.Read, user).getActiveVersion();
- VspDetails vspDetails = getVsp(vspId, version, user);
- UploadDataEntity uploadData = orchestrationTemplateDao.getOrchestrationTemplate(vspId, version);
- ToscaServiceModel serviceModel =
- serviceModelDao.getServiceModel(vspId, vspDetails.getVersion());
+ VspDetails vspDetails = getValidatedVsp(vspId, version);
+ Collection<ComponentDependencyModelEntity> componentDependencies =
+ componentDependencyModelDao.list(new ComponentDependencyModelEntity(vspId, version, null));
ValidationResponse validationResponse = new ValidationResponse();
- validationResponse
- .setVspErrors(validateCompletedVendorSoftwareProduct(vspDetails, uploadData, serviceModel),
- LoggerServiceName.Submit_VSP, LoggerTragetServiceName.SUBMIT_VSP);
-
- if (isCyclicDependencyInComponents(vspId, vspDetails.getVersion())) {
- Collection<ErrorCode> vspErrors = validationResponse.getVspErrors() == null
- ? new ArrayList<>()
- : validationResponse.getVspErrors();
- vspErrors.add(ComponentDependencyModelErrorBuilder
- .getcyclicDependencyComponentErrorBuilder());
- validationResponse.setVspErrors(vspErrors, LoggerServiceName.Submit_VSP,
- LoggerTragetServiceName.SUBMIT_VSP);
- }
-
- validationResponse.setLicensingDataErrors(validateLicensingData(vspDetails));
- validationResponse
- .setUploadDataErrors(validateUploadData(uploadData, vspDetails),
- LoggerServiceName.Submit_VSP,
- LoggerTragetServiceName.SUBMIT_VSP);
-
validationResponse.setQuestionnaireValidationResult(
- validateQuestionnaire(vspDetails.getId(), vspDetails.getVersion(), vspDetails
- .getOnboardingMethod()));
+ validateQuestionnaire(vspDetails.getId(), vspDetails.getVersion(),
+ vspDetails.getOnboardingMethod()));
- if ("Manual".equals(vspDetails.getOnboardingMethod())) {
- Collection<ErrorCode> deploymentFlavourValidationErrList =
- deploymentFlavorValidation(vspDetails.getId(), vspDetails.getVersion());
- if (validationResponse.getVspErrors() != null) {
- if (deploymentFlavourValidationErrList != null) {
- validationResponse.getVspErrors().addAll(deploymentFlavourValidationErrList);
- }
- } else {
- validationResponse
- .setVspErrors(deploymentFlavourValidationErrList, LoggerServiceName.Submit_VSP,
- LoggerTragetServiceName.SUBMIT_VSP);
+ List<ErrorCode> vspErrors = new ArrayList<>();
+ vspErrors.addAll(validateVspFields(vspDetails));
+ if (validateComponentDependencies(componentDependencies)) {
+ vspErrors
+ .add(ComponentDependencyModelErrorBuilder.getcyclicDependencyComponentErrorBuilder());
+ }
+ if (Objects.nonNull(vspDetails.getOnboardingMethod()) &&
+ OnboardingMethod.Manual.name().equals(vspDetails.getOnboardingMethod())) {
+ vspErrors.addAll(validateMandatoryLicenseFields(vspDetails));
+
+ Collection<DeploymentFlavorEntity> deploymentFlavors = deploymentFlavorDao
+ .list(new DeploymentFlavorEntity(vspDetails.getId(), vspDetails.getVersion(), null));
+ if (CollectionUtils.isEmpty(deploymentFlavors)) {
+ vspErrors
+ .add(VendorSoftwareProductInvalidErrorBuilder.VspMissingDeploymentFlavorErrorBuilder());
}
+ vspErrors.addAll(validateDeploymentFlavors(deploymentFlavors));
- Set<CompositionEntityValidationData> compositionEntityValidationData =
+ Set<CompositionEntityValidationData> componentValidationResult =
componentValidation(vspDetails.getId(), vspDetails.getVersion());
- if (validationResponse.getQuestionnaireValidationResult() != null) {
- if (!CollectionUtils.isEmpty(compositionEntityValidationData)) {
+ if (!CollectionUtils.isEmpty(componentValidationResult)) {
+ if (validationResponse.getQuestionnaireValidationResult() == null ||
+ validationResponse.getQuestionnaireValidationResult().getValidationData() == null) {
+ validationResponse.setQuestionnaireValidationResult(
+ new QuestionnaireValidationResult(componentValidationResult));
+ } else {
validationResponse.getQuestionnaireValidationResult().getValidationData()
- .addAll(compositionEntityValidationData);
+ .addAll(componentValidationResult);
}
- } else {
- validationResponse.setQuestionnaireValidationResult(
- CollectionUtils.isEmpty(compositionEntityValidationData) ? null :
- new QuestionnaireValidationResult(compositionEntityValidationData));
}
-
- //Generate Tosca service model for Manual Onboarding flow
- VspModelInfo vspModelInfo = manualVspToscaManager.gatherVspInformation(vspId, version, user);
- serviceModel = manualVspToscaManager.generateToscaModel(vspModelInfo);
+ } else {
+ if (vspDetails.getVlmVersion() != null || vspDetails.getLicenseAgreement() != null
+ || vspDetails.getFeatureGroups() != null) {
+ vspErrors.addAll(validateMandatoryLicenseFields(vspDetails));
+ }
+ OrchestrationTemplateEntity orchestrationTemplate =
+ orchestrationTemplateDao.get(vspId, version);
+ ToscaServiceModel serviceModel =
+ serviceModelDao.getServiceModel(vspId, vspDetails.getVersion());
+ if (!isOrchestrationTemplateExist(orchestrationTemplate) ||
+ !isServiceModelExist(serviceModel)) {
+ vspErrors.add(VendorSoftwareProductInvalidErrorBuilder
+ .VendorSoftwareProductMissingServiceModelErrorBuilder(vspDetails.getId(),
+ vspDetails.getVersion()));
+ }
+ validationResponse.setUploadDataErrors(validateOrchestrationTemplate(orchestrationTemplate),
+ LoggerServiceName.Submit_VSP, LoggerTragetServiceName.SUBMIT_VSP);
}
- validationResponse.setCompilationErrors(
- compile(vspId, vspDetails.getVersion(), serviceModel),
- LoggerServiceName.Submit_VSP, LoggerTragetServiceName.SUBMIT_VSP);
+ validationResponse
+ .setVspErrors(vspErrors, LoggerServiceName.Submit_VSP, LoggerTragetServiceName.SUBMIT_VSP);
+ validationResponse.setLicensingDataErrors(validateLicensingData(vspDetails));
- if (validationResponse.isValid()) {
- Version newVersion = versioningManager.submit(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
- vspId, user, null);
- ActivityLogEntity activityLogEntity = new ActivityLogEntity(vspDetails.getId(), String
- .valueOf(newVersion.getMajor()),
- ActivityType.SUBMIT.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
- }
MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vspId);
return validationResponse;
}
- private boolean isCyclicDependencyInComponents(String vendorSoftwareProductId,
- Version version) {
- final Collection<ComponentDependencyModelEntity> componentDependencyModelEntities =
- vendorSoftwareProductDao.listComponentDependencies(vendorSoftwareProductId, version);
+ @Override
+ public Map<String, List<ErrorMessage>> compile(String vspId, Version version) {
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
+
+ ToscaServiceModel serviceModel =
+ OnboardingMethod.Manual.name().equals(getValidatedVsp(vspId, version).getOnboardingMethod())
+ //Generate Tosca service model for Manual Onboarding flow
+ ? manualVspToscaManager
+ .generateToscaModel(manualVspToscaManager.gatherVspInformation(vspId, version))
+ : serviceModelDao.getServiceModel(vspId, version);
+
+ Map<String, List<ErrorMessage>> compilationErrors = compile(vspId, version, serviceModel);
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vspId);
+ return compilationErrors;
+ }
+
+ private boolean validateComponentDependencies(
+ Collection<ComponentDependencyModelEntity> componentDependencies) {
ComponentDependencyTracker dependencyTracker = new ComponentDependencyTracker();
- for (ComponentDependencyModelEntity entity : componentDependencyModelEntities) {
- dependencyTracker.addDependency(entity.getSourceComponentId(), entity.getTargetComponentId());
+ for (ComponentDependencyModelEntity componentDependency : componentDependencies) {
+ dependencyTracker.addDependency(componentDependency.getSourceComponentId(),
+ componentDependency.getTargetComponentId());
}
return dependencyTracker.isCyclicDependencyPresent();
}
- private Collection<ErrorCode> deploymentFlavorValidation(String vspId,
- Version version) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
- Set<CompositionEntityValidationData> validationData = new HashSet<>();
+ private Collection<ErrorCode> validateDeploymentFlavors(
+ Collection<DeploymentFlavorEntity> deploymentFlavors) {
+
Collection<ErrorCode> errorCodeList = new ArrayList<>();
- Collection<DeploymentFlavorEntity> deploymentFlavors =
- vendorSoftwareProductDao.listDeploymentFlavors(vspId, version);
if (!CollectionUtils.isEmpty(deploymentFlavors)) {
deploymentFlavors.forEach(deploymentFlavor -> {
- DeploymentFlavorEntity deployment = vendorSoftwareProductDao.getDeploymentFlavor(vspId,
- version, deploymentFlavor.getId());
+ DeploymentFlavorEntity deployment = deploymentFlavorDao.get(deploymentFlavor);
DeploymentFlavor deploymentlocalFlavor = deployment.getDeploymentFlavorCompositionData();
if (deploymentlocalFlavor != null) {
if (deploymentlocalFlavor.getFeatureGroupId() == null) {
@@ -455,7 +345,7 @@
Set<CompositionEntityValidationData> validationData = new HashSet<>();
Collection<ComponentEntity> components =
- vendorSoftwareProductDao.listComponents(vspId, version);
+ componentDao.list(new ComponentEntity(vspId, version, null));
if (!CollectionUtils.isEmpty(components)) {
components.forEach(component -> {
validateImage(vspId, version, validationData, component);
@@ -496,13 +386,13 @@
private void validateImage(String vspId, Version version,
Set<CompositionEntityValidationData> validationData,
ComponentEntity component) {
- Collection<ImageEntity> images = vendorSoftwareProductDao.listImages(vspId, version,
- component.getId());
+ Collection<ImageEntity> images =
+ imageDao.list(new ImageEntity(vspId, version, component.getId(), null));
if (CollectionUtils.isEmpty(images)) {
CompositionEntityValidationData compositionEntityValidationData = new
CompositionEntityValidationData(component.getType(), component.getId());
- compositionEntityValidationData.setEntityName(component.getComponentCompositionData()
- .getDisplayName());
+ compositionEntityValidationData
+ .setEntityName(component.getComponentCompositionData().getDisplayName());
ErrorCode vfcMissingImageErrorBuilder =
ComponentErrorBuilder.VfcMissingImageErrorBuilder();
List<String> errors = new ArrayList<>();
@@ -512,10 +402,7 @@
}
}
-
- private List<ErrorCode> validateCompletedVendorSoftwareProduct(
- VspDetails vspDetails, UploadDataEntity uploadData, Object serviceModel) {
-
+ private List<ErrorCode> validateVspFields(VspDetails vspDetails) {
List<ErrorCode> errors = new ArrayList<>();
if (vspDetails.getName() == null) {
@@ -533,36 +420,13 @@
if (vspDetails.getSubCategory() == null) {
errors.add(createMissingMandatoryFieldError("sub category"));
}
- if ("Manual".equals(vspDetails.getOnboardingMethod())) {
- //Manual Onboarding specific validations
- Collection<DeploymentFlavorEntity> deploymentFlavorEntities = vendorSoftwareProductDao
- .listDeploymentFlavors(vspDetails.getId(), vspDetails.getVersion());
- if (CollectionUtils.isEmpty(deploymentFlavorEntities)) {
- ErrorCode vspMissingDeploymentFlavorErrorBuilder =
- VendorSoftwareProductInvalidErrorBuilder.VspMissingDeploymentFlavorErrorBuilder();
- errors.add(vspMissingDeploymentFlavorErrorBuilder);
- }
- errors.addAll(validateMandatoryLicenseFields(vspDetails));
- } else {
- //Heat flow specific VSP validations
- if (uploadData == null || uploadData.getContentData() == null || serviceModel == null) {
- errors.add(VendorSoftwareProductInvalidErrorBuilder
- .VendorSoftwareProductMissingServiceModelErrorBuilder(vspDetails.getId(),
- vspDetails.getVersion()));
- }
- if (vspDetails.getVlmVersion() != null || vspDetails.getLicenseAgreement() != null
- || vspDetails.getFeatureGroups() != null) {
- errors.addAll(validateMandatoryLicenseFields(vspDetails));
- }
- }
- return errors.isEmpty() ? null : errors;
+ return errors;
}
private List<ErrorCode> validateMandatoryLicenseFields(VspDetails vspDetails) {
List<ErrorCode> errors = new ArrayList<>();
if (vspDetails.getVlmVersion() == null) {
- errors.add(createMissingMandatoryFieldError(
- "licensing version (in the format of: {integer}.{integer})"));
+ errors.add(createMissingMandatoryFieldError("licensing version"));
}
if (vspDetails.getLicenseAgreement() == null) {
errors.add(createMissingMandatoryFieldError("license agreement"));
@@ -577,23 +441,9 @@
return new ValidationErrorBuilder("must be supplied", fieldName).build();
}
- String getVspQuestionnaireSchema(SchemaTemplateInput schemaInput) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage(null);
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage(null);
- return SchemaGenerator
- .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.vsp, schemaInput);
- }
-
- private static void sortVspListByModificationTimeDescOrder(
- List<VersionedVendorSoftwareProductInfo> vsps) {
- vsps.sort((o1, o2) -> o2.getVspDetails().getWritetimeMicroSeconds()
- .compareTo(o1.getVspDetails().getWritetimeMicroSeconds()));
- }
-
-
private Map<String, List<ErrorMessage>> compile(String vendorSoftwareProductId, Version version,
ToscaServiceModel serviceModel) {
- if (serviceModel == null) {
+ if (!isServiceModelExist(serviceModel)) {
return null;
}
@@ -636,135 +486,47 @@
}
@Override
- public String fetchValidationVsp(String user) {
- try {
- validateUniqueName(VALIDATION_VSP_NAME);
- } catch (Exception ignored) {
- LOGGER.debug("Ignored exception when validating unique VSP name", ignored);
- return VALIDATION_VSP_ID;
- }
- VspDetails validationVsp = new VspDetails();
- validationVsp.setName(VALIDATION_VSP_NAME);
-
- vspInfoDao.create(validationVsp);
- Version version = versioningManager.create(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
- validationVsp.getId(), user);
- validationVsp.setVersion(version);
-
- createUniqueName(VALIDATION_VSP_NAME);
- VALIDATION_VSP_ID = validationVsp.getId();
- return VALIDATION_VSP_ID;
- }
-
- @Override
- public VspDetails createVsp(VspDetails vspDetails, String user) {
+ public VspDetails createVsp(VspDetails vspDetails) {
MDC_DATA_DEBUG_MESSAGE.debugEntryMessage(null);
- validateUniqueName(vspDetails.getName());
-
- vspDetails.setOnboardingOrigin(OnboardingTypesEnum.NONE.toString());
-
- vspInfoDao.create(vspDetails);//id will be set in the dao
- vspInfoDao.updateQuestionnaireData(vspDetails.getId(), null,
+ vspInfoDao.create(vspDetails);
+ vspInfoDao.updateQuestionnaireData(vspDetails.getId(), vspDetails.getVersion(),
new JsonSchemaDataGenerator(getVspQuestionnaireSchema(null)).generateData());
- Version version = versioningManager
- .create(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
- vspDetails.getId(), user);
- vspDetails.setVersion(version);
- ActivityLogEntity activityLogEntity = new ActivityLogEntity(vspDetails.getId(), String
- .valueOf(vspDetails.getVersion().getMajor() + 1),
- ActivityType.CREATE_NEW.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
- String vspName = vspDetails.getName();
- createUniqueName(vspName);
MDC_DATA_DEBUG_MESSAGE.debugExitMessage(null);
return vspDetails;
}
@Override
- public List<VersionedVendorSoftwareProductInfo> listVsps(String versionFilter, String user) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage(null);
-
- Map<String, VersionInfo> idToVersionsInfo = versioningManager.listEntitiesVersionInfo(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, user,
- VersionableEntityAction.Read);
-
- List<VersionedVendorSoftwareProductInfo> vsps = new ArrayList<>();
- for (Map.Entry<String, VersionInfo> entry : idToVersionsInfo.entrySet()) {
- VersionInfo versionInfo = entry.getValue();
- if (versionFilter != null && versionFilter.equals(VersionStatus.Final.name())) {
- if (versionInfo.getLatestFinalVersion() == null) {
- continue;
- }
- versionInfo.setActiveVersion(versionInfo.getLatestFinalVersion());
- versionInfo.setStatus(VersionStatus.Final);
- versionInfo.setLockingUser(null);
- }
-
- Version version = versionInfo.getActiveVersion();
- if (user.equals(versionInfo.getLockingUser())) {
- version.setStatus(VersionStatus.Locked);
- }
- try {
- VspDetails vsp = vspInfoDao.get(new VspDetails(entry.getKey(), version));
- if (vsp != null && !vsp.getId().equals(VALIDATION_VSP_ID)) {
- vsp.setValidationDataStructure(null);
- vsps.add(new VersionedVendorSoftwareProductInfo(vsp, versionInfo));
- }
- } catch (RuntimeException rte) {
- LOGGER.error(
- "Error trying to retrieve vsp[" + entry.getKey() + "] version[" + version.toString
- () + "] " +
- "message:" + rte.getMessage(), rte);
- }
- }
-
- sortVspListByModificationTimeDescOrder(vsps);
-
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage(null);
-
- return vsps;
- }
-
- @Override
- public void updateVsp(VspDetails vspDetails, String user) {
+ public void updateVsp(VspDetails vspDetails) {
MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspDetails.getId());
VspDetails retrieved = vspInfoDao.get(vspDetails);
- if (!Objects.equals(retrieved.getOnboardingMethod(), vspDetails.getOnboardingMethod())) {
- final ErrorCode onboardingMethodUpdateErrorCode = OnboardingMethodErrorBuilder
- .getOnboardingUpdateError();
-
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.UPDATE_VSP, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), onboardingMethodUpdateErrorCode.message());
-
- throw new CoreException(onboardingMethodUpdateErrorCode);
+ // TODO: 6/21/2017 remove this validation when validation will be added in the REST level
+ if (retrieved == null) {
+ throw new RuntimeException(String.format("Vsp with id %s and version %s does not exist.",
+ vspDetails.getId(), vspDetails.getVersion().getId()));
}
+ vspDetails.setOnboardingMethod(retrieved.getOnboardingMethod());
//If any existing feature group is removed from VSP which is also associated in DF then
//update DF to remove feature group associations.
- updateDeploymentFlavor(vspDetails, user);
+ updateDeploymentFlavor(vspDetails);
updateUniqueName(retrieved.getName(), vspDetails.getName());
- vspDetails.setOldVersion(retrieved.getOldVersion());
-
vspInfoDao.update(vspDetails);
- //vendorSoftwareProductDao.updateVspLatestModificationTime(vspDetails.getId(), activeVersion);
MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vspDetails.getId());
}
- private void updateDeploymentFlavor(VspDetails vspDetails, String user) {
+ private void updateDeploymentFlavor(VspDetails vspDetails) {
final List<String> featureGroups = vspDetails.getFeatureGroups();
if (featureGroups != null) {
final Collection<DeploymentFlavorEntity> deploymentFlavorEntities = deploymentFlavorDao
.list(new DeploymentFlavorEntity(vspDetails.getId(), vspDetails
.getVersion(), null));
if (Objects.nonNull(deploymentFlavorEntities)) {
- deploymentFlavorEntities.forEach(deploymentFlavorEntity -> {
+ for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) {
final String featureGroupId =
deploymentFlavorEntity.getDeploymentFlavorCompositionData().getFeatureGroupId();
if (!featureGroups.contains(featureGroupId)) {
@@ -773,18 +535,25 @@
deploymentFlavorCompositionData.setFeatureGroupId(null);
deploymentFlavorEntity.setDeploymentFlavorCompositionData
(deploymentFlavorCompositionData);
- vendorSoftwareProductDao.updateDeploymentFlavor(deploymentFlavorEntity);
+ deploymentFlavorDao.update(deploymentFlavorEntity);
}
- });
+ }
}
}
}
@Override
- public VspDetails getVsp(String vspId, Version version, String user) {
+ public VspDetails getVsp(String vspId, Version version) {
MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
+ VspDetails vsp = getValidatedVsp(vspId, version);
+
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vspId);
+ return vsp;
+ }
+
+ private VspDetails getValidatedVsp(String vspId, Version version) {
VspDetails vsp = vspInfoDao.get(new VspDetails(vspId, version));
if (vsp == null) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
@@ -792,64 +561,11 @@
LoggerErrorCode.DATA_ERROR.getErrorCode(), "Requested VSP not found");
throw new CoreException(new VendorSoftwareProductNotFoundErrorBuilder(vspId).build());
}
- vsp.setValidationData(orchestrationTemplateDao.getValidationData(vspId, version));
- if (Objects.isNull(vsp.getOnboardingOrigin())) { //todo should this only be done for non-Manual?
- vsp.setOnboardingOrigin(OnboardingTypesEnum.ZIP.toString());
- }
-
- if (Objects.isNull(vsp.getNetworkPackageName())) {
- vsp.setNetworkPackageName("Upload File");
- }
-
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vspId);
return vsp;
}
@Override
- public Version callAutoHeal(String vspId, VersionInfo versionInfo,
- VspDetails vendorSoftwareProductInfo, String user)
- throws Exception {
- switch (versionInfo.getStatus()) {
- case Locked:
- if (user.equals(versionInfo.getLockingUser())) {
- autoHeal(vspId, versionInfo.getActiveVersion(), vendorSoftwareProductInfo,
- versionInfo.getLockingUser());
- }
- return versionInfo.getActiveVersion();
- case Available:
- Version checkoutVersion = checkout(vspId, user);
- autoHeal(vspId, checkoutVersion, vendorSoftwareProductInfo, user);
- return checkin(vspId, user);
- case Final:
- return healAndAdvanceFinalVersion(vspId, vendorSoftwareProductInfo, user);
- default:
- //do nothing
- break;
- }
- return versionInfo.getActiveVersion();
- }
-
- public Version healAndAdvanceFinalVersion(String vspId, VspDetails vendorSoftwareProductInfo,
- String user) throws IOException {
-
- Version checkoutVersion = checkout(vspId, user);
- autoHeal(vspId, checkoutVersion, vendorSoftwareProductInfo, user);
- Version checkinVersion = checkin(vspId, user);
-
- ValidationResponse response = Objects.requireNonNull(submit(vspId, user),
- "Null response not expected");
-
- if (!response.isValid()) {
- return checkinVersion;
- }
-
- Version finalVersion = checkinVersion.calculateNextFinal();
- createPackage(vspId, finalVersion, user);
- return finalVersion;
- }
-
- @Override
- public void deleteVsp(String vspId, String user) {
+ public void deleteVsp(String vspId) {
MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
@@ -862,88 +578,16 @@
}
@Override
- public void heal(String vspId, Version version, String user) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
-
- VersionInfo versionInfo = getVersionInfo(vspId, VersionableEntityAction.Read, user);
-
- version = VersionStatus.Locked.equals(versionInfo.getStatus())
- ? versionInfo.getActiveVersion()
- : checkout(vspId, user);
- version.setStatus(VersionStatus.Locked);
-
- Optional<String> errorMessages =
- healingManager.healAll(getHealingParamsAsMap(vspId, version, user));
-
- VspDetails vspDetails = new VspDetails(vspId, version);
- vspDetails.setOldVersion(null);
- vspInfoDao.updateOldVersionIndication(vspDetails);
-
- LOGGER.audit("Healed VSP " + vspDetails.getId());
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vspId);
-
- errorMessages.ifPresent(s -> {
- throw new CoreException(new ErrorCode.ErrorCodeBuilder().withId("HEALING_ERROR")
- .withCategory(ErrorCategory.APPLICATION).withMessage(s).build());
- });
- }
-
- private void autoHeal(String vspId, Version checkoutVersion, VspDetails vspDetails, String user) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
-
- checkoutVersion.setStatus(VersionStatus.Locked);
- Map<String, Object> healingParams = getHealingParamsAsMap(vspId, checkoutVersion, user);
-
- Optional<String> errorMessages = healingManager.healAll(healingParams);
-
- vspDetails.setVersion(checkoutVersion);
- vspDetails.setOldVersion(null);
- vspInfoDao.updateOldVersionIndication(vspDetails);
-
- LOGGER.audit("Healed VSP " + vspDetails.getName());
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vspId);
-
- errorMessages.ifPresent(s -> {
- throw new CoreException(new ErrorCode.ErrorCodeBuilder().withId("HEALING_ERROR")
- .withCategory(ErrorCategory.APPLICATION).withMessage(s).build());
- });
- }
-
- private Map<String, Object> getHealingParamsAsMap(String vspId, Version version, String user) {
- Map<String, Object> healingParams = new HashMap<>();
-
- healingParams.put(SdcCommon.VSP_ID, vspId);
- healingParams.put(SdcCommon.VERSION, version);
- healingParams.put(SdcCommon.USER, user);
-
- return healingParams;
- }
-
- @Override
public List<PackageInfo> listPackages(String category, String subCategory) {
return packageInfoDao.listByCategory(category, subCategory);
}
@Override
- public File getTranslatedFile(String vspId, Version version, String user) {
+ public File getTranslatedFile(String vspId, Version version) {
MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
String errorMessage;
- if (version == null) {
- errorMessage = "Package not found";
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.GET_TRANSLATED_FILE, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), errorMessage);
- throw new CoreException(new PackageNotFoundErrorBuilder(vspId).build());
- } else if (!version.isFinal()) {
- errorMessage = "Invalid requested version";
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.GET_VERSION_INFO, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), errorMessage);
- throw new CoreException(new RequestedVersionInvalidErrorBuilder().build());
- }
- PackageInfo packageInfo =
- packageInfoDao.get(new PackageInfo(vspId, version));
+ PackageInfo packageInfo = packageInfoDao.get(new PackageInfo(vspId, version));
if (packageInfo == null) {
errorMessage = "Package not found";
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
@@ -981,10 +625,10 @@
@Override
- public byte[] getOrchestrationTemplateFile(String vspId, Version version, String user) {
+ public byte[] getOrchestrationTemplateFile(String vspId, Version version) {
MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
- UploadDataEntity uploadData = orchestrationTemplateDao.getOrchestrationTemplate(vspId, version);
+ OrchestrationTemplateEntity uploadData = orchestrationTemplateDao.get(vspId, version);
ByteBuffer contentData = uploadData.getContentData();
if (contentData == null) {
return null;
@@ -993,7 +637,7 @@
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (final ZipOutputStream zos = new ZipOutputStream(baos);
- ZipInputStream zipStream = new ZipInputStream(
+ ZipInputStream ignored = new ZipInputStream(
new ByteArrayInputStream(contentData.array()))) {
zos.write(contentData.array());
} catch (IOException exception) {
@@ -1008,29 +652,25 @@
}
@Override
- public PackageInfo createPackage(String vspId, Version version, String user) throws IOException {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
+ public OrchestrationTemplateEntity getOrchestrationTemplateInfo(String vspId, Version version) {
+ return orchestrationTemplateDao.getInfo(vspId, version);
+ }
- if (!version.isFinal()) {
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.CREATE_PACKAGE, ErrorLevel.ERROR.name(),
- LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Can't create package");
- throw new CoreException(
- new CreatePackageForNonFinalVendorSoftwareProductErrorBuilder(vspId, version)
- .build());
- }
+ @Override
+ public PackageInfo createPackage(String vspId, Version version) throws IOException {
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
ToscaServiceModel toscaServiceModel = enrichedServiceModelDao.getServiceModel(vspId, version);
VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));
Version vlmVersion = vspDetails.getVlmVersion();
- PackageInfo packageInfo = createPackageInfo(vspId, vspDetails);
+ PackageInfo packageInfo = createPackageInfo(vspDetails);
ToscaFileOutputServiceCsarImpl toscaServiceTemplateServiceCsar =
new ToscaFileOutputServiceCsarImpl();
FileContentHandler licenseArtifacts = licenseArtifactsService
.createLicenseArtifacts(vspDetails.getId(), vspDetails.getVendorId(), vlmVersion,
- vspDetails.getFeatureGroups(), user);
+ vspDetails.getFeatureGroups());
//todo add tosca validation here
packageInfo.setTranslatedFile(ByteBuffer.wrap(
toscaServiceTemplateServiceCsar.createOutputFile(toscaServiceModel, licenseArtifacts)));
@@ -1043,10 +683,8 @@
return packageInfo;
}
- private PackageInfo createPackageInfo(String vspId, VspDetails vspDetails) {
- PackageInfo packageInfo = new PackageInfo();
- packageInfo.setVspId(vspId);
- packageInfo.setVersion(vspDetails.getVersion());
+ private PackageInfo createPackageInfo(VspDetails vspDetails) {
+ PackageInfo packageInfo = new PackageInfo(vspDetails.getId(), vspDetails.getVersion());
packageInfo.setVspName(vspDetails.getName());
packageInfo.setVspDescription(vspDetails.getDescription());
packageInfo.setCategory(vspDetails.getCategory());
@@ -1059,7 +697,7 @@
@Override
- public QuestionnaireResponse getVspQuestionnaire(String vspId, Version version, String user) {
+ public QuestionnaireResponse getVspQuestionnaire(String vspId, Version version) {
MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
VspQuestionnaireEntity retrieved = vspInfoDao.getQuestionnaire(vspId, version);
@@ -1078,8 +716,7 @@
}
@Override
- public void updateVspQuestionnaire(String vspId, Version version, String questionnaireData,
- String user) {
+ public void updateVspQuestionnaire(String vspId, Version version, String questionnaireData) {
MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
vspInfoDao.updateQuestionnaireData(vspId, version, questionnaireData);
@@ -1088,21 +725,19 @@
}
- private Map<String, List<ErrorMessage>> validateUploadData(UploadDataEntity uploadData,
- VspDetails vspDetails)
- throws IOException {
+ private Map<String, List<ErrorMessage>> validateOrchestrationTemplate(
+ OrchestrationTemplateEntity orchestrationTemplate) throws IOException {
- Map<String, List<ErrorMessage>> validationErrors = new HashMap<>();
- if (uploadData == null || uploadData.getContentData() == null) {
+ if (!isOrchestrationTemplateExist(orchestrationTemplate)) {
return null;
}
+ Map<String, List<ErrorMessage>> validationErrors = new HashMap<>();
- FileContentHandler fileContentMap =
- CommonUtil.validateAndUploadFileContent(OnboardingTypesEnum.getOnboardingTypesEnum
- (vspDetails.getOnboardingOrigin()),
- uploadData.getContentData().array());
+ FileContentHandler fileContentMap = CommonUtil.validateAndUploadFileContent(
+ OnboardingTypesEnum.getOnboardingTypesEnum(orchestrationTemplate.getFileSuffix()),
+ orchestrationTemplate.getContentData().array());
- if (CommonUtil.isFileOriginFromZip(vspDetails.getOnboardingOrigin())) {
+ if (CommonUtil.isFileOriginFromZip(orchestrationTemplate.getFileSuffix())) {
ValidationManager validationManager =
ValidationManagerUtil.initValidationManager(fileContentMap);
validationErrors.putAll(validationManager.validate());
@@ -1113,14 +748,6 @@
? null : validationErrors;
}
- private VersionInfo getVersionInfo(String vendorSoftwareProductId, VersionableEntityAction action,
- String user) {
- return versioningManager.getEntityVersionInfo(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
- vendorSoftwareProductId, user, action);
- }
-
-
private QuestionnaireValidationResult validateQuestionnaire(String vspId, Version version,
String onboardingMethod) {
MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
@@ -1132,7 +759,7 @@
compositionEntityDataManager
.addEntity(vspInfoDao.getQuestionnaire(vspId, version), null);
- Collection<NicEntity> nics = vendorSoftwareProductDao.listNicsByVsp(vspId, version);
+ Collection<NicEntity> nics = nicDao.listByVsp(vspId, version);
Map<String, List<String>> nicNamesByComponent = new HashMap<>();
for (NicEntity nicEntity : nics) {
@@ -1147,16 +774,16 @@
}
Collection<ComponentEntity> components =
- vendorSoftwareProductDao.listComponentsCompositionAndQuestionnaire(vspId, version);
+ componentDao.listCompositionAndQuestionnaire(vspId, version);
components.forEach(component -> compositionEntityDataManager.addEntity(component,
new ComponentQuestionnaireSchemaInput(nicNamesByComponent.get(component.getId()),
JsonUtil.json2Object(component.getQuestionnaireData(), Map.class))));
- Collection<ComputeEntity> computes = vendorSoftwareProductDao.listComputesByVsp(vspId, version);
+ Collection<ComputeEntity> computes = computeDao.listByVsp(vspId, version);
computes.forEach(compute -> compositionEntityDataManager.addEntity(compute, null));
- if ("Manual".equals(onboardingMethod)) {
- Collection<ImageEntity> images = vendorSoftwareProductDao.listImagesByVsp(vspId, version);
+ if (OnboardingMethod.Manual.name().equals(onboardingMethod)) {
+ Collection<ImageEntity> images = imageDao.listByVsp(vspId, version);
images.forEach(image -> compositionEntityDataManager.addEntity(image, null));
}
@@ -1179,7 +806,7 @@
}
@Override
- public File getInformationArtifact(String vspId, Version version, String user) {
+ public File getInformationArtifact(String vspId, Version version) {
MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));
@@ -1209,14 +836,11 @@
return infoArtifactFile;
}
- void validateUniqueName(String vspName) {
- UniqueValueUtil.validateUniqueValue(
- VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME, vspName);
- }
-
- void createUniqueName(String vspName) {
- UniqueValueUtil.createUniqueValue(
- VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME, vspName);
+ String getVspQuestionnaireSchema(SchemaTemplateInput schemaInput) {
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage(null);
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage(null);
+ return SchemaGenerator
+ .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.vsp, schemaInput);
}
void updateUniqueName(String oldVspName, String newVspName) {
@@ -1226,13 +850,22 @@
}
@Override
- public Collection<ComputeEntity> getComputeByVsp(String vspId, Version version,
- String user) {
- return vendorSoftwareProductDao.listComputesByVsp(vspId, version);
+ public Collection<ComputeEntity> getComputeByVsp(String vspId, Version version) {
+ return computeDao.listByVsp(vspId, version);
+ }
+
+ private boolean isOrchestrationTemplateExist(OrchestrationTemplateEntity orchestrationTemplate) {
+ return orchestrationTemplate != null &&
+ orchestrationTemplate.getContentData() != null &&
+ orchestrationTemplate.getFileSuffix() != null &&
+ orchestrationTemplate.getFileName() != null;
+ }
+
+ private boolean isServiceModelExist(ToscaServiceModel serviceModel) {
+ return serviceModel != null && serviceModel.getEntryDefinitionServiceTemplate() != null;
}
private void auditIfContainsErrors(List<ErrorMessage> errorList, String vspId, String auditType) {
-
errorList.forEach(errorMessage -> {
if (errorMessage.getLevel().equals(ErrorLevel.ERROR)) {
LOGGER.audit(AuditMessages.AUDIT_MSG + String.format(auditType, errorMessage.getMessage(),
@@ -1240,4 +873,6 @@
}
});
}
+
+
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java
index 5615f8f..a2c0aea 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java
@@ -22,38 +22,38 @@
import org.openecomp.core.model.dao.EnrichedServiceModelDaoFactory;
import org.openecomp.core.model.dao.ServiceModelDaoFactory;
-import org.openecomp.sdc.activityLog.ActivityLogManagerFactory;
-import org.openecomp.sdc.healing.factory.HealingManagerFactory;
import org.openecomp.sdc.vendorlicense.VendorLicenseArtifactServiceFactory;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
import org.openecomp.sdc.vendorsoftwareproduct.VspManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.factory.InformationArtifactGeneratorFactory;
-import org.openecomp.sdc.versioning.VersioningManagerFactory;
public class VspManagerFactoryImpl extends VspManagerFactory {
private static final VendorSoftwareProductManager INSTANCE =
new VendorSoftwareProductManagerImpl(
- VersioningManagerFactory.getInstance().createInterface(),
- VendorSoftwareProductDaoFactory.getInstance().createInterface(),
OrchestrationTemplateDaoFactory.getInstance().createInterface(),
VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(),
VendorLicenseFacadeFactory.getInstance().createInterface(),
ServiceModelDaoFactory.getInstance().createInterface(),
EnrichedServiceModelDaoFactory.getInstance().createInterface(),
- HealingManagerFactory.getInstance().createInterface(),
VendorLicenseArtifactServiceFactory.getInstance().createInterface(),
InformationArtifactGeneratorFactory.getInstance().createInterface(),
PackageInfoDaoFactory.getInstance().createInterface(),
- ActivityLogManagerFactory.getInstance().createInterface(),
DeploymentFlavorDaoFactory.getInstance().createInterface(),
+ ComponentDaoFactory.getInstance().createInterface(),
+ ComponentDependencyModelDaoFactory.getInstance().createInterface(),
NicDaoFactory.getInstance().createInterface(),
+ ComputeDaoFactory.getInstance().createInterface(),
+ ImageDaoFactory.getInstance().createInterface(),
new ManualVspToscaManagerImpl());
@Override
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/BaseOrchestrationTemplateHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/BaseOrchestrationTemplateHandler.java
index c7fb437..d20dc07 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/BaseOrchestrationTemplateHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/BaseOrchestrationTemplateHandler.java
@@ -14,87 +14,94 @@
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService;
import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
-import org.openecomp.sdc.versioning.dao.types.Version;
import java.io.InputStream;
import java.util.Optional;
+
import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters;
+
public abstract class BaseOrchestrationTemplateHandler implements OrchestrationTemplateFileHandler {
- protected static final Logger logger =
- LoggerFactory.getLogger(BaseOrchestrationTemplateHandler.class);
- protected static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ protected static final Logger logger =
+ LoggerFactory.getLogger(BaseOrchestrationTemplateHandler.class);
+ protected static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
- @Override
- public UploadFileResponse upload(String vspId, Version version, InputStream fileToUpload, String user,
- CandidateService candidateService, VspDetails vspDetails) {
- UploadFileResponse uploadFileResponse = new UploadFileResponse();
- uploadFileResponse.setOnboardingType(getHandlerType());
- if (isNotEmptyFileToUpload(fileToUpload, uploadFileResponse, candidateService)) {
- return uploadFileResponse;
- }
-
- byte[] uploadedFileData = FileUtils.toByteArray(fileToUpload);
- if (isInvalidRawZipData(uploadFileResponse, uploadedFileData, candidateService)) {
- return uploadFileResponse;
- }
-
- Optional<FileContentHandler> optionalContentMap =
- getFileContentMap(uploadFileResponse, uploadedFileData);
- if (!optionalContentMap.isPresent()) {
- logger.error(getErrorWithParameters(Messages.FILE_CONTENT_MAP.getErrorMessage(), getHandlerType().toString()));
- uploadFileResponse
- .addStructureError(
- SdcCommon.UPLOAD_FILE,
- new ErrorMessage(ErrorLevel.ERROR,
- getErrorWithParameters(Messages.FILE_CONTENT_MAP.getErrorMessage(), getHandlerType().toString())));
-
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
- return uploadFileResponse;
- }
-
- if (!MapUtils.isEmpty(uploadFileResponse.getErrors())) {
-
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
- return uploadFileResponse;
- }
- if (updateCandidateData(vspId, user, candidateService, vspDetails, uploadFileResponse,
- uploadedFileData, optionalContentMap))
- return uploadFileResponse;
-
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
- return uploadFileResponse;
-
+ @Override
+ public UploadFileResponse upload(VspDetails vspDetails, InputStream fileToUpload,
+ String fileSuffix, String networkPackageName,
+ CandidateService candidateService) {
+ UploadFileResponse uploadFileResponse = new UploadFileResponse();
+ uploadFileResponse.setOnboardingType(getHandlerType());
+ if (isNotEmptyFileToUpload(fileToUpload, uploadFileResponse, candidateService)) {
+ return uploadFileResponse;
}
- protected abstract boolean updateCandidateData(String vspId, String user, CandidateService candidateService,
- VspDetails vspDetails, UploadFileResponse uploadFileResponse,
- byte[] uploadedFileData,
- Optional<FileContentHandler> optionalContentMap);
-
-
- private boolean isNotEmptyFileToUpload(InputStream fileToUpload,
- UploadFileResponse uploadFileResponse, CandidateService candidateService) {
- Optional<ErrorMessage> errorMessage =
- candidateService.validateNonEmptyFileToUpload(fileToUpload);
- if (errorMessage.isPresent()) {
- uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE, errorMessage.get());
- return true;
- }
- return false;
+ byte[] uploadedFileData = FileUtils.toByteArray(fileToUpload);
+ if (isInvalidRawZipData(uploadFileResponse, uploadedFileData, candidateService)) {
+ return uploadFileResponse;
}
- protected boolean isInvalidRawZipData(UploadFileResponse uploadFileResponse,
- byte[] uploadedFileData, CandidateService candidateService) {
- Optional<ErrorMessage> errorMessage;
- errorMessage = candidateService.validateRawZipData(uploadedFileData);
- if (errorMessage.isPresent()) {
- uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE, errorMessage.get());
- return true;
- }
- return false;
+ Optional<FileContentHandler> optionalContentMap =
+ getFileContentMap(uploadFileResponse, uploadedFileData);
+ if (!optionalContentMap.isPresent()) {
+ logger.error(getErrorWithParameters(Messages.FILE_CONTENT_MAP.getErrorMessage(),
+ getHandlerType().toString()));
+ uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR,
+ getErrorWithParameters(Messages.FILE_CONTENT_MAP.getErrorMessage(),
+ getHandlerType().toString())));
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspDetails.getId());
+ return uploadFileResponse;
}
- public abstract Optional<FileContentHandler> getFileContentMap(UploadFileResponse uploadFileResponse,
- byte[] uploadedFileData);
- protected abstract OnboardingTypesEnum getHandlerType();
+ if (!MapUtils.isEmpty(uploadFileResponse.getErrors())) {
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspDetails.getId());
+ return uploadFileResponse;
+ }
+ if (updateCandidateData(vspDetails, uploadedFileData, optionalContentMap.get(), fileSuffix,
+ networkPackageName, candidateService, uploadFileResponse)) {
+ return uploadFileResponse;
+ }
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspDetails.getId());
+ return uploadFileResponse;
+
+ }
+
+ protected abstract boolean updateCandidateData(VspDetails vspDetails,
+ byte[] uploadedFileData,
+ FileContentHandler contentMap,
+ String fileSuffix,
+ String networkPackageName,
+ CandidateService candidateService,
+ UploadFileResponse uploadFileResponse);
+
+ private boolean isNotEmptyFileToUpload(InputStream fileToUpload,
+ UploadFileResponse uploadFileResponse,
+ CandidateService candidateService) {
+ Optional<ErrorMessage> errorMessage =
+ candidateService.validateNonEmptyFileToUpload(fileToUpload);
+ if (errorMessage.isPresent()) {
+ uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE, errorMessage.get());
+ return true;
+ }
+ return false;
+ }
+
+ protected boolean isInvalidRawZipData(UploadFileResponse uploadFileResponse,
+ byte[] uploadedFileData,
+ CandidateService candidateService) {
+ Optional<ErrorMessage> errorMessage;
+ errorMessage = candidateService.validateRawZipData(uploadedFileData);
+ if (errorMessage.isPresent()) {
+ uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE, errorMessage.get());
+ return true;
+ }
+ return false;
+ }
+
+ public abstract Optional<FileContentHandler> getFileContentMap(
+ UploadFileResponse uploadFileResponse,
+ byte[] uploadedFileData);
+
+ protected abstract OnboardingTypesEnum getHandlerType();
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java
index db0851c..1614755 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java
@@ -30,131 +30,139 @@
import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.CSARConstants.MAIN_SERVICE_TEMPLATE_YAML_FILE_NAME;
public class OrchestrationTemplateCSARHandler extends BaseOrchestrationTemplateHandler
- implements OrchestrationTemplateFileHandler {
+ implements OrchestrationTemplateFileHandler {
- @Override
- public Optional<FileContentHandler> getFileContentMap(UploadFileResponse uploadFileResponse,
- byte[] uploadedFileData) {
- FileContentHandler contentMap = null;
- List<String> folderList = new ArrayList<>();
- try {
- Pair<FileContentHandler, List<String>> fileContentMapFromOrchestrationCandidateZip = CommonUtil.getFileContentMapFromOrchestrationCandidateZip(uploadedFileData);
- contentMap = fileContentMapFromOrchestrationCandidateZip.getKey();
- folderList = fileContentMapFromOrchestrationCandidateZip.getRight();
- } catch (IOException exception) {
- uploadFileResponse.addStructureError(
- SdcCommon.UPLOAD_FILE,
- new ErrorMessage(ErrorLevel.ERROR, Messages.INVALID_CSAR_FILE.getErrorMessage()));
- } catch (CoreException coreException) {
- uploadFileResponse.addStructureError(
- SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR, coreException.getMessage()));
- }
- validateContent(uploadFileResponse, contentMap, folderList);
- return Optional.ofNullable(contentMap);
+ @Override
+ public Optional<FileContentHandler> getFileContentMap(UploadFileResponse uploadFileResponse,
+ byte[] uploadedFileData) {
+ FileContentHandler contentMap = null;
+ List<String> folderList = new ArrayList<>();
+ try {
+ Pair<FileContentHandler, List<String>> fileContentMapFromOrchestrationCandidateZip =
+ CommonUtil.getFileContentMapFromOrchestrationCandidateZip(uploadedFileData);
+ contentMap = fileContentMapFromOrchestrationCandidateZip.getKey();
+ folderList = fileContentMapFromOrchestrationCandidateZip.getRight();
+ } catch (IOException exception) {
+ uploadFileResponse.addStructureError(
+ SdcCommon.UPLOAD_FILE,
+ new ErrorMessage(ErrorLevel.ERROR, Messages.INVALID_CSAR_FILE.getErrorMessage()));
+ } catch (CoreException coreException) {
+ uploadFileResponse.addStructureError(
+ SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR, coreException.getMessage()));
+ }
+ validateContent(uploadFileResponse, contentMap, folderList);
+ return Optional.ofNullable(contentMap);
+ }
+
+ private void validateContent(UploadFileResponse uploadFileResponse, FileContentHandler contentMap,
+ List<String> folderList) {
+ validateManifest(uploadFileResponse, contentMap);
+ validateFileExist(uploadFileResponse, contentMap, MAIN_SERVICE_TEMPLATE_YAML_FILE_NAME);
+ validateNoExtraFiles(uploadFileResponse, contentMap);
+ validateFolders(uploadFileResponse, folderList);
+ }
+
+ private void validateManifest(UploadFileResponse uploadFileResponse,
+ FileContentHandler contentMap) {
+
+ if (!validateFileExist(uploadFileResponse, contentMap, MAIN_SERVICE_TEMPLATE_MF_FILE_NAME)) {
+ return;
}
- private void validateContent(UploadFileResponse uploadFileResponse, FileContentHandler contentMap, List<String> folderList) {
- validateManifest(uploadFileResponse, contentMap);
- validateFileExist(uploadFileResponse, contentMap, MAIN_SERVICE_TEMPLATE_YAML_FILE_NAME);
- validateNoExtraFiles(uploadFileResponse, contentMap);
- validateFolders(uploadFileResponse, folderList);
+ try (InputStream fileContent = contentMap.getFileContent(MAIN_SERVICE_TEMPLATE_MF_FILE_NAME)) {
+
+ OnboardingManifest onboardingManifest = new OnboardingManifest(fileContent);
+ if (!onboardingManifest.isValid()) {
+ onboardingManifest.getErrors().forEach(error -> uploadFileResponse.addStructureError(
+ SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR, error)));
+ }
+
+ } catch (IOException e) {
+ // convert to runtime to keep the throws unchanged
+ throw new RuntimeException("Failed to validate manifest", e);
}
+ }
- private void validateManifest(UploadFileResponse uploadFileResponse, FileContentHandler contentMap) {
-
- if (!validateFileExist(uploadFileResponse, contentMap, MAIN_SERVICE_TEMPLATE_MF_FILE_NAME)){
- return;
- }
-
- try (InputStream fileContent = contentMap.getFileContent(MAIN_SERVICE_TEMPLATE_MF_FILE_NAME)) {
-
- OnboardingManifest onboardingManifest = new OnboardingManifest(fileContent);
- if (!onboardingManifest.isValid()) {
- onboardingManifest.getErrors().forEach(error -> uploadFileResponse.addStructureError(
- SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR, error)));
- }
-
- } catch (IOException e) {
- // convert to runtime to keep the throws unchanged
- throw new RuntimeException("Failed to validate manifest", e);
- }
+ private void validateNoExtraFiles(UploadFileResponse uploadFileResponse,
+ FileContentHandler contentMap) {
+ List<String> unwantedFiles = contentMap.getFileList().stream()
+ .filter(this::filterFiles).collect(Collectors.toList());
+ if (!unwantedFiles.isEmpty()) {
+ unwantedFiles.stream().filter(this::filterFiles).forEach(unwantedFile ->
+ uploadFileResponse.addStructureError(
+ SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR,
+ getErrorWithParameters(Messages.CSAR_FILES_NOT_ALLOWED.getErrorMessage(),
+ unwantedFile))));
}
+ }
- private void validateNoExtraFiles(UploadFileResponse uploadFileResponse, FileContentHandler contentMap) {
- List<String> unwantedFiles = contentMap.getFileList().stream()
- .filter(this::filterFiles).collect(Collectors.toList());
- if (!unwantedFiles.isEmpty()) {
- unwantedFiles.stream().filter(this::filterFiles).forEach(unwantedFile ->
- uploadFileResponse.addStructureError(
- SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR,
- getErrorWithParameters(Messages.CSAR_FILES_NOT_ALLOWED.getErrorMessage(),
- unwantedFile))));
- }
- }
-
- private void validateFolders(UploadFileResponse uploadFileResponse, List<String> folderList) {
- List<String> filterResult = folderList.stream().filter(this::filterFolders).collect(Collectors.toList());
- if (!filterResult.isEmpty()) {
- folderList.stream().filter(this::filterFolders).forEach( unwantedFolder ->
- uploadFileResponse.addStructureError(
- SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR,
- getErrorWithParameters(Messages.CSAR_DIRECTORIES_NOT_ALLOWED.getErrorMessage(),
- unwantedFolder))));
-
- }
- }
- private boolean filterFiles(String inFileName) {
- boolean valid = ELIGIBLE_FILES.stream().anyMatch(fileName -> fileName.equals(inFileName));
- return !valid && filterFolders(inFileName);
- }
-
- private boolean filterFolders(String fileName) {
- return ELIGBLE_FOLDERS.stream().noneMatch(fileName::startsWith);
- }
-
- private boolean validateFileExist(UploadFileResponse uploadFileResponse, FileContentHandler contentMap, String fileName) {
-
- boolean containsFile = contentMap.containsFile(fileName);
- if (!containsFile) {
- uploadFileResponse.addStructureError(
- SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR,
- getErrorWithParameters(Messages.CSAR_FILE_NOT_FOUND.getErrorMessage(), fileName)));
- }
- return containsFile;
- }
-
- @Override
- protected boolean updateCandidateData(String vspId, String user, CandidateService candidateService,
- VspDetails vspDetails, UploadFileResponse uploadFileResponse,
- byte[] uploadedFileData, Optional<FileContentHandler> optionalContentMap) {
- try {
- candidateService.updateCandidateUploadData(new OrchestrationTemplateCandidateData(
- ByteBuffer.wrap(uploadedFileData), ""), vspDetails.getId());
- } catch (Exception exception) {
- logger.error(getErrorWithParameters(Messages.FILE_CONTENT_MAP.getErrorMessage(),
- getHandlerType().toString()), exception);
- uploadFileResponse
- .addStructureError(
- SdcCommon.UPLOAD_FILE,
- new ErrorMessage(ErrorLevel.ERROR, exception.getMessage()));
-
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
- return true;
- }
- return false;
- }
-
-
- @Override
- protected OnboardingTypesEnum getHandlerType() {
- return OnboardingTypesEnum.CSAR;
- }
-
- @Override
- protected boolean isInvalidRawZipData(UploadFileResponse uploadFileResponse,
- byte[] uploadedFileData, CandidateService candidateService) {
- return super.isInvalidRawZipData(uploadFileResponse, uploadedFileData, candidateService);
+ private void validateFolders(UploadFileResponse uploadFileResponse, List<String> folderList) {
+ List<String> filterResult =
+ folderList.stream().filter(this::filterFolders).collect(Collectors.toList());
+ if (!filterResult.isEmpty()) {
+ folderList.stream().filter(this::filterFolders).forEach(unwantedFolder ->
+ uploadFileResponse.addStructureError(
+ SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR,
+ getErrorWithParameters(Messages.CSAR_DIRECTORIES_NOT_ALLOWED.getErrorMessage(),
+ unwantedFolder))));
}
+ }
+
+ private boolean filterFiles(String inFileName) {
+ boolean valid = ELIGIBLE_FILES.stream().anyMatch(fileName -> fileName.equals(inFileName));
+ return !valid && filterFolders(inFileName);
+ }
+
+ private boolean filterFolders(String fileName) {
+ return ELIGBLE_FOLDERS.stream().noneMatch(fileName::startsWith);
+ }
+
+ private boolean validateFileExist(UploadFileResponse uploadFileResponse,
+ FileContentHandler contentMap, String fileName) {
+
+ boolean containsFile = contentMap.containsFile(fileName);
+ if (!containsFile) {
+ uploadFileResponse.addStructureError(
+ SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR,
+ getErrorWithParameters(Messages.CSAR_FILE_NOT_FOUND.getErrorMessage(), fileName)));
+ }
+ return containsFile;
+ }
+
+ @Override
+ protected boolean updateCandidateData(VspDetails vspDetails, byte[] uploadedFileData,
+ FileContentHandler contentMap,
+ String fileSuffix, String networkPackageName,
+ CandidateService candidateService,
+ UploadFileResponse uploadFileResponse) {
+ try {
+ candidateService.updateCandidateUploadData(vspDetails.getId(), vspDetails.getVersion(),
+ new OrchestrationTemplateCandidateData(ByteBuffer.wrap(uploadedFileData), "", fileSuffix,
+ networkPackageName));
+ } catch (Exception exception) {
+ logger.error(getErrorWithParameters(Messages.FILE_CONTENT_MAP.getErrorMessage(),
+ getHandlerType().toString()), exception);
+ uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE,
+ new ErrorMessage(ErrorLevel.ERROR, exception.getMessage()));
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspDetails.getId());
+ return true;
+ }
+ return false;
+ }
+
+
+ @Override
+ protected OnboardingTypesEnum getHandlerType() {
+ return OnboardingTypesEnum.CSAR;
+ }
+
+ @Override
+ protected boolean isInvalidRawZipData(UploadFileResponse uploadFileResponse,
+ byte[] uploadedFileData,
+ CandidateService candidateService) {
+ return super.isInvalidRawZipData(uploadFileResponse, uploadedFileData, candidateService);
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateFileHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateFileHandler.java
index 3f7d18d..5e006a2 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateFileHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateFileHandler.java
@@ -3,10 +3,12 @@
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService;
import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
-import org.openecomp.sdc.versioning.dao.types.Version;
import java.io.InputStream;
+
public interface OrchestrationTemplateFileHandler {
- UploadFileResponse upload(String vspId, Version version, InputStream fileToUpload, String user,
- CandidateService candidateService, VspDetails vspDetails);
+
+ UploadFileResponse upload(VspDetails vspDetails, InputStream fileToUpload,
+ String fileSuffix, String networkPackageName,
+ CandidateService candidateService);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateZipHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateZipHandler.java
index 626d941..343c746 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateZipHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateZipHandler.java
@@ -15,41 +15,47 @@
import java.util.Optional;
import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters;
+
public class OrchestrationTemplateZipHandler extends BaseOrchestrationTemplateHandler
- implements OrchestrationTemplateFileHandler {
+ implements OrchestrationTemplateFileHandler {
- @Override
- public Optional<FileContentHandler> getFileContentMap(UploadFileResponse uploadFileResponse,
- byte[] uploadedFileData) {
- return OrchestrationUtil.getFileContentMap(OnboardingTypesEnum.ZIP, uploadFileResponse, uploadedFileData);
+ @Override
+ public Optional<FileContentHandler> getFileContentMap(UploadFileResponse uploadFileResponse,
+ byte[] uploadedFileData) {
+ return OrchestrationUtil
+ .getFileContentMap(OnboardingTypesEnum.ZIP, uploadFileResponse, uploadedFileData);
+ }
+
+ @Override
+ protected boolean updateCandidateData(VspDetails vspDetails, byte[] uploadedFileData,
+ FileContentHandler contentMap,
+ String fileSuffix, String networkPackageName,
+ CandidateService candidateService,
+ UploadFileResponse uploadFileResponse) {
+ try {
+ OrchestrationTemplateCandidateData candidateData =
+ new CandidateEntityBuilder(candidateService)
+ .buildCandidateEntityFromZip(vspDetails, uploadedFileData, contentMap,
+ uploadFileResponse.getErrors());
+ candidateData.setFileSuffix(fileSuffix);
+ candidateData.setFileName(networkPackageName);
+
+ candidateService
+ .updateCandidateUploadData(vspDetails.getId(), vspDetails.getVersion(), candidateData);
+ } catch (Exception exception) {
+ logger.error(getErrorWithParameters(Messages.FILE_CONTENT_MAP.getErrorMessage(),
+ getHandlerType().toString()), exception);
+ uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE,
+ new ErrorMessage(ErrorLevel.ERROR, exception.getMessage()));
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspDetails.getId());
+ return true;
}
+ return false;
+ }
- @Override
- protected boolean updateCandidateData(String vspId, String user, CandidateService candidateService,
- VspDetails vspDetails, UploadFileResponse uploadFileResponse,
- byte[] uploadedFileData, Optional<FileContentHandler> optionalContentMap) {
- try {
- OrchestrationTemplateCandidateData candidateData =
- new CandidateEntityBuilder(candidateService)
- .buildCandidateEntityFromZip(vspDetails, uploadedFileData, optionalContentMap.get(),
- uploadFileResponse.getErrors(), user);
- candidateService.updateCandidateUploadData(candidateData, vspDetails.getId());
- } catch (Exception exception) {
- logger.error(getErrorWithParameters(Messages.FILE_CONTENT_MAP.getErrorMessage(),
- getHandlerType().toString()),exception);
- uploadFileResponse
- .addStructureError(
- SdcCommon.UPLOAD_FILE,
- new ErrorMessage(ErrorLevel.ERROR, exception.getMessage()));
-
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
- return true;
- }
- return false;
- }
-
- @Override
- protected OnboardingTypesEnum getHandlerType() {
- return OnboardingTypesEnum.ZIP;
- }
+ @Override
+ protected OnboardingTypesEnum getHandlerType() {
+ return OnboardingTypesEnum.ZIP;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUploadFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUploadFactory.java
index 99b311e..3c3ab81 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUploadFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUploadFactory.java
@@ -24,8 +24,8 @@
}
- public static final OrchestrationTemplateFileHandler createOrchestrationTemplateFileHandler(String filePrefix) {
- String fileExtension = filePrefix.toLowerCase();
+ public static final OrchestrationTemplateFileHandler createOrchestrationTemplateFileHandler(String fileSuffix) {
+ String fileExtension = fileSuffix.toLowerCase();
ImplementationConfiguration orchestrationTemplateFileHandler = fileHanlders.get(fileExtension);
if(Objects.isNull(orchestrationTemplateFileHandler)){
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java
index 2ee7b26..e312e7c 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java
@@ -1,8 +1,5 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration;
-import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.GENERAL_COMPONENT_ID;
-import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME;
-
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.openecomp.core.model.dao.ServiceModelDao;
@@ -35,14 +32,16 @@
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VspMergeDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadData;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionDataExtractorFactory;
import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionEntityDataManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionDataExtractor;
@@ -62,13 +61,13 @@
import java.util.Set;
import java.util.stream.Collectors;
+import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME;
+
public class OrchestrationUtil {
public static final String ORCHESTRATION_CONFIG_NAMESPACE = "orchestration";
public static final String ORCHESTRATION_IMPL_KEY = "orchestration_impl";
-
- private VendorSoftwareProductDao vendorSoftwareProductDao;
private NicDao nicDao;
private ComponentArtifactDao componentArtifactDao;
private ProcessDao processDao;
@@ -80,8 +79,7 @@
private CompositionDataExtractor compositionDataExtractor;
public OrchestrationUtil() {
- this (VendorSoftwareProductDaoFactory.getInstance().createInterface(),
- NicDaoFactory.getInstance().createInterface(),
+ this(NicDaoFactory.getInstance().createInterface(),
MonitoringUploadDaoFactory.getInstance().createInterface(),
ProcessDaoFactory.getInstance().createInterface(),
OrchestrationTemplateDaoFactory.getInstance().createInterface(),
@@ -93,7 +91,6 @@
}
public OrchestrationUtil(
- VendorSoftwareProductDao vendorSoftwareProductDao,
NicDao nicDao,
ComponentArtifactDao componentArtifactDao,
ProcessDao processDao,
@@ -103,7 +100,6 @@
ComponentDependencyModelDao componentDependencyModelDao,
CompositionEntityDataManager compositionEntityDataManager,
CompositionDataExtractor compositionDataExtractor) {
- this.vendorSoftwareProductDao = vendorSoftwareProductDao;
this.nicDao = nicDao;
this.componentArtifactDao = componentArtifactDao;
this.processDao = processDao;
@@ -116,8 +112,7 @@
}
public static Optional<FileContentHandler> getFileContentMap(OnboardingTypesEnum type,
- UploadFileResponse
- uploadFileResponse,
+ UploadFileResponse uploadFileResponse,
byte[] uploadedFileData) {
FileContentHandler contentMap = null;
try {
@@ -133,95 +128,63 @@
return Optional.ofNullable(contentMap);
}
- public void backupComponentsQuestionnaireBeforeDelete(String vspId, Version activeVersion,
- Map<String, String> componentsQustanniare,
- Map<String, Map<String, String>>
- componentNicsQustanniare,
- Map<String, Collection<ComponentMonitoringUploadEntity>>
- componentMibList,
- Map<String, Collection<ProcessEntity>>
- componentProcesses,
- Map<String, ProcessEntity> processArtifact) {
- //backup VSP processes
- backupProcess(vspId, activeVersion, GENERAL_COMPONENT_ID, GENERAL_COMPONENT_ID,
- componentProcesses, processArtifact);
- Collection<ComponentEntity> componentsCompositionAndQuestionnaire = vendorSoftwareProductDao
- .listComponentsCompositionAndQuestionnaire(vspId,
- activeVersion);
+ public void backupComponentsQuestionnaireBeforeDelete(String vspId, Version version,
+ Map<String, String> componentsQustanniare,
+ Map<String, Map<String, String>>
+ componentNicsQustanniare,
+ Map<String, Collection<ComponentMonitoringUploadEntity>>
+ componentMibList,
+ Map<String, Collection<ProcessEntity>>
+ componentProcesses,
+ Map<String, ProcessEntity> processArtifact) {
+
+ Collection<ComponentEntity> componentsCompositionAndQuestionnaire =
+ componentDao.listCompositionAndQuestionnaire(vspId, version);
componentsCompositionAndQuestionnaire.forEach(componentEntity ->
- backupComponentQuestionnaire(vspId, activeVersion, componentEntity, componentsQustanniare,
+ backupComponentQuestionnaire(vspId, version, componentEntity, componentsQustanniare,
componentNicsQustanniare, componentMibList, componentProcesses, processArtifact));
}
- private void backupComponentQuestionnaire(String vspId, Version activeVersion,
- ComponentEntity componentEntity,
- Map<String, String> componentsQustanniare,
- Map<String, Map<String, String>>
- componentNicsQustanniare,
- Map<String, Collection<ComponentMonitoringUploadEntity>>
- componentMibList,
- Map<String, Collection<ProcessEntity>>
- componentProcesses,
- Map<String, ProcessEntity> processArtifact) {
+ private void backupComponentQuestionnaire(
+ String vspId, Version version,
+ ComponentEntity componentEntity,
+ Map<String, String> componentsQustanniare,
+ Map<String, Map<String, String>> componentNicsQustanniare,
+ Map<String, Collection<ComponentMonitoringUploadEntity>> componentMibList,
+ Map<String, Collection<ProcessEntity>> componentProcesses,
+ Map<String, ProcessEntity> processArtifact) {
String componentName = componentEntity.getComponentCompositionData().getName();
- backupMibData(componentsQustanniare, componentMibList, componentName, componentEntity, vspId,
- activeVersion);
- backupComponentProcessData(componentNicsQustanniare, vspId, activeVersion, componentName,
- componentEntity, componentProcesses, processArtifact);
+ componentsQustanniare.put(componentName, componentEntity.getQuestionnaireData());
+ backupMibData(vspId, version, componentEntity, componentName, componentMibList);
+ backupProcess(vspId, version, componentEntity.getId(), componentName, componentProcesses,
+ processArtifact);
+ backupNicsQuestionnaire(vspId, version, componentEntity, componentName,
+ componentNicsQustanniare);
}
- private void backupMibData(Map<String, String> componentsQustanniare,
- Map<String, Collection<ComponentMonitoringUploadEntity>>
- componentMibList,
- String componentName, ComponentEntity componentEntity,
- String vspId, Version activeVersion) {
- componentsQustanniare.put(componentName, componentEntity.getQuestionnaireData());
- //backup mib
+ private void backupMibData(String vspId, Version version, ComponentEntity componentEntity,
+ String componentName,
+ Map<String, Collection<ComponentMonitoringUploadEntity>> componentMibList) {
Collection<ComponentMonitoringUploadEntity> componentMib =
componentArtifactDao.listArtifacts(new
- ComponentMonitoringUploadEntity(vspId, activeVersion, componentEntity.getId(), null));
+ ComponentMonitoringUploadEntity(vspId, version, componentEntity.getId(),
+ null));
if (CollectionUtils.isNotEmpty(componentMib)) {
componentMibList.put(componentName, componentMib);
}
}
- private void backupComponentProcessData(Map<String, Map<String, String>> componentNicsQustanniare,
- String vspId, Version activeVersion, String componentName,
- ComponentEntity componentEntity,
- Map<String, Collection<ProcessEntity>> componentProcesses,
- Map<String, ProcessEntity> processArtifact) {
- Collection<NicEntity>
- nics = nicDao.list(new NicEntity(vspId, activeVersion, componentEntity.getId(), null));
- //backup component processes
- backupProcess(vspId, activeVersion, componentEntity.getId(), componentName,
- componentProcesses, processArtifact);
- if (CollectionUtils.isNotEmpty(nics)) {
- Map<String, String> nicsQustanniare = new HashMap<>();
- nics.forEach(nicEntity -> {
- NicEntity nic = nicDao.get(new NicEntity(vspId, activeVersion, componentEntity.getId(),
- nicEntity.getId()));
- NicEntity nicQuestionnaire = nicDao.getQuestionnaireData(vspId, activeVersion,
- componentEntity.getId(), nicEntity.getId());
-
- nicsQustanniare
- .put(nicEntity.getNicCompositionData().getName(),
- nicQuestionnaire.getQuestionnaireData());
- });
- componentNicsQustanniare.put(componentName, nicsQustanniare);
- }
- }
-
- private void backupProcess(String vspId, Version activeVersion, String componentId,
- String componentName, Map<String,
+ private void backupProcess(String vspId, Version version, String componentId,
+ String componentName, Map<String,
Collection<ProcessEntity>> processes,
- Map<String, ProcessEntity> processArtifact) {
- Collection<ProcessEntity> processList = vendorSoftwareProductDao.listProcesses(vspId,
- activeVersion, componentId);
+ Map<String, ProcessEntity> processArtifact) {
+ Collection<ProcessEntity> processList =
+ processDao.list(new ProcessEntity(vspId, version, componentId, null));
if (!processList.isEmpty()) {
processes.put(componentName, processList);
processList.forEach(process -> {
- ProcessEntity artifact =
- processDao.get(new ProcessEntity(vspId, activeVersion, componentId, process.getId()));
+ ProcessEntity artifact = processDao
+ .getArtifact(new ProcessEntity(vspId, version, componentId, process.getId()));
if (artifact.getArtifact() != null) {
processArtifact.put(process.getId(), artifact);
}
@@ -229,29 +192,45 @@
}
}
- public void retainComponentQuestionnaireData(String vspId, Version activeVersion,
- Map<String, String> componentsQustanniare,
- Map<String, Map<String, String>>
- componentNicsQustanniare,
- Map<String, Collection<ComponentMonitoringUploadEntity>> componentMibList,
- Map<String, Collection<ProcessEntity>> processes,
- Map<String, ProcessEntity> processArtifact) {
+ private void backupNicsQuestionnaire(String vspId, Version version,
+ ComponentEntity componentEntity,
+ String componentName,
+ Map<String, Map<String, String>> componentNicsQustanniare) {
+ Collection<NicEntity>
+ nics = nicDao.list(new NicEntity(vspId, version, componentEntity.getId(), null));
+ if (CollectionUtils.isNotEmpty(nics)) {
+ Map<String, String> nicsQuestionnaire = new HashMap<>();
+ nics.forEach(nicEntity -> {
+ NicEntity nicQuestionnaire = nicDao.getQuestionnaireData(vspId, version,
+ componentEntity.getId(), nicEntity.getId());
+
+ nicsQuestionnaire.put(nicEntity.getNicCompositionData().getName(),
+ nicQuestionnaire.getQuestionnaireData());
+ });
+ componentNicsQustanniare.put(componentName, nicsQuestionnaire);
+ }
+ }
+
+ public void retainComponentQuestionnaireData(String vspId, Version version,
+ Map<String, String> componentsQustanniare,
+ Map<String, Map<String, String>>
+ componentNicsQustanniare,
+ Map<String, Collection<ComponentMonitoringUploadEntity>> componentMibList,
+ Map<String, Collection<ProcessEntity>> processes,
+ Map<String, ProcessEntity> processArtifact) {
//VSP processes
- restoreProcess(vspId, activeVersion, GENERAL_COMPONENT_ID, GENERAL_COMPONENT_ID, processes,
- processArtifact);
- Collection<ComponentEntity>
- components = vendorSoftwareProductDao.listComponents(vspId, activeVersion);
+ restoreProcess(vspId, version, null, null, processes, processArtifact);
+ Collection<ComponentEntity> components =
+ componentDao.list(new ComponentEntity(vspId, version, null));
components.forEach(componentEntity -> {
String componentName = componentEntity.getComponentCompositionData().getName();
if (componentsQustanniare.containsKey(componentName)) {
- //Restore component questionnaire
- componentDao.updateQuestionnaireData(vspId, activeVersion,
+ componentDao.updateQuestionnaireData(vspId, version,
componentEntity.getId(),
componentsQustanniare.get(componentEntity.getComponentCompositionData()
.getName()));
- //Restore component nic questionnaire
if (componentNicsQustanniare.containsKey(componentName)) {
- restoreComponentNicQuestionnaire(vspId, activeVersion, componentName, componentEntity,
+ restoreComponentNicQuestionnaire(vspId, version, componentName, componentEntity,
componentNicsQustanniare);
}
//MIB //todo add for VES_EVENTS
@@ -259,33 +238,30 @@
restoreComponentMibData(componentName, componentEntity, componentMibList);
}
//VFC processes
- restoreProcess(vspId, activeVersion, componentEntity.getId(), componentName, processes,
+ restoreProcess(vspId, version, componentEntity.getId(), componentName, processes,
processArtifact);
}
});
}
- private void restoreComponentNicQuestionnaire(String vspId, Version activeVersion,
+ private void restoreComponentNicQuestionnaire(String vspId, Version version,
String componentName,
ComponentEntity componentEntity,
- Map<String, Map<String, String>>
- componentNicsQustanniare) {
+ Map<String, Map<String, String>> componentNicsQustanniare) {
Map<String, String> nicsQustanniare = componentNicsQustanniare.get(componentName);
Collection<NicEntity> nics =
- nicDao.list(new NicEntity(vspId, activeVersion, componentEntity.getId(), null));
+ nicDao.list(new NicEntity(vspId, version, componentEntity.getId(), null));
nics.forEach(nicEntity -> {
if (nicsQustanniare.containsKey(nicEntity.getNicCompositionData().getName())) {
- nicDao.updateQuestionnaireData(vspId, activeVersion,
+ nicDao.updateQuestionnaireData(vspId, version,
componentEntity.getId(), nicEntity.getId(),
nicsQustanniare.get(nicEntity.getNicCompositionData().getName()));
}
});
}
- private void restoreComponentMibData(String componentName,
- ComponentEntity componentEntity,
- Map<String, Collection<ComponentMonitoringUploadEntity>>
- componentMibList) {
+ private void restoreComponentMibData(String componentName, ComponentEntity componentEntity,
+ Map<String, Collection<ComponentMonitoringUploadEntity>> componentMibList) {
Collection<ComponentMonitoringUploadEntity> mibList = componentMibList.get(componentName);
mibList.forEach(mib -> {
mib.setComponentId(componentEntity.getId());
@@ -293,54 +269,58 @@
});
}
- private void restoreProcess(String vspId, Version activeVersion, String componentId,
- String componentName,
- Map<String, Collection<ProcessEntity>> processes,
- Map<String, ProcessEntity> processArtifact) {
+ private void restoreProcess(String vspId, Version version, String componentId,
+ String componentName,
+ Map<String, Collection<ProcessEntity>> processes,
+ Map<String, ProcessEntity> processArtifact) {
if (processes.containsKey(componentName)) {
Collection<ProcessEntity> processList = processes.get(componentName);
processList.forEach(process -> {
- //Reatin VFC process
- if (!GENERAL_COMPONENT_ID.equals(componentId)
- && processArtifact.containsKey(process.getId())) {
+ process.setComponentId(componentId);
+ UniqueValueUtil.createUniqueValue(PROCESS_NAME, vspId, version.getId(), componentId,
+ process.getName());
+ processDao.create(process);
+ if (processArtifact.containsKey(process.getId())) {
ProcessEntity artifact = processArtifact.get(process.getId());
- artifact.setComponentId(componentId);
- UniqueValueUtil.createUniqueValue(PROCESS_NAME, vspId, activeVersion.toString(),
- componentId, process.getName());
- vendorSoftwareProductDao.createProcess(artifact);
+ processDao.uploadArtifact(artifact);
}
});
}
}
public void deleteUploadDataAndContent(String vspId, Version version) {
- //fixme change this when more tables are zusammenized
- vendorSoftwareProductDao.deleteUploadData(vspId, version);
+ VendorSoftwareProductInfoDaoFactory.getInstance().createInterface()
+ .delete(new VspDetails(vspId, version));
}
- public void saveUploadData(String vspId, Version activeVersion,
- InputStream uploadedFileData,
- FileContentHandler fileContentMap, HeatStructureTree tree) {
+ public void saveUploadData(VspDetails vspDetails,
+ OrchestrationTemplateCandidateData candidateData,
+ InputStream uploadedFileData,
+ FileContentHandler fileContentMap, HeatStructureTree tree) {
Map<String, Object> manifestAsMap =
fileContentMap.containsFile(SdcCommon.MANIFEST_NAME)
? (Map<String, Object>) JsonUtil.json2Object(fileContentMap.getFileContent(
SdcCommon.MANIFEST_NAME), Map.class)
: new HashMap<>();
- UploadData uploadData = new UploadData();
+ OrchestrationTemplateEntity uploadData = new OrchestrationTemplateEntity();
+ uploadData.setFileSuffix(candidateData.getFileSuffix());
+ uploadData.setFileName(candidateData.getFileName());
uploadData.setContentData(ByteBuffer.wrap(FileUtils.toByteArray(uploadedFileData)));
uploadData.setValidationDataStructure(new ValidationStructureList(tree));
uploadData.setPackageName(Objects.isNull(manifestAsMap.get("name")) ? null :
(String) manifestAsMap.get("name"));
uploadData.setPackageVersion(Objects.isNull(manifestAsMap.get("version")) ? null :
(String) manifestAsMap.get("version"));
- orchestrationTemplateDataDao.updateOrchestrationTemplateData(vspId, uploadData);
+ orchestrationTemplateDataDao.update(vspDetails.getId(), vspDetails.getVersion(), uploadData);
+
+ VspMergeDaoFactory.getInstance().createInterface()
+ .updateVspModelId(vspDetails.getId(), vspDetails.getVersion());
}
- public void saveServiceModel(String vspId,
- Version version,
- ToscaServiceModel serviceModelToExtract,
- ToscaServiceModel serviceModelToStore) {
+ public void saveServiceModel(String vspId, Version version,
+ ToscaServiceModel serviceModelToExtract,
+ ToscaServiceModel serviceModelToStore) {
if (serviceModelToExtract != null) {
serviceModelDao.storeServiceModel(vspId, version, serviceModelToStore);
//Extracting the compostion data from the output service model of the first phase of
@@ -358,15 +338,14 @@
return heatTreeManager.getTree();
}
- public void updateVspComponentDependencies(String vspId, Version activeVersion,
- Map<String, String>
- vspComponentIdNameInfoBeforeProcess) {
- Map<String, String> updatedVspComponentNameIdInfo = getVspComponentNameIdInfo(vspId,
- activeVersion);
+ public void updateVspComponentDependencies(String vspId, Version version,
+ Map<String, String> vspComponentIdNameInfoBeforeProcess) {
+ Map<String, String> updatedVspComponentNameIdInfo = getVspComponentNameIdInfo(vspId, version);
if (MapUtils.isNotEmpty(updatedVspComponentNameIdInfo)) {
Set<String> updatedVspComponentNames = updatedVspComponentNameIdInfo.keySet();
Collection<ComponentDependencyModelEntity> componentDependencies =
- vendorSoftwareProductDao.listComponentDependencies(vspId, activeVersion);
+ componentDependencyModelDao.list(new ComponentDependencyModelEntity(vspId,
+ version, null));
if (CollectionUtils.isNotEmpty(componentDependencies)) {
updateComponentDependency(vspComponentIdNameInfoBeforeProcess, componentDependencies,
updatedVspComponentNames, updatedVspComponentNameIdInfo);
@@ -374,7 +353,6 @@
}
}
-
private void updateComponentDependency(Map<String, String> vspComponentIdNameInfoBeforeProcess,
Collection<ComponentDependencyModelEntity>
componentDependencies,
@@ -398,14 +376,14 @@
}
}
- public Map<String, String> getVspComponentIdNameInfo(String vspId, Version activeVersion) {
+ public Map<String, String> getVspComponentIdNameInfo(String vspId, Version version) {
Collection<ComponentEntity> updatedVspComponents =
- vendorSoftwareProductDao.listComponents(vspId, activeVersion);
+ componentDao.list(new ComponentEntity(vspId, version, null));
Map<String, String> vspComponentIdNameMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(updatedVspComponents)) {
vspComponentIdNameMap = updatedVspComponents.stream()
.filter(componentEntity -> componentEntity.getComponentCompositionData() != null)
- .collect(Collectors.toMap(componentEntity -> componentEntity.getId(),
+ .collect(Collectors.toMap(ComponentEntity::getId,
componentEntity -> componentEntity.getComponentCompositionData().getName()));
}
@@ -413,15 +391,16 @@
}
private Map<String, String> getVspComponentNameIdInfo(String vspId,
- Version activeVersion) {
+ Version version) {
Collection<ComponentEntity> updatedVspComponents =
- vendorSoftwareProductDao.listComponents(vspId, activeVersion);
+ componentDao.list(new ComponentEntity(vspId, version, null));
Map<String, String> vspComponentNameIdMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(updatedVspComponents)) {
vspComponentNameIdMap = updatedVspComponents.stream()
.filter(componentEntity -> componentEntity.getComponentCompositionData() != null)
- .collect(Collectors.toMap(componentEntity -> componentEntity
- .getComponentCompositionData().getName(), componentEntity -> componentEntity.getId()));
+ .collect(Collectors
+ .toMap(componentEntity -> componentEntity.getComponentCompositionData().getName(),
+ ComponentEntity::getId));
}
return vspComponentNameIdMap;
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/CSARConstants.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/CSARConstants.java
index 0d204ef..cf04aad 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/CSARConstants.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/CSARConstants.java
@@ -1,6 +1,7 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar;
import com.google.common.collect.ImmutableSet;
+
import static com.google.common.collect.ImmutableSet.of;
public class CSARConstants {
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/OnboardingManifest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/OnboardingManifest.java
index d88d883..c0da130 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/OnboardingManifest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/OnboardingManifest.java
@@ -7,12 +7,22 @@
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
-import java.io.*;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
import java.nio.charset.StandardCharsets;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters;
-import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.CSARConstants.*;
+import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.CSARConstants.METADATA_MF_ATTRIBUTE;
+import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.CSARConstants.SEPERATOR_MF_ATTRIBUTE;
+import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.CSARConstants.SOURCE_MF_ATTRIBUTE;
public class OnboardingManifest {
private static final Logger logger = LoggerFactory.getLogger(OnboardingManifest.class);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationProcessFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationProcessFactory.java
index 516d85c..6200b28 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationProcessFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationProcessFactory.java
@@ -27,13 +27,13 @@
}
- public static Optional<OrchestrationTemplateProcessHandler> getInstance(String filePrefix) {
- if (filePrefix == null) {
+ public static Optional<OrchestrationTemplateProcessHandler> getInstance(String fileSuffix) {
+ if (fileSuffix == null) {
return Optional.empty();
}
- filePrefix = filePrefix.toLowerCase().trim();
- OnboardingTypesEnum onboardingTypesEnum = OnboardingTypesEnum.getOnboardingTypesEnum(filePrefix);
+ fileSuffix = fileSuffix.toLowerCase().trim();
+ OnboardingTypesEnum onboardingTypesEnum = OnboardingTypesEnum.getOnboardingTypesEnum(fileSuffix);
if (onboardingTypesEnum == null) {
return Optional.empty();
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java
index d217c31..b0e1e17 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java
@@ -1,7 +1,6 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.process;
import org.apache.commons.collections4.MapUtils;
-import org.openecomp.core.converter.ToscaConverter;
import org.openecomp.core.impl.ToscaConverterImpl;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
@@ -26,7 +25,6 @@
import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService;
import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
-import org.openecomp.sdc.versioning.dao.types.Version;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -37,35 +35,35 @@
import java.util.Map;
import java.util.Optional;
-public class OrchestrationTemplateProcessCsarHandler implements OrchestrationTemplateProcessHandler {
-
- private static final Logger logger = LoggerFactory.getLogger(OrchestrationTemplateProcessCsarHandler.class);
- private CandidateService candidateService = CandidateServiceFactory.getInstance().createInterface();
+public class OrchestrationTemplateProcessCsarHandler
+ implements OrchestrationTemplateProcessHandler {
+ private static final Logger LOGGER =
+ LoggerFactory.getLogger(OrchestrationTemplateProcessCsarHandler.class);
+ private CandidateService candidateService =
+ CandidateServiceFactory.getInstance().createInterface();
ToscaTreeManager toscaTreeManager = new ToscaTreeManager();
@Override
public OrchestrationTemplateActionResponse process(VspDetails vspDetails,
- OrchestrationTemplateCandidateData candidateData,
- String user) {
- String vspId = vspDetails.getId();
- Version version = vspDetails.getVersion();
- logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.CSAR_VALIDATION_STARTED + vspId);
- OrchestrationTemplateActionResponse response = new OrchestrationTemplateActionResponse();
- UploadFileResponse uploadFileResponse = new UploadFileResponse();
- Optional<FileContentHandler> fileContent =
- OrchestrationUtil
- .getFileContentMap(
- OnboardingTypesEnum.CSAR, uploadFileResponse, candidateData.getContentData().array());
+ OrchestrationTemplateCandidateData candidateData) {
+ LOGGER.audit(
+ AuditMessages.AUDIT_MSG + AuditMessages.CSAR_VALIDATION_STARTED + vspDetails.getId());
- if(fileContent.isPresent()){
+ UploadFileResponse uploadFileResponse = new UploadFileResponse();
+ Optional<FileContentHandler> fileContent = OrchestrationUtil
+ .getFileContentMap(OnboardingTypesEnum.CSAR, uploadFileResponse,
+ candidateData.getContentData().array());
+
+ OrchestrationTemplateActionResponse response = new OrchestrationTemplateActionResponse();
+ if (fileContent.isPresent()) {
try {
FileContentHandler fileContentHandler = fileContent.get();
- processCsar(vspId, version, fileContentHandler, candidateData, response);
- } catch (CoreException e){
- logger.error(e.getMessage());
+ processCsar(vspDetails, fileContentHandler, candidateData, response);
+ } catch (CoreException e) {
+ LOGGER.error(e.getMessage());
response.addErrorMessageToMap(e.code().id(), e.code().message(),ErrorLevel.ERROR);
} catch (IOException ioe) {
- logger.error(ioe.getMessage());
+ LOGGER.error(ioe.getMessage());
ErrorCode errorCode = new GeneralErrorBuilder(ioe.getMessage()).build();
response.addErrorMessageToMap(errorCode.id(), errorCode.message(),ErrorLevel.ERROR);
}
@@ -77,13 +75,13 @@
return response;
}
- private void processCsar(String vspId, Version version,
+ private void processCsar(VspDetails vspDetails,
FileContentHandler fileContentHandler,
OrchestrationTemplateCandidateData candidateData,
OrchestrationTemplateActionResponse response) throws IOException {
response.setFileNames(new ArrayList<>(fileContentHandler.getFileList()));
- Map<String, List<ErrorMessage>> errors = validateCsar(fileContentHandler, response);
- if(!isValid(errors)){
+ Map<String, List<ErrorMessage>> errors = validateCsar(fileContentHandler);
+ if (!isValid(errors)) {
return;
}
@@ -95,32 +93,31 @@
Map<String, Collection<ProcessEntity>> processes = new HashMap<>();
Map<String, ProcessEntity> processArtifact = new HashMap<>();
OrchestrationUtil orchestrationUtil = new OrchestrationUtil();
- orchestrationUtil.backupComponentsQuestionnaireBeforeDelete(vspId,
- version, componentsQuestionnaire,
+ orchestrationUtil.backupComponentsQuestionnaireBeforeDelete(vspDetails.getId(),
+ vspDetails.getVersion(), componentsQuestionnaire,
componentNicsQuestionnaire, componentMibList, processes, processArtifact);
Optional<ByteArrayInputStream> zipByteArrayInputStream = candidateService
- .fetchZipFileByteArrayInputStream(vspId, candidateData, null, OnboardingTypesEnum.CSAR, errors);
+ .fetchZipFileByteArrayInputStream(vspDetails.getId(), candidateData, null,
+ OnboardingTypesEnum.CSAR, errors);
- orchestrationUtil.deleteUploadDataAndContent(vspId, version);
- orchestrationUtil.saveUploadData(
- vspId, version, zipByteArrayInputStream.get(), fileContentHandler, tree);
+ orchestrationUtil.deleteUploadDataAndContent(vspDetails.getId(), vspDetails.getVersion());
+ orchestrationUtil.saveUploadData(vspDetails, candidateData, zipByteArrayInputStream.get(),
+ fileContentHandler, tree);
ToscaServiceModel toscaServiceModel = new ToscaConverterImpl().convert(fileContentHandler);
- orchestrationUtil.saveServiceModel(vspId, version, toscaServiceModel, toscaServiceModel);
+ orchestrationUtil.saveServiceModel(vspDetails.getId(), vspDetails.getVersion(), toscaServiceModel,
+ toscaServiceModel);
}
- private void addFiles(FileContentHandler fileContentHandler){
- for(Map.Entry<String, byte[]> fileEntry : fileContentHandler.getFiles().entrySet()){
+ private void addFiles(FileContentHandler fileContentHandler) {
+ for (Map.Entry<String, byte[]> fileEntry : fileContentHandler.getFiles().entrySet()) {
toscaTreeManager.addFile(fileEntry.getKey(), fileEntry.getValue());
}
}
- private Map<String, List<ErrorMessage>> validateCsar(FileContentHandler fileContentHandler,
- OrchestrationTemplateActionResponse response){
-
-
+ private Map<String, List<ErrorMessage>> validateCsar(FileContentHandler fileContentHandler) {
Map<String, List<ErrorMessage>> errors = new HashMap<>();
addFiles(fileContentHandler);
toscaTreeManager.createTree();
@@ -129,7 +126,7 @@
return errors;
}
- private boolean isValid(Map<String, List<ErrorMessage>> errors){
+ private boolean isValid(Map<String, List<ErrorMessage>> errors) {
return MapUtils.isEmpty(MessageContainerUtil.getMessageByLevel(ErrorLevel.ERROR, errors));
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessHandler.java
index 8b513b4..1db48a5 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessHandler.java
@@ -6,7 +6,7 @@
import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse;
public interface OrchestrationTemplateProcessHandler {
+
OrchestrationTemplateActionResponse process(VspDetails vspDetails,
- OrchestrationTemplateCandidateData candidateData,
- String user);
+ OrchestrationTemplateCandidateData candidateData);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java
index 85ac262..da5cb01 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java
@@ -1,19 +1,12 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.process;
-import static org.openecomp.sdc.logging.messages.AuditMessages.HEAT_VALIDATION_ERROR;
-
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
-import org.openecomp.core.model.dao.ServiceModelDao;
-import org.openecomp.core.model.dao.ServiceModelDaoFactory;
import org.openecomp.core.translator.datatypes.TranslatorOutput;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.core.validation.util.MessageContainerUtil;
-import org.openecomp.sdc.activityLog.ActivityLogManager;
-import org.openecomp.sdc.activityLog.ActivityLogManagerFactory;
-import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
@@ -31,18 +24,13 @@
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.factory.CandidateServiceFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionDataExtractorFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionEntityDataManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationUtil;
-import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionDataExtractor;
-import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService;
import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure;
import org.openecomp.sdc.vendorsoftwareproduct.utils.VendorSoftwareProductUtils;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdcrests.activitylog.types.ActivityType;
import java.io.ByteArrayInputStream;
import java.util.Collection;
@@ -51,41 +39,29 @@
import java.util.Map;
import java.util.Optional;
+import static org.openecomp.sdc.logging.messages.AuditMessages.HEAT_VALIDATION_ERROR;
+
public class OrchestrationTemplateProcessZipHandler implements OrchestrationTemplateProcessHandler {
- Logger logger = LoggerFactory.getLogger(OrchestrationTemplateProcessZipHandler.class);
+ private Logger logger = LoggerFactory.getLogger(OrchestrationTemplateProcessZipHandler.class);
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
private CandidateService candidateService =
CandidateServiceFactory.getInstance().createInterface();
- private ServiceModelDao serviceModelDao = ServiceModelDaoFactory.getInstance().createInterface();
- private CompositionEntityDataManager compositionEntityDataManager =
- CompositionEntityDataManagerFactory.getInstance().createInterface();
- private CompositionDataExtractor compositionDataExtractor =
- CompositionDataExtractorFactory.getInstance().createInterface();
- private ActivityLogManager activityLogManager =
- ActivityLogManagerFactory.getInstance().createInterface();
-
- public OrchestrationTemplateProcessZipHandler(){}
-
+ @Override
public OrchestrationTemplateActionResponse process(VspDetails vspDetails,
- OrchestrationTemplateCandidateData
- candidateData,
- String user) {
+ OrchestrationTemplateCandidateData candidateData) {
String vspId = vspDetails.getId();
Version version = vspDetails.getVersion();
- logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.HEAT_VALIDATION_STARTED
- + vspId);
+ logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.HEAT_VALIDATION_STARTED + vspId);
OrchestrationTemplateActionResponse response = new OrchestrationTemplateActionResponse();
UploadFileResponse uploadFileResponse = new UploadFileResponse();
- Optional<FileContentHandler> fileContent =
- OrchestrationUtil
- .getFileContentMap(
- OnboardingTypesEnum.ZIP, uploadFileResponse,
- candidateData.getContentData().array());
+ Optional<FileContentHandler> fileContent = OrchestrationUtil
+ .getFileContentMap(OnboardingTypesEnum.ZIP, uploadFileResponse,
+ candidateData.getContentData().array());
if (!fileContent.isPresent()) {
response.addStructureErrors(uploadFileResponse.getErrors());
mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
- response.getErrors().values().forEach(errorList -> printAuditForErrors(errorList,vspId,
+ response.getErrors().values().forEach(errorList -> printAuditForErrors(errorList, vspId,
HEAT_VALIDATION_ERROR));
return response;
}
@@ -100,7 +76,7 @@
Messages.FOUND_UNASSIGNED_FILES.getErrorMessage(), ErrorLevel.ERROR);
mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
- response.getErrors().values().forEach(errorList -> printAuditForErrors(errorList,vspId,
+ response.getErrors().values().forEach(errorList -> printAuditForErrors(errorList, vspId,
HEAT_VALIDATION_ERROR));
return response;
}
@@ -113,8 +89,8 @@
.fetchZipFileByteArrayInputStream(
vspId, candidateData, manifest, OnboardingTypesEnum.ZIP, uploadErrors);
if (!zipByteArrayInputStream.isPresent()) {
- response.getErrors().values().forEach(errorList -> printAuditForErrors(errorList,vspId,
- HEAT_VALIDATION_ERROR));
+ response.getErrors().values()
+ .forEach(errorList -> printAuditForErrors(errorList, vspId, HEAT_VALIDATION_ERROR));
return response;
}
@@ -129,18 +105,19 @@
OrchestrationUtil orchestrationUtil = new OrchestrationUtil();
Map<String, String> vspComponentIdNameInfoBeforeProcess =
orchestrationUtil.getVspComponentIdNameInfo(vspId, version);
- orchestrationUtil.backupComponentsQuestionnaireBeforeDelete(vspId,
- version, componentsQuestionnaire,
- componentNicsQuestionnaire, componentMibList, processes, processArtifact);
+ orchestrationUtil
+ .backupComponentsQuestionnaireBeforeDelete(vspId, version, componentsQuestionnaire,
+ componentNicsQuestionnaire, componentMibList, processes, processArtifact);
orchestrationUtil.deleteUploadDataAndContent(vspId, version);
- orchestrationUtil.saveUploadData(vspId, version, zipByteArrayInputStream.get(), fileContentMap,
- tree);
+ orchestrationUtil
+ .saveUploadData(vspDetails, candidateData, zipByteArrayInputStream.get(), fileContentMap,
+ tree);
- response.getErrors().values().forEach(errorList -> printAuditForErrors(errorList,vspId,
+ response.getErrors().values().forEach(errorList -> printAuditForErrors(errorList, vspId,
HEAT_VALIDATION_ERROR));
- if ( MapUtils.isEmpty(MessageContainerUtil.getMessageByLevel(ErrorLevel.ERROR,
- response.getErrors()))) {
+ if (MapUtils
+ .isEmpty(MessageContainerUtil.getMessageByLevel(ErrorLevel.ERROR, response.getErrors()))) {
logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.HEAT_VALIDATION_COMPLETED + vspId);
}
@@ -150,20 +127,17 @@
HeatToToscaUtil.loadAndTranslateTemplateData(fileContentMap);
ToscaServiceModel toscaServiceModel = translatorOutput.getToscaServiceModel();
- orchestrationUtil.saveServiceModel(vspId, version, translatorOutput
- .getNonUnifiedToscaServiceModel(), toscaServiceModel);
+ orchestrationUtil
+ .saveServiceModel(vspId, version, translatorOutput.getNonUnifiedToscaServiceModel(),
+ toscaServiceModel);
orchestrationUtil.retainComponentQuestionnaireData(vspId, version, componentsQuestionnaire,
componentNicsQuestionnaire, componentMibList, processes, processArtifact);
orchestrationUtil.updateVspComponentDependencies(vspId, version,
vspComponentIdNameInfoBeforeProcess);
+
logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.HEAT_TRANSLATION_COMPLETED + vspId);
uploadFileResponse.addStructureErrors(uploadErrors);
- ActivityLogEntity activityLogEntity =
- new ActivityLogEntity(vspId, String.valueOf(version.getMajor() + 1),
- ActivityType.UPLOAD_HEAT.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
-
mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
return response;
}
@@ -182,8 +156,8 @@
errorList.forEach(errorMessage -> {
if (errorMessage.getLevel().equals(ErrorLevel.ERROR)) {
- logger.audit(AuditMessages.AUDIT_MSG + String.format(auditType, errorMessage.getMessage(),
- vspId));
+ logger.audit(
+ AuditMessages.AUDIT_MSG + String.format(auditType, errorMessage.getMessage(), vspId));
}
});
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/GetFileDataStructureResponseDTO.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/GetFileDataStructureResponseDTO.java
deleted file mode 100644
index c309782..0000000
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/GetFileDataStructureResponseDTO.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.vendorsoftwareproduct.types;
-
-import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.Module;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Avrahamg
- * @since November 07, 2016
- */
-public class GetFileDataStructureResponseDTO {
- private List<Module> modules = new ArrayList<>();
- private List<String> unassigned = new ArrayList<>();
- private List<String> artifacts = new ArrayList<>();
- private List<String> nested = new ArrayList<>();
-
- public List<Module> getModules() {
- return modules;
- }
-
- public void setModules(List<Module> modules) {
- this.modules = modules;
- }
-
- public List<String> getUnassigned() {
- return unassigned;
- }
-
- public void setUnassigned(List<String> unassigned) {
- this.unassigned = unassigned;
- }
-
- public List<String> getArtifacts() {
- return artifacts;
- }
-
- public void setArtifacts(List<String> artifacts) {
- this.artifacts = artifacts;
- }
-
- public List<String> getNested() {
- return nested;
- }
-
- public void setNested(List<String> nested) {
- this.nested = nested;
- }
-}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeTest.java
index ab7a70b..3df06ba 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeTest.java
@@ -1,33 +1,5 @@
package org.openecomp.sdc.vendorsoftwareproduct;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.ADD_COMPUTE_NOT_ALLOWED_IN_HEAT_ONBOARDING;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.DUPLICATE_COMPUTE_NAME_NOT_ALLOWED;
-
-import org.openecomp.core.utilities.CommonMethods;
-import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
-import org.openecomp.sdc.vendorsoftwareproduct.impl.VendorSoftwareProductManagerImpl;
-import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
-import org.openecomp.sdc.vendorsoftwareproduct.types.ListComputeResponse;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComputeData;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.errors.VersioningErrorCodes;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
public class ComputeTest {
/*private static final String USER1 = "componentsTestUser1";
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorTest.java
index 45ba4fb..77c8111 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorTest.java
@@ -1,33 +1,5 @@
package org.openecomp.sdc.vendorsoftwareproduct;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.FEATURE_GROUP_NOT_EXIST_FOR_VSP;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.INVALID_COMPONENT_COMPUTE_ASSOCIATION;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.INVALID_COMPUTE_FLAVOR_ID;
-import static org.openecomp.sdc.versioning.errors.VersioningErrorCodes.VERSIONABLE_ENTITY_NOT_EXIST;
-import static org.openecomp.sdc.versioning.errors.VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND;
-
-import org.openecomp.core.utilities.CommonMethods;
-import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.impl.VendorSoftwareProductManagerImpl;
-
-import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
public class DeploymentFlavorTest {
/*private static final String USER1 = "deploymentTestUser1";
private static final String USER2 = "deploymentTestUser2";
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ImagesTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ImagesTest.java
index 5dcb7f9..d78f404 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ImagesTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ImagesTest.java
@@ -21,50 +21,48 @@
public class ImagesTest {
- private static String VSP_ID = "VSP_ID";
- private static String COMP_ID = "COMP_ID";
- private static String ID = "ID";
- private static String USER = "USER";
- public static final Version VERSION01 = new Version(0, 1);
+ private static String VSP_ID = "VSP_ID";
+ private static String COMP_ID = "COMP_ID";
+ private static String ID = "ID";
+ public static final Version VERSION01 = new Version("version_id");
- @Mock
- private VendorSoftwareProductInfoDao vendorSoftwareProductInfoDao;
+ @Mock
+ private VendorSoftwareProductInfoDao vendorSoftwareProductInfoDao;
- @Mock
- private CompositionEntityDataManager compositionEntityDataManager;
+ @Mock
+ private CompositionEntityDataManager compositionEntityDataManager;
- @InjectMocks
- @Spy
- private ImageManagerImpl imageManager;
+ @InjectMocks
+ @Spy
+ private ImageManagerImpl imageManager;
- @BeforeMethod
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
+ @BeforeMethod
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void createImage() {
+ ImageEntity imageEntity = new ImageEntity(VSP_ID, VERSION01, COMP_ID, ID);
+ doReturn(true).when(vendorSoftwareProductInfoDao).isManual(anyObject(), anyObject());
+
+ imageManager.createImage(imageEntity);
+ verify(compositionEntityDataManager).createImage(imageEntity);
+ }
+
+ @Test
+ public void createImageHeat() {
+ ImageEntity imageEntity = new ImageEntity(VSP_ID, VERSION01, COMP_ID, ID);
+ doReturn(false).when(vendorSoftwareProductInfoDao).isManual(anyObject(), anyObject());
+
+ try {
+ imageManager.createImage(imageEntity);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(),
+ VendorSoftwareProductErrorCodes.ADD_IMAGE_NOT_ALLOWED_IN_HEAT_ONBOARDING);
}
-
- @Test
- public void createImage()
- {
- ImageEntity imageEntity = new ImageEntity(VSP_ID, VERSION01, COMP_ID, ID);
- doReturn(true).when(vendorSoftwareProductInfoDao).isManual(anyObject(), anyObject());
-
- imageManager.createImage(imageEntity, USER);
- verify(compositionEntityDataManager).createImage(imageEntity);
- }
-
- @Test
- public void createImageHeat()
- {
- ImageEntity imageEntity = new ImageEntity(VSP_ID, VERSION01, COMP_ID, ID);
- doReturn(false).when(vendorSoftwareProductInfoDao).isManual(anyObject(), anyObject());
-
- try {
- imageManager.createImage(imageEntity, USER);
- Assert.fail();
- } catch (CoreException exception) {
- Assert.assertEquals(exception.code().id(), VendorSoftwareProductErrorCodes.ADD_IMAGE_NOT_ALLOWED_IN_HEAT_ONBOARDING);
- }
- }
+ }
/*private static final String USER1 = "imageTestUser1";
private static final String USER2 = "imageTestUser2";
private static final Version VERSION01 = new Version(0, 1);
@@ -93,40 +91,40 @@
vsp1 = vendorSoftwareProductManager.createNewVsp(VSPCommon
.createVspDetails(null, null, "VSP_" + CommonMethods.nextUuId(), "Test-vsp1", "vendorName",
"vlm1Id", "icon", "category", "subCategory", "123", null,
- VSPCommon.OnboardingMethod.Manual.name()), USER1
+ VSPCommon.OnboardingMethod.Manual.name())1
);
vsp1Id = vsp1.getId();
VspDetails vsp2 = vendorSoftwareProductManager.createNewVsp(VSPCommon
.createVspDetails(null, null, "VSP_" + CommonMethods.nextUuId(), "Test-vsp2", "vendorName",
"vlm1Id", "icon", "category", "subCategory", "123", null, VSPCommon.OnboardingMethod.
- Manual.name()), USER1);
+ Manual.name())1);
vsp2Id = vsp2.getId();
VspDetails vsp3 = vendorSoftwareProductManager.createNewVsp(VSPCommon
.createVspDetails(null, null, "VSP_" + CommonMethods.nextUuId(), "Test-vsp3",
"vendorName",
"vlm1Id", "icon", "category", "subCategory", "123", null, VSPCommon
- .OnboardingMethod.HEAT.name()), USER1);
+ .OnboardingMethod.HEAT.name())1);
vsp3Id = vsp3.getId();
ComponentEntity comp = new ComponentEntity();
comp.setVspId(vsp2Id);
comp.setCompositionData(comp1);
- ComponentEntity createdComp = vendorSoftwareProductManager.createComponent(comp, USER1);
+ ComponentEntity createdComp = vendorSoftwareProductManager.createComponent(comp1);
comp1Id = createdComp.getId();
}
@Test
public void testListImagesNonExistingVspId_negative() {
- testList_negative("non existing vsp id", null, image1Id, USER1,
+ testList_negative("non existing vsp id", null, image1Id1,
VersioningErrorCodes.VERSIONABLE_ENTITY_NOT_EXIST,
"Versionable entity VendorSoftwareProduct with id non existing vsp id does not exist." );
}
@Test
public void testListImagesNonExistingVfcId_negative() {
- testList_negative(vsp1Id, VERSION01, "444", USER1,
+ testList_negative(vsp1Id, VERSION01, "444"1,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND,
"Vendor Software Product Component with Id 444 does not exist for Vendor Software Product "
+ "with id "+vsp1Id+ " and version "+VERSION01);
@@ -137,20 +135,20 @@
createImageEntity("media-vsrx-vmdisk-15.1X49-D40.6.aki", "aki");
createImageEntity("riverbed-15.1X49-D40.6.vdi", "vdi");
final Collection<ImageEntity> imageEntities =
- vendorSoftwareProductManager.listImages(vsp2Id, VERSION01, comp1Id, USER1);
+ vendorSoftwareProductManager.listImages(vsp2Id, VERSION01, comp1Id1);
System.out.println("size::"+imageEntities.size());
}
@Test
public void testCreateNonExistingVspId_negative() {
- testCreate_negative(new ImageEntity("non existing vsp id", null, null, null), USER1,
+ testCreate_negative(new ImageEntity("non existing vsp id", null, null, null)1,
VersioningErrorCodes.VERSIONABLE_ENTITY_NOT_EXIST,
"Versionable entity VendorSoftwareProduct with id non existing vsp id does not exist.");
}
@Test
public void testCreateNonExistingVfcId_negative() {
- testCreate_negative(new ImageEntity(vsp1Id, VERSION01, "222", null), USER1,
+ testCreate_negative(new ImageEntity(vsp1Id, VERSION01, "222", null)1,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND,
"Vendor Software Product Component with Id 222 does not exist for Vendor Software Product "
+ "with id "+vsp1Id + " and version "+VERSION01);
@@ -158,8 +156,8 @@
@Test(dependsOnMethods = "testUpdateNonExistingImageId_negative")
public void testCreateOnAvailableVsp_negative() {
- vendorSoftwareProductManager.checkin(vsp1Id, USER1);
- testCreate_negative(new ImageEntity(vsp1Id, null, null, null), USER1,
+ vendorSoftwareProductManager.checkin(vsp1Id1);
+ testCreate_negative(new ImageEntity(vsp1Id, null, null, null)1,
VersioningErrorCodes.EDIT_ON_UNLOCKED_ENTITY,
"Can not edit versionable entity VendorSoftwareProduct with id "+vsp1Id+ " since it is not"
+ " checked out.");
@@ -167,8 +165,8 @@
@Test(dependsOnMethods = "testCreateOnAvailableVsp_negative")
public void testCreateOnVspOtherUser_negative() {
- vendorSoftwareProductManager.checkout(vsp1Id, USER1);
- testCreate_negative(new ImageEntity(vsp1Id, null, null, null), USER2,
+ vendorSoftwareProductManager.checkout(vsp1Id1);
+ testCreate_negative(new ImageEntity(vsp1Id, null, null, null)2,
VersioningErrorCodes.EDIT_ON_ENTITY_LOCKED_BY_OTHER_USER,
"Versionable entity VendorSoftwareProduct with id " +vsp1Id+
" can not be edited since it is locked by other user "+ USER1+ ".");
@@ -180,11 +178,11 @@
ComponentEntity comp = new ComponentEntity();
comp.setVspId(vsp1Id);
comp.setCompositionData(comp1);
- ComponentEntity createdComp = vendorSoftwareProductManager.createComponent(comp, USER1);
+ ComponentEntity createdComp = vendorSoftwareProductManager.createComponent(comp1);
String compId = createdComp.getId();
- vendorSoftwareProductManager.checkin(vsp1Id, USER1);
- vendorSoftwareProductManager.checkout(vsp1Id, USER1);
+ vendorSoftwareProductManager.checkin(vsp1Id1);
+ vendorSoftwareProductManager.checkout(vsp1Id1);
for(int i = 1; i<=3; i++) {
ImageEntity imageEntity = new ImageEntity();
@@ -197,17 +195,17 @@
//image.setFormat("aki");
//image.setMd5("233343DDDD");
imageEntity.setImageCompositionData(image);
- ImageEntity createdImage = vendorSoftwareProductManager.createImage(imageEntity, USER1);
+ ImageEntity createdImage = vendorSoftwareProductManager.createImage(imageEntity1);
}
Collection<ImageEntity> imageEntities =
- vendorSoftwareProductManager.listImages(vsp1Id, null, compId, USER1);
+ vendorSoftwareProductManager.listImages(vsp1Id, null, compId1);
Assert.assertEquals(imageEntities.size(), 3);
- vendorSoftwareProductManager.undoCheckout(vsp1Id, USER1);
+ vendorSoftwareProductManager.undoCheckout(vsp1Id1);
- imageEntities = vendorSoftwareProductManager.listImages(vsp1Id, null, compId, USER1);
+ imageEntities = vendorSoftwareProductManager.listImages(vsp1Id, null, compId1);
Assert.assertEquals(imageEntities.size(), 0);
}
@@ -217,7 +215,7 @@
final ErrorCode addImageNotSupportedHeatOnboardMethodErrorBuilder =
NotSupportedHeatOnboardMethodErrorBuilder
.getAddImageNotSupportedHeatOnboardMethodErrorBuilder();
- testCreate_negative(new ImageEntity(vsp3Id, null, null, null), USER1,
+ testCreate_negative(new ImageEntity(vsp3Id, null, null, null)1,
addImageNotSupportedHeatOnboardMethodErrorBuilder.id(),
addImageNotSupportedHeatOnboardMethodErrorBuilder.message()
);
@@ -252,19 +250,19 @@
@Test
public void testGet() {
ImageEntity createdImage = createImageEntity("read-riverbed-WX-IMG-9.2.0.qcow2", "qcow2");
- testGet(vsp2Id, VERSION01, comp1Id, createdImage.getId(), USER1, createdImage);
+ testGet(vsp2Id, VERSION01, comp1Id, createdImage.getId()1, createdImage);
}
@Test
public void testGetNonExistingVspId_negative() {
- testGet_negative("non existing vsp id", null, null, image1Id, USER1,
+ testGet_negative("non existing vsp id", null, null, image1Id1,
VersioningErrorCodes.VERSIONABLE_ENTITY_NOT_EXIST,
"Versionable entity VendorSoftwareProduct with id non existing vsp id does not exist." );
}
@Test
public void testGetNonExistingVfcId_negative() {
- testGet_negative(vsp1Id, VERSION01, "111", null, USER1,
+ testGet_negative(vsp1Id, VERSION01, "111", null1,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND,
"Vendor Software Product Component with Id 111 does not exist for Vendor Software Product "
+ "with id "+vsp1Id + " and version "+VERSION01);
@@ -274,7 +272,7 @@
public void testUpdateNonExistingVspId_negative() {
ImageEntity imageEntity = new ImageEntity("non existing vsp id", null, null, image1Id);
- testUpdate_negative(imageEntity, USER1,
+ testUpdate_negative(imageEntity1,
VersioningErrorCodes.VERSIONABLE_ENTITY_NOT_EXIST,
"Versionable entity VendorSoftwareProduct with id non existing vsp id does not exist." );
}
@@ -283,7 +281,7 @@
public void testUpdateNonExistingVfcId_negative() {
ImageEntity imageEntity = new ImageEntity(vsp1Id, VERSION01, "111", null);
- testUpdate_negative(imageEntity, USER1,
+ testUpdate_negative(imageEntity1,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND,
"Vendor Software Product Component with Id 111 does not exist for Vendor Software Product "
+ "with id "+vsp1Id + " and version "+VERSION01);
@@ -293,7 +291,7 @@
public void testUpdateNonExistingImageId_negative() {
ImageEntity imageEntity = new ImageEntity(vsp2Id, VERSION01, comp1Id, "222");
- testUpdate_negative(imageEntity, USER1,
+ testUpdate_negative(imageEntity1,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND,
"Vendor Software Product Component Image with Id 222 does not exist for Vendor " +
"Software Product with id "+vsp2Id+ " and version "+VERSION01 );
@@ -308,7 +306,7 @@
//imageCompositionData.setVersion("10.0");
imageCompositionData.setDescription("updated image");
- vendorSoftwareProductManager.updateImage(imageEntity, USER1);
+ vendorSoftwareProductManager.updateImage(imageEntity1);
testGet(vsp2Id, VERSION01, comp1Id, imageEntity.getId(),USER1, imageEntity );
image2Id = imageEntity.getId();
@@ -318,7 +316,7 @@
public void testUpdateNegative_UniqueName() {
final CompositionEntityResponse<Image> image =
vendorSoftwareProductManager.getImage(vsp2Id, VERSION01, comp1Id,
- image2Id, USER1);
+ image2Id1);
final Image data = image.getData();
final Image imageCompositionData = data;
@@ -326,7 +324,7 @@
ImageEntity entity = new ImageEntity(vsp2Id, VERSION01, comp1Id, image2Id );
entity.setImageCompositionData(imageCompositionData);
- testUpdate_negative(entity, USER1, ImageErrorBuilder.getDuplicateImageNameErrorBuilder(
+ testUpdate_negative(entity1, ImageErrorBuilder.getDuplicateImageNameErrorBuilder(
"riverbed-WX-IMG-9.2.0.qcow2", comp1Id).id()
,ImageErrorBuilder.getDuplicateImageNameErrorBuilder("riverbed-WX-IMG-9.2.0.qcow2", comp1Id)
.message() );
@@ -335,13 +333,13 @@
@Test(dependsOnMethods = "testUpdateNegative_UniqueName")
public void testDeleteImage() {
CompositionEntityResponse<Image> image =
- vendorSoftwareProductManager.getImage(vsp2Id, VERSION01, comp1Id, image2Id, USER1);
+ vendorSoftwareProductManager.getImage(vsp2Id, VERSION01, comp1Id, image2Id1);
Assert.assertNotNull(image.getData());
- vendorSoftwareProductManager.deleteImage(vsp2Id, comp1Id, image2Id, USER1);
+ vendorSoftwareProductManager.deleteImage(vsp2Id, comp1Id, image2Id1);
- testGet_negative(vsp2Id, VERSION01, comp1Id, image2Id, USER1,
+ testGet_negative(vsp2Id, VERSION01, comp1Id, image2Id1,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND,
"Vendor Software Product Component Image with Id "+image2Id+ " does not exist for " +
"Vendor Software Product with id "+vsp2Id+ " and version "+VERSION01 );
@@ -352,7 +350,7 @@
public void testDeleteNonExistingVspId_negative() {
ImageEntity imageEntity = new ImageEntity("non existing vsp id", null, null, image1Id);
- testDelete_negative(imageEntity, USER1,
+ testDelete_negative(imageEntity1,
VersioningErrorCodes.VERSIONABLE_ENTITY_NOT_EXIST,
"Versionable entity VendorSoftwareProduct with id non existing vsp id does not exist." );
}
@@ -361,7 +359,7 @@
public void testDeleteNonExistingVfcId_negative() {
ImageEntity imageEntity = new ImageEntity(vsp1Id, VERSION01, "111", null);
- testDelete_negative(imageEntity, USER1,
+ testDelete_negative(imageEntity1,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND,
"Vendor Software Product Component with Id 111 does not exist for Vendor Software Product "
+ "with id "+vsp1Id + " and version "+VERSION01);
@@ -371,7 +369,7 @@
public void testDeleteNonExistingImageId_negative() {
ImageEntity imageEntity = new ImageEntity(vsp2Id, VERSION01, comp1Id, "222");
- testDelete_negative(imageEntity, USER1,
+ testDelete_negative(imageEntity1,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND,
"Vendor Software Product Component Image with Id 222 does not exist for Vendor " +
"Software Product with id "+vsp2Id+ " and version "+VERSION01 );
@@ -386,7 +384,7 @@
final QuestionnaireResponse imageQuestionnaire =
vendorSoftwareProductManager.getImageQuestionnaire(vsp2Id, VERSION01, comp1Id,
- imageEntity.getId(), USER1);
+ imageEntity.getId()1);
String imageDetails = imageQuestionnaire.getData();
Assert.assertEquals("vdi", JsonUtil.json2Object(imageDetails, ImageDetails.class).getFormat());
@@ -422,7 +420,7 @@
// image.setMd5("233343DDDD");
imageEntity.setImageCompositionData(image);
- ImageEntity createdImage = vendorSoftwareProductManager.createImage(imageEntity, USER1);
+ ImageEntity createdImage = vendorSoftwareProductManager.createImage(imageEntity1);
image1Id = createdImage.getId();
return createdImage;
}
@@ -430,7 +428,7 @@
private void testGet(String vspId, Version version, String componentId, String imageId, String
user, ImageEntity expected) {
CompositionEntityResponse<Image>
- response = vendorSoftwareProductManager.getImage(vspId, null, componentId, imageId, user);
+ response = vendorSoftwareProductManager.getImage(vspId, null, componentId, imageId);
Assert.assertEquals(response.getId(), expected.getId());
Assert.assertEquals(expected.getImageCompositionData().getFileName(), response.getData().
getFileName());
@@ -442,7 +440,7 @@
private void testCreate_negative(ImageEntity image, String user,
String expectedErrorCode, String expectedErrorMsg) {
try {
- vendorSoftwareProductManager.createImage(image, user);
+ vendorSoftwareProductManager.createImage(image);
Assert.fail();
} catch (CoreException exception) {
Assert.assertEquals(exception.code().id(), expectedErrorCode);
@@ -454,7 +452,7 @@
String user,
String expectedErrorCode, String expectedErrorMsg) {
try {
- vendorSoftwareProductManager.getImage(vspId, version, componentId, imageId, user);
+ vendorSoftwareProductManager.getImage(vspId, version, componentId, imageId);
Assert.fail();
} catch (CoreException exception) {
Assert.assertEquals(exception.code().id(), expectedErrorCode);
@@ -465,7 +463,7 @@
private void testList_negative(String vspId, Version version, String componentId, String user,
String expectedErrorCode, String expectedErrorMsg) {
try {
- vendorSoftwareProductManager.listImages(vspId, version, componentId, user);
+ vendorSoftwareProductManager.listImages(vspId, version, componentId);
Assert.fail();
} catch (CoreException exception) {
Assert.assertEquals(exception.code().id(), expectedErrorCode);
@@ -478,7 +476,7 @@
String expectedErrorCode, String expectedErrorMsg) {
try {
- vendorSoftwareProductManager.updateImage(imageEntity, user);
+ vendorSoftwareProductManager.updateImage(imageEntity);
Assert.fail();
} catch (CoreException exception) {
Assert.assertEquals(exception.code().id(), expectedErrorCode);
@@ -491,7 +489,7 @@
String expectedErrorCode, String expectedErrorMsg) {
try {
- vendorSoftwareProductManager.updateImage(imageEntity, user);
+ vendorSoftwareProductManager.updateImage(imageEntity);
Assert.fail();
} catch (CoreException exception) {
Assert.assertEquals(exception.code().id(), expectedErrorCode);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/QuestionnaireDataServiceTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/QuestionnaireDataServiceTest.java
index b544d13..e8e0f2c 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/QuestionnaireDataServiceTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/QuestionnaireDataServiceTest.java
@@ -30,12 +30,10 @@
import org.openecomp.core.model.dao.ServiceModelDao;
import org.openecomp.core.model.types.ServiceElement;
import org.openecomp.core.validation.util.MessageContainerUtil;
-import org.openecomp.sdc.activityLog.ActivityLogManager;
import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.healing.api.HealingManager;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
import org.openecomp.sdc.vendorsoftwareproduct.impl.OrchestrationTemplateCandidateManagerImpl;
import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactData;
import org.openecomp.sdc.vendorsoftwareproduct.questionnaire.QuestionnaireDataService;
@@ -54,16 +52,11 @@
import java.util.List;
import java.util.Objects;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Matchers.eq;
-
public class QuestionnaireDataServiceTest {
public static final Version VERSION = new Version(0, 1);
private QuestionnaireDataService questionnaireDataService;// = new QuestionnaireDataServiceImpl();
@Mock
- private VendorSoftwareProductDao vendorSoftwareProductDaoMock;
- @Mock
private CandidateService candidateServiceMock;
@Mock
private HealingManager healingManagerMock;
@@ -73,8 +66,6 @@
private ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDaoMock;
@Mock
private CompositionEntityDataManager compositionEntityDataManagerMock;
- @Mock
- private ActivityLogManager activityLogManagerMock;
@Captor
private ArgumentCaptor<ActivityLogEntity> activityLogEntityArg;
@@ -82,7 +73,7 @@
@InjectMocks
private OrchestrationTemplateCandidateManagerImpl candidateManager;
- private final UploadFileTest uploadFileTest = new UploadFileTest();
+ private UploadFileTest uploadFileTest = new UploadFileTest();
private static String vspId;
private static Version vspActiveVersion;
@@ -110,31 +101,27 @@
// TODO: 3/15/2017 fix and enable //@Test
public void testQuestionnaireDataAfterIllegalUpload() throws IOException {
-
try (InputStream zipInputStream = uploadFileTest.getZipInputStream("/missingYml")) {
- UploadFileResponse uploadFileResponse = candidateManager
- .upload(vspId, VERSION, zipInputStream, USER1, "zip", "missingYml");
+ UploadFileResponse uploadFileResponse =
+ candidateManager.upload(vspId, VERSION, zipInputStream, "zip", "missingYml");
}
-
InformationArtifactData informationArtifactData = questionnaireDataService
.generateQuestionnaireDataForInformationArtifact(vspId, vspActiveVersion);
}
private InformationArtifactData uploadFileAndValidateInformationArtifactData(String filePath,
- int listSizeToCheck) throws IOException {
+ int listSizeToCheck)
+ throws IOException {
try (InputStream zipInputStream = uploadFileTest.getZipInputStream(filePath)) {
- UploadFileResponse uploadFileResponse = candidateManager
- .upload(vspId, VERSION,
- zipInputStream, USER1, "zip", "file");
-
- candidateManager.process(vspId, VERSION, USER1);
+ UploadFileResponse uploadFileResponse =
+ candidateManager.upload(vspId, VERSION, zipInputStream, "zip", "file");
+ candidateManager.process(vspId, VERSION);
Assert.assertTrue(MapUtils.isEmpty(
MessageContainerUtil.getMessageByLevel(ErrorLevel.ERROR, uploadFileResponse.getErrors())));
}
-
InformationArtifactData informationArtifactData = questionnaireDataService
.generateQuestionnaireDataForInformationArtifact(vspId, vspActiveVersion);
Assert.assertNotNull(informationArtifactData);
@@ -143,11 +130,6 @@
informationArtifactData.getComponentQuestionnaires();
Assert.assertEquals(componentQuestionnaireList.size(), listSizeToCheck);
- verify(activityLogManagerMock).addActionLog(activityLogEntityArg.capture(),eq(USER1));
- ActivityLogEntity activityLogEntity = activityLogEntityArg.getValue();
- Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION.getMajor()+1));
- Assert.assertTrue(activityLogEntity.isSuccess());
-
return informationArtifactData;
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelTest.java
index c3f78b6..a2cbaa7 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelTest.java
@@ -6,136 +6,217 @@
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager;
-import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.errors.ComponentDependencyModelErrorBuilder;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.when;
+
public class ComponentDependencyModelTest {
- private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
+ private static final String VSP_ID = "vsp_id";
+ private static final Version VERSION = new Version("version_id");
+ private static final String COMP_DEP_ID = "comp_dep_id";
+
+ private static final String COMP_ID_1 = "comp_id_1";
+ private static final String COMP_ID_2 = "comp_id_2";
+ private static final String COMP_ID_3 = "comp_id_3";
+ private static final String COMP_ID_4 = "comp_id_4";
@Spy
@InjectMocks
private ComponentDependencyModelManagerImpl componentDependencyModelManager;
@Mock
- private VendorSoftwareProductManager vendorSoftwareProductManager;
- @Mock
- private VendorSoftwareProductDao vendorSoftwareProductDao;
- @Mock
- private ComponentDao componentDao;
- @Mock
private ComponentManager componentManager;
+ @Mock
+ private ComponentDependencyModelDao componentDependencyModelDao;
- private static String vsp1Id;
- private static String sourceComp1Id;
- private static String sourceComp2Id;
- private static String sourceComp3Id;
- private static String sourceComp4Id;
- private static final String USER1 = "TestUser1";
- private static final String USER2 = "TestUser2";
- private static final Version VERSION01 = new Version(0, 1);
- private static String modelId = "model1";
-
-
- @BeforeClass
+ @BeforeMethod
private void init() {
MockitoAnnotations.initMocks(this);
}
- public static VspDetails createVspDetails(String id, Version version, String name, String desc,
- String vendorName, String vlm, String icon,
- String category, String subCategory,
- String licenseAgreement, List<String> featureGroups
- ) {
- VspDetails vspDetails = new VspDetails(id, version);
- vspDetails.setName(name);
- vspDetails.setDescription(desc);
- vspDetails.setIcon(icon);
- vspDetails.setCategory(category);
- vspDetails.setSubCategory(subCategory);
- vspDetails.setVendorName(vendorName);
- vspDetails.setVendorId(vlm);
- vspDetails.setVlmVersion(new Version(1, 0));
- vspDetails.setLicenseAgreement(licenseAgreement);
- vspDetails.setFeatureGroups(featureGroups);
- return vspDetails;
+ @Test
+ public void testListDependency() {
+ List<ComponentDependencyModelEntity> entities = new ArrayList<>();
+ entities.add(createModelEntity(COMP_ID_1, COMP_ID_2));
+ entities.add(createModelEntity(COMP_ID_3, COMP_ID_4));
+
+ Mockito.when(componentDependencyModelDao
+ .list(new ComponentDependencyModelEntity(VSP_ID, VERSION, null)))
+ .thenReturn(entities);
+
+ Collection<ComponentDependencyModelEntity> list =
+ componentDependencyModelManager.list(VSP_ID, VERSION);
+
+ Mockito.verify(componentDependencyModelDao, Mockito.times(1))
+ .list(new ComponentDependencyModelEntity(VSP_ID, VERSION, null));
+
+ Assert.assertEquals(2, list.size());
}
@Test
- public void testCreateNegative_NoSourceId() {
- List<ComponentDependencyModelEntity> entities = new ArrayList<ComponentDependencyModelEntity>();
- entities.add(createModelEntity(null, sourceComp2Id));
- testCreate_negative(entities, vsp1Id, VERSION01, USER1,
- ComponentDependencyModelErrorBuilder.getNoSourceComponentErrorBuilder().id(),
- ComponentDependencyModelErrorBuilder.getNoSourceComponentErrorBuilder().message());
+ public void testCreateDependency() {
+ ComponentDependencyModelEntity modelEntity =
+ createModelEntity(COMP_ID_1, COMP_ID_2);
- entities.clear();
- entities.add(createModelEntity("", sourceComp2Id));
- testCreate_negative(entities, vsp1Id, VERSION01, USER1,
- ComponentDependencyModelErrorBuilder.getNoSourceComponentErrorBuilder().id(),
- ComponentDependencyModelErrorBuilder.getNoSourceComponentErrorBuilder().message());
+ componentDependencyModelManager.createComponentDependency(modelEntity, VSP_ID, VERSION);
+ Mockito.verify(componentDependencyModelDao, Mockito.times(1)).create(modelEntity);
}
@Test
- public void testCreateNegative_SameSourceTarget() {
- List<ComponentDependencyModelEntity> entities = new ArrayList<ComponentDependencyModelEntity>();
- entities.add(createModelEntity("sourceComp1Id", "sourceComp1Id"));
- testCreate_negative(entities, vsp1Id, VERSION01, USER1,
+ public void testCreateDependencyNegative_SameSourceTarget() {
+ ComponentDependencyModelEntity modelEntity =
+ createModelEntity(COMP_ID_1, COMP_ID_1);
+ testCreateDependency_negative(modelEntity, VSP_ID, VERSION,
ComponentDependencyModelErrorBuilder.getSourceTargetComponentEqualErrorBuilder().id(),
ComponentDependencyModelErrorBuilder.getSourceTargetComponentEqualErrorBuilder().message());
}
@Test
- public void testCreate() {
- List<ComponentDependencyModelEntity> entities = new ArrayList<ComponentDependencyModelEntity>();
- entities.add(createModelEntity("sourceComp1Id", "sourceComp2Id"));
- entities.add(createModelEntity("sourceComp3Id", "sourceComp4Id"));
+ public void testCreateDependencyNegative_NoSourceId() {
- componentDependencyModelManager.createComponentDependencyModel(entities, vsp1Id, VERSION01,
- USER1);
- Mockito.verify(vendorSoftwareProductDao, Mockito.times(1)).createComponentDependencyModel
- (entities, vsp1Id,
- VERSION01);
+ ComponentDependencyModelEntity modelEntity = createModelEntity(null, COMP_ID_1);
+ testCreateDependency_negative(modelEntity, VSP_ID, VERSION,
+ ComponentDependencyModelErrorBuilder.getNoSourceComponentErrorBuilder().id(),
+ ComponentDependencyModelErrorBuilder.getNoSourceComponentErrorBuilder().message());
+
+
+ ComponentDependencyModelEntity modelEntity1 = createModelEntity("", COMP_ID_1);
+ testCreateDependency_negative(modelEntity1, VSP_ID, VERSION,
+ ComponentDependencyModelErrorBuilder.getNoSourceComponentErrorBuilder().id(),
+ ComponentDependencyModelErrorBuilder.getNoSourceComponentErrorBuilder().message());
+ }
+
+ @Test
+ public void testUpdateDependency() {
+ ComponentDependencyModelEntity modelEntity =
+ createModelEntity(COMP_ID_1, COMP_ID_2);
+ modelEntity.setId(COMP_DEP_ID);
+
+ when(componentDependencyModelDao.get(anyObject())).thenReturn(modelEntity);
+
+ componentDependencyModelManager.update(modelEntity);
+ Mockito.verify(componentDependencyModelDao, Mockito.times(1)).update(modelEntity);
+ }
+
+ @Test
+ public void testUpdateDependencyNegative_NoSourceId() {
+
+ ComponentDependencyModelEntity modelEntity = createModelEntity(null, COMP_ID_1);
+ modelEntity.setId(COMP_DEP_ID);
+
+ when(componentDependencyModelDao.get(anyObject())).thenReturn(modelEntity);
+
+ testUpdateDependency_negative(modelEntity,
+ ComponentDependencyModelErrorBuilder.getNoSourceComponentErrorBuilder().id(),
+ ComponentDependencyModelErrorBuilder.getNoSourceComponentErrorBuilder().message());
+
+ ComponentDependencyModelEntity modelEntity1 = createModelEntity("", COMP_ID_1);
+ modelEntity1.setId(COMP_DEP_ID);
+
+ when(componentDependencyModelDao.get(anyObject())).thenReturn(modelEntity1);
+
+ testUpdateDependency_negative(modelEntity1,
+ ComponentDependencyModelErrorBuilder.getNoSourceComponentErrorBuilder().id(),
+ ComponentDependencyModelErrorBuilder.getNoSourceComponentErrorBuilder().message());
+ }
+
+ @Test
+ public void testUpdateDependencyNegative_SameSourceTarget() {
+ ComponentDependencyModelEntity modelEntity =
+ createModelEntity(COMP_ID_1, COMP_ID_1);
+ modelEntity.setId(COMP_DEP_ID);
+
+ when(componentDependencyModelDao.get(anyObject())).thenReturn(modelEntity);
+ testUpdateDependency_negative(modelEntity,
+ ComponentDependencyModelErrorBuilder.getSourceTargetComponentEqualErrorBuilder().id(),
+ ComponentDependencyModelErrorBuilder.getSourceTargetComponentEqualErrorBuilder().message());
+ }
+
+ @Test
+ public void testDeleteDependency() {
+ ComponentDependencyModelEntity modelEntity =
+ createModelEntity(COMP_ID_1, COMP_ID_2);
+ modelEntity.setId(COMP_DEP_ID);
+
+ when(componentDependencyModelDao.get(anyObject())).thenReturn(modelEntity);
+
+ componentDependencyModelManager.delete(VSP_ID, VERSION, COMP_DEP_ID);
+ Mockito.verify(componentDependencyModelDao, Mockito.times(1)).delete(modelEntity);
+ }
+
+ @Test
+ public void testDeleteInvalidDependency() {
+ ComponentDependencyModelEntity delModelEntity =
+ createModelEntity(COMP_ID_1, COMP_ID_2);
+ delModelEntity.setId(COMP_DEP_ID);
+
+ try {
+ componentDependencyModelManager.delete(VSP_ID, VERSION, COMP_DEP_ID);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), "VERSIONABLE_SUB_ENTITY_NOT_FOUND");
+ Assert.assertEquals(exception.getMessage(),
+ String.format("Vendor Software Product Component Dependency Model with Id %s " +
+ "does not exist for Vendor Software Product with id %s and version %s",
+ COMP_DEP_ID, VSP_ID, VERSION.getId()));
+ }
+ }
+
+
+ @Test
+ public void testGetDependency() {
+ ComponentDependencyModelEntity modelEntity =
+ createModelEntity(COMP_ID_1, COMP_ID_2);
+ modelEntity.setId(COMP_DEP_ID);
+
+ when(componentDependencyModelDao.get(anyObject())).thenReturn(modelEntity);
+
+ ComponentDependencyModelEntity retrieved =
+ componentDependencyModelManager.get(VSP_ID, VERSION, COMP_DEP_ID);
+
+ Assert.assertEquals(retrieved.getSourceComponentId(), COMP_ID_1);
+
}
private ComponentDependencyModelEntity createModelEntity(String sourceId, String targetId) {
ComponentDependencyModelEntity entity =
- new ComponentDependencyModelEntity(vsp1Id, VERSION01, modelId);
+ new ComponentDependencyModelEntity(VSP_ID, VERSION, COMP_DEP_ID);
entity.setSourceComponentId(sourceId);
entity.setTargetComponentId(targetId);
entity.setRelation("dependsOn");
return entity;
}
- private Collection<ComponentDependencyModelEntity> getDependencyModel(String vspId,
- Version version,
- String user) {
- return componentDependencyModelManager.list(vspId, version, user);
- }
-
- private void testCreate_negative(List<ComponentDependencyModelEntity> entities, String vspId,
- Version version, String user,
- String expectedErrorCode, String expectedErrorMsg) {
+ private void testCreateDependency_negative(ComponentDependencyModelEntity entity, String vspId,
+ Version version, String expectedErrorCode,
+ String expectedErrorMsg) {
try {
- componentDependencyModelManager.createComponentDependencyModel(entities, vspId, version,
- user);
+ componentDependencyModelManager.createComponentDependency(entity, vspId, version);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ Assert.assertEquals(exception.getMessage(), expectedErrorMsg);
+ }
+ }
+
+ private void testUpdateDependency_negative(ComponentDependencyModelEntity entity,
+ String expectedErrorCode, String expectedErrorMsg) {
+ try {
+ componentDependencyModelManager.update(entity);
+ Assert.fail();
+ } catch (CoreException exception) {
Assert.assertEquals(exception.code().id(), expectedErrorCode);
Assert.assertEquals(exception.getMessage(), expectedErrorMsg);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImplTest.java
index ee8295ca..c7aa818 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImplTest.java
@@ -2,12 +2,9 @@
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.NicManager;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
@@ -37,16 +34,13 @@
import static org.mockito.Mockito.verify;
public class ComponentManagerImplTest {
-
- private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
-
- private static final String COMP_NOT_EXIST_MSG =
- "Vendor Software Product Component with Id 1 does not exist for Vendor Software Product with id VSP_ID and version 0.1";
- private static final String USER = "componentsTestUser";
private static final String VSP_ID = "VSP_ID";
- private static final Version VERSION = new Version(0, 1);
- private static final String COMP1_ID = "1";
- private static final String COMP2_ID = "2";
+ private static final Version VERSION = new Version("version_id");
+ private static final String COMP1_ID = "comp1";
+ private static final String COMP2_ID = "comp2";
+ private static final String COMP_NOT_EXIST_MSG =
+ "Vendor Software Product Component with Id comp1 does not exist " +
+ "for Vendor Software Product with id VSP_ID and version version_id";
@Mock
private ComponentDao componentDaoMock;
@@ -67,20 +61,15 @@
@Test
public void testListWhenNone() {
- Collection<ComponentEntity> components =
- componentManager.listComponents(VSP_ID, VERSION, USER);
+ Collection<ComponentEntity> components = componentManager.listComponents(VSP_ID, VERSION);
Assert.assertEquals(components.size(), 0);
}
@Test(expectedExceptions = CoreException.class,
- expectedExceptionsMessageRegExp = "Vendor Software Product Component with Id dummyComponentId " +
- "does not exist for Vendor Software Product with id dummyVsp and version 1.0")
+ expectedExceptionsMessageRegExp = COMP_NOT_EXIST_MSG)
public void validateExceptionWhenTryingToRetriveNotExistingComponentEntity() {
- Version version = Mockito.mock(Version.class);
- doReturn("1.0").when(version).toString();
doReturn(null).when(componentDaoMock).get(anyObject());
- componentManager.validateComponentExistence("dummyVsp", version, "dummyComponentId",
- "dummyUser");
+ componentManager.validateComponentExistence(VSP_ID, VERSION, COMP1_ID);
}
@Test
@@ -90,21 +79,20 @@
createComponent(VSP_ID, VERSION, COMP2_ID)))
.when(componentDaoMock).list(anyObject());
- Collection<ComponentEntity> actual =
- componentManager.listComponents(VSP_ID, VERSION, USER);
+ Collection<ComponentEntity> actual = componentManager.listComponents(VSP_ID, VERSION);
Assert.assertEquals(actual.size(), 2);
}
@Test
public void testDeleteListOnUploadVsp_negative() {
- testDeleteList_negative(VSP_ID, VERSION, USER,
+ testDeleteList_negative(VSP_ID, VERSION,
VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED);
}
-/* @Test
- public void testCreate() {
- COMP1_ID = testCreate(VSP_ID);
- }*/
+ /* @Test
+ public void testCreate() {
+ COMP1_ID = testCreate(VSP_ID);
+ }*/
@Test
public void testCreate() {
ComponentEntity expected = new ComponentEntity(VSP_ID, null, null);
@@ -113,12 +101,12 @@
compData.setDescription("comp1 desc");
expected.setComponentCompositionData(compData);
- doReturn(true).when(vspInfoDao).isManual(anyObject(),anyObject());
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
Collection<ComponentEntity> vspComponentList = new ArrayList<>();
doReturn(vspComponentList).when(componentDaoMock).list(anyObject());
doReturn(expected).when(compositionEntityDataManagerMock).createComponent(anyObject());
- ComponentEntity created = componentManager.createComponent(expected, USER);
+ ComponentEntity created = componentManager.createComponent(expected);
Assert.assertNotNull(created);
//expected.setId(created.getId());
//expected.setVersion(VERSION);
@@ -137,15 +125,14 @@
compData.setDescription("comp1 desc");
expected.setComponentCompositionData(compData);
- doReturn(true).when(vspInfoDao).isManual(anyObject(),anyObject());
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
Collection<ComponentEntity> vspComponentList = new ArrayList<>();
vspComponentList.add(expected);
doReturn(vspComponentList).when(componentDaoMock).list(anyObject());
try {
- ComponentEntity created = componentManager.createComponent(expected, USER);
- } catch (CoreException exception) {
- log.debug("",exception);
+ ComponentEntity created = componentManager.createComponent(expected);
+ } catch (CoreException exception) {
Assert.assertEquals("Creation of only one VFC per VSP allowed.", exception.code().message());
Assert.assertEquals(VendorSoftwareProductErrorCodes.VSP_VFC_COUNT_EXCEED,
exception.code().id());
@@ -161,14 +148,14 @@
expected.setComponentCompositionData(compData);
doReturn(expected).when(componentDaoMock).get(anyObject());
- doReturn(true).when(vspInfoDao).isManual(anyObject(),anyObject());
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
Collection<ComponentEntity> vspComponentList = new ArrayList<>();
vspComponentList.add(expected);
doReturn(vspComponentList).when(componentDaoMock).list(anyObject());
- doReturn(new CompositionEntityValidationData(null,null)).when(compositionEntityDataManagerMock)
- .validateEntity(anyObject(),anyObject(),anyObject());
+ doReturn(new CompositionEntityValidationData(null, null)).when(compositionEntityDataManagerMock)
+ .validateEntity(anyObject(), anyObject(), anyObject());
- CompositionEntityValidationData created = componentManager.updateComponent(expected, USER);
+ CompositionEntityValidationData created = componentManager.updateComponent(expected);
Assert.assertNotNull(created);
}
@@ -182,20 +169,19 @@
expected.setComponentCompositionData(compData);
doReturn(expected).when(componentDaoMock).get(anyObject());
- doReturn(true).when(vspInfoDao).isManual(anyObject(),anyObject());
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
Collection<ComponentEntity> vspComponentList = new ArrayList<>();
vspComponentList.add(expected);
- ComponentEntity expected2 = new ComponentEntity(VSP_ID+"2", null, COMP1_ID+"2");
+ ComponentEntity expected2 = new ComponentEntity(VSP_ID + "2", null, COMP1_ID + "2");
expected2.setComponentCompositionData(compData);
vspComponentList.add(expected2);
doReturn(vspComponentList).when(componentDaoMock).list(anyObject());
- doReturn(new CompositionEntityValidationData(null,null)).when(compositionEntityDataManagerMock)
- .validateEntity(anyObject(),anyObject(),anyObject());
+ doReturn(new CompositionEntityValidationData(null, null)).when(compositionEntityDataManagerMock)
+ .validateEntity(anyObject(), anyObject(), anyObject());
try {
- CompositionEntityValidationData created = componentManager.updateComponent(expected, USER);
- } catch (CoreException exception) {
- log.debug("",exception);
+ CompositionEntityValidationData created = componentManager.updateComponent(expected);
+ } catch (CoreException exception) {
Assert.assertEquals("VFC with specified name already present in given VSP.",
exception.code().message());
Assert.assertEquals(VendorSoftwareProductErrorCodes.VSP_VFC_DUPLICATE_NAME,
@@ -220,7 +206,7 @@
@Test
public void testCreateOnUploadVsp_negative() {
- testCreate_negative(new ComponentEntity(VSP_ID, VERSION, null), USER,
+ testCreate_negative(new ComponentEntity(VSP_ID, VERSION, null),
VendorSoftwareProductErrorCodes.VFC_ADD_NOT_ALLOWED_IN_HEAT_ONBOARDING);
}
@@ -229,7 +215,7 @@
String componentId = "non existing component id";
doReturn(null).when(componentDaoMock).get(anyObject());
- testUpdate_negative(VSP_ID, VERSION, componentId, USER,
+ testUpdate_negative(VSP_ID, VERSION, componentId,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
@@ -254,7 +240,7 @@
CompositionEntityValidationData validationData =
- componentManager.updateComponent(component, USER);
+ componentManager.updateComponent(component);
Assert.assertTrue(validationData == null || validationData.getErrors() == null);
verify(componentDaoMock).update(component);
}
@@ -277,7 +263,7 @@
component.setComponentCompositionData(compData);
CompositionEntityValidationData validationData =
- componentManager.updateComponent(component, USER);
+ componentManager.updateComponent(component);
Assert.assertNotNull(validationData);
Assert.assertEquals(validationData.getErrors().size(), 2);
@@ -289,7 +275,7 @@
String componentId = "non existing component id";
doReturn(null).when(componentDaoMock).get(anyObject());
- testGet_negative(VSP_ID, VERSION, componentId, USER,
+ testGet_negative(VSP_ID, VERSION, componentId,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
@@ -300,7 +286,7 @@
doReturn("schema string").when(componentManager).getComponentCompositionSchema(anyObject());
- testGet(VSP_ID, VERSION, COMP1_ID, USER, expected);
+ testGet(VSP_ID, VERSION, COMP1_ID, expected);
}
@@ -329,14 +315,14 @@
@Test
public void testDeleteOnUploadVsp_negative() {
- testDelete_negative(VSP_ID, VERSION, COMP1_ID, USER,
+ testDelete_negative(VSP_ID, VERSION, COMP1_ID,
VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED);
}
@Test(expectedExceptions = CoreException.class,
expectedExceptionsMessageRegExp = COMP_NOT_EXIST_MSG)
public void testGetNonExistingComponentQuestionnaire() throws Exception {
- componentManager.getQuestionnaire(VSP_ID, VERSION, COMP1_ID, USER);
+ componentManager.getQuestionnaire(VSP_ID, VERSION, COMP1_ID);
}
@Test
@@ -347,7 +333,7 @@
doReturn(schema).when(componentManager).getComponentQuestionnaireSchema(anyObject());
QuestionnaireResponse questionnaire =
- componentManager.getQuestionnaire(VSP_ID, VERSION, COMP1_ID, USER);
+ componentManager.getQuestionnaire(VSP_ID, VERSION, COMP1_ID);
Assert.assertNotNull(questionnaire);
Assert.assertEquals(questionnaire.getData(), null);
Assert.assertEquals(questionnaire.getSchema(), schema);
@@ -372,13 +358,13 @@
nicEntity2.setNicCompositionData(nic2);
doReturn(Arrays.asList(nicEntity1, nicEntity2))
- .when(nicManagerMock).listNics(VSP_ID, VERSION, COMP1_ID, USER);
+ .when(nicManagerMock).listNics(VSP_ID, VERSION, COMP1_ID);
String schema = "schema string";
doReturn(schema).when(componentManager).getComponentQuestionnaireSchema(anyObject());
QuestionnaireResponse questionnaire =
- componentManager.getQuestionnaire(VSP_ID, VERSION, COMP1_ID, USER);
+ componentManager.getQuestionnaire(VSP_ID, VERSION, COMP1_ID);
Assert.assertNotNull(questionnaire);
Assert.assertEquals(questionnaire.getData(), component.getQuestionnaireData());
Assert.assertEquals(questionnaire.getSchema(), schema);
@@ -389,7 +375,7 @@
expectedExceptionsMessageRegExp = COMP_NOT_EXIST_MSG)
public void testUpdateNonExistingComponentQuestionnaire() throws Exception {
doReturn(null).when(componentDaoMock).get(anyObject());
- componentManager.updateQuestionnaire(VSP_ID, VERSION, COMP1_ID, "questionnaire data", USER);
+ componentManager.updateQuestionnaire(VSP_ID, VERSION, COMP1_ID, "questionnaire data");
}
@Test
@@ -397,7 +383,7 @@
ComponentEntity component = createComponent(VSP_ID, VERSION, COMP1_ID);
doReturn(component).when(componentDaoMock).get(anyObject());
- componentManager.updateQuestionnaire(VSP_ID, VERSION, COMP1_ID, "questionnaire data", USER);
+ componentManager.updateQuestionnaire(VSP_ID, VERSION, COMP1_ID, "questionnaire data");
verify(componentDaoMock)
.updateQuestionnaireData(VSP_ID, VERSION, COMP1_ID, "questionnaire data");
@@ -417,79 +403,72 @@
Assert.assertEquals(actual.size(), 0);
}*/
- private void testGet(String vspId, Version version, String componentId, String user,
+ private void testGet(String vspId, Version version, String componentId,
ComponentEntity expected) {
CompositionEntityResponse<ComponentData>
- response = componentManager.getComponent(vspId, version, componentId, user);
+ response = componentManager.getComponent(vspId, version, componentId);
Assert.assertEquals(response.getId(), expected.getId());
Assert.assertEquals(response.getData(), expected.getComponentCompositionData());
Assert.assertNotNull(response.getSchema());
}
- private void testCreate_negative(ComponentEntity component, String user,
+ private void testCreate_negative(ComponentEntity component,
String expectedErrorCode) {
try {
- componentManager.createComponent(component, user);
+ componentManager.createComponent(component);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
- private void testGet_negative(String vspId, Version version, String componentId, String user,
+ private void testGet_negative(String vspId, Version version, String componentId,
String expectedErrorCode) {
try {
- componentManager.getComponent(vspId, version, componentId, user);
+ componentManager.getComponent(vspId, version, componentId);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
- private void testUpdate_negative(String vspId, Version version, String componentId, String user,
+ private void testUpdate_negative(String vspId, Version version, String componentId,
String expectedErrorCode) {
try {
- componentManager
- .updateComponent(new ComponentEntity(vspId, version, componentId), user);
+ componentManager.updateComponent(new ComponentEntity(vspId, version, componentId));
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
- private void testList_negative(String vspId, Version version, String user,
+ private void testList_negative(String vspId, Version version,
String expectedErrorCode) {
try {
- componentManager.listComponents(vspId, version, user);
+ componentManager.listComponents(vspId, version);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
- private void testDeleteList_negative(String vspId, Version version, String user,
+ private void testDeleteList_negative(String vspId, Version version,
String expectedErrorCode) {
try {
- componentManager.deleteComponents(vspId, version, user);
+ componentManager.deleteComponents(vspId, version);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
- private void testDelete_negative(String vspId, Version version, String componentId, String user,
+ private void testDelete_negative(String vspId, Version version, String componentId,
String expectedErrorCode) {
try {
- componentManager.deleteComponent(vspId, version, componentId, user);
+ componentManager.deleteComponent(vspId, version, componentId);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImplTest.java
index eda5693..9058a73 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImplTest.java
@@ -1,378 +1,348 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.NetworkManager;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes;
import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.ListComputeResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComputeData;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdc.versioning.errors.VersioningErrorCodes;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.List;
+
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
public class ComputeManagerImplTest {
- private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
+ private static final String COMPUTE_NOT_EXIST_MSG =
+ "Vendor Software Product COMPUTE with Id compute1 does not exist for Vendor Software Product with " +
+ "id VSP_ID and version version_id";
- private static final String COMPUTE_NOT_EXIST_MSG =
- "Vendor Software Product COMPUTE with Id compute1 does not exist for Vendor Software Product with " +
- "id VSP_ID and version 0.1";
-
- private static final String USER = "computeTestUser";
- private static final String VSP_ID = "VSP_ID";
- private static final Version VERSION = new Version(0, 1);
- private static final String COMPONENT_ID = "COMPONENT_ID";
- private static final String COMPUTE1_ID = "compute1";
- private static final String COMPUTE2_ID = "compute2";
+ private static final String VSP_ID = "VSP_ID";
+ private static final Version VERSION = new Version("version_id");
+ private static final String COMPONENT_ID = "COMPONENT_ID";
+ private static final String COMPUTE1_ID = "compute1";
+ private static final String COMPUTE2_ID = "compute2";
@Mock
private ComputeDao computeDao;
-
@Mock
private CompositionEntityDataManager compositionEntityDataManagerMock;
-
- @Mock
- private NetworkManager networkManagerMock;
-
@Mock
private VendorSoftwareProductInfoDao vspInfoDao;
-
- @Mock
- private ComputeEntity computeEntity;
-
- @Mock
- private ListComputeResponse listComputeResponse;
-
- @Mock
- private DeploymentFlavorEntity deploymentFlavorEntity;
-
@Mock
private DeploymentFlavorDao deploymentFlavorDao;
-
- @Mock
- private ComponentComputeAssociation componentComputeAssociation;
-
- @Mock
- DeploymentFlavor deploymentFlavor;
-
@InjectMocks
@Spy
private ComputeManagerImpl computeManager;
@BeforeMethod
public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
+ MockitoAnnotations.initMocks(this);
}
- @Test
+ @Test
public void testListWhenNone() {
- Collection<ListComputeResponse> computes = computeManager.listCompute(VSP_ID, VERSION, COMPONENT_ID, USER);
+ Collection<ListComputeResponse> computes =
+ computeManager.listComputes(VSP_ID, VERSION, COMPONENT_ID);
Assert.assertEquals(computes.size(), 0);
}
@Test
- public void testList(){
- doReturn(Arrays.asList(
+ public void testList() {
+ doReturn(Arrays.asList(
createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID),
createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE2_ID)))
- .when(computeDao).list(anyObject());
+ .when(computeDao).list(anyObject());
- Collection<ListComputeResponse> computes = computeManager.listCompute(VSP_ID, VERSION, COMPONENT_ID, USER);
- Assert.assertEquals(computes.size(), 2);
- for (ListComputeResponse compute : computes) {
- Assert.assertEquals(compute.getComputeEntity().getComputeCompositionData().getName(),
- COMPUTE1_ID.equals(compute.getComputeEntity().getId())
- ? "compute1name"
- : "compute2name");
- };
+ Collection<ListComputeResponse> computes =
+ computeManager.listComputes(VSP_ID, VERSION, COMPONENT_ID);
+ Assert.assertEquals(computes.size(), 2);
+ for (ListComputeResponse compute : computes) {
+ Assert.assertEquals(compute.getComputeEntity().getComputeCompositionData().getName(),
+ COMPUTE1_ID.equals(compute.getComputeEntity().getId())
+ ? "compute1name"
+ : "compute2name");
+ }
}
- @Test
- public void testCreateOnNotManualCompute_negative() {
-
- testCreate_negative(new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, null), USER,
- VendorSoftwareProductErrorCodes.ADD_COMPUTE_NOT_ALLOWED_IN_HEAT_ONBOARDING);
- }
-
- @Test
- public void testCreateManualCompute() {
- ComputeEntity expected = createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
- computeManager.createCompute(expected, USER);
- verify(compositionEntityDataManagerMock).createCompute(expected);
- verify(compositionEntityDataManagerMock).createCompute(expected);
- }
-
- @Test
- public void testCreateManualComputeWithDuplicateName() {
- ComputeEntity expected = createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
-
- ComputeEntity expectedDiffName = createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
- expectedDiffName.setId(COMPUTE1_ID + "Name");
- ComputeData computeData = expectedDiffName.getComputeCompositionData();
- computeData.setName(COMPUTE1_ID + "Name");
- expectedDiffName.setComputeCompositionData(computeData);
- List<ComputeEntity> vfcImageList = new ArrayList<ComputeEntity>();
- vfcImageList.add(expectedDiffName);
- doReturn(vfcImageList).when(computeDao).list(anyObject());
-
- try {
- computeManager.createCompute(expected, USER);
- Assert.fail();
- }
- catch (CoreException ex) {
- log.debug("",ex);
- Assert.assertEquals(VendorSoftwareProductErrorCodes.DUPLICATE_COMPUTE_NAME_NOT_ALLOWED,
- ex.code().id());
- }
- }
-
- @Test
- public void testUpdateNonExistingComputeId_negative() {
-
- testUpdate_negative(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID, USER,
- VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
- }
-
- @Test
- public void testUpdateCompute() {
- doReturn(createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID))
- .when(computeDao).get(anyObject());
-
- doReturn(new CompositionEntityValidationData(CompositionEntityType.compute, COMPUTE1_ID))
- .when(compositionEntityDataManagerMock)
- .validateEntity(anyObject(), anyObject(), anyObject());
-
- ComputeEntity computeEntity = new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
- ComputeData computeData = new ComputeData();
- computeData.setName(COMPUTE1_ID + "name");
- computeData.setDescription(COMPUTE1_ID + "desc updated");
- computeEntity.setComputeCompositionData(computeData);
-
- CompositionEntityValidationData validationData =
- computeManager.updateCompute(computeEntity, USER);
- Assert.assertTrue(validationData == null || validationData.getErrors() == null);
- verify(computeDao).update(computeEntity);
- }
-
- @Test
- public void testIllegalComputeUpdate() {
- doReturn(createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID))
- .when(computeDao).get(anyObject());
-
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
-
- CompositionEntityValidationData toBeReturned =
- new CompositionEntityValidationData(CompositionEntityType.compute, COMPUTE1_ID);
- toBeReturned.setErrors(Arrays.asList("error1", "error2"));
- doReturn(toBeReturned)
- .when(compositionEntityDataManagerMock)
- .validateEntity(anyObject(), anyObject(), anyObject());
-
- ComputeEntity computeEntity = new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
- ComputeData computeData = new ComputeData();
- computeData.setName(COMPUTE1_ID + "_name_updated");
- computeData.setDescription(COMPUTE1_ID + " desc updated");
- computeEntity.setComputeCompositionData(computeData);
-
- CompositionEntityValidationData validationData = computeManager.updateCompute(computeEntity, USER);
- Assert.assertNotNull(validationData);
- Assert.assertEquals(validationData.getErrors().size(), 2);
-
- verify(computeDao, never()).update(computeEntity);
- }
-
- @Test
- public void testUpdateHEATComputeName() throws Exception {
- doReturn(createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID))
- .when(computeDao).get(anyObject());
- ComputeEntity computeEntity = new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
- ComputeData computeData = new ComputeData();
- computeData.setName(COMPUTE1_ID + " name updated");
- computeData.setDescription(COMPUTE1_ID + " desc updated");
- computeEntity.setComputeCompositionData(computeData);
-
- try {
- computeManager.updateCompute(computeEntity, USER);
- }
- catch (CoreException ex) {
- log.debug("",ex);
- Assert.assertEquals(ex.code().id(), VendorSoftwareProductErrorCodes.UPDATE_COMPUTE_NOT_ALLOWED);
- }
-
- }
-
- @Test
- public void testUpdateManualComputeQuestionnaire() throws Exception {
- String json = "{\"md5\" :\"FFDSD33SS\"}";
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
- doReturn(new ComputeEntity(null,null,null,null)).when(computeDao).get(anyObject());
-
- computeManager.updateComputeQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID, json, USER);
- verify(computeDao).updateQuestionnaireData(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID, json);
- }
-
- @Test
- public void testGetNonExistingComputeId_negative() {
- testGet_negative(VSP_ID, VERSION, COMPONENT_ID, "non existing compute id", USER,
- VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
- }
-
- @Test
- public void testGet() {
- ComputeEntity expected = createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
- doReturn(expected).when(computeDao).get(anyObject());
- String compositionSchema = "schema string";
- doReturn(compositionSchema).when(computeManager).getComputeCompositionSchema(anyObject());
-
- CompositionEntityResponse<ComputeData> response =
- computeManager.getCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID, USER);
- Assert.assertEquals(response.getId(), expected.getId());
- Assert.assertEquals(response.getData().getName(), expected.getComputeCompositionData().getName());
- Assert.assertEquals(response.getData().getDescription(), expected.getComputeCompositionData().
- getDescription());
- Assert.assertEquals(response.getSchema(), compositionSchema);
- }
-
- @Test
- public void testGetQuestionnaire() throws Exception {
- ComputeEntity compute = new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
- compute.setQuestionnaireData("{}");
- doReturn(compute).when(computeDao).getQuestionnaireData(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
-
- String schema = "schema string";
-
-
- doReturn(schema).when(computeManager).getComputeQuestionnaireSchema(anyObject());
-
- QuestionnaireResponse questionnaire =
- computeManager.getComputeQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID, USER);
-
- Assert.assertNotNull(questionnaire);
- Assert.assertEquals(questionnaire.getData(), compute.getQuestionnaireData());
- Assert.assertEquals(questionnaire.getSchema(), schema);
- Assert.assertNull(questionnaire.getErrorMessage());
- }
-
- @Test
- public void testDeleteOnNotManualCompute() {
- ComputeEntity expected = createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
- doReturn(expected).when(computeDao).get(anyObject());
- testDelete_negative(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID, USER,
- VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED);
- }
-
- @Test
- public void testDeleteOnManualCompute() {
- ComputeEntity expected = createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
- doReturn(expected).when(computeDao).get(anyObject());
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
- computeManager.deleteCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID, USER);
- verify(computeDao).delete(anyObject());
- }
-
- @Test
- public void testDeleteOnNotExistCompute() {
- testDelete_negative(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID, USER,
- VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED);
- }
-
-
- private void testDelete_negative(String vspId, Version version, String componentId, String computeId,
- String user,
- String expectedErrorCode) {
- try {
- computeManager.deleteCompute(vspId, version, componentId, computeId, user);
- Assert.fail();
- } catch (CoreException exception) {
- log.debug("",exception);
- Assert.assertEquals(exception.code().id(), expectedErrorCode);
- }
- }
-
- private void testGet_negative(String vspId, Version version, String componentId, String computeId,
- String user, String expectedErrorCode) {
- try {
- computeManager.getCompute(vspId, version, componentId, computeId, user);
- Assert.fail();
- } catch (CoreException exception) {
- log.debug("",exception);
- Assert.assertEquals(exception.code().id(), expectedErrorCode);
- }
+ @Test
+ public void testCreateOnNotManualCompute_negative() {
+ testCreate_negative(new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, null),
+ VendorSoftwareProductErrorCodes.ADD_COMPUTE_NOT_ALLOWED_IN_HEAT_ONBOARDING);
}
- private void testList_negative(String vspId, Version version, String componentId, String user,
- String expectedErrorCode, String expectedErrorMsg) {
- try {
- computeManager.listCompute(vspId, version, componentId, user);
- Assert.fail();
- } catch (CoreException exception) {
- log.debug("",exception);
- Assert.assertEquals(exception.code().id(), expectedErrorCode);
- Assert.assertEquals(exception.getMessage(), expectedErrorMsg);
- }
+ @Test
+ public void testCreateManualCompute() {
+ ComputeEntity expected = createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
+ doNothing().when(computeManager)
+ .validateUniqueName(VSP_ID, VERSION, COMPONENT_ID,
+ expected.getComputeCompositionData().getName());
+ doNothing().when(computeManager)
+ .createUniqueName(VSP_ID, VERSION, COMPONENT_ID,
+ expected.getComputeCompositionData().getName());
+ String questionnaireSchema = "{}";
+ doReturn(questionnaireSchema).when(computeManager).getComputeQuestionnaireSchema(anyObject());
+
+ computeManager.createCompute(expected);
+ verify(computeDao).create(expected);
+ }
+
+ @Test(expectedExceptions = CoreException.class)
+ public void testCreateManualComputeWithDuplicateName() {
+ ComputeEntity expected = createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
+
+ doThrow(new CoreException(
+ new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION).build()))
+ .when(computeManager).validateUniqueName(VSP_ID, VERSION, COMPONENT_ID,
+ expected.getComputeCompositionData().getName());
+
+ computeManager.createCompute(expected);
+ }
+
+ @Test
+ public void testUpdateNonExistingComputeId_negative() {
+ testUpdate_negative(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID,
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ }
+
+ @Test
+ public void testUpdateCompute() {
+ ComputeEntity retrieved = createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ doReturn(retrieved).when(computeDao).get(anyObject());
+
+ doReturn(new CompositionEntityValidationData(CompositionEntityType.compute, COMPUTE1_ID))
+ .when(compositionEntityDataManagerMock)
+ .validateEntity(anyObject(), anyObject(), anyObject());
+
+ ComputeEntity computeEntity = new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ ComputeData computeData = new ComputeData();
+ computeData.setName(COMPUTE1_ID + "name");
+ computeData.setDescription(COMPUTE1_ID + "desc updated");
+ computeEntity.setComputeCompositionData(computeData);
+
+ doNothing().when(computeManager)
+ .updateUniqueName(VSP_ID, VERSION, COMPONENT_ID, retrieved.getComputeCompositionData().getName(),
+ computeData.getName());
+
+ CompositionEntityValidationData validationData =
+ computeManager.updateCompute(computeEntity);
+ Assert.assertTrue(validationData == null || validationData.getErrors() == null);
+ verify(computeDao).update(computeEntity);
+ }
+
+ @Test
+ public void testIllegalComputeUpdate() {
+ doReturn(createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID))
+ .when(computeDao).get(anyObject());
+
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
+
+ CompositionEntityValidationData toBeReturned =
+ new CompositionEntityValidationData(CompositionEntityType.compute, COMPUTE1_ID);
+ toBeReturned.setErrors(Arrays.asList("error1", "error2"));
+ doReturn(toBeReturned)
+ .when(compositionEntityDataManagerMock)
+ .validateEntity(anyObject(), anyObject(), anyObject());
+
+ ComputeEntity computeEntity = new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ ComputeData computeData = new ComputeData();
+ computeData.setName(COMPUTE1_ID + "_name_updated");
+ computeData.setDescription(COMPUTE1_ID + " desc updated");
+ computeEntity.setComputeCompositionData(computeData);
+
+ CompositionEntityValidationData validationData =
+ computeManager.updateCompute(computeEntity);
+ Assert.assertNotNull(validationData);
+ Assert.assertEquals(validationData.getErrors().size(), 2);
+
+ verify(computeDao, never()).update(computeEntity);
+ }
+
+ @Test
+ public void testUpdateHEATComputeName() throws Exception {
+ doReturn(createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID))
+ .when(computeDao).get(anyObject());
+ ComputeEntity computeEntity = new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ ComputeData computeData = new ComputeData();
+ computeData.setName(COMPUTE1_ID + " name updated");
+ computeData.setDescription(COMPUTE1_ID + " desc updated");
+ computeEntity.setComputeCompositionData(computeData);
+
+ try {
+ computeManager.updateCompute(computeEntity);
+ } catch (CoreException ex) {
+ Assert
+ .assertEquals(ex.code().id(), VendorSoftwareProductErrorCodes.UPDATE_COMPUTE_NOT_ALLOWED);
}
+ }
+
+ @Test
+ public void testUpdateManualComputeQuestionnaire() throws Exception {
+ String json = "{\"md5\" :\"FFDSD33SS\"}";
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
+ doReturn(new ComputeEntity(null, null, null, null)).when(computeDao).get(anyObject());
+
+ computeManager
+ .updateComputeQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID, json);
+ verify(computeDao).updateQuestionnaireData(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID, json);
+ }
+
+ @Test
+ public void testGetNonExistingComputeId_negative() {
+ testGet_negative(VSP_ID, VERSION, COMPONENT_ID, "non existing compute id",
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ }
+
+ @Test
+ public void testGet() {
+ ComputeEntity expected = createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ doReturn(expected).when(computeDao).get(anyObject());
+ String compositionSchema = "schema string";
+ doReturn(compositionSchema).when(computeManager).getComputeCompositionSchema(anyObject());
+
+ CompositionEntityResponse<ComputeData> response =
+ computeManager.getCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ Assert.assertEquals(response.getId(), expected.getId());
+ Assert
+ .assertEquals(response.getData().getName(), expected.getComputeCompositionData().getName());
+ Assert.assertEquals(response.getData().getDescription(), expected.getComputeCompositionData().
+ getDescription());
+ Assert.assertEquals(response.getSchema(), compositionSchema);
+ }
+
+ @Test
+ public void testGetQuestionnaire() throws Exception {
+ ComputeEntity compute = new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ compute.setQuestionnaireData("{}");
+ doReturn(compute).when(computeDao)
+ .getQuestionnaireData(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+
+ String schema = "schema string";
+
+ doReturn(schema).when(computeManager).getComputeQuestionnaireSchema(anyObject());
+
+ QuestionnaireResponse questionnaire =
+ computeManager.getComputeQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+
+ Assert.assertNotNull(questionnaire);
+ Assert.assertEquals(questionnaire.getData(), compute.getQuestionnaireData());
+ Assert.assertEquals(questionnaire.getSchema(), schema);
+ Assert.assertNull(questionnaire.getErrorMessage());
+ }
+
+ @Test
+ public void testDeleteOnNotManualCompute() {
+ ComputeEntity expected = createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ doReturn(expected).when(computeDao).get(anyObject());
+ testDelete_negative(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID,
+ VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED);
+ }
+
+ @Test
+ public void testDeleteOnManualCompute() {
+ ComputeEntity expected = createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ doReturn(expected).when(computeDao).get(anyObject());
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
+ doNothing().when(computeManager).deleteUniqueValue(VSP_ID, VERSION, COMPONENT_ID,
+ expected.getComputeCompositionData().getName());
+
+ computeManager.deleteCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ verify(computeDao).delete(anyObject());
+ }
+
+ @Test
+ public void testDeleteOnNotExistCompute() {
+ testDelete_negative(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID,
+ VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED);
+ }
-
- private void testUpdate_negative(String vspId, Version version, String componentId, String computeId,
- String user, String expectedErrorCode) {
- try {
- computeManager.updateCompute(new ComputeEntity(vspId, version, componentId, computeId), user);
- Assert.fail();
- } catch (CoreException exception) {
- log.debug("",exception);
+ private void testDelete_negative(String vspId, Version version, String componentId,
+ String computeId,
+ String expectedErrorCode) {
+ try {
+ computeManager.deleteCompute(vspId, version, componentId, computeId);
+ Assert.fail();
+ } catch (CoreException exception) {
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
- private void testCreate_negative(ComputeEntity computeEntity1, String user, String expectedErrorCode) {
- try {
- computeManager.createCompute(computeEntity1, user);
- Assert.fail();
- } catch (CoreException exception) {
- log.debug("",exception);
- Assert.assertEquals(exception.code().id(), expectedErrorCode);
- }
+ private void testGet_negative(String vspId, Version version, String componentId, String computeId,
+ String expectedErrorCode) {
+ try {
+ computeManager.getCompute(vspId, version, componentId, computeId);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
+ }
- static ComputeEntity createCompute(String vspId, Version version, String compId, String computeId){
- ComputeEntity computeEntity1 = new ComputeEntity(vspId, version, compId, computeId);
- ComputeData computeData = new ComputeData();
- computeData.setName(computeId+"name");
- computeData.setDescription(computeId+"desc");
- computeEntity1.setComputeCompositionData(computeData);
- return computeEntity1;
+ private void testList_negative(String vspId, Version version, String componentId,
+ String expectedErrorCode, String expectedErrorMsg) {
+ try {
+ computeManager.listComputes(vspId, version, componentId);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ Assert.assertEquals(exception.getMessage(), expectedErrorMsg);
+ }
+ }
+
+
+ private void testUpdate_negative(String vspId, Version version, String componentId,
+ String computeId, String expectedErrorCode) {
+ try {
+ computeManager.updateCompute(new ComputeEntity(vspId, version, componentId, computeId));
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ }
+ }
+
+ private void testCreate_negative(ComputeEntity computeEntity1, String expectedErrorCode) {
+ try {
+ computeManager.createCompute(computeEntity1);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ }
+ }
+
+ private static ComputeEntity createCompute(String vspId, Version version, String compId,
+ String computeId) {
+ ComputeEntity computeEntity1 = new ComputeEntity(vspId, version, compId, computeId);
+ ComputeData computeData = new ComputeData();
+ computeData.setName(computeId + "name");
+ computeData.setDescription(computeId + "desc");
+ computeEntity1.setComputeCompositionData(computeData);
+ return computeEntity1;
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeplomentFlavorManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeplomentFlavorManagerImplTest.java
deleted file mode 100644
index 598b97b..0000000
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeplomentFlavorManagerImplTest.java
+++ /dev/null
@@ -1,463 +0,0 @@
-package org.openecomp.sdc.vendorsoftwareproduct.impl;
-
-
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.verify;
-
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.mockito.Spy;
-import org.openecomp.core.utilities.json.JsonUtil;
-import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
-import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes;
-import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
-import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.errors.VersioningErrorCodes;
-import org.testng.Assert;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-
-public class DeplomentFlavorManagerImplTest {
- private static final String USER = "depFlavorTestUser";
- private static final String VSP_ID = "VSP_ID";
- private static final Version VERSION = new Version(0, 1);
- private static final String COMPONENT_ID = "COMPONENT_ID";
- private static final String DF1_ID = "df1";
- private static final String DF2_ID = "df2";
-
- @Mock
- private CompositionEntityDataManager compositionEntityDataManagerMock;
- @Mock
- private VendorSoftwareProductInfoDao vspInfoDao;
- @Mock
- DeploymentFlavorDao deploymentFlavorDaoMock;
- @Mock
- ComponentDao componentDaoMock;
- @Mock
- ComputeDao computeDaoMock;
- @InjectMocks
- @Spy
- private DeploymentFlavorManagerImpl deploymentFlavorManager;
-
- @BeforeMethod
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void testListWhenNone() {
- final Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
- deploymentFlavorManager.listDeploymentFlavors(VSP_ID, VERSION, USER);
- Assert.assertEquals(deploymentFlavorEntities.size(), 0);
- }
-
- @Test
- public void testCreateOnNotManual_negative() {
-
- testCreate_negative(new DeploymentFlavorEntity(VSP_ID, VERSION, null), USER,
- VendorSoftwareProductErrorCodes.CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
- }
-
- @Test
- public void testCreateManualDepFlavor() {
- DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
-
- VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
- doReturn(vspDetails).when(vspInfoDao).get(anyObject());
-
- deploymentFlavorManager.createDeploymentFlavor(expected, USER);
- verify(compositionEntityDataManagerMock).createDeploymentFlavor(expected);
- }
-
- @Test
- public void testCreateManualDepFlavorWithDuplicateName() {
- DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
-
- DeploymentFlavorEntity expectedDiffName = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
- DeploymentFlavor deploymentFlavor = expectedDiffName.getDeploymentFlavorCompositionData();
- deploymentFlavor.setModel(DF1_ID + "Name");
- expectedDiffName.setDeploymentFlavorCompositionData(deploymentFlavor);
- List<DeploymentFlavorEntity> list = new ArrayList<DeploymentFlavorEntity>();
- list.add(expectedDiffName);
- doReturn(list).when(deploymentFlavorDaoMock).list(anyObject());
-
- try {
- deploymentFlavorManager.createDeploymentFlavor(expected, USER);
- Assert.fail();
- }
- catch (CoreException ex) {
- Assert.assertEquals(VendorSoftwareProductErrorCodes.DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED,
- ex.code().id());
- }
- }
-
- @Test
- public void testCreateManualDepFlavorWithIncorrectNameFormat() {
- DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
-
- DeploymentFlavorEntity expectedDiffName = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
- DeploymentFlavor deploymentFlavor = expectedDiffName.getDeploymentFlavorCompositionData();
- deploymentFlavor.setModel(DF1_ID + "Name/*");
- expectedDiffName.setDeploymentFlavorCompositionData(deploymentFlavor);
- List<DeploymentFlavorEntity> list = new ArrayList<DeploymentFlavorEntity>();
- list.add(expectedDiffName);
- doReturn(list).when(deploymentFlavorDaoMock).list(anyObject());
-
- try {
- deploymentFlavorManager.createDeploymentFlavor(expectedDiffName, USER);
- Assert.fail();
- }
- catch (CoreException ex) {
- Assert.assertEquals(VendorSoftwareProductErrorCodes.DEPLOYMENT_FLAVOR_NAME_FORMAT_NOT_ALLOWED,
- ex.code().id());
- }
- }
- @Test
- public void testCreateManualDepFlavorWithFGNotInVSP() {
- DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
- final DeploymentFlavor deploymentFlavor =
- JsonUtil.json2Object(expected.getCompositionData(), DeploymentFlavor.class);
- deploymentFlavor.setFeatureGroupId("fg3");
- expected.setCompositionData(JsonUtil.object2Json(deploymentFlavor));
-
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
-
- List<String> featureGrps = new ArrayList<String>();
- featureGrps.add("fg1");
- featureGrps.add("fg2");
-
- VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
- vspDetails.setFeatureGroups(featureGrps);
- doReturn(vspDetails).when(vspInfoDao).get(anyObject());
-
-
- try {
- deploymentFlavorManager.createDeploymentFlavor(expected, USER);
- Assert.fail();
- }
- catch (CoreException ex) {
- Assert.assertEquals(VendorSoftwareProductErrorCodes.FEATURE_GROUP_NOT_EXIST_FOR_VSP,
- ex.code().id());
- }
- }
-
- @Test
- public void testCreateManualDepFlavorWithNullCompInAssociation() {
- DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
- final DeploymentFlavor deploymentFlavor =
- JsonUtil.json2Object(expected.getCompositionData(), DeploymentFlavor.class);
- ComponentComputeAssociation association = new ComponentComputeAssociation();
- association.setComponentId(null);
- association.setComputeFlavorId("CF1");
- List<ComponentComputeAssociation> list = new ArrayList<ComponentComputeAssociation>();
- list.add(association);
- deploymentFlavor.setComponentComputeAssociations(list);
- expected.setCompositionData(JsonUtil.object2Json(deploymentFlavor));
-
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
-
- VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
- doReturn(vspDetails).when(vspInfoDao).get(anyObject());
-
- try {
- deploymentFlavorManager.createDeploymentFlavor(expected, USER);
- }
- catch (CoreException ex) {
- Assert.assertEquals(VendorSoftwareProductErrorCodes.INVALID_COMPONENT_COMPUTE_ASSOCIATION,
- ex.code().id());
- Assert.assertEquals("Invalid request,for valid association please provide ComponentId for Compute Flavor",
- ex.getMessage());
- }
- }
-
- @Test
- public void testCreateManualDepFlavorWithInvalidComputeInAssociation() {
- DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
- final DeploymentFlavor deploymentFlavor =
- JsonUtil.json2Object(expected.getCompositionData(), DeploymentFlavor.class);
- ComponentComputeAssociation association = new ComponentComputeAssociation();
- association.setComponentId(COMPONENT_ID);
- association.setComputeFlavorId("CF1");
- List<ComponentComputeAssociation> list = new ArrayList<ComponentComputeAssociation>();
- list.add(association);
- deploymentFlavor.setComponentComputeAssociations(list);
- expected.setCompositionData(JsonUtil.object2Json(deploymentFlavor));
-
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
-
- VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
- doReturn(vspDetails).when(vspInfoDao).get(anyObject());
-
- ComponentEntity component = new ComponentEntity(VSP_ID, VERSION, USER);
- doReturn(component).when(componentDaoMock).get(anyObject());
-
- doReturn(null).when(computeDaoMock).get(anyObject());
-
- try {
- deploymentFlavorManager.createDeploymentFlavor(expected, USER);
- }
- catch (CoreException ex) {
- Assert.assertEquals(VendorSoftwareProductErrorCodes.INVALID_COMPUTE_FLAVOR_ID,
- ex.code().id());
- }
- }
-
- @Test
- public void testCreateManualDepFlavorWithDuplicateVfcAssociation() {
- DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
- final DeploymentFlavor deploymentFlavor =
- JsonUtil.json2Object(expected.getCompositionData(), DeploymentFlavor.class);
- ComponentComputeAssociation association = new ComponentComputeAssociation();
- association.setComponentId(COMPONENT_ID);
- association.setComputeFlavorId("CF1");
- List<ComponentComputeAssociation> list = new ArrayList<ComponentComputeAssociation>();
- list.add(association);
- list.add(association);
- deploymentFlavor.setComponentComputeAssociations(list);
- expected.setCompositionData(JsonUtil.object2Json(deploymentFlavor));
-
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
-
- VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
- doReturn(vspDetails).when(vspInfoDao).get(anyObject());
-
- ComponentEntity component = new ComponentEntity(VSP_ID, VERSION, USER);
- doReturn(component).when(componentDaoMock).get(anyObject());
-
- ComputeEntity computeEntity = new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, "CF1");
- doReturn(computeEntity).when(computeDaoMock).get(anyObject());
-
- try {
- deploymentFlavorManager.createDeploymentFlavor(expected, USER);
- }
- catch (CoreException ex) {
- Assert.assertEquals(VendorSoftwareProductErrorCodes.SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED,
- ex.code().id());
- }
- }
-
- @Test
- public void testList() {
-
- doReturn(Arrays.asList(
- createDeploymentFlavor(VSP_ID, VERSION, DF1_ID),
- createDeploymentFlavor(VSP_ID, VERSION, DF2_ID)))
- .when(deploymentFlavorDaoMock).list(anyObject());
-
-
- final Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
- deploymentFlavorManager.listDeploymentFlavors(VSP_ID, VERSION, USER);
- Assert.assertEquals(deploymentFlavorEntities.size(), 2);
- for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) {
- Assert.assertEquals(deploymentFlavorEntity.getDeploymentFlavorCompositionData().getModel()
- , DF1_ID.equals(deploymentFlavorEntity.getId()) ? DF1_ID+"name" : DF2_ID+"name" );
- }
- }
-
- @Test
- public void testUpdateHeatDepFlavor() {
- testUpdate_negative(VSP_ID, VERSION, DF1_ID, USER,
- VendorSoftwareProductErrorCodes.EDIT_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
- }
-
- @Test
- public void testUpdateNonExistingManualDepFlavorId_negative() {
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
- testUpdate_negative(VSP_ID, VERSION, DF1_ID, USER,
- VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
- }
-
- @Test
- public void testManualUpdateDepFlavor() {
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
-
- doReturn(createDeploymentFlavor(VSP_ID, VERSION, DF1_ID))
- .when(deploymentFlavorDaoMock).get(anyObject());
-
- doReturn(new CompositionEntityValidationData(CompositionEntityType.image, DF1_ID))
- .when(compositionEntityDataManagerMock)
- .validateEntity(anyObject(), anyObject(), anyObject());
-
- VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
- doReturn(vspDetails).when(vspInfoDao).get(anyObject());
-
- DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(VSP_ID, VERSION, DF1_ID);
- DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
- deploymentFlavor.setModel(DF1_ID + "_name");
- deploymentFlavor.setDescription(DF1_ID + " desc updated");
- deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
-
- CompositionEntityValidationData validationData =
- deploymentFlavorManager.updateDeploymentFlavor(deploymentFlavorEntity, USER);
- Assert.assertTrue(validationData == null || validationData.getErrors() == null);
- verify(deploymentFlavorDaoMock).update(deploymentFlavorEntity);
- }
-
- @Test
- public void testManualUpdateDepFlavorIncorrectNameFormat() {
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
-
- doReturn(createDeploymentFlavor(VSP_ID, VERSION, DF1_ID))
- .when(deploymentFlavorDaoMock).get(anyObject());
-
- doReturn(new CompositionEntityValidationData(CompositionEntityType.image, DF1_ID))
- .when(compositionEntityDataManagerMock)
- .validateEntity(anyObject(), anyObject(), anyObject());
-
- VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
- doReturn(vspDetails).when(vspInfoDao).get(anyObject());
-
- DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(VSP_ID, VERSION, DF1_ID);
- DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
- deploymentFlavor.setModel(DF1_ID + "_name/*");
- deploymentFlavor.setDescription(DF1_ID + " desc updated");
- deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
-
- try {
- deploymentFlavorManager.updateDeploymentFlavor(deploymentFlavorEntity, USER);
- Assert.fail();
- }
- catch (CoreException ex) {
- Assert.assertEquals(VendorSoftwareProductErrorCodes.DEPLOYMENT_FLAVOR_NAME_FORMAT_NOT_ALLOWED,
- ex.code().id());
- }
- }
-
- @Test
- public void testGetNonExistingDepFlavorId_negative() {
- testGet_negative(VSP_ID, VERSION, "non existing image id", USER,
- VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
- }
-
- @Test
- public void testGet() {
- DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
- doReturn(expected).when(deploymentFlavorDaoMock).get(anyObject());
-
- VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
- doReturn(vspDetails).when(vspInfoDao).get(anyObject());
-
- CompositionEntityResponse<DeploymentFlavor> response =
- deploymentFlavorManager.getDeploymentFlavor(VSP_ID, VERSION, DF1_ID, USER);
- Assert.assertEquals(response.getId(), expected.getId());
- Assert.assertEquals(response.getData().getModel(), expected.getDeploymentFlavorCompositionData().
- getModel());
- Assert.assertEquals(response.getData().getDescription(), expected.getDeploymentFlavorCompositionData().
- getDescription());
- }
-
- @Test
- public void testDeleteDepFlavorOnHEAT() {
- DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
- doReturn(expected).when(deploymentFlavorDaoMock).get(anyObject());
- testDelete_negative(VSP_ID, VERSION, DF1_ID, USER,
- VendorSoftwareProductErrorCodes.DELETE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
- }
-
- @Test
- public void testDeleteOnNotExistImage() {
- testDelete_negative(VSP_ID, VERSION, DF1_ID, USER,
- VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
- }
-
- @Test
- public void testDeleteOnManualImage() {
- DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
- doReturn(expected).when(deploymentFlavorDaoMock).get(anyObject());
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
- deploymentFlavorManager.deleteDeploymentFlavor(VSP_ID, VERSION, DF1_ID, USER);
- verify(deploymentFlavorDaoMock).delete(anyObject());
- }
-
- private void testList_negative(String vspId, Version version, String componentId, String user,
- String expectedErrorCode, String expectedErrorMsg) {
- try {
- deploymentFlavorManager.listDeploymentFlavors(vspId, version, user);
- Assert.fail();
- } catch (CoreException exception) {
- Assert.assertEquals(exception.code().id(), expectedErrorCode);
- Assert.assertEquals(exception.getMessage(), expectedErrorMsg);
- }
- }
-
- private void testCreate_negative(DeploymentFlavorEntity deploymentFlavorEntity, String user, String
- expectedErrorCode) {
- try {
- deploymentFlavorManager.createDeploymentFlavor(deploymentFlavorEntity, user);
- Assert.fail();
- } catch (CoreException exception) {
- Assert.assertEquals(exception.code().id(), expectedErrorCode);
- }
- }
-
- private void testDelete_negative(String vspId, Version version, String deploymentFlavorId,
- String user,
- String expectedErrorCode) {
- try {
- deploymentFlavorManager.deleteDeploymentFlavor(vspId, version, deploymentFlavorId, user);
- Assert.fail();
- } catch (CoreException exception) {
- Assert.assertEquals(exception.code().id(), expectedErrorCode);
- }
- }
-
- static DeploymentFlavorEntity createDeploymentFlavor(String vspId, Version version, String deploymentFlavorId) {
-
- DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(vspId, version, deploymentFlavorId);
- DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
- deploymentFlavor.setModel(deploymentFlavorId + "name");
- deploymentFlavor.setDescription(deploymentFlavorId + " desc");
-
- deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
- return deploymentFlavorEntity;
- }
-
- private void testUpdate_negative(String vspId, Version version, String
- deploymentFlavorId, String user, String expectedErrorCode) {
- try {
- DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(vspId, version, deploymentFlavorId);
- DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
- deploymentFlavor.setModel("Name");
- deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
- deploymentFlavorManager
- .updateDeploymentFlavor(deploymentFlavorEntity, user);
- Assert.fail();
- } catch (CoreException exception) {
- Assert.assertEquals(exception.code().id(), expectedErrorCode);
- }
- }
-
- private void testGet_negative(String vspId, Version version, String deploymentFlavorId,
- String user, String expectedErrorCode) {
- try {
- deploymentFlavorManager.getDeploymentFlavor(vspId, version, deploymentFlavorId, user);
- Assert.fail();
- } catch (CoreException exception) {
- Assert.assertEquals(exception.code().id(), expectedErrorCode);
- }
- }
-
-}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImplTest.java
index 82715d3..6a5e7fa 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImplTest.java
@@ -1,18 +1,12 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.verify;
-
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
@@ -23,7 +17,6 @@
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes;
import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
-import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
@@ -39,13 +32,13 @@
import java.util.Collection;
import java.util.List;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
+
public class DeploymentFlavorManagerImplTest {
-
- private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
-
- private static final String USER = "depFlavorTestUser";
private static final String VSP_ID = "VSP_ID";
- private static final Version VERSION = new Version(0, 1);
+ private static final Version VERSION = new Version("version_id");
private static final String COMPONENT_ID = "COMPONENT_ID";
private static final String DF1_ID = "df1";
private static final String DF2_ID = "df2";
@@ -55,11 +48,11 @@
@Mock
private VendorSoftwareProductInfoDao vspInfoDao;
@Mock
- DeploymentFlavorDao deploymentFlavorDaoMock;
+ private DeploymentFlavorDao deploymentFlavorDaoMock;
@Mock
- ComponentDao componentDaoMock;
+ private ComponentDao componentDaoMock;
@Mock
- ComputeDao computeDaoMock;
+ private ComputeDao computeDaoMock;
@InjectMocks
@Spy
private DeploymentFlavorManagerImpl deploymentFlavorManager;
@@ -72,26 +65,26 @@
@Test
public void testListWhenNone() {
final Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
- deploymentFlavorManager.listDeploymentFlavors(VSP_ID, VERSION, USER);
+ deploymentFlavorManager.listDeploymentFlavors(VSP_ID, VERSION);
Assert.assertEquals(deploymentFlavorEntities.size(), 0);
}
@Test
public void testCreateOnNotManual_negative() {
- testCreate_negative(new DeploymentFlavorEntity(VSP_ID, VERSION, null), USER,
+ testCreate_negative(new DeploymentFlavorEntity(VSP_ID, VERSION, null),
VendorSoftwareProductErrorCodes.CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
}
@Test
public void testCreateManualDepFlavor() {
- DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
+ DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
doReturn(vspDetails).when(vspInfoDao).get(anyObject());
- deploymentFlavorManager.createDeploymentFlavor(expected, USER);
+ deploymentFlavorManager.createDeploymentFlavor(expected);
verify(compositionEntityDataManagerMock).createDeploymentFlavor(expected);
}
@@ -104,17 +97,16 @@
DeploymentFlavor deploymentFlavor = expectedDiffName.getDeploymentFlavorCompositionData();
deploymentFlavor.setModel(DF1_ID + "Name");
expectedDiffName.setDeploymentFlavorCompositionData(deploymentFlavor);
- List<DeploymentFlavorEntity> list = new ArrayList<DeploymentFlavorEntity>();
+ List<DeploymentFlavorEntity> list = new ArrayList<>();
list.add(expectedDiffName);
doReturn(list).when(deploymentFlavorDaoMock).list(anyObject());
try {
- deploymentFlavorManager.createDeploymentFlavor(expected, USER);
+ deploymentFlavorManager.createDeploymentFlavor(expected);
Assert.fail();
- }
- catch (CoreException ex) {
- log.debug("",ex);
- Assert.assertEquals(VendorSoftwareProductErrorCodes.DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED,
+ } catch (CoreException ex) {
+ Assert.assertEquals(
+ VendorSoftwareProductErrorCodes.DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED,
ex.code().id());
}
}
@@ -129,7 +121,7 @@
doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
- List<String> featureGrps = new ArrayList<String>();
+ List<String> featureGrps = new ArrayList<>();
featureGrps.add("fg1");
featureGrps.add("fg2");
@@ -139,11 +131,9 @@
try {
- deploymentFlavorManager.createDeploymentFlavor(expected, USER);
+ deploymentFlavorManager.createDeploymentFlavor(expected);
Assert.fail();
- }
- catch (CoreException ex) {
- log.debug("",ex);
+ } catch (CoreException ex) {
Assert.assertEquals(VendorSoftwareProductErrorCodes.FEATURE_GROUP_NOT_EXIST_FOR_VSP,
ex.code().id());
}
@@ -151,13 +141,13 @@
@Test
public void testCreateManualDepFlavorWithNullCompInAssociation() {
- DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
+ DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
final DeploymentFlavor deploymentFlavor =
JsonUtil.json2Object(expected.getCompositionData(), DeploymentFlavor.class);
ComponentComputeAssociation association = new ComponentComputeAssociation();
association.setComponentId(null);
association.setComputeFlavorId("CF1");
- List<ComponentComputeAssociation> list = new ArrayList<ComponentComputeAssociation>();
+ List<ComponentComputeAssociation> list = new ArrayList<>();
list.add(association);
deploymentFlavor.setComponentComputeAssociations(list);
expected.setCompositionData(JsonUtil.object2Json(deploymentFlavor));
@@ -168,26 +158,25 @@
doReturn(vspDetails).when(vspInfoDao).get(anyObject());
try {
- deploymentFlavorManager.createDeploymentFlavor(expected, USER);
- }
- catch (CoreException ex) {
- log.debug("",ex);
+ deploymentFlavorManager.createDeploymentFlavor(expected);
+ } catch (CoreException ex) {
Assert.assertEquals(VendorSoftwareProductErrorCodes.INVALID_COMPONENT_COMPUTE_ASSOCIATION,
ex.code().id());
- Assert.assertEquals("Invalid request,for valid association please provide ComponentId for Compute Flavor",
+ Assert.assertEquals(
+ "Invalid request,for valid association please provide ComponentId for Compute Flavor",
ex.getMessage());
}
}
@Test
public void testCreateManualDepFlavorWithInvalidComputeInAssociation() {
- DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
+ DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
final DeploymentFlavor deploymentFlavor =
JsonUtil.json2Object(expected.getCompositionData(), DeploymentFlavor.class);
ComponentComputeAssociation association = new ComponentComputeAssociation();
association.setComponentId(COMPONENT_ID);
association.setComputeFlavorId("CF1");
- List<ComponentComputeAssociation> list = new ArrayList<ComponentComputeAssociation>();
+ List<ComponentComputeAssociation> list = new ArrayList<>();
list.add(association);
deploymentFlavor.setComponentComputeAssociations(list);
expected.setCompositionData(JsonUtil.object2Json(deploymentFlavor));
@@ -197,16 +186,14 @@
VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
doReturn(vspDetails).when(vspInfoDao).get(anyObject());
- ComponentEntity component = new ComponentEntity(VSP_ID, VERSION, USER);
+ ComponentEntity component = new ComponentEntity(VSP_ID, VERSION, null);
doReturn(component).when(componentDaoMock).get(anyObject());
doReturn(null).when(computeDaoMock).get(anyObject());
try {
- deploymentFlavorManager.createDeploymentFlavor(expected, USER);
- }
- catch (CoreException ex) {
- log.debug("",ex);
+ deploymentFlavorManager.createDeploymentFlavor(expected);
+ } catch (CoreException ex) {
Assert.assertEquals(VendorSoftwareProductErrorCodes.INVALID_COMPUTE_FLAVOR_ID,
ex.code().id());
}
@@ -214,13 +201,13 @@
@Test
public void testCreateManualDepFlavorWithDuplicateVfcAssociation() {
- DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
+ DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
final DeploymentFlavor deploymentFlavor =
JsonUtil.json2Object(expected.getCompositionData(), DeploymentFlavor.class);
ComponentComputeAssociation association = new ComponentComputeAssociation();
association.setComponentId(COMPONENT_ID);
association.setComputeFlavorId("CF1");
- List<ComponentComputeAssociation> list = new ArrayList<ComponentComputeAssociation>();
+ List<ComponentComputeAssociation> list = new ArrayList<>();
list.add(association);
list.add(association);
deploymentFlavor.setComponentComputeAssociations(list);
@@ -231,18 +218,17 @@
VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
doReturn(vspDetails).when(vspInfoDao).get(anyObject());
- ComponentEntity component = new ComponentEntity(VSP_ID, VERSION, USER);
+ ComponentEntity component = new ComponentEntity(VSP_ID, VERSION, null);
doReturn(component).when(componentDaoMock).get(anyObject());
ComputeEntity computeEntity = new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, "CF1");
doReturn(computeEntity).when(computeDaoMock).get(anyObject());
try {
- deploymentFlavorManager.createDeploymentFlavor(expected, USER);
- }
- catch (CoreException ex) {
- log.debug("",ex);
- Assert.assertEquals(VendorSoftwareProductErrorCodes.SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED,
+ deploymentFlavorManager.createDeploymentFlavor(expected);
+ } catch (CoreException ex) {
+ Assert.assertEquals(
+ VendorSoftwareProductErrorCodes.SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED,
ex.code().id());
}
}
@@ -251,30 +237,30 @@
public void testList() {
doReturn(Arrays.asList(
- createDeploymentFlavor(VSP_ID, VERSION, DF1_ID),
- createDeploymentFlavor(VSP_ID, VERSION, DF2_ID)))
+ createDeploymentFlavor(VSP_ID, VERSION, DF1_ID),
+ createDeploymentFlavor(VSP_ID, VERSION, DF2_ID)))
.when(deploymentFlavorDaoMock).list(anyObject());
final Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
- deploymentFlavorManager.listDeploymentFlavors(VSP_ID, VERSION, USER);
+ deploymentFlavorManager.listDeploymentFlavors(VSP_ID, VERSION);
Assert.assertEquals(deploymentFlavorEntities.size(), 2);
for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) {
Assert.assertEquals(deploymentFlavorEntity.getDeploymentFlavorCompositionData().getModel()
- , DF1_ID.equals(deploymentFlavorEntity.getId()) ? DF1_ID+"name" : DF2_ID+"name" );
+ , DF1_ID.equals(deploymentFlavorEntity.getId()) ? DF1_ID + "name" : DF2_ID + "name");
}
}
@Test
public void testUpdateHeatDepFlavor() {
- testUpdate_negative(VSP_ID, VERSION, DF1_ID, USER,
+ testUpdate_negative(VSP_ID, VERSION, DF1_ID,
VendorSoftwareProductErrorCodes.EDIT_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
}
@Test
public void testUpdateNonExistingManualDepFlavorId_negative() {
doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
- testUpdate_negative(VSP_ID, VERSION, DF1_ID, USER,
+ testUpdate_negative(VSP_ID, VERSION, DF1_ID,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
@@ -292,21 +278,22 @@
VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
doReturn(vspDetails).when(vspInfoDao).get(anyObject());
- DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(VSP_ID, VERSION, DF1_ID);
+ DeploymentFlavorEntity deploymentFlavorEntity =
+ new DeploymentFlavorEntity(VSP_ID, VERSION, DF1_ID);
DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
deploymentFlavor.setModel(DF1_ID + "_name");
deploymentFlavor.setDescription(DF1_ID + " desc updated");
deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
CompositionEntityValidationData validationData =
- deploymentFlavorManager.updateDeploymentFlavor(deploymentFlavorEntity, USER);
+ deploymentFlavorManager.updateDeploymentFlavor(deploymentFlavorEntity);
Assert.assertTrue(validationData == null || validationData.getErrors() == null);
verify(deploymentFlavorDaoMock).update(deploymentFlavorEntity);
}
@Test
public void testGetNonExistingDepFlavorId_negative() {
- testGet_negative(VSP_ID, VERSION, "non existing image id", USER,
+ testGet_negative(VSP_ID, VERSION, "non existing image id",
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
@@ -320,25 +307,27 @@
doReturn(vspDetails).when(vspInfoDao).get(anyObject());
CompositionEntityResponse<DeploymentFlavor> response =
- deploymentFlavorManager.getDeploymentFlavor(VSP_ID, VERSION, DF1_ID, USER);
+ deploymentFlavorManager.getDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
Assert.assertEquals(response.getId(), expected.getId());
- Assert.assertEquals(response.getData().getModel(), expected.getDeploymentFlavorCompositionData().
- getModel());
- Assert.assertEquals(response.getData().getDescription(), expected.getDeploymentFlavorCompositionData().
- getDescription());
+ Assert
+ .assertEquals(response.getData().getModel(), expected.getDeploymentFlavorCompositionData().
+ getModel());
+ Assert.assertEquals(response.getData().getDescription(),
+ expected.getDeploymentFlavorCompositionData().
+ getDescription());
}
*/
@Test
public void testDeleteDepFlavorOnHEAT() {
DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
doReturn(expected).when(deploymentFlavorDaoMock).get(anyObject());
- testDelete_negative(VSP_ID, VERSION, DF1_ID, USER,
+ testDelete_negative(VSP_ID, VERSION, DF1_ID,
VendorSoftwareProductErrorCodes.DELETE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
}
@Test
public void testDeleteOnNotExistImage() {
- testDelete_negative(VSP_ID, VERSION, DF1_ID, USER,
+ testDelete_negative(VSP_ID, VERSION, DF1_ID,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
@@ -347,48 +336,35 @@
DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
doReturn(expected).when(deploymentFlavorDaoMock).get(anyObject());
doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
- deploymentFlavorManager.deleteDeploymentFlavor(VSP_ID, VERSION, DF1_ID, USER);
+ deploymentFlavorManager.deleteDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
verify(deploymentFlavorDaoMock).delete(anyObject());
}
- private void testList_negative(String vspId, Version version, String componentId, String user,
- String expectedErrorCode, String expectedErrorMsg) {
+ private void testCreate_negative(DeploymentFlavorEntity deploymentFlavorEntity,
+ String expectedErrorCode) {
try {
- deploymentFlavorManager.listDeploymentFlavors(vspId, version, user);
+ deploymentFlavorManager.createDeploymentFlavor(deploymentFlavorEntity);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
- Assert.assertEquals(exception.code().id(), expectedErrorCode);
- Assert.assertEquals(exception.getMessage(), expectedErrorMsg);
- }
- }
-
- private void testCreate_negative(DeploymentFlavorEntity deploymentFlavorEntity, String user, String
- expectedErrorCode) {
- try {
- deploymentFlavorManager.createDeploymentFlavor(deploymentFlavorEntity, user);
- Assert.fail();
- } catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
private void testDelete_negative(String vspId, Version version, String deploymentFlavorId,
- String user,
String expectedErrorCode) {
try {
- deploymentFlavorManager.deleteDeploymentFlavor(vspId, version, deploymentFlavorId, user);
+ deploymentFlavorManager.deleteDeploymentFlavor(vspId, version, deploymentFlavorId);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
- static DeploymentFlavorEntity createDeploymentFlavor(String vspId, Version version, String deploymentFlavorId) {
+ private static DeploymentFlavorEntity createDeploymentFlavor(String vspId, Version version,
+ String deploymentFlavorId) {
- DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(vspId, version, deploymentFlavorId);
+ DeploymentFlavorEntity deploymentFlavorEntity =
+ new DeploymentFlavorEntity(vspId, version, deploymentFlavorId);
DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
deploymentFlavor.setModel(deploymentFlavorId + "name");
deploymentFlavor.setDescription(deploymentFlavorId + " desc");
@@ -397,29 +373,28 @@
return deploymentFlavorEntity;
}
- private void testUpdate_negative(String vspId, Version version, String
- deploymentFlavorId, String user, String expectedErrorCode) {
+ private void testUpdate_negative(String vspId, Version version, String deploymentFlavorId,
+ String expectedErrorCode) {
try {
- DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(vspId, version, deploymentFlavorId);
+ DeploymentFlavorEntity deploymentFlavorEntity =
+ new DeploymentFlavorEntity(vspId, version, deploymentFlavorId);
DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
deploymentFlavor.setModel("Name");
deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
deploymentFlavorManager
- .updateDeploymentFlavor(deploymentFlavorEntity, user);
+ .updateDeploymentFlavor(new DeploymentFlavorEntity(vspId, version, deploymentFlavorId));
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
private void testGet_negative(String vspId, Version version, String deploymentFlavorId,
- String user, String expectedErrorCode) {
+ String expectedErrorCode) {
try {
- deploymentFlavorManager.getDeploymentFlavor(vspId, version, deploymentFlavorId, user);
+ deploymentFlavorManager.getDeploymentFlavor(vspId, version, deploymentFlavorId);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImplTest.java
index 9f932b9..d9b4188 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImplTest.java
@@ -1,18 +1,11 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
@@ -29,21 +22,20 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.List;
+
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
public class ImageManagerImplTest {
- private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
-
private static final String IMAGE_NOT_EXIST_MSG =
- "Vendor Software Product Image with Id image1 does not exist for Vendor Software Product with" +
- " " +
- "id VSP_ID and version 0.1";
+ "Vendor Software Product Image with Id image1 does not exist for Vendor Software Product with" +
+ " id VSP_ID and version 0.1";
- private static final String USER = "imageTestUser";
private static final String VSP_ID = "VSP_ID";
private static final Version VERSION = new Version(0, 1);
private static final String COMPONENT_ID = "COMPONENT_ID";
@@ -68,7 +60,7 @@
@Test
public void testListWhenNone() {
final Collection<ImageEntity> imageEntities =
- imageManager.listImages(VSP_ID, VERSION, COMPONENT_ID, USER);
+ imageManager.listImages(VSP_ID, VERSION, COMPONENT_ID);
Assert.assertEquals(imageEntities.size(), 0);
}
@@ -76,32 +68,32 @@
public void testList() {
doReturn(Arrays.asList(
- createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID),
- createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE2_ID)))
- .when(imageDao).list(anyObject());
+ createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID),
+ createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE2_ID)))
+ .when(imageDao).list(anyObject());
final Collection<ImageEntity> images =
- imageManager.listImages(VSP_ID, VERSION, COMPONENT_ID, USER);
+ imageManager.listImages(VSP_ID, VERSION, COMPONENT_ID);
Assert.assertEquals(images.size(), 2);
for (ImageEntity image : images) {
Assert.assertEquals(image.getImageCompositionData().getFileName(),
- IMAGE1_ID.equals(image.getId()) ? IMAGE1_ID+"_name" : IMAGE2_ID+"_name" );
+ IMAGE1_ID.equals(image.getId()) ? IMAGE1_ID + "_name" : IMAGE2_ID + "_name");
}
}
@Test
public void testCreateOnNotManualImage_negative() {
- testCreate_negative(new ImageEntity(VSP_ID, VERSION, COMPONENT_ID, null), USER,
- VendorSoftwareProductErrorCodes.ADD_IMAGE_NOT_ALLOWED_IN_HEAT_ONBOARDING);
+ testCreate_negative(new ImageEntity(VSP_ID, VERSION, COMPONENT_ID, null),
+ VendorSoftwareProductErrorCodes.ADD_IMAGE_NOT_ALLOWED_IN_HEAT_ONBOARDING);
}
@Test
public void testCreateManualImage() {
ImageEntity expected = createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
- imageManager.createImage(expected, USER);
+ imageManager.createImage(expected);
verify(compositionEntityDataManagerMock).createImage(expected);
verify(compositionEntityDataManagerMock).createImage(expected);
}
@@ -115,14 +107,13 @@
Image image = expectedDiffName.getImageCompositionData();
image.setFileName(IMAGE1_ID + "_Name");
expectedDiffName.setImageCompositionData(image);
- List<ImageEntity> vfcImageList = new ArrayList<ImageEntity>();
+ List<ImageEntity> vfcImageList = new ArrayList<>();
vfcImageList.add(expectedDiffName);
doReturn(vfcImageList).when(imageDao).list(anyObject());
try {
- imageManager.createImage(expected, USER);
+ imageManager.createImage(expected);
Assert.fail();
- }
- catch (CoreException ex) {
+ } catch (CoreException ex) {
Assert.assertEquals(VendorSoftwareProductErrorCodes.DUPLICATE_IMAGE_NAME_NOT_ALLOWED,
ex.code().id());
}
@@ -130,18 +121,18 @@
@Test
public void testUpdateNonExistingImageId_negative() {
- testUpdate_negative(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, USER,
- VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ testUpdate_negative(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID,
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
@Test
public void testUpdateImage() {
doReturn(createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID))
- .when(imageDao).get(anyObject());
+ .when(imageDao).get(anyObject());
doReturn(new CompositionEntityValidationData(CompositionEntityType.image, IMAGE1_ID))
- .when(compositionEntityDataManagerMock)
- .validateEntity(anyObject(), anyObject(), anyObject());
+ .when(compositionEntityDataManagerMock)
+ .validateEntity(anyObject(), anyObject(), anyObject());
ImageEntity imageEntity = new ImageEntity(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
Image imageData = new Image();
@@ -150,7 +141,7 @@
imageEntity.setImageCompositionData(imageData);
CompositionEntityValidationData validationData =
- imageManager.updateImage(imageEntity, USER);
+ imageManager.updateImage(imageEntity);
Assert.assertTrue(validationData == null || validationData.getErrors() == null);
verify(imageDao).update(imageEntity);
}
@@ -158,16 +149,16 @@
@Test
public void testIllegalImageUpdate() {
doReturn(createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID))
- .when(imageDao).get(anyObject());
+ .when(imageDao).get(anyObject());
doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
CompositionEntityValidationData toBeReturned =
- new CompositionEntityValidationData(CompositionEntityType.image, IMAGE1_ID);
+ new CompositionEntityValidationData(CompositionEntityType.image, IMAGE1_ID);
toBeReturned.setErrors(Arrays.asList("error1", "error2"));
doReturn(toBeReturned)
- .when(compositionEntityDataManagerMock)
- .validateEntity(anyObject(), anyObject(), anyObject());
+ .when(compositionEntityDataManagerMock)
+ .validateEntity(anyObject(), anyObject(), anyObject());
ImageEntity imageEntity = new ImageEntity(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
Image imageData = new Image();
@@ -175,7 +166,7 @@
imageData.setDescription(IMAGE1_ID + " desc updated");
imageEntity.setImageCompositionData(imageData);
- CompositionEntityValidationData validationData = imageManager.updateImage(imageEntity, USER);
+ CompositionEntityValidationData validationData = imageManager.updateImage(imageEntity);
Assert.assertNotNull(validationData);
Assert.assertEquals(validationData.getErrors().size(), 2);
@@ -185,7 +176,7 @@
@Test
public void testUpdateHEATImageFileName() throws Exception {
doReturn(createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID))
- .when(imageDao).get(anyObject());
+ .when(imageDao).get(anyObject());
ImageEntity imageEntity = new ImageEntity(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
Image imageData = new Image();
imageData.setFileName(IMAGE1_ID + " name updated");
@@ -193,10 +184,8 @@
imageEntity.setImageCompositionData(imageData);
try {
- imageManager.updateImage(imageEntity, USER);
- }
- catch (CoreException ex) {
- log.debug("",ex);
+ imageManager.updateImage(imageEntity);
+ } catch (CoreException ex) {
Assert.assertEquals(ex.code().id(), VendorSoftwareProductErrorCodes.UPDATE_IMAGE_NOT_ALLOWED);
}
@@ -204,8 +193,8 @@
@Test
public void testGetNonExistingImageId_negative() {
- testGet_negative(VSP_ID, VERSION, COMPONENT_ID, "non existing image id", USER,
- VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ testGet_negative(VSP_ID, VERSION, COMPONENT_ID, "non existing image id",
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
@Test
@@ -216,12 +205,12 @@
doReturn(compositionSchema).when(imageManager).getImageCompositionSchema(anyObject());
CompositionEntityResponse<Image> response =
- imageManager.getImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, USER);
+ imageManager.getImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
Assert.assertEquals(response.getId(), expected.getId());
Assert.assertEquals(response.getData().getFileName(), expected.getImageCompositionData().
- getFileName());
+ getFileName());
Assert.assertEquals(response.getData().getDescription(), expected.getImageCompositionData().
- getDescription());
+ getDescription());
Assert.assertEquals(response.getSchema(), compositionSchema);
}
@@ -229,14 +218,14 @@
public void testDeleteOnNotManualImage() {
ImageEntity expected = createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
doReturn(expected).when(imageDao).get(anyObject());
- testDelete_negative(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, USER,
- VendorSoftwareProductErrorCodes.DELETE_IMAGE_NOT_ALLOWED);
+ testDelete_negative(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID,
+ VendorSoftwareProductErrorCodes.DELETE_IMAGE_NOT_ALLOWED);
}
@Test
public void testDeleteOnNotExistImage() {
- testDelete_negative(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, USER,
- VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ testDelete_negative(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID,
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
@Test
@@ -244,7 +233,7 @@
ImageEntity expected = createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
doReturn(expected).when(imageDao).get(anyObject());
doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
- imageManager.deleteImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, USER);
+ imageManager.deleteImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
verify(imageDao).delete(anyObject());
}
@@ -258,7 +247,7 @@
doReturn(schema).when(imageManager).getImageQuestionnaireSchema(anyObject());
QuestionnaireResponse questionnaire =
- imageManager.getImageQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, USER);
+ imageManager.getImageQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
Assert.assertNotNull(questionnaire);
Assert.assertEquals(questionnaire.getData(), image.getQuestionnaireData());
Assert.assertEquals(questionnaire.getSchema(), schema);
@@ -270,7 +259,8 @@
String json = "{\"md5\" :\"FFDSD33SS\"}";
doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
doReturn(new ImageEntity()).when(imageDao).get(anyObject());
- imageManager.updateImageQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, json, USER);
+
+ imageManager.updateImageQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, json);
verify(imageDao).updateQuestionnaireData(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, json);
}
@@ -291,10 +281,9 @@
doReturn(imageEntities).when(imageDao).list(anyObject());
doReturn(imageEntities.get(0)).when(imageDao).getQuestionnaireData(anyObject(), anyObject(), anyObject(), anyObject());
- imageManager.updateImageQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, json, USER);
+ imageManager.updateImageQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, json);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(), VendorSoftwareProductErrorCodes.DUPLICATE_IMAGE_VERSION_NOT_ALLOWED);
}
@@ -316,12 +305,9 @@
String updJson = "{\"format\" :\"aki\"}";
try {
- imageManager.updateImageQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, updJson,
- USER);
+ imageManager.updateImageQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, updJson);
Assert.fail();
- }
- catch(CoreException ex) {
- log.debug("",ex);
+ } catch (CoreException ex) {
Assert.assertEquals(ex.code().id(), VendorSoftwareProductErrorCodes.UPDATE_IMAGE_NOT_ALLOWED);
}
}
@@ -337,51 +323,34 @@
String updJson = "{\"format\" :\"a22\"}";
try {
- imageManager.updateImageQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, updJson,
- USER);
+ imageManager.updateImageQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, updJson);
Assert.fail();
- }
- catch(CoreException ex) {
- log.debug("",ex);
+ } catch (CoreException ex) {
Assert.assertEquals(ex.code().id(), VendorSoftwareProductErrorCodes.VFC_IMAGE_INVALID_FORMAT);
}
}
- private void testList_negative(String vspId, Version version, String componentId, String user,
- String expectedErrorCode, String expectedErrorMsg) {
+ private void testCreate_negative(ImageEntity image, String expectedErrorCode) {
try {
- imageManager.listImages(vspId, version, componentId, user);
+ imageManager.createImage(image);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
- Assert.assertEquals(exception.code().id(), expectedErrorCode);
- Assert.assertEquals(exception.getMessage(), expectedErrorMsg);
- }
- }
-
- private void testCreate_negative(ImageEntity image, String user, String expectedErrorCode) {
- try {
- imageManager.createImage(image, user);
- Assert.fail();
- } catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
private void testDelete_negative(String vspId, Version version, String componentId, String nicId,
- String user,
String expectedErrorCode) {
try {
- imageManager.deleteImage(vspId, version, componentId, nicId, user);
+ imageManager.deleteImage(vspId, version, componentId, nicId);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
- static ImageEntity createImage(String vspId, Version version, String compId, String imageId) {
+ private static ImageEntity createImage(String vspId, Version version, String compId,
+ String imageId) {
ImageEntity imageEntity = new ImageEntity(vspId, version, compId, imageId);
Image imageData = new Image();
imageData.setFileName(imageId + "_name");
@@ -390,21 +359,20 @@
return imageEntity;
}
- private void testUpdate_negative(String vspId, Version version, String componentId, String
- imageId, String user, String expectedErrorCode) {
+ private void testUpdate_negative(String vspId, Version version, String componentId,
+ String imageId, String expectedErrorCode) {
try {
- imageManager.updateImage(new ImageEntity(vspId, version, componentId, imageId), user);
+ imageManager.updateImage(new ImageEntity(vspId, version, componentId, imageId));
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
private void testGet_negative(String vspId, Version version, String componentId, String imageId,
- String user, String expectedErrorCode) {
+ String expectedErrorCode) {
try {
- imageManager.getImage(vspId, version, componentId, imageId, user);
+ imageManager.getImage(vspId, version, componentId, imageId);
Assert.fail();
} catch (CoreException exception) {
Assert.assertEquals(exception.code().id(), expectedErrorCode);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImplTest.java
index ecfe0e6..2360dc7 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImplTest.java
@@ -1,57 +1,10 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.doThrow;
-import static org.openecomp.sdc.generator.util.GeneratorConstants.ALLOWED_FLAVORS_PROPERTY;
-import static org.openecomp.sdc.generator.util.GeneratorConstants.IMAGES_PROPERTY;
-import static org.openecomp.sdc.generator.util.GeneratorConstants.PORT_NODE_TEMPLATE_ID_SUFFIX;
-import static org.openecomp.sdc.tosca.services.ToscaConstants.BINDING_REQUIREMENT_ID;
-import static org.openecomp.sdc.tosca.services.ToscaConstants.COUNT_PROPERTY_NAME;
-import static org.openecomp.sdc.tosca.services.ToscaConstants.SERVICE_TEMPLATE_FILTER_PROPERTY_NAME;
-import static org.openecomp.sdc.tosca.services.ToscaConstants.SUBSTITUTE_SERVICE_TEMPLATE_PROPERTY_NAME;
-import static org.openecomp.sdc.translator.services.heattotosca.Constants.GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME;
-
-import org.junit.Assert;
-import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
-import org.openecomp.sdc.generator.core.utils.GeneratorUtils;
-import org.openecomp.sdc.generator.datatypes.tosca.ComputeFlavor;
-import org.openecomp.sdc.generator.datatypes.tosca.DeploymentFlavorModel;
-import org.openecomp.sdc.generator.datatypes.tosca.LicenseFlavor;
-import org.openecomp.sdc.generator.datatypes.tosca.MultiFlavorVfcImage;
-import org.openecomp.sdc.generator.datatypes.tosca.VendorInfo;
-import org.openecomp.sdc.generator.datatypes.tosca.VspModelInfo;
-import org.openecomp.sdc.generator.util.GeneratorConstants;
-import org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType;
-import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
-import org.openecomp.sdc.tosca.datatypes.ToscaRelationshipType;
-import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
-import org.openecomp.sdc.tosca.datatypes.model.CapabilityDefinition;
-import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate;
-import org.openecomp.sdc.tosca.datatypes.model.NodeType;
-import org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition;
-import org.openecomp.sdc.tosca.datatypes.model.PropertyType;
-import org.openecomp.sdc.tosca.datatypes.model.RequirementAssignment;
-import org.openecomp.sdc.tosca.datatypes.model.RequirementDefinition;
-import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
-import org.openecomp.sdc.tosca.datatypes.model.SubstitutionMapping;
-import org.openecomp.sdc.tosca.services.ToscaConstants;
-import org.openecomp.sdc.tosca.services.ToscaUtil;
-import org.openecomp.sdc.tosca.services.impl.ToscaAnalyzerServiceImpl;
import org.openecomp.sdc.vendorsoftwareproduct.ManualVspToscaManager;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic;
import org.openecomp.sdc.vendorsoftwareproduct.services.ManualVspDataCollectionService;
-import org.openecomp.sdc.versioning.dao.types.Version;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
public class ManualVspToscaManagerImplTest {
@@ -96,36 +49,27 @@
private ManualVspDataCollectionService manualVspDataCollectionServiceMock;
/*
- private static List<String> supportedCapabilities = new ArrayList<>();
- private static List<String> supportedRequirements = new ArrayList<>();
-
- static {
- //TODO : Read from configuration
- supportedCapabilities.addAll(Arrays.asList("host", "os", "endpoint", "scalable"));
- supportedRequirements.addAll(Arrays.asList("link"));
- }
-
@Test
public void testGatherVspInformationInvalidVsp() {
MockitoAnnotations.initMocks(this);
VspModelInfo expectedVspData = new VspModelInfo();
doThrow(new RuntimeException())
.when(manualVspDataCollectionServiceMock)
- .getReleaseVendor(INVALID_VSP_ID, Version.valueOf(VSP_VERSION), USER);
+ .getReleaseVendor(INVALID_VSP_ID, Version.valueOf(VSP_VERSION));
doThrow(new RuntimeException())
.when(manualVspDataCollectionServiceMock)
- .getAllowedFlavors(INVALID_VSP_ID, Version.valueOf(VSP_VERSION), USER);
+ .getAllowedFlavors(INVALID_VSP_ID, Version.valueOf(VSP_VERSION));
doThrow(new RuntimeException())
.when(manualVspDataCollectionServiceMock)
- .getVspComponentImages(INVALID_VSP_ID, Version.valueOf(VSP_VERSION), USER);
+ .getVspComponentImages(INVALID_VSP_ID, Version.valueOf(VSP_VERSION));
doThrow(new RuntimeException())
.when(manualVspDataCollectionServiceMock)
- .getVspComponents(INVALID_VSP_ID, Version.valueOf(VSP_VERSION), USER);
+ .getVspComponents(INVALID_VSP_ID, Version.valueOf(VSP_VERSION));
doThrow(new RuntimeException())
.when(manualVspDataCollectionServiceMock)
- .getVspComponentNics(INVALID_VSP_ID, Version.valueOf(VSP_VERSION), USER);
+ .getVspComponentNics(INVALID_VSP_ID, Version.valueOf(VSP_VERSION));
VspModelInfo vspModelInfo = manualVspToscaManagerMock.gatherVspInformation(INVALID_VSP_ID,
- Version.valueOf(VSP_VERSION), USER);
+ Version.valueOf(VSP_VERSION));
Assert.assertEquals(expectedVspData, vspModelInfo);
}
@@ -138,17 +82,17 @@
Map<String, String> componentData = getComponentData();
Map<String, List<MultiFlavorVfcImage>> vfcImageData = getVfcImageData();
doReturn(Optional.of(RELEASE_VENDOR)).when(manualVspDataCollectionServiceMock)
- .getReleaseVendor(VSP_ID, Version.valueOf(VSP_VERSION), USER);
+ .getReleaseVendor(VSP_ID, Version.valueOf(VSP_VERSION));
doReturn(deploymentFlavorData).when(manualVspDataCollectionServiceMock)
- .getAllowedFlavors(VSP_ID, Version.valueOf(VSP_VERSION), USER);
+ .getAllowedFlavors(VSP_ID, Version.valueOf(VSP_VERSION));
doReturn(vfcImageData).when(manualVspDataCollectionServiceMock)
- .getVspComponentImages(VSP_ID, Version.valueOf(VSP_VERSION), USER);
+ .getVspComponentImages(VSP_ID, Version.valueOf(VSP_VERSION));
doReturn(componentData).when(manualVspDataCollectionServiceMock)
- .getVspComponents(VSP_ID, Version.valueOf(VSP_VERSION), USER);
+ .getVspComponents(VSP_ID, Version.valueOf(VSP_VERSION));
doReturn(componentNics).when(manualVspDataCollectionServiceMock)
- .getVspComponentNics(VSP_ID, Version.valueOf(VSP_VERSION), USER);
+ .getVspComponentNics(VSP_ID, Version.valueOf(VSP_VERSION));
VspModelInfo vspModelInfo = manualVspToscaManagerMock.gatherVspInformation(VSP_ID,
- Version.valueOf(VSP_VERSION), USER);
+ Version.valueOf(VSP_VERSION));
VspModelInfo expectedVspData = new VspModelInfo();
expectedVspData.setReleaseVendor(RELEASE_VENDOR);
@@ -449,9 +393,9 @@
private void validateSubstitutionCapabilities(Map<String, List<String>> capabilities,
String componentName) {
- List<String> SupportedCapabilities = supportedCapabilities;
- Assert.assertEquals(SupportedCapabilities.size(), capabilities.size());
- for (String capability : SupportedCapabilities) {
+ List<String> supportedCapabilities = GeneratorUtils.supportedCapabilities;
+ Assert.assertEquals(supportedCapabilities.size(), capabilities.size());
+ for (String capability : supportedCapabilities) {
String expectedCapabilityId = capability + "_" + componentName;
Assert.assertEquals(true, capabilities.containsKey(expectedCapabilityId));
List<String> expectedCapabilityValue = new ArrayList<>(2);
@@ -464,10 +408,10 @@
private void validateSubstitutionRequirements(Map<String, List<String>> requirements,
List<Nic> nics) {
- List<String> SupportedRequirements = supportedRequirements;
+ List<String> supportedRequirements = GeneratorUtils.supportedRequirements;
for(Nic nic : nics) {
String nicNodeTemplateId = nic.getName() + PORT_NODE_TEMPLATE_ID_SUFFIX;
- for (String requirement : SupportedRequirements) {
+ for (String requirement : supportedRequirements) {
String expectedRequirementId = requirement + "_" + nicNodeTemplateId;
Assert.assertEquals(true, requirements.containsKey(expectedRequirementId));
List<String> expectedRequirementValue = new ArrayList<>(2);
@@ -508,11 +452,11 @@
List<Map<String, RequirementDefinition>> requirements =
deploymentFlavorNodeType.getRequirements();
- List<String> SupportedRequirements = supportedRequirements;
+ List<String> supportedRequirements = GeneratorUtils.supportedRequirements;
for (Nic nic : nics) {
boolean found = false;
String nicNodeTemplateId = nic.getName() + PORT_NODE_TEMPLATE_ID_SUFFIX;
- for (String requirementId : SupportedRequirements) {
+ for (String requirementId : supportedRequirements) {
String expectedRequirementId = requirementId + "_" + nicNodeTemplateId;
for (Map<String, RequirementDefinition> requirement : requirements) {
if (requirement.containsKey(expectedRequirementId)) {
@@ -525,8 +469,8 @@
}
Map<String, CapabilityDefinition> capabilities = deploymentFlavorNodeType.getCapabilities();
- List<String> SupportedCapabilities = supportedCapabilities;
- for (String capabilityId : SupportedCapabilities) {
+ List<String> supportedCapabilities = GeneratorUtils.supportedCapabilities;
+ for (String capabilityId : supportedCapabilities) {
String expectedCapabilityId = capabilityId + "_" + componentName;
Assert.assertEquals (true, capabilities.containsKey(expectedCapabilityId));
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImplTest.java
index 966e1f2..5e735ff 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImplTest.java
@@ -28,10 +28,9 @@
public class MonitoringUploadsManagerImplTest {
- private static final String USER1 = "ComponentsUploadTestUser";
private static final String COMPONENT_ID = "COMPONENT_ID";
private static final String VSP_ID = "vspId";
- private static final Version VERSION = new Version(0, 1);
+ private static final Version VERSION = new Version("version_id");
private static final String TRAP_FILE_NAME = "MMSC.zip";
private static final String POLL_FILE_NAME = "MNS OAM FW.zip";
private static final String VES_FILE_NAME = "vesTest-yml_only.zip";
@@ -54,22 +53,19 @@
@Test(expectedExceptions = CoreException.class)
public void testUploadEmptyZip() {
processFile(ZIP_DIR + EMPTY_ZIP_FILE_NAME, inputStream ->
- monitoringUploadsManager.upload(inputStream, EMPTY_ZIP_FILE_NAME, VSP_ID, VERSION, COMPONENT_ID,
- MonitoringUploadType.SNMP_TRAP, USER1));
+ monitoringUploadsManager
+ .upload(inputStream, EMPTY_ZIP_FILE_NAME, VSP_ID, VERSION, COMPONENT_ID,
+ MonitoringUploadType.SNMP_TRAP));
}
- @Test
+ @Test(expectedExceptions = CoreException.class, expectedExceptionsMessageRegExp =
+ "Monitoring file uploaded for vendor software product with Id vspId and version version_id " +
+ "is invalid: Invalid zip file")
public void testUploadInvalidZip() {
-
- try {
- processFile("/notZipFile", inputStream ->
+ processFile("/notZipFile", inputStream ->
monitoringUploadsManager
.upload(inputStream, NOT_ZIP_FILE_NAME, VSP_ID, VERSION, COMPONENT_ID,
- MonitoringUploadType.VES_EVENTS, USER1));
- Assert.fail();
- } catch (Exception exception) {
- Assert.assertEquals(exception.getMessage(), "Invalid zip file");
- }
+ MonitoringUploadType.VES_EVENTS));
}
@Test
@@ -78,7 +74,7 @@
try {
processFile(ZIP_DIR + ZIP_WITH_FOLDERS_FILE_NAME, inputStream -> monitoringUploadsManager
.upload(inputStream, ZIP_WITH_FOLDERS_FILE_NAME, VSP_ID, VERSION, COMPONENT_ID,
- MonitoringUploadType.SNMP_TRAP, USER1));
+ MonitoringUploadType.SNMP_TRAP));
Assert.fail();
} catch (Exception exception) {
Assert.assertEquals(exception.getMessage(), "Zip file should not contain folders");
@@ -91,7 +87,7 @@
try {
processFile(ZIP_DIR + INVALID_VES_FILE_NAME, inputStream -> monitoringUploadsManager
.upload(inputStream, INVALID_VES_FILE_NAME, VSP_ID, VERSION, COMPONENT_ID,
- MonitoringUploadType.VES_EVENTS, USER1));
+ MonitoringUploadType.VES_EVENTS));
Assert.fail();
} catch (Exception exception) {
Assert.assertEquals(exception.getMessage(),
@@ -122,18 +118,18 @@
.when(componentArtifactDaoMock).list(anyObject());
MonitoringUploadStatus monitoringUploadStatus =
- monitoringUploadsManager.listFilenames(VSP_ID, VERSION, COMPONENT_ID, USER1);
+ monitoringUploadsManager.listFilenames(VSP_ID, VERSION, COMPONENT_ID);
Assert.assertEquals(monitoringUploadStatus.getSnmpTrap(), TRAP_FILE_NAME);
Assert.assertEquals(monitoringUploadStatus.getSnmpPoll(), POLL_FILE_NAME);
Assert.assertEquals(monitoringUploadStatus.getVesEvent(), VES_FILE_NAME);
}
- @Test (expectedExceptions = CoreException.class)
+ @Test(expectedExceptions = CoreException.class)
public void testDeleteComponentMibWhenNone() {
doReturn(Optional.empty()).when(componentArtifactDaoMock).getByType(any());
monitoringUploadsManager
- .delete(VSP_ID, VERSION, COMPONENT_ID, MonitoringUploadType.SNMP_POLL, USER1);
+ .delete(VSP_ID, VERSION, COMPONENT_ID, MonitoringUploadType.SNMP_POLL);
verify(componentArtifactDaoMock, never()).delete(anyObject());
}
@@ -146,7 +142,7 @@
(componentArtifactDaoMock).getByType(anyObject());
monitoringUploadsManager
- .delete(VSP_ID, VERSION, COMPONENT_ID, MonitoringUploadType.SNMP_POLL, USER1);
+ .delete(VSP_ID, VERSION, COMPONENT_ID, MonitoringUploadType.SNMP_POLL);
verify(componentArtifactDaoMock).delete(anyObject());
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImplTest.java
index ebdbc6a..54687dc 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImplTest.java
@@ -53,10 +53,8 @@
private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
- private static final String USER1 = "networksTestUser1";
- private static final String USER2 = "networksTestUser2";
private static final String VSP_ID = "vsp";
- private static final Version VERSION = new Version(0, 1);
+ private static final Version VERSION = new Version("version_id");
private static final String NETWORK1_ID = "network1";
private static final String NETWORK2_ID = "network2";
@@ -85,7 +83,7 @@
@Test
public void testListWhenNone() {
Collection<NetworkEntity> networks =
- networkManager.listNetworks(VSP_ID, null, USER1);
+ networkManager.listNetworks(VSP_ID, null);
Assert.assertEquals(networks.size(), 0);
}
@@ -96,7 +94,7 @@
createNetwork(VSP_ID, VERSION, NETWORK2_ID)))
.when(networkDaoMock).list(anyObject());
- Collection<NetworkEntity> actual = networkManager.listNetworks(VSP_ID, VERSION, USER1);
+ Collection<NetworkEntity> actual = networkManager.listNetworks(VSP_ID, VERSION);
Assert.assertEquals(actual.size(), 2);
}
@@ -113,7 +111,7 @@
expected.setNetworkCompositionData(networkData);
- NetworkEntity created = networkManager.createNetwork(expected, USER1);
+ NetworkEntity created = networkManager.createNetwork(expected);
Assert.assertNotNull(created);
expected.setId(created.getId());
expected.setVersion(VERSION01);
@@ -131,12 +129,12 @@
networkData.setName("network1 name");
networkData.setDhcp(true);
network.setNetworkCompositionData(networkData);
- testCreate_negative(network, USER1, UniqueValueUtil.UNIQUE_VALUE_VIOLATION);
+ testCreate_negative(network, UniqueValueUtil.UNIQUE_VALUE_VIOLATION);
}*/
@Test
public void testCreateOnUploadVsp_negative() {
- testCreate_negative(new NetworkEntity(VSP_ID, VERSION, null), USER1,
+ testCreate_negative(new NetworkEntity(VSP_ID, VERSION, null),
VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED);
}
@@ -148,7 +146,7 @@
@Test
public void testUpdateNonExistingNetworkId_negative() {
- testUpdate_negative(VSP_ID, VERSION, NETWORK1_ID, USER1,
+ testUpdate_negative(VSP_ID, VERSION, NETWORK1_ID,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
@@ -171,7 +169,7 @@
networkEntity.setNetworkCompositionData(networkData);
CompositionEntityValidationData validationData =
- networkManager.updateNetwork(networkEntity, USER1);
+ networkManager.updateNetwork(networkEntity);
Assert.assertNotNull(validationData);
Assert.assertEquals(validationData.getErrors().size(), 2);
@@ -180,7 +178,7 @@
@Test
public void testGetNonExistingNetworkId_negative() {
- testGet_negative(VSP_ID, VERSION, NETWORK1_ID, USER1,
+ testGet_negative(VSP_ID, VERSION, NETWORK1_ID,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
@@ -192,7 +190,7 @@
doReturn("schema string").when(networkManager).getCompositionSchema(anyObject());
CompositionEntityResponse<Network> response =
- networkManager.getNetwork(VSP_ID, VERSION, NETWORK1_ID, USER1);
+ networkManager.getNetwork(VSP_ID, VERSION, NETWORK1_ID);
Assert.assertEquals(response.getId(), network.getId());
Assert.assertEquals(response.getData(), network.getNetworkCompositionData());
Assert.assertNotNull(response.getSchema());
@@ -206,13 +204,13 @@
@Test(dependsOnMethods = "testList")
public void testDeleteNonExistingNetworkId_negative() {
- testDelete_negative(VSP_ID, "non existing network id", USER1, VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ testDelete_negative(VSP_ID, "non existing network id", VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}*/
/*
@Test(dependsOnMethods = "testList")
public void testDelete() {
- networkManager.deleteNetwork(VSP_ID, NETWORK1_ID, USER1);
+ networkManager.deleteNetwork(VSP_ID, NETWORK1_ID);
NetworkEntity actual = networkDaoMock.getNetwork(VSP_ID, VERSION01, NETWORK1_ID);
Assert.assertNull(actual);
}
@@ -224,70 +222,69 @@
NetworkEntity network3 = new NetworkEntity(VSP_ID, null, null);
network3.setName("network3 name");
network3.setDescription("network3 desc");
- networkManager.createNetwork(network3, USER1);
+ networkManager.createNetwork(network3);
- networkManager.deleteNetworks(VSP_ID, USER1);
+ networkManager.deleteNetworks(VSP_ID);
- Collection<NetworkEntity> actual = networkManager.listNetworks(VSP_ID, null, USER1);
+ Collection<NetworkEntity> actual = networkManager.listNetworks(VSP_ID, null);
Assert.assertEquals(actual.size(), 0);
}*/
@Test(dependsOnMethods = "testList")
public void testDeleteOnUploadVsp_negative() {
- testDelete_negative(VSP_ID, VERSION, NETWORK1_ID, USER1,
+ testDelete_negative(VSP_ID, VERSION, NETWORK1_ID,
VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED);
}
- private void testCreate_negative(NetworkEntity network, String user, String expectedErrorCode) {
+ private void testCreate_negative(NetworkEntity network, String expectedErrorCode) {
try {
- networkManager.createNetwork(network, user);
+ networkManager.createNetwork(network);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
+ log.debug("", exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
- private void testGet_negative(String vspId, Version version, String networkId, String user,
+ private void testGet_negative(String vspId, Version version, String networkId,
String expectedErrorCode) {
try {
- networkManager.getNetwork(vspId, version, networkId, user);
+ networkManager.getNetwork(vspId, version, networkId);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
+ log.debug("", exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
- private void testUpdate_negative(String vspId, Version version, String networkId, String user,
+ private void testUpdate_negative(String vspId, Version version, String networkId,
String expectedErrorCode) {
try {
- networkManager.updateNetwork(new NetworkEntity(vspId, version, networkId), user);
+ networkManager.updateNetwork(new NetworkEntity(vspId, version, networkId));
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
+ log.debug("", exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
- private void testList_negative(String vspId, Version version, String user,
- String expectedErrorCode) {
+ private void testList_negative(String vspId, Version version, String expectedErrorCode) {
try {
- networkManager.listNetworks(vspId, version, user);
+ networkManager.listNetworks(vspId, version);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
+ log.debug("", exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
- private void testDelete_negative(String vspId, Version version, String networkId, String user,
+ private void testDelete_negative(String vspId, Version version, String networkId,
String expectedErrorCode) {
try {
- networkManager.deleteNetwork(vspId, version, networkId, user);
+ networkManager.deleteNetwork(vspId, version, networkId);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
+ log.debug("", exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImplTest.java
index ba04e91..959b501 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImplTest.java
@@ -1,10 +1,5 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -35,17 +30,21 @@
import java.util.Arrays;
import java.util.Collection;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+
public class NicManagerImplTest {
private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
private static final String NIC_NOT_EXIST_MSG =
"Vendor Software Product NIC with Id nic1 does not exist for Vendor Software Product with " +
- "id VSP_ID and version 0.1";
+ "id VSP_ID and version version_id";
- private static final String USER = "nicTestUser";
private static final String VSP_ID = "VSP_ID";
- private static final Version VERSION = new Version(0, 1);
+ private static final Version VERSION = new Version("version_id");
private static final String COMPONENT_ID = "COMPONENT_ID";
private static final String NIC1_ID = "nic1";
private static final String NIC2_ID = "nic2";
@@ -71,7 +70,7 @@
@Test
public void testListWhenNone() {
- Collection<NicEntity> nics = nicManager.listNics(VSP_ID, VERSION, COMPONENT_ID, USER);
+ Collection<NicEntity> nics = nicManager.listNics(VSP_ID, VERSION, COMPONENT_ID);
Assert.assertEquals(nics.size(), 0);
}
@@ -85,9 +84,9 @@
NetworkEntity network1 = NetworkManagerImplTest.createNetwork(VSP_ID, VERSION, NETWORK1_ID);
NetworkEntity network2 = NetworkManagerImplTest.createNetwork(VSP_ID, VERSION, NETWORK2_ID);
doReturn(Arrays.asList(network1, network2))
- .when(networkManagerMock).listNetworks(VSP_ID, VERSION, USER);
+ .when(networkManagerMock).listNetworks(VSP_ID, VERSION);
- Collection<NicEntity> nics = nicManager.listNics(VSP_ID, VERSION, COMPONENT_ID, USER);
+ Collection<NicEntity> nics = nicManager.listNics(VSP_ID, VERSION, COMPONENT_ID);
Assert.assertEquals(nics.size(), 2);
for (NicEntity nic : nics) {
Assert.assertEquals(nic.getNicCompositionData().getNetworkName(),
@@ -103,12 +102,12 @@
Nic nic = nicEntity.getNicCompositionData();
nic.setNetworkType(NetworkType.Internal);
nicEntity.setNicCompositionData(nic);
- doReturn(true).when(vspInfoDao).isManual(anyObject(),anyObject());
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
Collection<NicEntity> nicEntities = new ArrayList<>();
doReturn(nicEntities).when(nicDao).list(anyObject());
doReturn(nicEntity).when(compositionEntityDataManagerMock).createNic(anyObject());
- NicEntity created = nicManager.createNic(nicEntity,USER);
+ NicEntity created = nicManager.createNic(nicEntity);
Assert.assertNotNull(created);
}
@@ -118,7 +117,7 @@
Nic nic = nicEntity.getNicCompositionData();
nic.setNetworkType(NetworkType.Internal);
nicEntity.setNicCompositionData(nic);
- doReturn(true).when(vspInfoDao).isManual(anyObject(),anyObject());
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
Collection<NicEntity> nicEntities = new ArrayList<>();
NicEntity nicEntityDiffName = createNic(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, NETWORK1_ID);
@@ -130,11 +129,11 @@
doReturn(nicEntity).when(compositionEntityDataManagerMock).createNic(anyObject());
try {
- NicEntity created = nicManager.createNic(nicEntity,USER);
- } catch (CoreException exception) {
- log.debug("",exception);
- Assert.assertEquals(VendorSoftwareProductErrorCodes.NIC_NAME_FORMAT_NOT_ALLOWED,
- exception.code().id());
+ NicEntity created = nicManager.createNic(nicEntity);
+ } catch (CoreException exception) {
+ log.debug("", exception);
+ Assert.assertEquals(VendorSoftwareProductErrorCodes.NIC_NAME_FORMAT_NOT_ALLOWED,
+ exception.code().id());
}
}
@@ -144,7 +143,7 @@
Nic nic = nicEntity.getNicCompositionData();
nic.setNetworkType(NetworkType.Internal);
nicEntity.setNicCompositionData(nic);
- doReturn(true).when(vspInfoDao).isManual(anyObject(),anyObject());
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
Collection<NicEntity> nicEntities = new ArrayList<>();
NicEntity nicEntityDiffName = createNic(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, NETWORK1_ID);
@@ -156,11 +155,11 @@
doReturn(nicEntity).when(compositionEntityDataManagerMock).createNic(anyObject());
try {
- NicEntity created = nicManager.createNic(nicEntity,USER);
- } catch (CoreException exception) {
- log.debug("",exception);
- Assert.assertEquals("Invalid request, NIC with name "+ nic.getName() +
- " already exist for component with ID "+ nicEntity.getComponentId() +".",
+ NicEntity created = nicManager.createNic(nicEntity);
+ } catch (CoreException exception) {
+ log.debug("", exception);
+ Assert.assertEquals("Invalid request, NIC with name " + nic.getName() +
+ " already exist for component with ID " + nicEntity.getComponentId() + ".",
exception.code().message());
Assert.assertEquals(VendorSoftwareProductErrorCodes.DUPLICATE_NIC_NAME_NOT_ALLOWED,
exception.code().id());
@@ -173,19 +172,20 @@
Nic nic = nicEntity.getNicCompositionData();
nic.setNetworkType(NetworkType.External);
nicEntity.setNicCompositionData(nic);
- doReturn(true).when(vspInfoDao).isManual(anyObject(),anyObject());
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
Collection<NicEntity> nicEntities = new ArrayList<>();
doReturn(nicEntities).when(nicDao).list(anyObject());
doReturn(nicEntity).when(compositionEntityDataManagerMock).createNic(anyObject());
try {
- NicEntity created = nicManager.createNic(nicEntity,USER);
- } catch (CoreException exception) {
- log.debug("",exception);
+ NicEntity created = nicManager.createNic(nicEntity);
+ } catch (CoreException exception) {
+ log.debug("", exception);
Assert.assertEquals("Invalid request,NetworkId not allowed for External Networks",
exception.code().message());
- Assert.assertEquals(VendorSoftwareProductErrorCodes.NETWORKID_NOT_ALLOWED_FOR_EXTERNAL_NETWORK,
- exception.code().id());
+ Assert
+ .assertEquals(VendorSoftwareProductErrorCodes.NETWORKID_NOT_ALLOWED_FOR_EXTERNAL_NETWORK,
+ exception.code().id());
}
}
@@ -196,29 +196,29 @@
nic.setNetworkType(NetworkType.Internal);
nic.setNetworkDescription(NIC1_ID);
nicEntity.setNicCompositionData(nic);
- doReturn(true).when(vspInfoDao).isManual(anyObject(),anyObject());
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
Collection<NicEntity> nicEntities = new ArrayList<>();
doReturn(nicEntities).when(nicDao).list(anyObject());
doReturn(nicEntity).when(compositionEntityDataManagerMock).createNic(anyObject());
try {
- NicEntity created = nicManager.createNic(nicEntity,USER);
- } catch (CoreException exception) {
- log.debug("",exception);
+ NicEntity created = nicManager.createNic(nicEntity);
+ } catch (CoreException exception) {
+ log.debug("", exception);
Assert.assertEquals("Invalid request, Network Description not allowed for Internal Networks",
exception.code().message());
Assert.assertEquals(VendorSoftwareProductErrorCodes
- .NETWORK_DESCRIPTION_NOT_ALLOWED_FOR_INTERNAL_NETWORK,exception.code().id());
+ .NETWORK_DESCRIPTION_NOT_ALLOWED_FOR_INTERNAL_NETWORK, exception.code().id());
}
}
@Test
public void testDeleteNic() {
NicEntity nicEntity = createNic(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, NETWORK1_ID);
- doReturn(true).when(vspInfoDao).isManual(anyObject(),anyObject());
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
doReturn(nicEntity).when(nicDao).get(anyObject());
- nicManager.deleteNic(VSP_ID,new Version(0,1),COMPONENT_ID,NIC1_ID,USER);
+ nicManager.deleteNic(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID);
}
@@ -227,9 +227,12 @@
NicEntity nicEntity = createNic(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, NETWORK1_ID);
doReturn(nicEntity).when(nicDao).get(anyObject());
+ doReturn("{}").when(nicManager).getNicCompositionSchema(anyObject());
- nicManager.updateNicQuestionnaire(VSP_ID,new Version(0,1),COMPONENT_ID,NIC1_ID,"Ques",USER);
+ nicManager
+ .updateNicQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, "Ques");
+ verify(nicDao).updateQuestionnaireData(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, "Ques");
}
// @Test(dependsOnMethods = "testListWhenNone")
@@ -243,7 +246,7 @@
Nic nicData = new Nic();
nicData.setName("nic1 name");
nic.setNicCompositionData(nicData);
- testCreate_negative(nic, USER, UniqueValueUtil.UNIQUE_VALUE_VIOLATION);
+ testCreate_negative(nic, UniqueValueUtil.UNIQUE_VALUE_VIOLATION);
}*/
// @Test(dependsOnMethods = {"testCreate"})
@@ -254,7 +257,7 @@
// compData12.setDescription("comp12 desc");
// component12.setComponentCompositionData(compData12);
//
-// String component12Id = nicManager.createComponent(component12, USER).getId();
+// String component12Id = nicManager.createComponent(component12).getId();
// testCreate(VSP_ID, component12Id, NETWORK1_ID, NETWORK1_ID.getNetworkCompositionData().getName());
// }
@@ -266,7 +269,7 @@
@Test
public void testCreateOnUploadVsp_negative() {
- testCreate_negative(new NicEntity(VSP_ID, VERSION, COMPONENT_ID, null), USER,
+ testCreate_negative(new NicEntity(VSP_ID, VERSION, COMPONENT_ID, null),
VendorSoftwareProductErrorCodes.ADD_NIC_NOT_ALLOWED_IN_HEAT_ONBOARDING);
}
@@ -274,7 +277,7 @@
public void testUpdateNonExistingNicId_negative() {
doReturn(null).when(nicDao).get(anyObject());
- testUpdate_negative(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, USER,
+ testUpdate_negative(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
@@ -295,7 +298,7 @@
nicEntity.setNicCompositionData(nicData);
CompositionEntityValidationData validationData =
- nicManager.updateNic(nicEntity, USER);
+ nicManager.updateNic(nicEntity);
Assert.assertTrue(validationData == null || validationData.getErrors() == null);
verify(nicDao).update(nicEntity);
}
@@ -319,7 +322,7 @@
nicData.setNetworkId(NETWORK1_ID);
nicEntity.setNicCompositionData(nicData);
- CompositionEntityValidationData validationData = nicManager.updateNic(nicEntity, USER);
+ CompositionEntityValidationData validationData = nicManager.updateNic(nicEntity);
Assert.assertNotNull(validationData);
Assert.assertEquals(validationData.getErrors().size(), 2);
@@ -329,14 +332,14 @@
@Test
public void testUpdateIncorrectNameFormat() {
doReturn(createNic(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, NETWORK1_ID))
- .when(nicDao).get(anyObject());
+ .when(nicDao).get(anyObject());
CompositionEntityValidationData toBeReturned =
- new CompositionEntityValidationData(CompositionEntityType.nic, NIC1_ID);
+ new CompositionEntityValidationData(CompositionEntityType.nic, NIC1_ID);
toBeReturned.setErrors(Arrays.asList("error1", "error2"));
doReturn(toBeReturned)
- .when(compositionEntityDataManagerMock)
- .validateEntity(anyObject(), anyObject(), anyObject());
+ .when(compositionEntityDataManagerMock)
+ .validateEntity(anyObject(), anyObject(), anyObject());
doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
NicEntity nicEntity = new NicEntity(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID);
@@ -347,20 +350,19 @@
nicEntity.setNicCompositionData(nicData);
try {
- nicManager.updateNic(nicEntity, USER);
+ nicManager.updateNic(nicEntity);
Assert.fail();
- }
- catch (CoreException ex) {
- log.debug("",ex);
+ } catch (CoreException ex) {
+ log.debug("", ex);
Assert.assertEquals(VendorSoftwareProductErrorCodes.NIC_NAME_FORMAT_NOT_ALLOWED,
- ex.code().id());
+ ex.code().id());
}
}
@Test
public void testGetNonExistingNicId_negative() {
- testGet_negative(VSP_ID, VERSION, COMPONENT_ID, "non existing nic id", USER,
+ testGet_negative(VSP_ID, VERSION, COMPONENT_ID, "non existing nic id",
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
@@ -373,7 +375,7 @@
doReturn(compositionSchema).when(nicManager).getNicCompositionSchema(anyObject());
CompositionEntityResponse<Nic> response =
- nicManager.getNic(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, USER);
+ nicManager.getNic(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID);
Assert.assertEquals(response.getId(), expected.getId());
Assert.assertEquals(response.getData(), expected.getNicCompositionData());
Assert.assertEquals(response.getSchema(), compositionSchema);
@@ -387,32 +389,32 @@
@Test
public void testDeleteNonExistingNicId_negative() {
- testDelete_negative(VSP_ID, COMPONENT_ID, "non existing nic id", USER, VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ testDelete_negative(VSP_ID, COMPONENT_ID, "non existing nic id", VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
@Test(dependsOnMethods = "testList")
public void testDeleteNonExistingComponentId_negative() {
- testDelete_negative(VSP_ID, "non existing component id", NIC1_ID, USER, VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ testDelete_negative(VSP_ID, "non existing component id", NIC1_ID, VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}*/
/*
@Test(dependsOnMethods = "testList")
public void testDelete() {
- nicManager.deleteNic(VSP_ID, COMPONENT_ID, NIC1_ID, USER);
+ nicManager.deleteNic(VSP_ID, COMPONENT_ID, NIC1_ID);
NicEntity actual = vendorSoftwareProductDao.getNic(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID);
Assert.assertNull(actual);
}*/
@Test
public void testDeleteOnUploadVsp_negative() {
- testDelete_negative(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, USER,
+ testDelete_negative(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID,
VendorSoftwareProductErrorCodes.DELETE_NIC_NOT_ALLOWED);
}
@Test(expectedExceptions = CoreException.class,
expectedExceptionsMessageRegExp = NIC_NOT_EXIST_MSG)
public void testGetNonExistingNicQuestionnaire() throws Exception {
- nicManager.getNicQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, USER);
+ nicManager.getNicQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID);
}
@Test
@@ -425,7 +427,7 @@
doReturn(schema).when(nicManager).getNicQuestionnaireSchema(anyObject());
QuestionnaireResponse questionnaire =
- nicManager.getNicQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, USER);
+ nicManager.getNicQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID);
Assert.assertNotNull(questionnaire);
Assert.assertEquals(questionnaire.getData(), nic.getQuestionnaireData());
Assert.assertEquals(questionnaire.getSchema(), schema);
@@ -437,7 +439,7 @@
public void testUpdateNonExistingNicQuestionnaire() throws Exception {
doReturn(null).when(nicDao).get(anyObject());
nicManager
- .updateNicQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, "questionnaire data", USER);
+ .updateNicQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, "questionnaire data");
}
@Test
@@ -445,46 +447,45 @@
}
- private void testCreate_negative(NicEntity nic, String user, String expectedErrorCode) {
+ private void testCreate_negative(NicEntity nic, String expectedErrorCode) {
try {
- nicManager.createNic(nic, user);
+ nicManager.createNic(nic);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
+ log.debug("", exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
private void testGet_negative(String vspId, Version version, String componentId, String nicId,
- String user, String expectedErrorCode) {
+ String expectedErrorCode) {
try {
- nicManager.getNic(vspId, version, componentId, nicId, user);
+ nicManager.getNic(vspId, version, componentId, nicId);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
+ log.debug("", exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
private void testUpdate_negative(String vspId, Version version, String componentId, String nicId,
- String user, String expectedErrorCode) {
+ String expectedErrorCode) {
try {
- nicManager.updateNic(new NicEntity(vspId, version, componentId, nicId), user);
+ nicManager.updateNic(new NicEntity(vspId, version, componentId, nicId));
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
+ log.debug("", exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
private void testDelete_negative(String vspId, Version version, String componentId, String nicId,
- String user,
String expectedErrorCode) {
try {
- nicManager.deleteNic(vspId, version, componentId, nicId, user);
+ nicManager.deleteNic(vspId, version, componentId, nicId);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
+ log.debug("", exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImplTest.java
index d1cba65..26ec917 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImplTest.java
@@ -1,18 +1,14 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.doReturn;
-
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
@@ -37,10 +33,13 @@
import java.util.Map;
import java.util.Optional;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doReturn;
+
public class OrchestrationTemplateCandidateManagerImplTest {
- private static final String USER1 = "vspTestUser1";
private static final String VSP_ID = "vspId";
- private static final Version VERSION01 = new Version(0, 1);
+ private static final Version VERSION01 = new Version("versionId");
private static final String COMPONENT_ORIG_ID_1 = "Component_Pd_Server_Id_Orig";
private static final String COMPONENT_ORIG_ID_2 = "Component_Sm_Server_Id_Orig";
@@ -58,8 +57,6 @@
private static final String COMPONENT_NAME_4 = "ps_server";
@Mock
- private VendorSoftwareProductDao vendorSoftwareProductDaoMock;
- @Mock
private VendorSoftwareProductInfoDao vspInfoDaoMock;
@Mock
private CandidateService candidateServiceMock;
@@ -67,6 +64,8 @@
private OrchestrationTemplateDao orchestrationTemplateDaoMock;
@Mock
private ComponentDependencyModelDao componentDependencyModelDaoMock;
+ @Mock
+ private ComponentDao componentDaoMock;
@InjectMocks
private OrchestrationTemplateCandidateManagerImpl candidateManager;
@@ -100,7 +99,7 @@
doReturn(new VspDetails(VSP_ID, VERSION01))
.when(vspInfoDaoMock).get(anyObject());
doReturn(null)
- .when(orchestrationTemplateDaoMock).getValidationData(anyObject(), anyObject());
+ .when(orchestrationTemplateDaoMock).getInfo(anyObject(), anyObject());
doReturn("{}").when(candidateServiceMock).createManifest(anyObject(), anyObject());
doReturn(Optional.empty()).when(candidateServiceMock)
@@ -109,7 +108,7 @@
OrchestrationTemplateActionResponse response =
- candidateManager.process(VSP_ID, VERSION01, USER1);
+ candidateManager.process(VSP_ID, VERSION01);
Assert.assertNotNull(response);
}
@@ -118,12 +117,11 @@
public void testUpdateVspComponentDependenciesHeatReuploadMoreComponents() {
Collection<ComponentDependencyModelEntity> existingComponentsDependencies =
getExistingComponentDependencies();
- doReturn(existingComponentsDependencies).
- when(vendorSoftwareProductDaoMock).listComponentDependencies(anyObject(), anyObject());
+ doReturn(existingComponentsDependencies).when(componentDependencyModelDaoMock)
+ .list(anyObject());
Collection<ComponentEntity> componentListWithMoreComponentsInHeat =
getComponentListWithMoreComponentsInHeat();
- doReturn(componentListWithMoreComponentsInHeat).when(vendorSoftwareProductDaoMock)
- .listComponents(anyObject(), anyObject());
+ doReturn(componentListWithMoreComponentsInHeat).when(componentDaoMock).list(anyObject());
Map<String, String> componentIdNameInfoBeforeProcess = getVspInitComponentIdNameInfo();
orchestrationUtil.updateVspComponentDependencies(anyObject(), anyObject(),
componentIdNameInfoBeforeProcess);
@@ -136,14 +134,14 @@
Collection<ComponentDependencyModelEntity> existingComponentsDependencies =
getExistingComponentDependencies();
doReturn(existingComponentsDependencies).
- when(vendorSoftwareProductDaoMock).listComponentDependencies(anyObject(), anyObject());
+ when(componentDependencyModelDaoMock).list(anyObject());
Collection<ComponentEntity> componentListWithLessComponentsInHeat =
getComponentListWithLessComponentsInHeat();
- doReturn(componentListWithLessComponentsInHeat).when(vendorSoftwareProductDaoMock)
- .listComponents(anyObject(), anyObject());
+ doReturn(componentListWithLessComponentsInHeat).when(componentDaoMock).list(anyObject());
Map<String, String> componentIdNameInfoBeforeProcess = getVspInitComponentIdNameInfo();
- orchestrationUtil.updateVspComponentDependencies(anyObject(), anyObject(),
- componentIdNameInfoBeforeProcess);
+ orchestrationUtil
+ .updateVspComponentDependencies(anyObject(), anyObject(),
+ componentIdNameInfoBeforeProcess);
Mockito.verify(componentDependencyModelDaoMock, Mockito.times(1)).update(anyObject());
Mockito.verify(componentDependencyModelDaoMock, Mockito.times(1)).delete(anyObject());
}
@@ -152,12 +150,11 @@
public void testUpdateVspComponentDependenciesHeatReuploadSameComponents() {
Collection<ComponentDependencyModelEntity> existingComponentsDependencies =
getExistingComponentDependencies();
- doReturn(existingComponentsDependencies).
- when(vendorSoftwareProductDaoMock).listComponentDependencies(anyObject(), anyObject());
+ doReturn(existingComponentsDependencies).when(componentDependencyModelDaoMock)
+ .list(anyObject());
Collection<ComponentEntity> componentListWithSameComponentsInHeat =
getComponentListWithSameComponentsInHeat();
- doReturn(componentListWithSameComponentsInHeat).when(vendorSoftwareProductDaoMock)
- .listComponents(anyObject(), anyObject());
+ doReturn(componentListWithSameComponentsInHeat).when(componentDaoMock).list(anyObject());
Map<String, String> componentIdNameInfoBeforeProcess = getVspInitComponentIdNameInfo();
orchestrationUtil.updateVspComponentDependencies(anyObject(), anyObject(),
componentIdNameInfoBeforeProcess);
@@ -169,12 +166,11 @@
public void testUpdateVspComponentDependenciesHeatReuploadNoComponents() {
Collection<ComponentDependencyModelEntity> existingComponentsDependencies =
getExistingComponentDependencies();
- doReturn(existingComponentsDependencies).
- when(vendorSoftwareProductDaoMock).listComponentDependencies(anyObject(), anyObject());
+ doReturn(existingComponentsDependencies).when(componentDependencyModelDaoMock)
+ .list(anyObject());
Collection<ComponentEntity> componentListWithMoreComponentsInHeat =
new ArrayList<>();
- doReturn(componentListWithMoreComponentsInHeat).when(vendorSoftwareProductDaoMock)
- .listComponents(anyObject(), anyObject());
+ doReturn(componentListWithMoreComponentsInHeat).when(componentDaoMock).list(anyObject());
Map<String, String> componentIdNameInfoBeforeProcess = getVspInitComponentIdNameInfo();
orchestrationUtil.updateVspComponentDependencies(anyObject(), anyObject(),
componentIdNameInfoBeforeProcess);
@@ -193,8 +189,7 @@
@Test
public void testVspComponentIdNameInfo() {
Collection<ComponentEntity> initialVspComponents = getInitialVspComponents();
- doReturn(initialVspComponents).when(vendorSoftwareProductDaoMock)
- .listComponents(anyObject(), anyObject());
+ doReturn(initialVspComponents).when(componentDaoMock).list(anyObject());
Map<String, String> vspComponentIdNameInfo =
orchestrationUtil.getVspComponentIdNameInfo(anyObject(), anyObject());
Assert.assertEquals(vspComponentIdNameInfo.size(), 3);
@@ -210,8 +205,7 @@
componentEntity.setId(COMPONENT_ORIG_ID_4);
initialVspComponents.add(componentEntity);
- doReturn(initialVspComponents).when(vendorSoftwareProductDaoMock)
- .listComponents(anyObject(), anyObject());
+ doReturn(initialVspComponents).when(componentDaoMock).list(anyObject());
Map<String, String> vspComponentIdNameInfo =
orchestrationUtil.getVspComponentIdNameInfo(anyObject(), anyObject());
Assert.assertEquals(vspComponentIdNameInfo.size(), 3);
@@ -250,7 +244,7 @@
private Collection<ComponentEntity> getComponentListWithLessComponentsInHeat() {
Collection<ComponentEntity> vspComponents = getInitialVspComponents();
- for (Iterator<ComponentEntity> iterator = vspComponents.iterator(); iterator.hasNext();) {
+ for (Iterator<ComponentEntity> iterator = vspComponents.iterator(); iterator.hasNext(); ) {
ComponentEntity componentEntity = iterator.next();
if (componentEntity.getComponentCompositionData().getName().equals(COMPONENT_NAME_1)) {
iterator.remove();
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateProcessCsarHandlerTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateProcessCsarHandlerTest.java
index c2a207d..bc37273 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateProcessCsarHandlerTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateProcessCsarHandlerTest.java
@@ -6,14 +6,12 @@
import org.openecomp.core.factory.impl.AbstractFactoryBase;
import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.factory.CandidateServiceFactory;
import org.openecomp.sdc.vendorsoftwareproduct.impl.mock.CandidateServiceFactoryMock;
import org.openecomp.sdc.vendorsoftwareproduct.impl.mock.NoSqlDbFactoryMock;
import org.openecomp.sdc.vendorsoftwareproduct.impl.mock.PackageInfoDaoFactoryImplMock;
-import org.openecomp.sdc.vendorsoftwareproduct.impl.mock.VendorSoftwareProductDaoFactoryMock;
import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.process.OrchestrationTemplateProcessCsarHandler;
import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse;
import org.openecomp.sdc.versioning.dao.types.Version;
@@ -21,27 +19,31 @@
import java.nio.ByteBuffer;
import static org.junit.Assert.assertFalse;
+
public class OrchestrationTemplateProcessCsarHandlerTest {
- @Before
- public void insertMocks(){
- EnrichmentManagerFactory.getInstance();
- AbstractFactoryBase.registerFactory(NoSqlDbFactory.class, NoSqlDbFactoryMock.class);
- AbstractFactoryBase.registerFactory(PackageInfoDaoFactory.class, PackageInfoDaoFactoryImplMock.class);
- AbstractFactoryBase.registerFactory(PackageInfoDaoFactory.class, PackageInfoDaoFactoryImplMock.class);
- AbstractFactoryBase.registerFactory(VendorSoftwareProductDaoFactory.class, VendorSoftwareProductDaoFactoryMock.class);
- AbstractFactoryBase.registerFactory(CandidateServiceFactory.class, CandidateServiceFactoryMock.class);
- }
+ @Before
+ public void insertMocks() {
+ EnrichmentManagerFactory.getInstance();
+ AbstractFactoryBase.registerFactory(NoSqlDbFactory.class, NoSqlDbFactoryMock.class);
+ AbstractFactoryBase
+ .registerFactory(PackageInfoDaoFactory.class, PackageInfoDaoFactoryImplMock.class);
+ AbstractFactoryBase
+ .registerFactory(PackageInfoDaoFactory.class, PackageInfoDaoFactoryImplMock.class);
+ AbstractFactoryBase
+ .registerFactory(CandidateServiceFactory.class, CandidateServiceFactoryMock.class);
+ }
-
- @Test
- public void validateErrorHandling(){
- VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
- OrchestrationTemplateCandidateData orchestrationTemplateCandidateData = new OrchestrationTemplateCandidateData(ByteBuffer.wrap("".getBytes()),"");
- OrchestrationTemplateProcessCsarHandler handler = new OrchestrationTemplateProcessCsarHandler();
- OrchestrationTemplateActionResponse response = handler.process(vspDetails, orchestrationTemplateCandidateData, "007");
- assertFalse(response.getErrors().isEmpty());
- }
+ @Test
+ public void validateErrorHandling() {
+ VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
+ OrchestrationTemplateCandidateData orchestrationTemplateCandidateData =
+ new OrchestrationTemplateCandidateData(ByteBuffer.wrap("".getBytes()), "", "zip", "file");
+ OrchestrationTemplateProcessCsarHandler handler = new OrchestrationTemplateProcessCsarHandler();
+ OrchestrationTemplateActionResponse response =
+ handler.process(vspDetails, orchestrationTemplateCandidateData);
+ assertFalse(response.getErrors().isEmpty());
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImplTest.java
index 478bdfb..b925ab9 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImplTest.java
@@ -1,19 +1,18 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Captor;
-import org.openecomp.sdc.activityLog.ActivityLogManager;
import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessType;
import org.openecomp.sdc.versioning.dao.types.Version;
@@ -28,12 +27,13 @@
import java.util.Arrays;
import java.util.Collection;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
-import static org.mockito.Matchers.eq;
public class ProcessManagerImplTest {
@@ -48,9 +48,7 @@
private static final String ARTIFACT_NAME = "artifact.sh";
@Mock
- private VendorSoftwareProductDao vendorSoftwareProductDaoMock;
- @Mock
- private ActivityLogManager activityLogManagerMock;
+ private ProcessDao processDaoMock;
@InjectMocks
@Spy
@@ -66,7 +64,7 @@
@Test
public void testListWhenNone() {
Collection<ProcessEntity> processes =
- processManager.listProcesses(VSP_ID, VERSION, COMPONENT_ID, USER1);
+ processManager.listProcesses(VSP_ID, VERSION, COMPONENT_ID);
Assert.assertEquals(processes.size(), 0);
}
@@ -75,17 +73,17 @@
doReturn(Arrays.asList(
createProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID),
createProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS2_ID)))
- .when(vendorSoftwareProductDaoMock).listProcesses(VSP_ID, VERSION, COMPONENT_ID);
+ .when(processDaoMock).list(any(ProcessEntity.class));
Collection<ProcessEntity> actual =
- processManager.listProcesses(VSP_ID, VERSION, COMPONENT_ID, USER1);
+ processManager.listProcesses(VSP_ID, VERSION, COMPONENT_ID);
Assert.assertEquals(actual.size(), 2);
}
@Test
public void testDeleteListWhenNone() {
- processManager.deleteProcesses(VSP_ID, VERSION, COMPONENT_ID, USER1);
- verify(vendorSoftwareProductDaoMock, never()).deleteProcesses(VSP_ID, VERSION, COMPONENT_ID);
+ processManager.deleteProcesses(VSP_ID, VERSION, COMPONENT_ID);
+ verify(processDaoMock, never()).delete(any(ProcessEntity.class));
}
@Test
@@ -93,15 +91,15 @@
ProcessEntity process1 = createProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
ProcessEntity process2 = createProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS2_ID);
doReturn(Arrays.asList(process1, process2))
- .when(vendorSoftwareProductDaoMock).listProcesses(VSP_ID, VERSION, COMPONENT_ID);
+ .when(processDaoMock).list(any(ProcessEntity.class));
doNothing().when(processManager)
.deleteUniqueValue(VSP_ID, VERSION, COMPONENT_ID, process1.getName());
doNothing().when(processManager)
.deleteUniqueValue(VSP_ID, VERSION, COMPONENT_ID, process2.getName());
- processManager.deleteProcesses(VSP_ID, VERSION, COMPONENT_ID, USER1);
+ processManager.deleteProcesses(VSP_ID, VERSION, COMPONENT_ID);
- verify(vendorSoftwareProductDaoMock).deleteProcesses(VSP_ID, VERSION, COMPONENT_ID);
+ verify(processDaoMock).deleteAll(eq(new ProcessEntity(VSP_ID, VERSION, COMPONENT_ID, null)));
verify(processManager)
.deleteUniqueValue(VSP_ID, VERSION, COMPONENT_ID, process1.getName());
verify(processManager)
@@ -118,7 +116,7 @@
doNothing().when(processManager)
.createUniqueName(VSP_ID, VERSION, COMPONENT_ID, processToCreate.getName());
- ProcessEntity process = processManager.createProcess(processToCreate, USER1);
+ ProcessEntity process = processManager.createProcess(processToCreate);
Assert.assertNotNull(process);
process.setId(process.getId());
@@ -134,13 +132,12 @@
new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION).build()))
.when(processManager).validateUniqueName(VSP_ID, VERSION, COMPONENT_ID, process.getName());
- processManager.createProcess(process, USER1);
+ processManager.createProcess(process);
}
@Test
public void testUpdateNonExistingProcessId_negative() {
- doReturn(null).when(vendorSoftwareProductDaoMock)
- .getProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
+ doReturn(null).when(processDaoMock).get(any(ProcessEntity.class));
testUpdate_negative(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID, USER1,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
@@ -149,8 +146,7 @@
@Test(expectedExceptions = CoreException.class)
public void testUpdateWithExistingName_negative() {
ProcessEntity existingProcess = createProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
- doReturn(existingProcess).when
- (vendorSoftwareProductDaoMock).getProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
+ doReturn(existingProcess).when(processDaoMock).get(any(ProcessEntity.class));
ProcessEntity processToUpdate = createProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
doThrow(new CoreException(
@@ -159,22 +155,21 @@
.updateUniqueName(VSP_ID, VERSION, COMPONENT_ID, existingProcess.getName(),
processToUpdate.getName());
- processManager.updateProcess(processToUpdate, USER1);
+ processManager.updateProcess(processToUpdate);
}
@Test
public void testUpdate() {
ProcessEntity existingProcess = createProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
- doReturn(existingProcess).when
- (vendorSoftwareProductDaoMock).getProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
+ doReturn(existingProcess).when(processDaoMock).get(any(ProcessEntity.class));
ProcessEntity processToUpdate = createProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
doNothing().when(processManager)
.updateUniqueName(VSP_ID, VERSION, COMPONENT_ID, existingProcess.getName(),
processToUpdate.getName());
- processManager.updateProcess(processToUpdate, USER1);
- verify(vendorSoftwareProductDaoMock).updateProcess(processToUpdate);
+ processManager.updateProcess(processToUpdate);
+ verify(processDaoMock).update(processToUpdate);
}
@@ -187,10 +182,9 @@
@Test
public void testGet() {
ProcessEntity process = createProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
- doReturn(process).when
- (vendorSoftwareProductDaoMock).getProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
+ doReturn(process).when(processDaoMock).get(any(ProcessEntity.class));
ProcessEntity actual =
- processManager.getProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID, USER1);
+ processManager.getProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
Assert.assertEquals(actual, process);
Assert.assertNull(actual.getArtifactName());
}
@@ -199,29 +193,28 @@
public void testGetAfterUploadArtifact() {
ProcessEntity process = createProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
process.setArtifactName(ARTIFACT_NAME);
- doReturn(process).when
- (vendorSoftwareProductDaoMock).getProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
+ doReturn(process).when(processDaoMock).get(any(ProcessEntity.class));
ProcessEntity actual =
- processManager.getProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID, USER1);
+ processManager.getProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
Assert.assertEquals(actual, process);
Assert.assertEquals(actual.getArtifactName(), ARTIFACT_NAME);
}
@Test(expectedExceptions = CoreException.class)
public void testDeleteNonExistingProcessId_negative() {
- processManager.deleteProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID, USER1);
+ processManager.deleteProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
}
@Test
public void testDelete() {
ProcessEntity processToDelete = createProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
- doReturn(processToDelete).when
- (vendorSoftwareProductDaoMock).getProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
+ doReturn(processToDelete).when(processDaoMock)
+ .get(any(ProcessEntity.class));
doNothing().when(processManager).deleteUniqueValue(VSP_ID, VERSION, COMPONENT_ID,
processToDelete.getName());
- processManager.deleteProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID, USER1);
- verify(vendorSoftwareProductDaoMock).deleteProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
+ processManager.deleteProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
+ verify(processDaoMock).delete(any(ProcessEntity.class));
verify(processManager)
.deleteUniqueValue(VSP_ID, VERSION, COMPONENT_ID, processToDelete.getName());
}
@@ -235,21 +228,13 @@
@Test
public void testUploadArtifact() {
ProcessEntity process = createProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
- doReturn(process).when
- (vendorSoftwareProductDaoMock).getProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
+ doReturn(process).when(processDaoMock).get(any(ProcessEntity.class));
byte[] artifactBytes = "bla bla".getBytes();
processManager
.uploadProcessArtifact(new ByteArrayInputStream(artifactBytes), ARTIFACT_NAME,
- VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID, USER1);
- verify(vendorSoftwareProductDaoMock)
- .uploadProcessArtifact(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID, artifactBytes,
- ARTIFACT_NAME);
-
- verify(activityLogManagerMock).addActionLog(activityLogEntityArg.capture(), eq(USER1));
- ActivityLogEntity activityLogEntity = activityLogEntityArg.getValue();
- Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION.getMajor()+1));
- Assert.assertTrue(activityLogEntity.isSuccess());
+ VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
+ verify(processDaoMock).uploadArtifact(any(ProcessEntity.class));
}
@Test
@@ -269,11 +254,11 @@
ProcessEntity processArtifact =
new ProcessEntity(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
processArtifact.setArtifact(ByteBuffer.wrap("bla bla".getBytes()));
- doReturn(processArtifact).when(vendorSoftwareProductDaoMock)
- .getProcessArtifact(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
+ doReturn(processArtifact).when(processDaoMock)
+ .getArtifact(any(ProcessEntity.class));
File actual =
- processManager.getProcessArtifact(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID, USER1);
+ processManager.getProcessArtifact(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
Assert.assertNotNull(actual);
}
@@ -294,12 +279,12 @@
ProcessEntity processArtifact =
new ProcessEntity(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
processArtifact.setArtifact(ByteBuffer.wrap("bla bla".getBytes()));
- doReturn(processArtifact).when(vendorSoftwareProductDaoMock)
- .getProcessArtifact(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
+ doReturn(processArtifact).when(processDaoMock)
+ .getArtifact(any(ProcessEntity.class));
- processManager.deleteProcessArtifact(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID, USER1);
- verify(vendorSoftwareProductDaoMock)
- .deleteProcessArtifact(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
+ processManager.deleteProcessArtifact(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
+ verify(processDaoMock)
+ .deleteArtifact(any(ProcessEntity.class));
}
@@ -315,10 +300,10 @@
private void testGet_negative(String vspId, Version version, String componentId, String processId,
String user, String expectedErrorCode) {
try {
- processManager.getProcess(vspId, version, componentId, processId, user);
+ processManager.getProcess(vspId, version, componentId, processId);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
+ log.debug("", exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
@@ -328,10 +313,10 @@
String expectedErrorCode) {
try {
processManager
- .updateProcess(new ProcessEntity(vspId, version, componentId, processId), user);
+ .updateProcess(new ProcessEntity(vspId, version, componentId, processId));
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
+ log.debug("", exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
@@ -339,10 +324,10 @@
private void testGetFile_negative(String vspId, Version version, String componentId,
String processId, String user, String expectedErrorCode) {
try {
- processManager.getProcessArtifact(vspId, version, componentId, processId, user);
+ processManager.getProcessArtifact(vspId, version, componentId, processId);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
+ log.debug("", exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
@@ -353,10 +338,10 @@
try {
processManager
.uploadProcessArtifact(new ByteArrayInputStream("bla bla".getBytes()), "artifact.sh",
- vspId, version, componentId, processId, user);
+ vspId, version, componentId, processId);
Assert.fail();
} catch (CoreException exception) {
- log.error("",exception);
+ log.error("", exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
@@ -364,10 +349,10 @@
private void testDeleteArtifact_negative(String vspId, String componentId, String processId,
String user, String expectedErrorCode) {
try {
- processManager.deleteProcessArtifact(vspId, VERSION, componentId, processId, user);
+ processManager.deleteProcessArtifact(vspId, VERSION, componentId, processId);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
+ log.debug("", exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java
index 5199dfd..7721817 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java
@@ -33,15 +33,12 @@
import org.openecomp.core.model.types.ServiceElement;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.file.FileUtils;
-import org.openecomp.sdc.activityLog.ActivityLogManager;
import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.healing.api.HealingManager;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.tosca.datatypes.model.CapabilityDefinition;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
@@ -53,18 +50,16 @@
import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadDataEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.impl.mock.EnrichmentManagerFactoryImpl;
import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactGenerator;
import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse;
-import org.openecomp.sdc.vendorsoftwareproduct.types.VersionedVendorSoftwareProductInfo;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
import org.openecomp.sdc.versioning.VersioningManager;
import org.openecomp.sdc.versioning.dao.types.Version;
@@ -94,7 +89,6 @@
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
@@ -103,13 +97,10 @@
public class VendorSoftwareProductManagerImplTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(VendorSoftwareProductManagerImplTest.class);
-
private static final String INVALID_VERSION_MSG = "Invalid requested version.";
- private static final String VSP_ID = "vspId";
- private static final String VERSION_ID = "versionId";
+ private static String VSP_ID = "vspId";
+ private static String VERSION_ID = "versionId";
public static final Version VERSION01 = new Version(0, 1);
private static final Version VERSION10 = new Version(1, 0);
private static final String USER1 = "vspTestUser1";
@@ -121,8 +112,6 @@
@Mock
private VersioningManager versioningManagerMock;
@Mock
- private VendorSoftwareProductDao vendorSoftwareProductDaoMock; // todo get rid of
- @Mock
private OrchestrationTemplateDao orchestrationTemplateDataDaoMock;
@Mock
private VendorLicenseFacade vendorLicenseFacadeMock;
@@ -139,8 +128,6 @@
@Mock
private InformationArtifactGenerator informationArtifactGeneratorMock;
@Mock
- private ActivityLogManager activityLogManagerMock;
- @Mock
private PackageInfoDao packageInfoDao;
@Mock
private VendorSoftwareProductInfoDao vspInfoDaoMock;
@@ -164,14 +151,14 @@
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
}
-
+/*
@Test
public void testListWhenNone() {
doReturn(new HashMap<>()).when(versioningManagerMock).listEntitiesVersionInfo
- (VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, USER1,
- VersionableEntityAction.Read);
+ (VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, USER1,
+ VersionableEntityAction.Read);
List<VersionedVendorSoftwareProductInfo> vsps =
- vendorSoftwareProductManager.listVsps(null, USER1);
+ vendorSoftwareProductManager.listVsps(null);
Assert.assertEquals(vsps.size(), 0);
}
@@ -190,16 +177,16 @@
vspsTobeReturned.put(vsp2id, versionInfo2);
doReturn(vspsTobeReturned).when(versioningManagerMock).listEntitiesVersionInfo
- (VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, USER1,
- VersionableEntityAction.Read);
+ (VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, USER1,
+ VersionableEntityAction.Read);
VspDetails vsp1 = new VspDetails(vsp1id, VERSION01);
vsp1.setWritetimeMicroSeconds(8L);
doReturn(vsp1).when(vspInfoDaoMock)
- .get(any(VspDetails.class));
+ .get(any(VspDetails.class));
List<VersionedVendorSoftwareProductInfo> vsps =
- vendorSoftwareProductManager.listVsps(null, USER1);
+ vendorSoftwareProductManager.listVsps(null);
Assert.assertEquals(vsps.size(), 2);
}
@@ -218,11 +205,11 @@
vspsTobeReturned.put(vsp2id, versionInfo2);
doReturn(vspsTobeReturned).when(versioningManagerMock).listEntitiesVersionInfo
- (VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, USER1,
- VersionableEntityAction.Read);
+ (VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, USER1,
+ VersionableEntityAction.Read);
List<VersionedVendorSoftwareProductInfo> vsps =
- vendorSoftwareProductManager.listVsps(VersionStatus.Final.name(), USER1);
+ vendorSoftwareProductManager.listVsps(VersionStatus.Certified.name());
Assert.assertEquals(vsps.size(), 0);
}
@@ -242,53 +229,36 @@
vspsTobeReturned.put(vsp2id, versionInfo2);
doReturn(vspsTobeReturned).when(versioningManagerMock).listEntitiesVersionInfo
- (VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, USER1,
- VersionableEntityAction.Read);
+ (VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, USER1,
+ VersionableEntityAction.Read);
VspDetails vsp2 = new VspDetails(vsp2id, VERSION10);
vsp2.setWritetimeMicroSeconds(8L);
doReturn(vsp2).when(vspInfoDaoMock)
- .get(any(VspDetails.class));
+ .get(any(VspDetails.class));
List<VersionedVendorSoftwareProductInfo> vsps =
- vendorSoftwareProductManager.listVsps(VersionStatus.Final.name(), USER1);
+ vendorSoftwareProductManager.listVsps(VersionStatus.Certified.name());
Assert.assertEquals(vsps.size(), 1);
- }
+ }*/
- @Test(expectedExceptions = CoreException.class)
- public void testCreateWithExistingName_negative() {
- doThrow(new CoreException(
- new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION).build()))
- .when(vendorSoftwareProductManager).validateUniqueName("Vsp1");
- VspDetails expectedVsp =
- createVspDetails(null, null, "Vsp1", "Test-vsp", "vendorName", "vlm1Id", "icon",
- "category", "subCategory", "123", null);
-
- vendorSoftwareProductManager.createVsp(expectedVsp, USER1);
- }
@Test
public void testCreate() {
- doNothing().when(vendorSoftwareProductManager).validateUniqueName("Vsp1");
- doNothing().when(vendorSoftwareProductManager).createUniqueName("Vsp1");
- doReturn(VERSION01).when(versioningManagerMock).create(anyObject(), anyObject(), anyObject());
+ //doReturn(VERSION01).when(versioningManagerMock).create(anyObject(), anyObject(), anyObject());
doReturn("{}")
- .when(vendorSoftwareProductManager).getVspQuestionnaireSchema(anyObject());
+ .when(vendorSoftwareProductManager).getVspQuestionnaireSchema(anyObject());
VspDetails vspToCreate =
- createVspDetails(null, null, "Vsp1", "Test-vsp", "vendorName", "vlm1Id", "icon",
- "category", "subCategory", "123", null);
+ createVspDetails(null, null, "Vsp1", "Test-vsp", "vendorName", "vlm1Id", "icon",
+ "category", "subCategory", "123", null);
- VspDetails vsp = vendorSoftwareProductManager.createVsp(vspToCreate, USER1);
+ VspDetails vsp = vendorSoftwareProductManager.createVsp(vspToCreate);
Assert.assertNotNull(vsp);
vspToCreate.setId(vsp.getId());
vspToCreate.setVersion(VERSION01);
assertVspsEquals(vsp, vspToCreate);
- verify(activityLogManagerMock).addActionLog(activityLogEntityArg.capture(), eq(USER1));
- ActivityLogEntity activityLogEntity = activityLogEntityArg.getValue();
- Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION01.getMajor() + 1));
- Assert.assertTrue(activityLogEntity.isSuccess());
}
@Test(expectedExceptions = CoreException.class)
@@ -296,23 +266,23 @@
VersionInfo versionInfo = new VersionInfo();
versionInfo.setActiveVersion(VERSION01);
doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
- VersionableEntityAction.Write);
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
+ VersionableEntityAction.Write);
VspDetails existingVsp =
- createVspDetails(VSP_ID, VERSION01, "Vsp1", "Test-existingVsp", "vendorName", "vlm1Id",
- "icon", "category", "subCategory", "123", null);
+ createVspDetails(VSP_ID, VERSION01, "Vsp1", "Test-existingVsp", "vendorName", "vlm1Id",
+ "icon", "category", "subCategory", "123", null);
VspDetails updatedVsp =
- createVspDetails(VSP_ID, VERSION01, "Vsp1_updated", "Test-existingVsp", "vendorName",
- "vlm1Id", "icon", "category", "subCategory", "123", null);
+ createVspDetails(VSP_ID, VERSION01, "Vsp1_updated", "Test-existingVsp", "vendorName",
+ "vlm1Id", "icon", "category", "subCategory", "123", null);
doReturn(existingVsp).when(vspInfoDaoMock)
- .get(any(VspDetails.class));
+ .get(any(VspDetails.class));
doThrow(new CoreException(
- new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION).build()))
- .when(vendorSoftwareProductManager)
- .updateUniqueName(existingVsp.getName(), updatedVsp.getName());
+ new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION).build()))
+ .when(vendorSoftwareProductManager)
+ .updateUniqueName(existingVsp.getName(), updatedVsp.getName());
- vendorSoftwareProductManager.updateVsp(updatedVsp, USER1);
+ vendorSoftwareProductManager.updateVsp(updatedVsp);
}
@Test
@@ -320,23 +290,23 @@
VersionInfo versionInfo = new VersionInfo();
versionInfo.setActiveVersion(VERSION01);
doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
- VersionableEntityAction.Write);
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
+ VersionableEntityAction.Write);
VspDetails existingVsp =
- createVspDetails(VSP_ID, VERSION01, "VSP1", null, "vendorName", "vlm1Id", "icon",
- "category",
- "subCategory", "456", null);
+ createVspDetails(VSP_ID, VERSION01, "VSP1", null, "vendorName", "vlm1Id", "icon",
+ "category",
+ "subCategory", "456", null);
VspDetails updatedVsp =
- createVspDetails(VSP_ID, VERSION01, "VSP1_updated", null, "vendorName", "vlm1Id", "icon",
- "category_updated",
- "subCategory", "456", null);
+ createVspDetails(VSP_ID, VERSION01, "VSP1_updated", null, "vendorName", "vlm1Id", "icon",
+ "category_updated",
+ "subCategory", "456", null);
existingVsp.setWritetimeMicroSeconds(8L);
doReturn(existingVsp).when(vspInfoDaoMock)
- .get(any(VspDetails.class));
+ .get(any(VspDetails.class));
doNothing().when(vendorSoftwareProductManager)
- .updateUniqueName(existingVsp.getName(), updatedVsp.getName());
+ .updateUniqueName(existingVsp.getName(), updatedVsp.getName());
- vendorSoftwareProductManager.updateVsp(updatedVsp, USER1);
+ vendorSoftwareProductManager.updateVsp(updatedVsp);
verify(vspInfoDaoMock).update(updatedVsp);
}
@@ -346,40 +316,41 @@
VersionInfo versionInfo = new VersionInfo();
versionInfo.setActiveVersion(VERSION01);
doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
- VersionableEntityAction.Write);
- List<String> fgs = new ArrayList<>();
- fgs.add("fg1"); fgs.add("fg2");
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
+ VersionableEntityAction.Write);
+ List<String> fgs = new ArrayList<String>();
+ fgs.add("fg1");
+ fgs.add("fg2");
VspDetails existingVsp =
- createVspDetails(VSP_ID, VERSION01, "VSP1", null, "vendorName", "vlm1Id", "icon",
- "category",
- "subCategory", "456", fgs);
+ createVspDetails(VSP_ID, VERSION01, "VSP1", null, "vendorName", "vlm1Id", "icon",
+ "category",
+ "subCategory", "456", fgs);
- List<String> updFgs = new ArrayList<>();
- updFgs.add("fg2");
+ List<String> updFgs = new ArrayList<String>();
+ //updFgs.add("fg2");
VspDetails updatedVsp =
- createVspDetails(VSP_ID, VERSION01, "VSP1_updated", null, "vendorName", "vlm1Id", "icon",
- "category_updated",
- "subCategory", "456", updFgs);
+ createVspDetails(VSP_ID, VERSION01, "VSP1_updated", null, "vendorName", "vlm1Id", "icon",
+ "category_updated",
+ "subCategory", "456", updFgs);
existingVsp.setWritetimeMicroSeconds(8L);
doReturn(existingVsp).when(vspInfoDaoMock)
- .get(any(VspDetails.class));
+ .get(any(VspDetails.class));
doNothing().when(vendorSoftwareProductManager)
- .updateUniqueName(existingVsp.getName(), updatedVsp.getName());
+ .updateUniqueName(existingVsp.getName(), updatedVsp.getName());
- DeploymentFlavorEntity dfEntity = new DeploymentFlavorEntity(VSP_ID,VERSION01,"DF_ID");
+ DeploymentFlavorEntity dfEntity = new DeploymentFlavorEntity(VSP_ID, VERSION01, "DF_ID");
DeploymentFlavor flavor = new DeploymentFlavor();
flavor.setFeatureGroupId("fg1");
dfEntity.setDeploymentFlavorCompositionData(flavor);
- List<DeploymentFlavorEntity> dfList = new ArrayList<>();
+ List<DeploymentFlavorEntity> dfList = new ArrayList<DeploymentFlavorEntity>();
dfList.add(dfEntity);
doReturn(dfList).when(deploymentFlavorDaoMock).list(anyObject());
- vendorSoftwareProductManager.updateVsp(updatedVsp, USER1);
+ vendorSoftwareProductManager.updateVsp(updatedVsp);
- verify(vendorSoftwareProductDaoMock).updateDeploymentFlavor(dfEntity);
+ verify(deploymentFlavorDaoMock).update(dfEntity);
Assert.assertNull(dfEntity.getDeploymentFlavorCompositionData().getFeatureGroupId());
@@ -389,7 +360,7 @@
public void testGetNonExistingVersion_negative() {
Version notExistversion = new Version(43, 8);
doReturn(null).when(vspInfoDaoMock).get(any(VspDetails.class));
- vendorSoftwareProductManager.getVsp(VSP_ID, notExistversion, USER1);
+ vendorSoftwareProductManager.getVsp(VSP_ID, notExistversion);
}
@Test
@@ -399,18 +370,18 @@
versionInfo.setStatus(VersionStatus.Locked);
versionInfo.setLockingUser(USER1);
doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
- VersionableEntityAction.Read);
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
+ VersionableEntityAction.Read);
VspDetails existingVsp =
- createVspDetails(VSP_ID, VERSION01, "VSP1", null, "vendorName", "vlm1Id", "icon",
- "category",
- "subCategory", "456", null);
+ createVspDetails(VSP_ID, VERSION01, "VSP1", null, "vendorName", "vlm1Id", "icon",
+ "category",
+ "subCategory", "456", null);
existingVsp.setWritetimeMicroSeconds(8L);
doReturn(existingVsp).when(vspInfoDaoMock).get(any(VspDetails.class));
VspDetails actualVsp =
- vendorSoftwareProductManager.getVsp(VSP_ID, VERSION01, USER1);
+ vendorSoftwareProductManager.getVsp(VSP_ID, VERSION01);
assertVspsEquals(actualVsp, existingVsp);
}
@@ -423,84 +394,26 @@
versionInfo.setStatus(VersionStatus.Locked);
versionInfo.setLockingUser(USER2);
doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
- VersionableEntityAction.Read);
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
+ VersionableEntityAction.Read);
VspDetails existingVsp =
- createVspDetails(VSP_ID, VERSION01, "VSP1", null, "vendorName", "vlm1Id", "icon",
- "category",
- "subCategory", "456", null);
+ createVspDetails(VSP_ID, VERSION01, "VSP1", null, "vendorName", "vlm1Id", "icon",
+ "category",
+ "subCategory", "456", null);
existingVsp.setWritetimeMicroSeconds(8L);
doReturn(existingVsp)
- .when(vspInfoDaoMock).get(any(VspDetails.class));
+ .when(vspInfoDaoMock).get(any(VspDetails.class));
VspDetails actualVsp =
- vendorSoftwareProductManager.getVsp(VSP_ID, VERSION01, USER1);
+ vendorSoftwareProductManager.getVsp(VSP_ID, VERSION01);
VspDetails expectedVsp =
- vspInfoDaoMock
- .get(new VspDetails(VSP_ID, VERSION01));
+ vspInfoDaoMock
+ .get(new VspDetails(VSP_ID, VERSION01));
assertVspsEquals(actualVsp, expectedVsp);
}
- @Test
- public void testCheckin() {
- doReturn(VERSION01).when(versioningManagerMock)
- .checkin(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID,
- USER1, null);
- Version version = vendorSoftwareProductManager.checkin(VSP_ID, USER1);
-
- Assert.assertEquals(version, VERSION01);
- verify(versioningManagerMock)
- .checkin(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID,
- USER1, null);
- verify(activityLogManagerMock).addActionLog(activityLogEntityArg.capture(), eq(USER1));
- ActivityLogEntity activityLogEntity = activityLogEntityArg.getValue();
- Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION01.getMajor() + 1));
- Assert.assertTrue(activityLogEntity.isSuccess());
- }
-
- @Test
- public void testCheckout() {
- doReturn(VERSION01).when(versioningManagerMock)
- .checkout(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID,
- USER1);
- Version version = vendorSoftwareProductManager.checkout(VSP_ID, USER1);
-
- Assert.assertEquals(version, VERSION01);
- verify(versioningManagerMock)
- .checkout(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID,
- USER1);
-
- verify(activityLogManagerMock).addActionLog(activityLogEntityArg.capture(), eq(USER1));
- ActivityLogEntity activityLogEntity = activityLogEntityArg.getValue();
- Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION01.getMajor() + 1));
- Assert.assertTrue(activityLogEntity.isSuccess());
- }
-
-
- @Test
- public void testUndoCheckout() {
- Version existingVersion = new Version(0, 2);
- VersionInfo versionInfo = new VersionInfo();
- versionInfo.setActiveVersion(existingVersion);
- doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
- VSP_ID, USER1, VersionableEntityAction.Read);
-
- doReturn(VERSION01).when(versioningManagerMock).undoCheckout(VendorSoftwareProductConstants
- .VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1);
-
- VspDetails vsp = new VspDetails(VSP_ID, existingVersion);
- vsp.setName("ExistingName");
- doReturn(vsp).when(vspInfoDaoMock).get(anyObject());
- doNothing().when(vendorSoftwareProductManager).updateUniqueName(vsp.getName(), vsp.getName());
-
- Version undoCheckoutVersion = vendorSoftwareProductManager.undoCheckout(VSP_ID, USER1);
-
- Assert.assertEquals(undoCheckoutVersion, VERSION01);
- }
-
/*
@Test
public void testSubmitWithMissingData() throws IOException {
@@ -551,35 +464,33 @@
VersionInfo versionInfo = new VersionInfo();
versionInfo.setActiveVersion(VERSION01);
doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
- VSP_ID, USER1, VersionableEntityAction.Read);
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
+ VSP_ID, USER1, VersionableEntityAction.Read);
VspDetails vsp =
- createVspDetails(VSP_ID, VERSION01, "Vsp1", "Test-vsp", "vendorName", "vlm1Id", "icon",
- "category", "subCategory", "licenseAgreementId",
- Collections.singletonList("featureGroupId"));
+ createVspDetails(VSP_ID, VERSION01, "Vsp1", "Test-vsp", "vendorName", "vlm1Id", "icon",
+ "category", "subCategory", "licenseAgreementId",
+ Collections.singletonList("featureGroupId"));
doReturn(vsp).when(vspInfoDaoMock).get(anyObject());
- UploadDataEntity uploadData = new UploadDataEntity(VSP_ID, VERSION01);
+ OrchestrationTemplateEntity uploadData = new OrchestrationTemplateEntity(VSP_ID, VERSION01);
uploadData.setContentData(
- ByteBuffer.wrap(getBytes("/emptyComposition")));
+ ByteBuffer.wrap(FileUtils.toByteArray(getFileInputStream("/emptyComposition"))));
doReturn(uploadData).when(orchestrationTemplateDataDaoMock)
- .getOrchestrationTemplate(anyObject(), anyObject());
+ .get(anyObject(), anyObject());
doReturn(new ToscaServiceModel(new FileContentHandler(), new HashMap<>(),
- "MainServiceTemplate.yaml"))
- .when(serviceModelDaoMock).getServiceModel(VSP_ID, VERSION01);
+ "MainServiceTemplate.yaml"))
+ .when(serviceModelDaoMock).getServiceModel(VSP_ID, VERSION01);
- ValidationResponse validationResponse = vendorSoftwareProductManager.submit(VSP_ID, USER1);
+ ValidationResponse validationResponse =
+ vendorSoftwareProductManager.validate(VSP_ID, VERSION01);
Assert.assertNotNull(validationResponse);
Assert.assertFalse(validationResponse.isValid());
Assert.assertNull(validationResponse.getVspErrors());
- Assert.assertEquals(validationResponse.getLicensingDataErrors(), 1);
+ Assert.assertEquals(validationResponse.getLicensingDataErrors().size(), 1);
verify(versioningManagerMock, never())
- .submit(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID,
- USER1, null);
-
- //TODO - check..
- verify(activityLogManagerMock, never()).addActionLog(any(ActivityLogEntity.class), eq(USER1));
+ .submit(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID,
+ USER1, null);
}
// TODO: 3/15/2017 fix and enable
@@ -589,40 +500,32 @@
EnrichmentManagerFactory.getInstance();
AbstractFactoryBase
- .registerFactory(EnrichmentManagerFactory.class, EnrichmentManagerFactoryImpl.class);
+ .registerFactory(EnrichmentManagerFactory.class, EnrichmentManagerFactoryImpl.class);
VspDetails vsp =
- createVspDetails(VSP_ID, VERSION01, "Vsp1", "Test-vsp", "vendorName", "vlm1Id", "icon",
- "category", "subCategory", "123", Collections.singletonList("fg1"));
+ createVspDetails(VSP_ID, VERSION01, "Vsp1", "Test-vsp", "vendorName", "vlm1Id", "icon",
+ "category", "subCategory", "123", Collections.singletonList("fg1"));
doReturn(vsp).when(vspInfoDaoMock).get(anyObject());
- UploadDataEntity uploadData = new UploadDataEntity(VSP_ID, VERSION01);
+ OrchestrationTemplateEntity uploadData = new OrchestrationTemplateEntity(VSP_ID, VERSION01);
uploadData.setContentData(
- ByteBuffer.wrap(getBytes("/emptyComposition")));
+ ByteBuffer.wrap(FileUtils.toByteArray(getFileInputStream("/emptyComposition"))));
doReturn(uploadData).when(orchestrationTemplateDataDaoMock)
- .getOrchestrationTemplate(anyObject(), anyObject());
+ .get(anyObject(), anyObject());
doReturn(new ToscaServiceModel(new FileContentHandler(), new HashMap<>(),
- "MainServiceTemplate.yaml"))
- .when(serviceModelDaoMock).getServiceModel(VSP_ID, VERSION01);
+ "MainServiceTemplate.yaml"))
+ .when(serviceModelDaoMock).getServiceModel(VSP_ID, VERSION01);
- ValidationResponse validationResponse = vendorSoftwareProductManager.submit(VSP_ID, USER1);
+ ValidationResponse validationResponse =
+ vendorSoftwareProductManager.validate(VSP_ID, VERSION01);
Assert.assertTrue(validationResponse.isValid());
-/* Assert.assertEquals(vsp2.getVersionInfo().getActiveVersion(), VERSION10);
- Assert.assertEquals(vsp2.getVersionInfo().getStatus(), VersionStatus.Final);
+/* Assert.assertEquals(vsp2.getVersionInfo().getVersion(), VERSION10);
+ Assert.assertEquals(vsp2.getVersionInfo().getStatus(), VersionStatus.Certified);
Assert.assertNull(vsp2.getVersionInfo().getLockingUser());*/
verify(versioningManagerMock)
- .submit(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID,
- USER1, null);
- verify(activityLogManagerMock).addActionLog(activityLogEntityArg.capture(), eq(USER1));
- ActivityLogEntity activityLogEntity = activityLogEntityArg.getValue();
- Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION10.getMajor()));
- Assert.assertTrue(activityLogEntity.isSuccess());
- }
-
- @Test(expectedExceptions = CoreException.class)
- public void testCreatePackageOnNonFinalVersion_negative() throws IOException {
- vendorSoftwareProductManager.createPackage(VSP_ID, VERSION01, USER1);
+ .submit(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID,
+ USER1, null);
}
@Test
@@ -632,11 +535,11 @@
VersionInfo versionInfo = new VersionInfo();
versionInfo.setActiveVersion(VERSION10);
doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
- VersionableEntityAction.Read);
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
+ VersionableEntityAction.Read);
doReturn(new ToscaServiceModel(new FileContentHandler(), new HashMap<>(), "")).when
- (enrichedServiceModelDaoMock).getServiceModel(VSP_ID, VERSION10);
+ (enrichedServiceModelDaoMock).getServiceModel(VSP_ID, VERSION10);
VspDetails vsp = new VspDetails(VSP_ID, VERSION10);
vsp.setVendorId("vendorId");
@@ -645,20 +548,20 @@
doReturn(vsp).when(vspInfoDaoMock).get(any(VspDetails.class));
doReturn(new FileContentHandler()).when(licenseArtifactsServiceMock)
- .createLicenseArtifacts(VSP_ID, vsp.getVendorId(), VERSION10, vsp.getFeatureGroups(),
- USER1);
+ .createLicenseArtifacts(VSP_ID, vsp.getVendorId(), VERSION10, vsp.getFeatureGroups()
+ );
- PackageInfo packageInfo = vendorSoftwareProductManager.createPackage(VSP_ID, VERSION10, USER1);
+ PackageInfo packageInfo = vendorSoftwareProductManager.createPackage(VSP_ID, VERSION10);
Assert.assertNotNull(packageInfo.getVspId());
}
// TODO: 3/15/2017 fix and enable
//@Test(dependsOnMethods = {"testListFinals"})
public void testUploadFileMissingFile() throws IOException {
+ try (InputStream zis = getFileInputStream("/vspmanager/zips/missingYml.zip")) {
- try (InputStream zis = this.getClass().getResourceAsStream("/vspmanager/zips/missingYml.zip")) {
UploadFileResponse uploadFileResponse =
- candidateManager.upload(VSP_ID, VERSION01, zis, USER1, "zip", "missingYml");
+ candidateManager.upload(VSP_ID, VERSION01, zis, "zip", "file");
Assert.assertEquals(uploadFileResponse.getErrors().size(), 0);
}
@@ -667,38 +570,130 @@
// TODO: 3/15/2017 fix and enable
//@Test(dependsOnMethods = {"testUploadFileMissingFile"})
public void testUploadNotZipFile() throws IOException {
-
URL url = this.getClass().getResource("/notZipFile");
- try (InputStream inputStream = url.openStream()) {
- candidateManager
- .upload(VSP_ID, VERSION01,
- inputStream, USER1, "zip", "notZipFile");
- candidateManager.process(VSP_ID, VERSION01, USER1);
+ try {
+ candidateManager.upload(VSP_ID, VERSION01, url.openStream(), "zip", "file");
+ candidateManager.process(VSP_ID, VERSION01);
} catch (Exception ce) {
Assert.assertEquals(ce.getMessage(), Messages.CREATE_MANIFEST_FROM_ZIP.getErrorMessage());
}
+ }
+/*
+ @Test
+ public void testEnrichModelInSubmit() {
+ UniqueValueUtil
+ .deleteUniqueValue(VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME,
+ "VSP_syb");
+ VspDetails vspDetails = vendorSoftwareProductManager.createVsp(
+ createVspDetails(null, null, "VSP_syb", "Test-vsp_syb", "vendorName", "vlm1Id", "icon",
+ "category", "subCategory", "456", null), USER1);
+ String id = vspDetails.getId();
- verify(activityLogManagerMock, never()).addActionLog(any(ActivityLogEntity.class), eq(USER1));
+ //upload file
+ InputStream zis = getFileInputStream("/vspmanager/zips/fullComposition.zip");
+ candidateManager.upload(id, VERSION01, zis, USER1);
+ OrchestrationTemplateActionResponse uploadFileResponse =
+ candidateManager.process(id, VERSION01, USER1);
+
+ //check in
+ vendorSoftwareProductManager.checkin(id, USER1);
+ //submit
+ try {
+ ValidationResponse result = vendorSoftwareProductManager.submit(id, USER1);
+ } catch (IOException exception) {
+ Assert.fail();
+ }
+ VersionedVendorSoftwareProductInfo details =
+ vendorSoftwareProductManager.getVsp(id, null, USER1);
+ Collection<ComponentEntity> components =vendorSoftwareProductManager
+ .listComponents(id, details.getVersionInfo().getVersion(), USER1);
+
+ ToscaServiceModel model =
+ (ToscaServiceModel) EnrichedServiceModelDaoFactory.getInstance().createInterface()
+ .getServiceModel(id, details.getVersionInfo().getVersion());
+
+ Map<String, CapabilityDefinition> capabilities = new HashMap<>();
+ for (ComponentEntity component : components) {
+ model.getServiceTemplates().
+ entrySet().
+ stream().
+ filter(entryValue -> entryValue.getValue() != null &&
+ entryValue.getValue().getNode_types() != null &&
+ entryValue.getValue().
+ getNode_types().
+ containsKey(component.getComponentCompositionData().getName())).
+ forEach(entryValue -> entryValue.getValue().getNode_types().
+ values().
+ stream().
+ filter(type -> MapUtils.isNotEmpty(type.getCapabilities())).
+ forEach(type -> type.getCapabilities().
+ entrySet().
+ forEach(entry -> addCapability(entryValue.getKey(), capabilities, entry.getKey(),
+ entry.getValue()))));
+
+ }
+
+ Assert.assertNotNull(capabilities);
}
+ @Test(dependsOnMethods = {"testCreatePackage"})
+ public void testEnrichedFilesDeletedOnNewUpload() throws IOException {
+ Version activeVersion;
+
+ createPackageFromUpload(VSP_ID, USER1, "/fullComposition");
+ activeVersion = vendorSoftwareProductManager.getVsp(VSP_ID, null, USER1).getVersionInfo()
+ .getVersion();
+
+ List<ServiceArtifact> firstExternalArtifacts = enrichedServiceModelDaoMock
+ .getExternalArtifacts(VSP_ID, activeVersion);
+ ToscaServiceModel firstServiceModel = enrichedServiceModelDaoMock.getServiceModel(VSP_ID,
+ activeVersion);
+
+ createPackageFromUpload(VSP_ID, USER1, "/emptyComposition");
+ activeVersion = vendorSoftwareProductManager.getVsp(VSP_ID, null, USER1).getVersionInfo()
+ .getVersion();
+
+ List<ServiceArtifact> secondExternalArtifacts = enrichedServiceModelDaoMock
+ .getExternalArtifacts(VSP_ID, activeVersion);
+ ToscaServiceModel secondServiceModel = enrichedServiceModelDaoMock.getServiceModel(VSP_ID,
+ activeVersion);
+
+ Assert.assertNotEquals(firstExternalArtifacts, secondExternalArtifacts);
+ Assert.assertNotEquals(firstServiceModel, secondServiceModel);
+
+ }
+
+ @Test(dependsOnMethods = {"testMibsDeletedInCsar"})
+ public void testServiceTemplatesAreDeletedInCsarOnNewUpload() throws IOException {
+ String nestedPath = "Definitions" + File.separator + "nested";
+
+ uploadFileAndProcess(VSP_ID, USER1, "/vspmanager/zips/fullCompositionNested.zip");
+ checkinSubmitCreatePackage(VSP_ID, USER1);
+ List<String> nestedFileNamesServiceTemplates =
+ getWantedFileNamesFromCsar(nestedPath);
+
+ uploadFileAndProcess(VSP_ID, USER1, "/vspmanager/zips/fullComposition.zip");
+ checkinSubmitCreatePackage(VSP_ID, USER1);
+ List<String> emptyNestedNamesList = getWantedFileNamesFromCsar(nestedPath);
+
+ Assert.assertEquals(emptyNestedNamesList.size(), 0);
+ Assert.assertNotEquals(emptyNestedNamesList.size(), nestedFileNamesServiceTemplates.size());
+ }*/
private List<String> getWantedFileNamesFromCsar(String pathInCsar)
- throws IOException {
- File translatedFile = vendorSoftwareProductManager.getTranslatedFile(VSP_ID, VERSION10, USER1);
+ throws IOException {
+ File translatedFile = vendorSoftwareProductManager.getTranslatedFile(VSP_ID, VERSION10);
return getFileNamesFromFolderInCsar(translatedFile,
- pathInCsar);
+ pathInCsar);
}
private List<String> getFileNamesFromFolderInCsar(File csar, String folderName)
- throws IOException {
-
+ throws IOException {
List<String> fileNames = new ArrayList<>();
- try (FileInputStream fileInputStream = new FileInputStream(csar);
- ZipInputStream zip = new ZipInputStream(fileInputStream)) {
-
+ try (ZipInputStream zip = new ZipInputStream(new FileInputStream(csar))) {
ZipEntry ze;
while ((ze = zip.getNextEntry()) != null) {
@@ -711,28 +706,26 @@
return fileNames;
}
+ /*
+ //Disabled for sonar null pointer issue for componentEntities
+ private Pair<String, String> uploadMib(String vspId, String user, String filePath,
+ String fileName) {
+ List<ComponentEntity> componentEntities = null;
+ //(List<ComponentEntity>) vendorSoftwareProductManager.listComponents(vspId, null, user);
+ monitoringUploadsManager.upload(getFileInputStream(filePath),
+ fileName, vspId,
+<<<<<<< HEAD
+ VERSION01, componentEntities.get(0).getId(), ArtifactType.SNMP_POLL);
+ //TODO: add validate of logActivity() func call
+=======
+ VERSION01, componentEntities.get(0).getId(), MonitoringUploadType.SNMP_POLL, user);
+ //TODO: add validate of addActionLog() func call
+>>>>>>> feature/Amdocs-ASDC-1710
- private void createPackageFromUpload(String vspId, String user, String filePath)
- throws IOException {
- uploadFileAndProcess(vspId, user, filePath);
- checkinSubmitCreatePackage(vspId, user);
- }
-
- private void uploadFileAndProcess(String vspId, String user, String filePath) throws IOException {
- vendorSoftwareProductManager.checkout(vspId, user);
-
- try (InputStream inputStream = this.getClass().getResourceAsStream(filePath)) {
- candidateManager.upload(vspId, VERSION01, inputStream, user, "zip", "file");
- candidateManager.process(vspId, VERSION01, user);
- }
- }
-
- private void checkinSubmitCreatePackage(String vspId, String user) throws IOException {
- vendorSoftwareProductManager.checkin(vspId, user);
- ValidationResponse submitResponse = vendorSoftwareProductManager.submit(vspId, user);
- Assert.assertTrue(submitResponse.isValid());
- vendorSoftwareProductManager.createPackage(vspId, VERSION10, user);
- }
+ return new ImmutablePair<>(componentEntities.get(0).getId(),
+ componentEntities.get(0).getComponentCompositionData()
+ .getDisplayName());
+ }*/
// TODO: 3/15/2017 fix and enable
/*
@@ -781,11 +774,11 @@
*/
private void testLegalUpload(String vspId, Version version, InputStream upload, String user) {
- candidateManager.upload(vspId, VERSION01, upload, USER1, "zip", "file");
- candidateManager.process(vspId, VERSION01, user);
+ candidateManager.upload(vspId, VERSION01, upload, "zip", "file");
+ candidateManager.process(vspId, VERSION01);
- UploadDataEntity uploadData =
- orchestrationTemplateDataDaoMock.getOrchestrationTemplate(vspId, version);
+ OrchestrationTemplateEntity uploadData =
+ orchestrationTemplateDataDaoMock.get(vspId, version);
Assert.assertNotNull(uploadData);
}
@@ -795,20 +788,40 @@
capabilities.put(entryValueKey + "_" + key, value);
}
- private byte[] getBytes(String fileName) throws IOException {
+ public InputStream getFileInputStream(String fileName) {
URL url = this.getClass().getResource(fileName);
- try (InputStream inputStream = url.openStream()) {
- return FileUtils.toByteArray(inputStream);
+ try {
+ return url.openStream();
+ } catch (IOException exception) {
+ exception.printStackTrace();
+ return null;
}
}
- private void assertVSPInWantedLocationInVSPList(String vspId, int location, String user) {
+/* private void assertVSPInWantedLocationInVSPList(String vspId, int location, String user) {
List<VersionedVendorSoftwareProductInfo> vspList =
- vendorSoftwareProductManager.listVsps(null, user);
+ vendorSoftwareProductManager.listVsps(null);
Assert.assertEquals(vspList.get(location).getVspDetails().getId(), vspId);
- }
+ }*/
+ // private void assertInfoArtifactIsInRightPathInCsar(String vspId, String zipFileName)
+// throws IOException {
+// ZipInputStream inputZipStream = new ZipInputStream(new FileInputStream(new File(zipFileName)));
+// boolean isInfoArtifactInZip = false;
+//
+// ZipEntry zipEntry;
+// while ((zipEntry = inputZipStream.getNextEntry()) != null) {
+// String currentEntryName = zipEntry.getName();
+// if(currentEntryName.equals("Artifacts\\Informative\\Guide\\VSP_" +
+// vspId + "_Information.txt")){
+// isInfoArtifactInZip = true;
+// break;
+// }
+// }
+//
+// Assert.assertTrue(isInfoArtifactInZip);
+// }
static VspDetails createVspDetails(String id, Version version, String name, String desc,
String vendorName, String vlm, String icon,
String category, String subCategory,
@@ -842,30 +855,68 @@
Assert.assertEquals(actual.getFeatureGroups(), expected.getFeatureGroups());
}
- // todo ********************** move to common **************************************
+
+// @Test
+// public void testDownloadFile() throws IOException {
+// VspDetails expectedVsp = VSPCommon.createVspDetails(null, null, String.format("VSP-test-%s", vlm1Id), "Test-vsp", "vendorName", "vlm1Id", "icon", "category", "subCategory", "123", null);
+// VspDetails createdVsp = vendorSoftwareProductManager.createVsp(expectedVsp, USER1);
+//
+// id005 = createdVsp.getId();
+// Assert.assertNotNull(id005);
+// Assert.assertNotNull(createdVsp.getVersion());
+//
+// try (InputStream zipInputStream = new ZipFileUtils().getZipInputStream("/legalUploadWithWarning")) {
+//
+// UploadFileResponse uploadFileResponse = vendorSoftwareProductManager.upload(id005, zipInputStream, USER1);
+// vendorSoftwareProductManager.process(id005, USER1);
+// Optional<File> fileCandidate = vendorSoftwareProductManager.get(id005, USER1);
+//
+// File latestHeatPackage = fileCandidate.get();
+//
+// zipInputStream.reset();
+// byte[] uploaded = IOUtils.toByteArray(zipInputStream);
+//
+// Optional<FileContentHandler> zipContentMap = vendorSoftwareProductManager.getZipContentMap(uploadFileResponse, uploaded);
+// FileContentHandler fileContentHandler = new FileContentHandler();
+// if(zipContentMap.isPresent()){
+// fileContentHandler = zipContentMap.get();
+// }
+//
+// uploaded = IOUtils.toByteArray(fileContentHandler.getFiles().values());
+//
+// byte[] downloaded;
+// try (BufferedInputStream fileStream = new BufferedInputStream(new FileInputStream(latestHeatPackage))) {
+// downloaded = IOUtils.toByteArray(fileStream);
+// }
+//
+// Assert.assertTrue(Arrays.equals(uploaded, downloaded));
+// }
+// }
+
+ // todo ********************** move to common **************************************
private void mockVersioning(VersionableEntityAction action) {
VersionInfo versionInfo = new VersionInfo();
versionInfo.setActiveVersion(VERSION01);
doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
- action);
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
+ action);
}
private void mockVersioningEntityNotExist(VersionableEntityAction action, String vspId) {
doThrow(new CoreException(new EntityNotExistErrorBuilder(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, vspId).build()))
- .when(versioningManagerMock).getEntityVersionInfo(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, vspId, USER1,
- action);
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, vspId).build()))
+ .when(versioningManagerMock).getEntityVersionInfo(
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, vspId, USER1,
+ action);
}
private void MockVersioningEntityLocked(VersionableEntityAction action) {
doThrow(new CoreException(new EditOnEntityLockedByOtherErrorBuilder(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1)
- .build()))
- .when(versioningManagerMock).getEntityVersionInfo(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER2,
- action);
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1)
+ .build()))
+ .when(versioningManagerMock).getEntityVersionInfo(
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER2,
+ action);
}
}
\ No newline at end of file
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/mock/VendorSoftwareProductDaoFactoryMock.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/mock/VendorSoftwareProductDaoFactoryMock.java
deleted file mode 100644
index ede8620..0000000
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/mock/VendorSoftwareProductDaoFactoryMock.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.openecomp.sdc.vendorsoftwareproduct.impl.mock;
-
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
-
-public class VendorSoftwareProductDaoFactoryMock extends VendorSoftwareProductDaoFactory {
-
- @Override
- public VendorSoftwareProductDao createInterface() {
- return null;
- }
-}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/CandidateServiceImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/CandidateServiceImplTest.java
index 3d98ab7..1c9d61b 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/CandidateServiceImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/CandidateServiceImplTest.java
@@ -30,7 +30,6 @@
import org.openecomp.sdc.heat.datatypes.manifest.FileData;
import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
import org.openecomp.sdc.heat.datatypes.structure.HeatStructureTree;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.ManifestCreator;
import org.openecomp.sdc.vendorsoftwareproduct.services.impl.filedatastructuremodule.CandidateServiceImpl;
@@ -57,8 +56,6 @@
public class CandidateServiceImplTest {
@Mock
private ManifestCreator manifestCreatorMock;
- @Mock
- private VendorSoftwareProductDao vendorSoftwareProductDaoMock;
@InjectMocks
private CandidateServiceImpl candidateService;
@@ -95,7 +92,8 @@
//vspDetails.setOnboardingMethod(VSPCommon.OnboardingMethod.HEAT.name());
vspDetails.setOnboardingMethod("HEAT");
- FilesDataStructure structure = JsonUtil.json2Object(getExpectedJson(), FilesDataStructure.class);
+ FilesDataStructure structure =
+ JsonUtil.json2Object(getExpectedJson(), FilesDataStructure.class);
Optional<ManifestContent> expectedManifest = getExpectedManifestJson();
doReturn(expectedManifest)
@@ -191,7 +189,8 @@
fileData = createFileData("file1.yaml", true, FileData.Type.HEAT, null);
mockFileData.add(fileData);
fileData = createFileData("file1_vol.yaml", null, FileData.Type.HEAT_VOL, fileData);
- fileData = createFileData("file1.env", null, FileData.Type.HEAT_ENV, mockFileData.get(1).getData().get(0));
+ fileData = createFileData("file1.env", null, FileData.Type.HEAT_ENV,
+ mockFileData.get(1).getData().get(0));
mockFileData.add(createFileData("file2.sh", null, FileData.Type.OTHER, null));
mockFileData.add(createFileData("file3.yml", null, FileData.Type.OTHER, null));
mock.setData(mockFileData);
@@ -202,7 +201,7 @@
FileData fileDataToAddTo) {
FileData fileData = new FileData();
fileData.setFile(fileName);
- if(isBase != null) {
+ if (isBase != null) {
fileData.setBase(isBase);
}
fileData.setType(fileType);
@@ -211,11 +210,9 @@
}
private void addFileDataToList(FileData fileDataToAddTo, FileData fileData) {
- if(fileDataToAddTo != null)
- {
+ if (fileDataToAddTo != null) {
List<FileData> list = fileDataToAddTo.getData();
- if(CollectionUtils.isEmpty(list))
- {
+ if (CollectionUtils.isEmpty(list)) {
list = new ArrayList<>();
}
list.add(fileData);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImplTest.java
index 2f85f30..9385d4a 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImplTest.java
@@ -27,8 +27,8 @@
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
-import org.openecomp.sdc.tosca.services.ToscaUtil;
import org.openecomp.sdc.tosca.services.ToscaExtensionYamlUtil;
+import org.openecomp.sdc.tosca.services.ToscaUtil;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Component;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionData;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network;
@@ -110,11 +110,12 @@
try (InputStream yamlFile = new FileInputStream(file)) {
ServiceTemplate serviceTemplateFromYaml =
toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
- serviceTemplates.put(ToscaUtil.getServiceTemplateFileName(serviceTemplateFromYaml), serviceTemplateFromYaml);
+ serviceTemplates.put(ToscaUtil.getServiceTemplateFileName(serviceTemplateFromYaml),
+ serviceTemplateFromYaml);
try {
yamlFile.close();
} catch (IOException ignore) {
- log.debug("",ignore);
+ log.debug("", ignore);
}
} catch (FileNotFoundException exception) {
throw exception;
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionEntityDataManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionEntityDataManagerImplTest.java
index 1acd58d..0d9245d 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionEntityDataManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionEntityDataManagerImplTest.java
@@ -22,12 +22,10 @@
import org.apache.commons.collections.CollectionUtils;
import org.mockito.InjectMocks;
-import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
@@ -43,6 +41,7 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -90,8 +89,6 @@
"}";
private Map<CompositionEntityId, Collection<String>> errorsById;
- @Mock
- private VendorSoftwareProductDao vendorSoftwareProductDaoMock;
@InjectMocks
@Spy
private CompositionEntityDataManagerImpl compositionEntityDataManager;
@@ -248,7 +245,7 @@
Map<CompositionEntityId, Collection<String>> errorsById =
compositionEntityDataManager.validateEntitiesQuestionnaire();
- Assert.assertEquals(errorsById.size(), 0);
+ Assert.assertEquals(errorsById.size(), 1);
}
@Test(dependsOnMethods = "testNicAndComponentValidQuestionnaire")
@@ -259,9 +256,9 @@
Map<CompositionEntityId, Collection<String>> errorsById =
compositionEntityDataManager.validateEntitiesQuestionnaire();
- Assert.assertEquals(errorsById.size(), 1);
+ Assert.assertEquals(errorsById.size(), 2);
- CompositionEntityId component = errorsById.keySet().iterator().next();
+ CompositionEntityId component = new ArrayList<>(errorsById.keySet()).get(1);
List<String> errors = (List<String>) errorsById.get(component);
Assert.assertEquals(errors.size(), 1);
Assert.assertEquals(errors.get(0),
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGeneratorTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGeneratorTest.java
index acd76a1..237e9cc 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGeneratorTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGeneratorTest.java
@@ -20,27 +20,6 @@
package org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator;
-import org.everit.json.schema.EmptySchema;
-import org.everit.json.schema.loader.SchemaLoader;
-import org.json.JSONObject;
-import org.openecomp.core.utilities.json.JsonUtil;
-import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGenerator;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.NetworkType;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic;
-import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.ComponentCompositionSchemaInput;
-import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.ComponentQuestionnaireSchemaInput;
-import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.NetworkCompositionSchemaInput;
-import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.NicCompositionSchemaInput;
-import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import java.util.Arrays;
-import java.util.Map;
-
public class SchemaGeneratorTest {
/*
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/tree/UploadFileTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/tree/UploadFileTest.java
index df386b1..2a475fe 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/tree/UploadFileTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/tree/UploadFileTest.java
@@ -21,9 +21,6 @@
package org.openecomp.sdc.vendorsoftwareproduct.tree;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doReturn;
-
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -32,13 +29,10 @@
import org.openecomp.core.model.types.ServiceElement;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.sdc.healing.api.HealingManager;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadDataEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.impl.OrchestrationTemplateCandidateManagerImpl;
import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionDataExtractor;
@@ -50,7 +44,11 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.io.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
import java.net.URL;
import java.util.zip.ZipOutputStream;
@@ -59,70 +57,69 @@
import static org.testng.Assert.assertEquals;
public class UploadFileTest {
- private static final String USER1 = "vspTestUser1";
+ private static final String USER1 = "vspTestUser1";
- public static final Version VERSION01 = new Version(0, 1);
- @Mock
- private VendorSoftwareProductDao vendorSoftwareProductDaoMock;
- @Mock
- private OrchestrationTemplateDao orchestrationTemplateDataDaoMock;
- @Spy
- private CandidateServiceImpl candidateService;
- @Mock
- private HealingManager healingManagerMock;
- @Mock
- private CompositionDataExtractor compositionDataExtractorMock;
- @Mock
- private ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDaoMock;
- @Mock
- private CompositionEntityDataManager compositionEntityDataManagerMock;
- @Mock
- private VendorSoftwareProductInfoDao vspInfoDaoMock;
+ public static final Version VERSION01 = new Version(0, 1);
- @InjectMocks
- private OrchestrationTemplateCandidateManagerImpl candidateManager;
+ @Mock
+ private OrchestrationTemplateDao orchestrationTemplateDataDaoMock;
+ @Spy
+ private CandidateServiceImpl candidateService;
+ @Mock
+ private HealingManager healingManagerMock;
+ @Mock
+ private CompositionDataExtractor compositionDataExtractorMock;
+ @Mock
+ private ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDaoMock;
+ @Mock
+ private CompositionEntityDataManager compositionEntityDataManagerMock;
+ @Mock
+ private VendorSoftwareProductInfoDao vspInfoDaoMock;
- private static String vlm1Id;
- public static String id001 = null;
- public static String id002 = null;
+ @InjectMocks
+ private OrchestrationTemplateCandidateManagerImpl candidateManager;
- public static Version activeVersion002 = null;
+ private static String vlm1Id;
+ public static String id001 = null;
+ public static String id002 = null;
+
+ public static Version activeVersion002 = null;
- @BeforeMethod
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
+ @BeforeMethod
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testUploadFile() {
+ VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
+ doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
+ candidateManager.upload(id001, activeVersion002, getZipInputStream("/legalUpload"),
+ OnboardingTypesEnum.ZIP.toString(), "legalUpload");
+ }
+
+
+ private void testLegalUpload(String vspId, Version version, InputStream upload, String user) {
+ UploadFileResponse uploadFileResponse = candidateManager.upload(vspId, activeVersion002,
+ upload, OnboardingTypesEnum.ZIP.toString(), "file");
+ assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.ZIP);
+ OrchestrationTemplateEntity uploadData = orchestrationTemplateDataDaoMock.get(vspId, version);
+
+ }
+
+ public InputStream getZipInputStream(String name) {
+ URL url = this.getClass().getResource(name);
+ File templateDir = new File(url.getFile());
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (ZipOutputStream zos = new ZipOutputStream(baos)) {
+ VSPCommon.zipDir(templateDir, "", zos, true);
+ } catch (IOException e) {
+ e.printStackTrace();
}
-
- @Test
- public void testUploadFile() {
- VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
- doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
- candidateManager.upload(id001, activeVersion002, getZipInputStream("/legalUpload"), USER1, OnboardingTypesEnum.ZIP.toString(), "legalUpload");
- }
-
-
- private void testLegalUpload(String vspId, Version version, InputStream upload, String user) {
- UploadFileResponse uploadFileResponse = candidateManager.upload(vspId, activeVersion002,
- upload, user, OnboardingTypesEnum.ZIP.toString(),"file" );
- assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.ZIP);
- UploadDataEntity uploadData =
- orchestrationTemplateDataDaoMock.getOrchestrationTemplate(vspId, version);
-
- }
-
- public InputStream getZipInputStream(String name) {
- URL url = this.getClass().getResource(name);
- File templateDir = new File(url.getFile());
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (ZipOutputStream zos = new ZipOutputStream(baos)) {
- VSPCommon.zipDir(templateDir, "", zos, true);
- } catch (IOException e) {
- e.printStackTrace();
- }
- return new ByteArrayInputStream(baos.toByteArray());
- }
+ return new ByteArrayInputStream(baos.toByteArray());
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/HeatCleanup/HeatCleanupOnNewUploadTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/HeatCleanup/HeatCleanupOnNewUploadTest.java
index 4d925c0..13f3859 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/HeatCleanup/HeatCleanupOnNewUploadTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/HeatCleanup/HeatCleanupOnNewUploadTest.java
@@ -38,7 +38,7 @@
UploadDataEntity uploadDataEntity =
vendorSoftwareProductDao.getUploadData(new UploadDataEntity(vspId, vspActiveVersion));
Assert.assertTrue((uploadDataEntity.getContentData() != null) == exist);
- Assert.assertTrue((uploadDataEntity.getValidationData() != null) == exist);
+ Assert.assertTrue((uploadDataEntity.getInfo() != null) == exist);
Assert.assertTrue((uploadDataEntity.getPackageName() != null) == exist);
Assert.assertTrue((uploadDataEntity.getPackageVersion() != null) == exist);
//TODO: talio - delete enrich data on new upload
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/csar/ManifestParsingTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/csar/ManifestParsingTest.java
index 3332e81..ee451e0 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/csar/ManifestParsingTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/csar/ManifestParsingTest.java
@@ -7,52 +7,55 @@
import java.io.IOException;
import java.io.InputStream;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
public class ManifestParsingTest {
- @Test
- public void testSuccessfulParsing() throws IOException {
- try (InputStream is = getClass().getResourceAsStream("/vspmanager.csar/manifest/ValidTosca.mf")) {
- OnboardingManifest onboardingManifest = new OnboardingManifest(is);
- assertTrue(onboardingManifest.isValid());
- assertEquals(onboardingManifest.getMetadata().size(), 4);
- assertEquals(onboardingManifest.getSources().size(), 5);
- }
+ @Test
+ public void testSuccessfulParsing() throws IOException {
+ try (InputStream is = getClass()
+ .getResourceAsStream("/vspmanager.csar/manifest/ValidTosca.mf")) {
+ OnboardingManifest onboardingManifest = new OnboardingManifest(is);
+ assertTrue(onboardingManifest.isValid());
+ assertEquals(onboardingManifest.getMetadata().size(), 4);
+ assertEquals(onboardingManifest.getSources().size(), 5);
}
+ }
- @Test
- public void testNoMetadataParsing() throws IOException {
- try (InputStream is = getClass().getResourceAsStream("/vspmanager.csar/manifest/InvalidTosca1.mf")) {
- OnboardingManifest onboardingManifest = new OnboardingManifest(is);
- assertFalse(onboardingManifest.isValid());
- assertTrue(onboardingManifest.getErrors().stream().
- filter(error -> error.contains(Messages.MANIFEST_INVALID_LINE.getErrorMessage().substring(0, 10)))
- .findAny().isPresent());
- }
+ @Test
+ public void testNoMetadataParsing() throws IOException {
+ try (InputStream is = getClass()
+ .getResourceAsStream("/vspmanager.csar/manifest/InvalidTosca1.mf")) {
+ OnboardingManifest onboardingManifest = new OnboardingManifest(is);
+ assertFalse(onboardingManifest.isValid());
+ assertTrue(onboardingManifest.getErrors().stream().anyMatch(error -> error
+ .contains(Messages.MANIFEST_INVALID_LINE.getErrorMessage().substring(0, 10))));
}
+ }
- @Test
- public void testBrokenMDParsing() throws IOException {
- try (InputStream is = getClass().getResourceAsStream("/vspmanager.csar/manifest/InvalidTosca2.mf")) {
- OnboardingManifest onboardingManifest = new OnboardingManifest(is);
- assertFalse(onboardingManifest.isValid());
- assertTrue(onboardingManifest.getErrors().stream().
- filter(error -> error.contains(Messages.MANIFEST_INVALID_LINE.getErrorMessage().substring(0, 10)))
- .findAny().isPresent());
- }
+ @Test
+ public void testBrokenMDParsing() throws IOException {
+ try (InputStream is = getClass()
+ .getResourceAsStream("/vspmanager.csar/manifest/InvalidTosca2.mf")) {
+ OnboardingManifest onboardingManifest = new OnboardingManifest(is);
+ assertFalse(onboardingManifest.isValid());
+ assertTrue(onboardingManifest.getErrors().stream().anyMatch(error -> error
+ .contains(Messages.MANIFEST_INVALID_LINE.getErrorMessage().substring(0, 10))));
}
+ }
- @Test
- public void testNoMetaParsing() throws IOException {
- try (InputStream is = getClass().getResourceAsStream("/vspmanager.csar/manifest/InvalidTosca4.mf")) {
- OnboardingManifest onboardingManifest = new OnboardingManifest(is);
- assertFalse(onboardingManifest.isValid());
- assertTrue(onboardingManifest.getErrors().stream().
- filter(error -> error.contains(Messages.MANIFEST_NO_METADATA.getErrorMessage().substring(0, 10)))
- .findAny().isPresent());
- }
+ @Test
+ public void testNoMetaParsing() throws IOException {
+ try (InputStream is = getClass()
+ .getResourceAsStream("/vspmanager.csar/manifest/InvalidTosca4.mf")) {
+ OnboardingManifest onboardingManifest = new OnboardingManifest(is);
+ assertFalse(onboardingManifest.isValid());
+ assertTrue(onboardingManifest.getErrors().stream().anyMatch(error -> error
+ .contains(Messages.MANIFEST_NO_METADATA.getErrorMessage().substring(0, 10))));
}
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/csar/UploadCSARFileTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/csar/UploadCSARFileTest.java
index a7fc0e1..d574c9e 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/csar/UploadCSARFileTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/csar/UploadCSARFileTest.java
@@ -33,7 +33,6 @@
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.impl.OrchestrationTemplateCandidateManagerImpl;
@@ -51,171 +50,163 @@
import java.util.List;
import java.util.function.Predicate;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doReturn;
public class UploadCSARFileTest {
- private static final String USER1 = "vspTestUser1";
- public static final Version VERSION01 = new Version(0, 1);
+ public static final Version VERSION01 = new Version("0.1");
- @Mock
- private VendorSoftwareProductDao vendorSoftwareProductDaoMock;
- @Mock
- private OrchestrationTemplateDao orchestrationTemplateDataDaoMock;
+ @Mock
+ private OrchestrationTemplateDao orchestrationTemplateDataDaoMock;
+ @Spy
+ private CandidateServiceImpl candidateService;
+ @Mock
+ private HealingManager healingManagerMock;
+ @Mock
+ private CompositionDataExtractor compositionDataExtractorMock;
+ @Mock
+ private ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDaoMock;
+ @Mock
+ private CompositionEntityDataManager compositionEntityDataManagerMock;
+ @Mock
+ private VendorSoftwareProductInfoDao vspInfoDaoMock;
+ @Mock
+ private OrchestrationTemplateCandidateDao orchestrationTemplateCandidateDao;
+ @Mock
+ private ManifestCreatorNamingConventionImpl manifestCreator;
- @Spy
- private CandidateServiceImpl candidateService;
- @Mock
- private HealingManager healingManagerMock;
- @Mock
- private CompositionDataExtractor compositionDataExtractorMock;
- @Mock
- private ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDaoMock;
- @Mock
- private CompositionEntityDataManager compositionEntityDataManagerMock;
- @Mock
- private VendorSoftwareProductInfoDao vspInfoDaoMock;
- @Mock
- private OrchestrationTemplateCandidateDao orchestrationTemplateCandidateDao;
- @Mock
- private ManifestCreatorNamingConventionImpl manifestCreator;
-
- private OrchestrationTemplateCandidateManagerImpl candidateManager;
+ private OrchestrationTemplateCandidateManagerImpl candidateManager;
- public static String id001 = null;
+ public static String id001 = null;
- public static Version activeVersion002 = null;
+ public static Version activeVersion002 = null;
- @BeforeMethod
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- candidateService = new CandidateServiceImpl(manifestCreator,orchestrationTemplateCandidateDao);
- candidateManager = new OrchestrationTemplateCandidateManagerImpl( vendorSoftwareProductDaoMock,
- vspInfoDaoMock,
- orchestrationTemplateDataDaoMock,
- candidateService, healingManagerMock,
- compositionDataExtractorMock,
- serviceModelDaoMock,
- compositionEntityDataManagerMock,
- null,
- null,
- null,
- null,
- null);
+ @BeforeMethod
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ candidateService = new CandidateServiceImpl(manifestCreator, orchestrationTemplateCandidateDao);
+ candidateManager = new OrchestrationTemplateCandidateManagerImpl(vspInfoDaoMock,
+ candidateService, healingManagerMock);
+ }
+
+ @Test
+ public void testSuccessfulUploadFile() throws Exception {
+ VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
+ doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
+
+ try (InputStream is = getClass().getResourceAsStream("/vspmanager.csar/SDCmock.csar")) {
+ UploadFileResponse uploadFileResponse =
+ candidateManager.upload(id001, activeVersion002, is, "csar", "SDCmock");
+ assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.CSAR);
+ assertEquals(0, uploadFileResponse.getErrors().size());
+ assertTrue(uploadFileResponse.getErrors().isEmpty());
}
+ }
- @Test
- public void testSuccessfulUploadFile() throws Exception {
- VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
- doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
+ @Test
+ public void testFail1UploadFile() throws Exception {
+ VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
+ doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
- try (InputStream is = getClass().getResourceAsStream("/vspmanager.csar/SDCmock.csar")) {
- UploadFileResponse uploadFileResponse = candidateManager.upload(id001, activeVersion002, is, USER1, "csar", "SDCmock");
- assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.CSAR);
- assertEquals(0, uploadFileResponse.getErrors().size());
- assertTrue(uploadFileResponse.getErrors().isEmpty());
- }
+ try (InputStream is = getClass().getResourceAsStream("/vspmanager.csar/SDCmockFail1.csar")) {
+ UploadFileResponse uploadFileResponse =
+ candidateManager.upload(id001, activeVersion002, is,
+ "csar", "SDCmockFail1");
+ assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.CSAR);
+ assertEquals(1, uploadFileResponse.getErrors().size());
+ assertTrue(uploadFileResponse.getErrors().values().stream().anyMatch(
+ getListPredicate(Messages.CSAR_FILES_NOT_ALLOWED.getErrorMessage().substring(0, 7))));
}
+ }
- @Test
- public void testFail1UploadFile() throws Exception {
- VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
- doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
+ private Predicate<List<ErrorMessage>> getListPredicate(String substring) {
+ return error -> isEquals(substring, error);
+ }
- try (InputStream is = getClass().getResourceAsStream("/vspmanager.csar/SDCmockFail1.csar")) {
- UploadFileResponse uploadFileResponse = candidateManager.upload(id001, activeVersion002, is, USER1,
- "csar", "SDCmockFail1");
- assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.CSAR);
- assertEquals(1, uploadFileResponse.getErrors().size());
- assertTrue( uploadFileResponse.getErrors().values().stream()
- .filter(getListPredicate(Messages.CSAR_FILES_NOT_ALLOWED
- .getErrorMessage().substring(0, 7))).findAny().isPresent());
- }
+ private boolean isEquals(String substring, List<ErrorMessage> error) {
+ return error.iterator().next().getMessage().contains(substring);
+ }
+
+ @Test
+ public void testFail2UploadFile() throws Exception {
+ VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
+ doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
+
+ try (InputStream is = getClass().getResourceAsStream("/vspmanager.csar/SDCmockFail2.csar")) {
+ UploadFileResponse uploadFileResponse =
+ candidateManager.upload(id001, activeVersion002, is,
+ "csar", "SDCmockFail2");
+ assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.CSAR);
+ assertEquals(1, uploadFileResponse.getErrors().size());
+ assertTrue(uploadFileResponse.getErrors().values().stream().anyMatch(
+ getListPredicate(Messages.CSAR_FILE_NOT_FOUND.getErrorMessage().substring(0, 7))));
}
+ }
- private Predicate<List<ErrorMessage>> getListPredicate(String substring) {
- return error -> isEquals(substring, error);
+ @Test
+ public void testFail3UploadFile() throws Exception {
+ VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
+ doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
+
+ try (InputStream is = getClass().getResourceAsStream("/vspmanager.csar/SDCmockFail3.csar")) {
+ UploadFileResponse uploadFileResponse =
+ candidateManager.upload(id001, activeVersion002, is,
+ "csar", "SDCmockFail3");
+ assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.CSAR);
+ assertEquals(1, uploadFileResponse.getErrors().size());
}
+ }
- private boolean isEquals(String substring, List<ErrorMessage> error) {
- return error.iterator().next().getMessage().contains(substring);
+ @Test
+ public void testUploadFileIsNotZip() throws Exception {
+ VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
+ doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
+
+ try (InputStream is = new ByteArrayInputStream("Thia is not a zip file".getBytes());) {
+ UploadFileResponse uploadFileResponse =
+ candidateManager.upload(id001, activeVersion002, is,
+ "csar", "file");
+ assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.CSAR);
+ assertFalse(uploadFileResponse.getErrors().isEmpty());
+ assertTrue(uploadFileResponse.getErrors().values().stream().anyMatch(
+ getListPredicate(Messages.CSAR_FILE_NOT_FOUND.getErrorMessage().substring(0, 7))));
}
+ }
- @Test
- public void testFail2UploadFile() throws Exception {
- VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
- doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
+ @Test
+ public void testUploadFileIsEmpty() throws Exception {
+ VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
+ doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
- try (InputStream is = getClass().getResourceAsStream("/vspmanager.csar/SDCmockFail2.csar")) {
- UploadFileResponse uploadFileResponse = candidateManager.upload(id001, activeVersion002, is, USER1,
- "csar", "SDCmockFail2");
- assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.CSAR);
- assertEquals(1, uploadFileResponse.getErrors().size());
- assertTrue( uploadFileResponse.getErrors().values().stream()
- .filter(getListPredicate(Messages.CSAR_FILE_NOT_FOUND
- .getErrorMessage().substring(0,7))).findAny().isPresent());
- }
+ try (InputStream is = new ByteArrayInputStream(new byte[]{})) {
+ UploadFileResponse uploadFileResponse = candidateManager.upload(id001,
+ activeVersion002, is, "csar", "file");
+ assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.CSAR);
+ assertEquals(1, uploadFileResponse.getErrors().size());
}
- @Test
- public void testFail3UploadFile() throws Exception {
- VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
- doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
+ }
- try (InputStream is = getClass().getResourceAsStream("/vspmanager.csar/SDCmockFail3.csar")) {
- UploadFileResponse uploadFileResponse = candidateManager.upload(id001, activeVersion002, is, USER1,
- "csar", "SDCmockFail3");
- assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.CSAR);
- assertEquals(1, uploadFileResponse.getErrors().size());
- }
+ @Test
+ public void testMFError() throws Exception {
+ VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
+ doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
+
+ try (InputStream is = getClass().getResourceAsStream("/vspmanager.csar/SDCmockBrokenMF.csar")) {
+ UploadFileResponse uploadFileResponse =
+ candidateManager.upload(id001, activeVersion002, is, "csar", "SDCmockBrokenMF");
+ assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.CSAR);
+ assertEquals(1, uploadFileResponse.getErrors().size());
+ assertTrue(uploadFileResponse.getErrors().values().stream()
+ .anyMatch(getListPredicate(Messages.MANIFEST_NO_METADATA.getErrorMessage())));
+
}
-
- @Test
- public void testUploadFileIsNotZip() throws Exception {
- VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
- doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
-
- try (InputStream is = new ByteArrayInputStream( "Thia is not a zip file".getBytes() );) {
- UploadFileResponse uploadFileResponse = candidateManager.upload(id001, activeVersion002, is, USER1,
- "csar", "file");
- assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.CSAR);
- assertFalse(uploadFileResponse.getErrors().isEmpty());
- assertTrue( uploadFileResponse.getErrors().values().stream()
- .filter(getListPredicate(Messages.CSAR_FILE_NOT_FOUND
- .getErrorMessage().substring(0,7))).findAny().isPresent());
- }
- }
- @Test
- public void testUploadFileIsEmpty() throws Exception {
- VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
- doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
-
- try (InputStream is = new ByteArrayInputStream( new byte[]{} )) {
- UploadFileResponse uploadFileResponse = candidateManager.upload(id001,
- activeVersion002, is, USER1, "csar", "file");
- assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.CSAR);
- assertEquals(1, uploadFileResponse.getErrors().size());
- }
- }
-
- @Test
- public void testMFError() throws Exception {
- VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
- doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
-
- try (InputStream is = getClass().getResourceAsStream("/vspmanager.csar/SDCmockBrokenMF.csar")) {
- UploadFileResponse uploadFileResponse = candidateManager.upload(id001, activeVersion002, is, USER1, "csar", "SDCmockBrokenMF");
- assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.CSAR);
- assertEquals(1, uploadFileResponse.getErrors().size());
- assertTrue( uploadFileResponse.getErrors()
- .values().stream()
- .filter(getListPredicate(Messages.MANIFEST_NO_METADATA.getErrorMessage())).findAny().isPresent());
-
- }
- }
+ }
}
diff --git a/openecomp-be/backend/pom.xml b/openecomp-be/backend/pom.xml
index a627ed0..2d98aa5 100644
--- a/openecomp-be/backend/pom.xml
+++ b/openecomp-be/backend/pom.xml
@@ -23,6 +23,8 @@
<module>openecomp-sdc-application-config-manager</module>
<module>openecomp-sdc-activity-log-manager</module>
<module>openecomp-sdc-healthcheck-manager</module>
+ <module>openecomp-sdc-conflict-manager</module>
+ <module>openecomp-sdc-item-permissions-manager</module>
</modules>
diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java
index de33804..565e60e 100644
--- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java
+++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java
@@ -39,6 +39,8 @@
FAILED_TO_TRANSLATE_ZIP_FILE("Failed to translate zip file"),
ZIP_NOT_EXIST("Zip file doesn't exist"),
+ PERMISSIONS_ERROR("Permissions Error. The user does not have permission to perform this action."),
+
ZIP_SHOULD_NOT_CONTAIN_FOLDERS("Zip file should not contain folders"),
VES_ZIP_SHOULD_CONTAIN_YML_ONLY(
"Wrong VES EVENT Artifact was uploaded - all files contained in Artifact must be YAML files" +
@@ -148,7 +150,11 @@
+ "Contrail 2 resources can be found in %s. Contrail 3 resources can be found in %s"),
CONTRAIL_VM_TYPE_NAME_NOT_ALIGNED_WITH_NAMING_CONVENSION(
"Service Template naming convention in Image and Flavor "
- + "properties is not consistent in Resource, Resource ID %s");
+ + "properties is not consistent in Resource, Resource ID %s"),
+
+ /* Notifications */
+ FAILED_TO_MARK_NOTIFICATION_AS_READ("Failed to mark notifications as read"),
+ FAILED_TO_UPDATE_LAST_SEEN_NOTIFICATION("Failed to update last seen notification for user %s");
private String errorMessage;
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspCreationDto.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/SdcRuntimeException.java
similarity index 63%
copy from openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspCreationDto.java
copy to openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/SdcRuntimeException.java
index f77005f..6e41d58 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspCreationDto.java
+++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/SdcRuntimeException.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,19 +18,25 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdcrests.vendorsoftwareproducts.types;
+package org.openecomp.sdc.common.errors;
-/**
- * Created by TALIO on 4/26/2016.
- */
-public class VspCreationDto {
- private String vspId;
-
- public String getVspId() {
- return vspId;
+public class SdcRuntimeException extends RuntimeException {
+ public SdcRuntimeException() {
}
- public void setVspId(String vspId) {
- this.vspId = vspId;
+ public SdcRuntimeException(String message) {
+ super(message);
+ }
+
+ public SdcRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public SdcRuntimeException(Throwable cause) {
+ super(cause);
+ }
+
+ public SdcRuntimeException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
}
}
diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/SdcCommon.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/SdcCommon.java
index 24da836..9de0e7b 100644
--- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/SdcCommon.java
+++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/SdcCommon.java
@@ -33,6 +33,7 @@
public static final String PARENT = "parent";
public static final String VSP_ID = "vspId";
+ public static final String VLM_ID = "vlmId";
public static final String VERSION = "version";
public static final String USER = "user";
}
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/pom.xml b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/pom.xml
new file mode 100644
index 0000000..413cae7
--- /dev/null
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/pom.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-conflict-lib</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <artifactId>openecomp-conflict-api</artifactId>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-facade-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-facade-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-versioning-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+
+
+</project>
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/ItemMergeHandler.java b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/ItemMergeHandler.java
new file mode 100644
index 0000000..189e4ce
--- /dev/null
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/ItemMergeHandler.java
@@ -0,0 +1,27 @@
+package org.openecomp.conflicts;
+
+import org.openecomp.conflicts.types.Conflict;
+import org.openecomp.conflicts.types.ConflictResolution;
+import org.openecomp.conflicts.types.ItemVersionConflict;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.Optional;
+
+public interface ItemMergeHandler {
+
+ boolean isConflicted(String itemId, Version version);
+
+ void finalizeMerge(String itemId, Version version);
+
+ void postListConflicts(String itemId, Version version, ItemVersionConflict conflicts);
+
+ Optional<Conflict> getConflict(String itemId, Version version, String conflictId);
+
+ void postGetConflict(String itemId, Version version, Conflict conflict);
+
+ void preResolveConflict(String itemId, Version version, String conflictId,
+ ConflictResolution resolution);
+
+ boolean resolveConflict(String itemId, Version version, String conflictId,
+ ConflictResolution resolution);
+}
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/ItemMergeHandlerFactory.java b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/ItemMergeHandlerFactory.java
new file mode 100644
index 0000000..8fb0a48
--- /dev/null
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/ItemMergeHandlerFactory.java
@@ -0,0 +1,16 @@
+package org.openecomp.conflicts;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+import java.util.Optional;
+
+public abstract class ItemMergeHandlerFactory
+ extends AbstractComponentFactory<ItemMergeHandler> {
+
+ public static ItemMergeHandlerFactory getInstance() {
+ return AbstractFactory.getInstance(ItemMergeHandlerFactory.class);
+ }
+
+ public abstract Optional<ItemMergeHandler> createInterface(String itemId);
+}
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/dao/ConflictsDao.java b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/dao/ConflictsDao.java
new file mode 100644
index 0000000..273233a
--- /dev/null
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/dao/ConflictsDao.java
@@ -0,0 +1,18 @@
+package org.openecomp.conflicts.dao;
+
+import org.openecomp.conflicts.types.Conflict;
+import org.openecomp.conflicts.types.ConflictResolution;
+import org.openecomp.conflicts.types.ItemVersionConflict;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+public interface ConflictsDao {
+
+ boolean isConflicted(String itemId, Version version);
+
+ ItemVersionConflict getConflict(String itemId, Version version);
+
+ Conflict getConflict(String itemId, Version version, String conflictId);
+
+ void resolveConflict(String itemId, Version version, String conflictId,
+ ConflictResolution conflictResolution);
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDaoFactory.java b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/dao/ConflictsDaoFactory.java
similarity index 79%
copy from openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDaoFactory.java
copy to openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/dao/ConflictsDaoFactory.java
index 9654551..e4c88d6 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDaoFactory.java
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/dao/ConflictsDaoFactory.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,14 +18,15 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.vendorsoftwareproduct.dao;
+package org.openecomp.conflicts.dao;
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
-public abstract class UploadDataDaoFactory extends AbstractComponentFactory<UploadDataDao> {
+public abstract class ConflictsDaoFactory
+ extends AbstractComponentFactory<ConflictsDao> {
- public static UploadDataDaoFactory getInstance() {
- return AbstractFactory.getInstance(UploadDataDaoFactory.class);
+ public static ConflictsDaoFactory getInstance() {
+ return AbstractFactory.getInstance(ConflictsDaoFactory.class);
}
}
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/Conflict.java b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/Conflict.java
new file mode 100644
index 0000000..bc324af
--- /dev/null
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/Conflict.java
@@ -0,0 +1,30 @@
+package org.openecomp.conflicts.types;
+
+import org.openecomp.sdc.datatypes.model.ElementType;
+
+public class Conflict<T> extends ConflictInfo {
+ private T yours;
+ private T theirs;
+
+ public Conflict(String id, ElementType type, String name) {
+ super(id, type, name);
+ }
+
+ public T getYours() {
+ return yours;
+ }
+
+ public void setYours(T yours) {
+ this.yours = yours;
+ }
+
+ public T getTheirs() {
+ return theirs;
+ }
+
+ public void setTheirs(T theirs) {
+ this.theirs = theirs;
+ }
+
+
+}
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/ConflictInfo.java b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/ConflictInfo.java
new file mode 100644
index 0000000..ff58f00
--- /dev/null
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/ConflictInfo.java
@@ -0,0 +1,39 @@
+package org.openecomp.conflicts.types;
+
+import org.openecomp.sdc.datatypes.model.ElementType;
+
+public class ConflictInfo {
+ private String id;
+ private ElementType type;
+ private String name;
+
+ public ConflictInfo(String id, ElementType type, String name) {
+ this.id = id;
+ this.type = type;
+ this.name = name;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public ElementType getType() {
+ return type;
+ }
+
+ public void setType(ElementType type) {
+ this.type = type;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/ConflictResolution.java b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/ConflictResolution.java
new file mode 100644
index 0000000..961f908
--- /dev/null
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/ConflictResolution.java
@@ -0,0 +1,32 @@
+package org.openecomp.conflicts.types;
+
+import java.util.Map;
+
+public class ConflictResolution {
+ private Resolution resolution;
+ // sits in lower level...
+ private Map<String, Object> otherResolution;
+
+ public ConflictResolution() {
+ }
+
+ public ConflictResolution(Resolution resolution) {
+ this.resolution = resolution;
+ }
+
+ public Resolution getResolution() {
+ return resolution;
+ }
+
+ public void setResolution(Resolution resolution) {
+ this.resolution = resolution;
+ }
+
+ public Map<String, Object> getOtherResolution() {
+ return otherResolution;
+ }
+
+ public void setOtherResolution(Map<String, Object> otherResolution) {
+ this.otherResolution = otherResolution;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/ItemVersionConflict.java b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/ItemVersionConflict.java
new file mode 100644
index 0000000..a4749f3
--- /dev/null
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/ItemVersionConflict.java
@@ -0,0 +1,31 @@
+package org.openecomp.conflicts.types;
+
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+public class ItemVersionConflict {
+ private Conflict<Version> versionConflict;
+ private Collection<ConflictInfo> elementConflicts = new ArrayList<>();
+
+ public Conflict<Version> getVersionConflict() {
+ return versionConflict;
+ }
+
+ public void setVersionConflict(Conflict<Version> versionConflict) {
+ this.versionConflict = versionConflict;
+ }
+
+ public Collection<ConflictInfo> getElementConflicts() {
+ return elementConflicts;
+ }
+
+ public void setElementConflicts(Collection<ConflictInfo> elementConflicts) {
+ this.elementConflicts = elementConflicts;
+ }
+
+ public void addElementConflictInfo(ConflictInfo conflictInfo) {
+ elementConflicts.add(conflictInfo);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/Resolution.java b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/Resolution.java
new file mode 100644
index 0000000..2222f81
--- /dev/null
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/Resolution.java
@@ -0,0 +1,5 @@
+package org.openecomp.conflicts.types;
+
+public enum Resolution {
+ THEIRS,YOURS,OTHER
+}
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/pom.xml b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/pom.xml
new file mode 100644
index 0000000..ddeb03d
--- /dev/null
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/pom.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-conflict-lib</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <artifactId>openecomp-conflict-core</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-conflict-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-zusammen-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-vendor-software-product-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-vendor-license-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/ItemMergeHandlerFactoryImpl.java b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/ItemMergeHandlerFactoryImpl.java
new file mode 100644
index 0000000..4c981ac
--- /dev/null
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/ItemMergeHandlerFactoryImpl.java
@@ -0,0 +1,40 @@
+package org.openecomp.conflicts;
+
+import org.openecomp.conflicts.dao.ConflictsDaoFactory;
+import org.openecomp.conflicts.impl.VspMergeHandler;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.datatypes.model.ItemType;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VspMergeDaoFactory;
+import org.openecomp.sdc.versioning.ItemManagerFactory;
+import org.openecomp.sdc.versioning.errors.EntityNotExistErrorBuilder;
+import org.openecomp.sdc.versioning.types.Item;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+public class ItemMergeHandlerFactoryImpl extends ItemMergeHandlerFactory {
+ // TODO: 11/1/2017 read this map from configuration, move Vsp merge handler to vsp lib, rearrange lib deps
+ private static final Map<ItemType, ItemMergeHandler> MERGE_HANDLER_BY_ITEM_TYPE =
+ new HashMap<>();
+
+ static {
+ MERGE_HANDLER_BY_ITEM_TYPE.put(ItemType.vsp,
+ new VspMergeHandler(ConflictsDaoFactory.getInstance().createInterface(),
+ VspMergeDaoFactory.getInstance().createInterface()));
+ }
+
+ @Override
+ public Optional<ItemMergeHandler> createInterface(String itemId) {
+ Item item = ItemManagerFactory.getInstance().createInterface().get(itemId);
+ if (item == null) {
+ throw new CoreException(new EntityNotExistErrorBuilder("", itemId).build());
+ }
+ return Optional.ofNullable(MERGE_HANDLER_BY_ITEM_TYPE.get(ItemType.valueOf(item.getType())));
+ }
+
+ @Override
+ public ItemMergeHandler createInterface() {
+ return null; // call the one with the item id arg
+ }
+}
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ConflictsDaoFactoryImpl.java b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ConflictsDaoFactoryImpl.java
new file mode 100644
index 0000000..7cb3598
--- /dev/null
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ConflictsDaoFactoryImpl.java
@@ -0,0 +1,17 @@
+package org.openecomp.conflicts.dao.impl.zusammen;
+
+
+import org.openecomp.conflicts.dao.ConflictsDao;
+import org.openecomp.conflicts.dao.ConflictsDaoFactory;
+import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
+
+public class ConflictsDaoFactoryImpl extends ConflictsDaoFactory {
+
+ private static final ConflictsDao INSTANCE = new
+ ConflictsDaoImpl(ZusammenAdaptorFactory.getInstance().createInterface());
+
+ @Override
+ public ConflictsDao createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ConflictsDaoImpl.java b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ConflictsDaoImpl.java
new file mode 100644
index 0000000..eac1be3
--- /dev/null
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ConflictsDaoImpl.java
@@ -0,0 +1,175 @@
+package org.openecomp.conflicts.dao.impl.zusammen;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementConflict;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import com.amdocs.zusammen.datatypes.item.Item;
+import com.amdocs.zusammen.datatypes.item.ItemVersion;
+import com.amdocs.zusammen.datatypes.item.Resolution;
+import org.openecomp.conflicts.dao.ConflictsDao;
+import org.openecomp.conflicts.types.Conflict;
+import org.openecomp.conflicts.types.ConflictResolution;
+import org.openecomp.conflicts.types.ItemVersionConflict;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.core.zusammen.api.ZusammenAdaptor;
+import org.openecomp.sdc.datatypes.model.ElementType;
+import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor.ElementToEntitlementPoolConvertor;
+import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor.ElementToFeatureGroupConvertor;
+import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor.ElementToLicenseAgreementConvertor;
+import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor.ElementToLicenseKeyGroupConvertor;
+import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor.ElementToLimitConvertor;
+import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor.ElementToVLMGeneralConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToComponentConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToComponentDependencyModelConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToCompositionEntityConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToComputeConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToImageConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToMonitoringUploadMapConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToNetworkConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToNicConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToOrchestrationTemplateCandidateMapConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToProcessConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToServiceModelMapConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToVSPGeneralConvertor;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
+public class ConflictsDaoImpl implements ConflictsDao {
+ private final ZusammenAdaptor zusammenAdaptor;
+
+ public ConflictsDaoImpl(ZusammenAdaptor zusammenAdaptor) {
+ this.zusammenAdaptor = zusammenAdaptor;
+ }
+
+ @Override
+ public boolean isConflicted(String itemId, Version version) {
+ com.amdocs.zusammen.adaptor.inbound.api.types.item.ItemVersionConflict itemVersionConflict =
+ zusammenAdaptor
+ .getVersionConflict(createSessionContext(), new Id(itemId), new Id(version.getId()));
+ return !(itemVersionConflict == null
+ || (itemVersionConflict.getVersionDataConflict() == null
+ && itemVersionConflict.getElementConflictInfos().isEmpty()));
+ }
+
+ @Override
+ public ItemVersionConflict getConflict(String itemId, Version version) {
+ return new ItemVersionConflictConvertorFromZusammen().convert(itemId, version,
+ zusammenAdaptor
+ .getVersionConflict(createSessionContext(), new Id(itemId), new Id(version.getId())));
+ }
+
+ @Override
+ public Conflict getConflict(String itemId, Version version, String conflictId) {
+ return zusammenAdaptor.getElementConflict(createSessionContext(),
+ new ElementContext(new Id(itemId), new Id(version.getId())), new Id(conflictId))
+ .map(elementConflict -> convertElementConflict(conflictId, elementConflict))
+ .orElse(null);
+ }
+
+ @Override
+ public void resolveConflict(String itemId, Version version, String conflictId,
+ ConflictResolution conflictResolution) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(new Id(itemId), new Id(version.getId()));
+
+ // TODO: 7/31/2017 when 'OTHER' resolution will be supported - populate zusammen element with it
+ zusammenAdaptor.resolveElementConflict(context, elementContext,
+ buildElement(new Id(conflictId), null),
+ Resolution.valueOf(conflictResolution.getResolution().name()));
+ }
+
+ private Conflict convertElementConflict(String conflictId, ElementConflict elementConflict) {
+ Element element = elementConflict.getLocalElement() == null
+ ? elementConflict.getRemoteElement()
+ : elementConflict.getLocalElement();
+ ElementType elementType = ElementConvertor.getElementType(element);
+
+ Conflict conflict =
+ new Conflict(conflictId, elementType, ElementConvertor.getElementName(element));
+ ElementConvertor convertor = getConvertor(elementType);
+ if (elementConflict.getLocalElement() != null) {
+ conflict.setYours(convertor.convert(elementConflict.getLocalElement()));
+ }
+ if (elementConflict.getRemoteElement() != null) {
+ conflict.setTheirs(convertor.convert(elementConflict.getRemoteElement()));
+ }
+ return conflict;
+ }
+
+ private ElementConvertor getConvertor(ElementType type) {
+ switch (type) {
+ case VendorSoftwareProduct:
+ return new ElementToVSPGeneralConvertor();
+ case Process:
+ return new ElementToProcessConvertor();
+ case Nic:
+ return new ElementToNicConvertor();
+ case Network:
+ return new ElementToNetworkConvertor();
+ case SNMP_POLL:
+ case SNMP_TRAP:
+ case VES_EVENTS:
+ return new ElementToMonitoringUploadMapConvertor();
+ case Image:
+ return new ElementToImageConvertor();
+ case Compute:
+ return new ElementToComputeConvertor();
+ case Component:
+ return new ElementToComponentConvertor();
+ case ComponentDependencies:
+ return new ElementToComponentDependencyModelConvertor();
+ case VendorLicenseModel:
+ return new ElementToVLMGeneralConvertor();
+ case LicenseAgreement:
+ return new ElementToLicenseAgreementConvertor();
+ case FeatureGroup:
+ return new ElementToFeatureGroupConvertor();
+ case LicenseKeyGroup:
+ return new ElementToLicenseKeyGroupConvertor();
+ case EntitlementPool:
+ return new ElementToEntitlementPoolConvertor();
+ case Limit:
+ return new ElementToLimitConvertor();
+ case OrchestrationTemplateCandidate:
+ return new ElementToOrchestrationTemplateCandidateMapConvertor();
+ case ServiceModel:
+ return new ElementToServiceModelMapConvertor();
+ case VSPQuestionnaire:
+ case ImageQuestionnaire:
+ case ComponentQuestionnaire:
+ case ComputeQuestionnaire:
+ case NicQuestionnaire:
+ return new ElementToCompositionEntityConvertor();
+ default:
+ return new EchoConvertor();
+ }
+ }
+
+ public static class EchoConvertor extends ElementConvertor {
+
+ @Override
+ public Object convert(Element element) {
+ return element;
+ }
+
+ @Override
+ public Object convert(Item item) {
+ return item;
+ }
+
+ @Override
+ public Object convert(ElementInfo elementInfo) {
+ return elementInfo;
+ }
+
+ @Override
+ public Object convert(ItemVersion itemVersion) {
+ return null;
+ }
+ }
+}
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ItemVersionConflictConvertorFromZusammen.java b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ItemVersionConflictConvertorFromZusammen.java
new file mode 100644
index 0000000..4dffaf8
--- /dev/null
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ItemVersionConflictConvertorFromZusammen.java
@@ -0,0 +1,73 @@
+package org.openecomp.conflicts.dao.impl.zusammen;
+
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementConflictInfo;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ItemVersionConflict;
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.item.ItemVersion;
+import com.amdocs.zusammen.datatypes.item.ItemVersionData;
+import com.amdocs.zusammen.datatypes.item.ItemVersionDataConflict;
+import org.openecomp.conflicts.types.Conflict;
+import org.openecomp.conflicts.types.ConflictInfo;
+import org.openecomp.sdc.datatypes.model.ElementType;
+import org.openecomp.sdc.versioning.dao.impl.zusammen.convertor.ItemVersionToVersionConvertor;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.types.ElementPropertyName;
+
+import java.util.stream.Collectors;
+
+public class ItemVersionConflictConvertorFromZusammen {
+ public org.openecomp.conflicts.types.ItemVersionConflict convert(String itemId, Version version,
+ ItemVersionConflict source) {
+ org.openecomp.conflicts.types.ItemVersionConflict target =
+ new org.openecomp.conflicts.types.ItemVersionConflict();
+
+ target.setVersionConflict(
+ convertVersionDataConflict(itemId, version, source.getVersionDataConflict()));
+ target.setElementConflicts(source.getElementConflictInfos().stream()
+ .map(this::convertElementConflictInfo)
+ .collect(Collectors.toList()));
+
+ return target;
+ }
+
+
+ private Conflict<Version> convertVersionDataConflict(String itemId, Version version,
+ ItemVersionDataConflict versionDataConflict) {
+ if (versionDataConflict == null) {
+ return null;
+ }
+
+ Conflict<Version> conflict =
+ new Conflict<>(version.getId(), ElementType.itemVersion, null);
+
+ ItemVersionToVersionConvertor convertor = new ItemVersionToVersionConvertor();
+ conflict.setYours(convertor.convert(
+ getItemVersion(version.getId(), versionDataConflict.getLocalData())));
+ conflict.setTheirs(convertor.convert(
+ getItemVersion(version.getId(), versionDataConflict.getRemoteData())));
+ return conflict;
+ }
+
+ private ItemVersion getItemVersion(String versionId, ItemVersionData versionData) {
+ if (versionData == null) {
+ return null;
+ }
+ ItemVersion itemVersion = new ItemVersion();
+ itemVersion.setId(new Id(versionId));
+ itemVersion.setData(versionData);
+ return itemVersion;
+ }
+
+ private ConflictInfo convertElementConflictInfo(ElementConflictInfo elementConflictInfo) {
+ ElementInfo elementInfo = elementConflictInfo.getLocalElementInfo() == null
+ ? elementConflictInfo.getRemoteElementInfo()
+ : elementConflictInfo.getLocalElementInfo();
+
+ return new ConflictInfo(elementInfo.getId().getValue(),
+ ElementType
+ .valueOf(elementInfo.getInfo().getProperty(ElementPropertyName.elementType.name())),
+ elementInfo.getInfo().getName());
+ }
+}
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/impl/VspMergeHandler.java b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/impl/VspMergeHandler.java
new file mode 100644
index 0000000..f7d0bca
--- /dev/null
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/impl/VspMergeHandler.java
@@ -0,0 +1,204 @@
+package org.openecomp.conflicts.impl;
+
+import org.openecomp.conflicts.ItemMergeHandler;
+import org.openecomp.conflicts.dao.ConflictsDao;
+import org.openecomp.conflicts.types.Conflict;
+import org.openecomp.conflicts.types.ConflictInfo;
+import org.openecomp.conflicts.types.ConflictResolution;
+import org.openecomp.conflicts.types.ItemVersionConflict;
+import org.openecomp.conflicts.types.Resolution;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdc.datatypes.model.ElementType;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VspMergeDao;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static org.openecomp.sdc.datatypes.model.ElementType.NetworkPackage;
+import static org.openecomp.sdc.datatypes.model.ElementType.OrchestrationTemplate;
+import static org.openecomp.sdc.datatypes.model.ElementType.OrchestrationTemplateCandidate;
+import static org.openecomp.sdc.datatypes.model.ElementType.OrchestrationTemplateCandidateContent;
+import static org.openecomp.sdc.datatypes.model.ElementType.OrchestrationTemplateValidationData;
+import static org.openecomp.sdc.datatypes.model.ElementType.VspModel;
+
+public class VspMergeHandler implements ItemMergeHandler {
+
+ private static final String VSP_MODEL_CONFLICT_ID = "vspModelConflictId";
+ private static final String ELEMENT_CONFLICT_NOT_EXIST_ERR_ID = "ELEMENT_CONFLICT_NOT_EXIST";
+ private static final String ELEMENT_CONFLICT_NOT_EXISTS_MSG =
+ "Item Id %s, version Id %s, element conflict with Id %s does not exists.";
+ private static final Set<ElementType> FILTERED_OUT_TYPES = Stream
+ .of(OrchestrationTemplateCandidateContent, OrchestrationTemplateValidationData)
+ .collect(Collectors.toSet());
+ private static final Map<ElementType, Set<ElementType>> ELEMENT_TYPE_TO_CONFLICT_DEPENDANT_TYPES =
+ new HashMap<>();
+
+ static {
+ ELEMENT_TYPE_TO_CONFLICT_DEPENDANT_TYPES.put(OrchestrationTemplateCandidate,
+ Collections.singleton(OrchestrationTemplateCandidateContent));
+ ELEMENT_TYPE_TO_CONFLICT_DEPENDANT_TYPES.put(OrchestrationTemplate,
+ Collections.singleton(OrchestrationTemplateValidationData));
+ }
+
+ private ConflictsDao conflictsDao;
+ private VspMergeDao vspMergeDao;
+
+ public VspMergeHandler(ConflictsDao conflictsDao, VspMergeDao vspMergeDao) {
+ this.conflictsDao = conflictsDao;
+ this.vspMergeDao = vspMergeDao;
+ }
+
+ @Override
+ public boolean isConflicted(String itemId, Version version) {
+ return vspMergeDao.isVspModelConflicted(itemId, version);
+ }
+
+ @Override
+ public void finalizeMerge(String itemId, Version version) {
+ if (!conflictsDao.isConflicted(itemId, version)) {
+ vspMergeDao.applyVspModelConflictResolution(itemId, version);
+ }
+ }
+
+ @Override
+ public void postListConflicts(String itemId, Version version, ItemVersionConflict conflicts) {
+ List<ConflictInfo> elementConflicts = new ArrayList<>();
+
+ boolean vspModelConflicted = false;
+ for (ConflictInfo elementConflict : conflicts.getElementConflicts()) {
+ if (elementConflict.getType() == VspModel) {
+ elementConflicts.add(
+ new ConflictInfo(elementConflict.getId(), NetworkPackage, NetworkPackage.name()));
+ vspModelConflicted = true;
+ continue;
+ }
+ if (!FILTERED_OUT_TYPES.contains(elementConflict.getType())) {
+ elementConflicts.add(elementConflict);
+ }
+ }
+
+ if (!vspModelConflicted && vspMergeDao.isVspModelConflicted(itemId, version)) {
+ elementConflicts
+ .add(new ConflictInfo(VSP_MODEL_CONFLICT_ID, NetworkPackage, NetworkPackage.name()));
+ }
+
+ conflicts.setElementConflicts(elementConflicts);
+ }
+
+ @Override
+ public Optional<Conflict> getConflict(String itemId, Version version, String conflictId) {
+ return VSP_MODEL_CONFLICT_ID.equals(conflictId)
+ ? Optional.of(buildVspModelConflict(conflictId))
+ : Optional.empty();
+ }
+
+ @Override
+ public void postGetConflict(String itemId, Version version, Conflict conflict) {
+ if (conflict.getType() == VspModel) {
+ Conflict vspModelConflict = buildVspModelConflict(null);
+ conflict.setType(vspModelConflict.getType());
+ conflict.setName(vspModelConflict.getName());
+ conflict.setYours(vspModelConflict.getYours());
+ conflict.setTheirs(vspModelConflict.getTheirs());
+ }
+ }
+
+ @Override
+ public void preResolveConflict(String itemId, Version version, String conflictId,
+ ConflictResolution resolution) {
+ if (VSP_MODEL_CONFLICT_ID.equals(conflictId)) {
+ return;
+ }
+ resolveDependantConflicts(itemId, version, conflictId, resolution);
+ }
+
+ @Override
+ public boolean resolveConflict(String itemId, Version version, String conflictId,
+ ConflictResolution resolution) {
+ if (VSP_MODEL_CONFLICT_ID.equals(conflictId)) {
+ vspMergeDao.updateVspModelConflictResolution(itemId, version,
+ com.amdocs.zusammen.datatypes.item.Resolution.valueOf(resolution.getResolution().name()));
+ return true;
+ }
+ Conflict conflict = conflictsDao.getConflict(itemId, version, conflictId);
+ if (conflict == null) {
+ throw getConflictNotExistException(itemId, version, conflictId);
+ }
+ if (conflict.getType() == VspModel) {
+ vspMergeDao.updateVspModelConflictResolution(itemId, version,
+ com.amdocs.zusammen.datatypes.item.Resolution.valueOf(resolution.getResolution().name()));
+
+ conflictsDao.resolveConflict(itemId, version, conflictId, new ConflictResolution(
+ conflict.getTheirs() == null ? Resolution.YOURS : Resolution.THEIRS));
+ return true;
+ }
+ return false;
+ }
+
+ private void resolveDependantConflicts(String itemId, Version version, String conflictId,
+ ConflictResolution resolution) {
+ ItemVersionConflict conflicts = conflictsDao.getConflict(itemId, version);
+
+ Set<ElementType> conflictDependantTypes =
+ ELEMENT_TYPE_TO_CONFLICT_DEPENDANT_TYPES
+ .get(findConflictById(conflicts, conflictId).getType());
+
+ if (conflictDependantTypes == null) {
+ return;
+ }
+
+ findConflictsByTypes(conflicts, conflictDependantTypes)
+ .forEach(dependantConflict ->
+ conflictsDao.resolveConflict(itemId, version, dependantConflict.getId(), resolution));
+ }
+
+ private ConflictInfo findConflictById(ItemVersionConflict versionConflicts,
+ String conflictId) {
+ return versionConflicts.getElementConflicts().stream()
+ .filter(elementConflict -> conflictId.equals(elementConflict.getId()))
+ .findFirst()
+ .orElseThrow(() -> new IllegalStateException(
+ String.format("Conflict Id %s does not exist on conflicts list", conflictId)));
+ }
+
+ private Collection<ConflictInfo> findConflictsByTypes(ItemVersionConflict versionConflicts,
+ Set<ElementType> elementTypes) {
+ return versionConflicts.getElementConflicts().stream()
+ .filter(elementConflict -> elementTypes.contains(elementConflict.getType()))
+ .collect(Collectors.toList());
+ }
+
+ private Conflict buildVspModelConflict(String conflictId) {
+ Conflict conflict = new Conflict(conflictId, NetworkPackage, NetworkPackage.name());
+
+ Map<String, String> yours = new HashMap<>();
+ yours.put("File", "Local (Me)");
+ conflict.setYours(yours);
+
+ Map<String, String> theirs = new HashMap<>();
+ theirs.put("File", "Last Committed");
+ conflict.setTheirs(theirs);
+ return conflict;
+ }
+
+ private CoreException getConflictNotExistException(String itemId, Version version,
+ String conflictId) {
+ return new CoreException(new ErrorCode.ErrorCodeBuilder()
+ .withCategory(ErrorCategory.APPLICATION)
+ .withId(ELEMENT_CONFLICT_NOT_EXIST_ERR_ID)
+ .withMessage(
+ String.format(ELEMENT_CONFLICT_NOT_EXISTS_MSG, itemId, version.getId(), conflictId))
+ .build());
+ }
+}
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/resources/factoryConfiguration.json b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/resources/factoryConfiguration.json
new file mode 100644
index 0000000..ec9f370
--- /dev/null
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/resources/factoryConfiguration.json
@@ -0,0 +1,4 @@
+{
+ "org.openecomp.conflicts.ItemMergeHandlerFactory": "org.openecomp.conflicts.ItemMergeHandlerFactoryImpl",
+ "org.openecomp.conflicts.dao.ConflictsDaoFactory": "org.openecomp.conflicts.dao.impl.zusammen.ConflictsDaoFactoryImpl"
+}
\ No newline at end of file
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/pom.xml b/openecomp-be/lib/openecomp-conflict-lib/pom.xml
similarity index 65%
copy from openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/pom.xml
copy to openecomp-be/lib/openecomp-conflict-lib/pom.xml
index 0b3c83c..de6bcd6 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/pom.xml
+++ b/openecomp-be/lib/openecomp-conflict-lib/pom.xml
@@ -4,19 +4,17 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>activity-log-rest</artifactId>
- <packaging>pom</packaging>
-
<parent>
<groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-rest-webapp</artifactId>
+ <artifactId>openecomp-sdc-lib</artifactId>
<version>1.2.0-SNAPSHOT</version>
+ <relativePath>..</relativePath>
</parent>
+ <artifactId>openecomp-conflict-lib</artifactId>
+ <packaging>pom</packaging>
<modules>
- <module>activity-log-rest-services</module>
- <module>activity-log-rest-types</module>
+ <module>openecomp-conflict-api</module>
+ <module>openecomp-conflict-core</module>
</modules>
-
-</project>
+</project>
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/test/java/org/openecomp/sdc/applicationconfig/dao/ApplicationConfigImplDaoTest.java b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/test/java/org/openecomp/sdc/applicationconfig/dao/ApplicationConfigImplDaoTest.java
index 6b5c5f9..e3d8765 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/test/java/org/openecomp/sdc/applicationconfig/dao/ApplicationConfigImplDaoTest.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-config-lib/src/test/java/org/openecomp/sdc/applicationconfig/dao/ApplicationConfigImplDaoTest.java
@@ -20,23 +20,6 @@
package org.openecomp.sdc.applicationconfig.dao;
-import org.openecomp.core.utilities.applicationconfig.ApplicationConfig;
-import org.openecomp.core.utilities.applicationconfig.ApplicationConfigFactory;
-import org.openecomp.core.utilities.applicationconfig.dao.ApplicationConfigDao;
-import org.openecomp.core.utilities.applicationconfig.dao.ApplicationConfigDaoFactory;
-import org.openecomp.core.utilities.applicationconfig.dao.type.ApplicationConfigEntity;
-import org.openecomp.core.utilities.applicationconfig.type.ConfigurationData;
-import org.openecomp.core.utilities.file.FileUtils;
-import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.common.errors.ErrorCategory;
-import org.openecomp.sdc.common.errors.ErrorCode;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-
public class ApplicationConfigImplDaoTest {
/*
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-api/src/main/java/org/openecomp/core/factory/impl/AbstractFactoryBase.java b/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-api/src/main/java/org/openecomp/core/factory/impl/AbstractFactoryBase.java
index 9353de6..7b53f34 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-api/src/main/java/org/openecomp/core/factory/impl/AbstractFactoryBase.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-api/src/main/java/org/openecomp/core/factory/impl/AbstractFactoryBase.java
@@ -21,9 +21,6 @@
package org.openecomp.core.factory.impl;
-import static org.openecomp.core.utilities.CommonMethods.isEmpty;
-import static org.openecomp.core.utilities.CommonMethods.newInstance;
-
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
@@ -32,6 +29,9 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import static org.openecomp.core.utilities.CommonMethods.isEmpty;
+import static org.openecomp.core.utilities.CommonMethods.newInstance;
+
public abstract class AbstractFactoryBase {
/**
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-api/src/main/java/org/openecomp/core/util/UniqueValueUtil.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-api/src/main/java/org/openecomp/core/util/UniqueValueUtil.java
index dce34a1..15e9cee 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-api/src/main/java/org/openecomp/core/util/UniqueValueUtil.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-api/src/main/java/org/openecomp/core/util/UniqueValueUtil.java
@@ -32,7 +32,7 @@
import java.util.Optional;
public class UniqueValueUtil {
- public static final String UNIQUE_VALUE_VIOLATION = "UNIQUE_VALUE_VIOLATION";
+ private static final String UNIQUE_VALUE_VIOLATION = "UNIQUE_VALUE_VIOLATION";
private static final String UNIQUE_VALUE_VIOLATION_MSG = "%s with the value '%s' already exists.";
private static final UniqueValueDao uniqueValueDao =
@@ -46,9 +46,7 @@
* @param uniqueCombination the unique combination
*/
public static void createUniqueValue(String type, String... uniqueCombination) {
-
-
- mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugEntryMessage(null);
Optional<String> value = formatValue(uniqueCombination);
if (!value.isPresent()) {
@@ -57,7 +55,7 @@
validateUniqueValue(type, value.get(), uniqueCombination);
uniqueValueDao.create(new UniqueValueEntity(type, value.get()));
- mdcDataDebugMessage.debugExitMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null);
}
/**
@@ -69,7 +67,7 @@
public static void deleteUniqueValue(String type, String... uniqueCombination) {
- mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugEntryMessage(null);
Optional<String> value = formatValue(uniqueCombination);
if (!value.isPresent()) {
@@ -77,7 +75,7 @@
}
uniqueValueDao.delete(new UniqueValueEntity(type, value.get()));
- mdcDataDebugMessage.debugExitMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null);
}
/**
@@ -92,17 +90,14 @@
String... uniqueContext) {
- mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugEntryMessage(null);
- boolean nonEqual = (newValue != null) && (oldValue != null)
- && !newValue.toLowerCase().equals(oldValue.toLowerCase());
-
- if (nonEqual || newValue == null || oldValue == null) {
+ if (newValue == null || oldValue == null || !newValue.equalsIgnoreCase(oldValue)) {
createUniqueValue(type, CommonMethods.concat(uniqueContext, new String[]{newValue}));
deleteUniqueValue(type, CommonMethods.concat(uniqueContext, new String[]{oldValue}));
}
- mdcDataDebugMessage.debugExitMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null);
}
/**
@@ -112,7 +107,7 @@
* @param uniqueCombination the unique combination
*/
public static void validateUniqueValue(String type, String... uniqueCombination) {
- mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugEntryMessage(null);
Optional<String> value = formatValue(uniqueCombination);
if (!value.isPresent()) {
@@ -120,11 +115,11 @@
}
validateUniqueValue(type, value.get(), uniqueCombination);
- mdcDataDebugMessage.debugExitMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null);
}
private static void validateUniqueValue(String type, String value, String... uniqueCombination) {
- mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugEntryMessage(null);
if (uniqueValueDao.get(new UniqueValueEntity(type, value)) != null) {
throw new CoreException(new ErrorCode.ErrorCodeBuilder()
@@ -134,13 +129,13 @@
uniqueCombination[uniqueCombination.length - 1])).build());
}
- mdcDataDebugMessage.debugExitMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null);
}
private static Optional<String> formatValue(String[] uniqueCombination) {
- mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugEntryMessage(null);
if (uniqueCombination == null || uniqueCombination.length == 0
|| uniqueCombination[uniqueCombination.length - 1] == null) {
@@ -150,7 +145,7 @@
uniqueCombination[uniqueCombination.length - 1] =
uniqueCombination[uniqueCombination.length - 1].toLowerCase();
- mdcDataDebugMessage.debugExitMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null);
return Optional.of(CommonMethods.arrayToSeparatedString(uniqueCombination, '_'));
}
}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/impl/cassandra/CassandraNoSqlDbImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/impl/cassandra/CassandraNoSqlDbImpl.java
index 93410bc..2172e1b 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/impl/cassandra/CassandraNoSqlDbImpl.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/impl/cassandra/CassandraNoSqlDbImpl.java
@@ -20,7 +20,11 @@
package org.openecomp.core.nosqldb.impl.cassandra;
-import com.datastax.driver.core.*;
+import com.datastax.driver.core.BoundStatement;
+import com.datastax.driver.core.Host;
+import com.datastax.driver.core.PreparedStatement;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Session;
import com.datastax.driver.mapping.MappingManager;
import org.openecomp.core.nosqldb.api.NoSqlDb;
import org.openecomp.core.nosqldb.util.CassandraUtils;
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/org/openecomp/core/nosqldb/NoSqlDbTest.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/org/openecomp/core/nosqldb/NoSqlDbTest.java
index 5c4f951..2bab7e0 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/org/openecomp/core/nosqldb/NoSqlDbTest.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/org/openecomp/core/nosqldb/NoSqlDbTest.java
@@ -20,14 +20,7 @@
package org.openecomp.core.nosqldb;
-import com.datastax.driver.core.ResultSet;
-import com.datastax.driver.core.Row;
import org.openecomp.core.nosqldb.api.NoSqlDb;
-import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import java.util.List;
public class NoSqlDbTest {
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/org/openecomp/core/nosqldb/util/ConfigurationManagerTest.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/org/openecomp/core/nosqldb/util/ConfigurationManagerTest.java
index f8d5d2d..7a6343d 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/org/openecomp/core/nosqldb/util/ConfigurationManagerTest.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/org/openecomp/core/nosqldb/util/ConfigurationManagerTest.java
@@ -7,7 +7,7 @@
import java.io.IOException;
import java.lang.reflect.Field;
-import static org.testng.Assert.*;
+import static org.testng.Assert.assertNotNull;
/**
* @author EVITALIY
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/pom.xml b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/pom.xml
new file mode 100644
index 0000000..c0618ba
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/pom.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-core-lib</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>openecomp-session-lib</artifactId>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-facade-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-facade-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+
+</project>
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/SessionContext.java b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/SessionContext.java
new file mode 100644
index 0000000..a1b410c
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/SessionContext.java
@@ -0,0 +1,8 @@
+package org.openecomp.sdc.common.session;
+
+public interface SessionContext {
+
+ User getUser();
+
+ String getTenant();
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/SessionContextProvider.java b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/SessionContextProvider.java
new file mode 100644
index 0000000..8efbbd1
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/SessionContextProvider.java
@@ -0,0 +1,10 @@
+package org.openecomp.sdc.common.session;
+
+public interface SessionContextProvider {
+
+ void create(String user);
+
+ SessionContext get();
+
+ void close();
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDaoFactory.java b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/SessionContextProviderFactory.java
similarity index 77%
copy from openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDaoFactory.java
copy to openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/SessionContextProviderFactory.java
index 9654551..cfa6a34 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDaoFactory.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/SessionContextProviderFactory.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,14 +18,15 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.vendorsoftwareproduct.dao;
+package org.openecomp.sdc.common.session;
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
-public abstract class UploadDataDaoFactory extends AbstractComponentFactory<UploadDataDao> {
+public abstract class SessionContextProviderFactory
+ extends AbstractComponentFactory<SessionContextProvider> {
- public static UploadDataDaoFactory getInstance() {
- return AbstractFactory.getInstance(UploadDataDaoFactory.class);
+ public static SessionContextProviderFactory getInstance() {
+ return AbstractFactory.getInstance(SessionContextProviderFactory.class);
}
}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/User.java b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/User.java
new file mode 100644
index 0000000..5319a0b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/User.java
@@ -0,0 +1,13 @@
+package org.openecomp.sdc.common.session;
+
+public class User {
+ private final String userId;
+
+ public User(String userId) {
+ this.userId = userId;
+ }
+
+ public String getUserId() {
+ return userId;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/impl/AsdcSessionContextProvider.java b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/impl/AsdcSessionContextProvider.java
new file mode 100644
index 0000000..53a40a1
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/impl/AsdcSessionContextProvider.java
@@ -0,0 +1,50 @@
+package org.openecomp.sdc.common.session.impl;
+
+import org.openecomp.sdc.common.session.SessionContext;
+import org.openecomp.sdc.common.session.SessionContextProvider;
+import org.openecomp.sdc.common.session.User;
+
+public class AsdcSessionContextProvider implements SessionContextProvider {
+
+ private static final ThreadLocal<String> threadUserId = new ThreadLocal<>();
+
+ @Override
+ public void create(String userId) {
+ threadUserId.set(userId);
+ }
+
+ @Override
+ public SessionContext get() {
+ if (threadUserId.get() == null) {
+ throw new RuntimeException("UserId was not set for this thread");
+ }
+
+ return new AsdcSessionContext(new User(threadUserId.get()), "dox");
+ }
+
+ @Override
+ public void close() {
+ threadUserId.remove();
+ }
+
+ private static class AsdcSessionContext implements SessionContext {
+
+ private final User user;
+ private final String tenant;
+
+ private AsdcSessionContext(User user, String tenant) {
+ this.user = user;
+ this.tenant = tenant;
+ }
+
+ @Override
+ public User getUser() {
+ return user;
+ }
+
+ @Override
+ public String getTenant() {
+ return tenant;
+ }
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activityLog/ActivityLogManager.java b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/impl/SessionContextProviderFactoryImpl.java
similarity index 68%
copy from openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activityLog/ActivityLogManager.java
copy to openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/impl/SessionContextProviderFactoryImpl.java
index a40e101..635aa5b 100644
--- a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activityLog/ActivityLogManager.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/impl/SessionContextProviderFactoryImpl.java
@@ -18,14 +18,16 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.activityLog;
+package org.openecomp.sdc.common.session.impl;
-import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
-import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.common.session.SessionContextProvider;
+import org.openecomp.sdc.common.session.SessionContextProviderFactory;
-import java.util.Collection;
+public class SessionContextProviderFactoryImpl extends SessionContextProviderFactory {
+ private static final SessionContextProvider INSTANCE = new AsdcSessionContextProvider();
-public interface ActivityLogManager {
- void addActionLog(ActivityLogEntity activityLogEntity, String user);
- Collection<ActivityLogEntity> listActivityLogs(String itemId, Version versionId, String user);
+ @Override
+ public SessionContextProvider createInterface() {
+ return INSTANCE;
+ }
}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/resources/factoryConfiguration.json b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/resources/factoryConfiguration.json
new file mode 100644
index 0000000..cd1637a
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/resources/factoryConfiguration.json
@@ -0,0 +1,3 @@
+{
+ "org.openecomp.sdc.common.session.SessionContextProviderFactory": "org.openecomp.sdc.common.session.impl.SessionContextProviderFactoryImpl"
+}
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/file/FileUtils.java b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/file/FileUtils.java
index 6ab3f8b..5a8a2db 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/file/FileUtils.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/file/FileUtils.java
@@ -23,12 +23,9 @@
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
import org.openecomp.core.utilities.json.JsonUtil;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.services.YamlUtil;
import java.io.ByteArrayInputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/test/java/org/openecomp/core/utilities/file/FileContentHandlerTest.java b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/test/java/org/openecomp/core/utilities/file/FileContentHandlerTest.java
index 527ba22..be0686e 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/test/java/org/openecomp/core/utilities/file/FileContentHandlerTest.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/test/java/org/openecomp/core/utilities/file/FileContentHandlerTest.java
@@ -6,7 +6,9 @@
import java.util.Arrays;
import java.util.Optional;
-import static org.testng.Assert.*;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
/**
* @author EVITALIY
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/pom.xml b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/pom.xml
index 538a7fb..ee59b5b 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/pom.xml
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/pom.xml
@@ -20,6 +20,16 @@
</dependency>
<dependency>
<groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-session-lib</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-versioning-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
<artifactId>openecomp-facade-api</artifactId>
<version>${project.version}</version>
</dependency>
@@ -43,6 +53,11 @@
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
+ <dependency>
+ <groupId>com.amdocs.zusammen</groupId>
+ <artifactId>zusammen-datatypes</artifactId>
+ <version>${zusammen.version}</version>
+ </dependency>
</dependencies>
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/convertor/ElementConvertor.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/convertor/ElementConvertor.java
new file mode 100644
index 0000000..68c7098
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/convertor/ElementConvertor.java
@@ -0,0 +1,37 @@
+package org.openecomp.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.item.Item;
+import com.amdocs.zusammen.datatypes.item.ItemVersion;
+import org.openecomp.sdc.datatypes.model.ElementType;
+import org.openecomp.types.ElementPropertyName;
+
+public abstract class ElementConvertor<T> {
+
+ public static ElementType getElementType(Element element) {
+ return ElementType
+ .valueOf(element.getInfo().getProperty(ElementPropertyName.elementType.name()));
+ }
+
+ public static String getElementName(Element element) {
+ return element.getInfo().getName();
+ }
+
+
+ abstract public T convert(Element element);
+
+ public T convert( ElementInfo elementInfo) {
+ throw new UnsupportedOperationException("convert elementInfo item is not supported ");
+ }
+
+
+ public T convert( Item item) {
+ throw new UnsupportedOperationException("convert from item is not supported ");
+ }
+
+
+ public T convert( ItemVersion itemVersion) {
+ throw new UnsupportedOperationException("convert from itemVersion is not supported ");
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenAdaptor.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenAdaptor.java
index 2ba447f..35c07cb 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenAdaptor.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenAdaptor.java
@@ -1,7 +1,9 @@
package org.openecomp.core.zusammen.api;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementConflict;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ItemVersionConflict;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
import com.amdocs.zusammen.commons.health.data.HealthInfo;
import com.amdocs.zusammen.datatypes.Id;
@@ -11,31 +13,53 @@
import com.amdocs.zusammen.datatypes.item.Item;
import com.amdocs.zusammen.datatypes.item.ItemVersion;
import com.amdocs.zusammen.datatypes.item.ItemVersionData;
+import com.amdocs.zusammen.datatypes.item.ItemVersionStatus;
+import com.amdocs.zusammen.datatypes.item.Resolution;
import com.amdocs.zusammen.datatypes.itemversion.Tag;
+import org.openecomp.sdc.versioning.dao.types.Revision;
import java.util.Collection;
+import java.util.List;
import java.util.Optional;
public interface ZusammenAdaptor {
Collection<Item> listItems(SessionContext context);
+ Item getItem(SessionContext context, Id itemId);
+
Id createItem(SessionContext context, Info info);
void updateItem(SessionContext context, Id itemId, Info info);
- // TODO: 4/4/2017 fix this workaround when versionId will be recieved from UI
+ // TODO: 4/4/2017 remove this workaround when versionId will be recieved from UI
Optional<ItemVersion> getFirstVersion(SessionContext context, Id itemId);
+ Collection<ItemVersion> listPublicVersions(SessionContext context, Id itemId);
+
+ ItemVersion getPublicVersion(SessionContext context, Id itemId, Id versionId);
+
Id createVersion(SessionContext context, Id itemId, Id baseVersionId,
ItemVersionData itemVersionData);
void updateVersion(SessionContext context, Id itemId, Id versionId,
ItemVersionData itemVersionData);
+ ItemVersion getVersion(SessionContext context, Id itemId, Id versionId);
+
+ ItemVersionStatus getVersionStatus(SessionContext context, Id itemId, Id versionId);
+
+ ItemVersionConflict getVersionConflict(SessionContext context, Id itemId, Id versionId);
+
void tagVersion(SessionContext context, Id itemId, Id versionId, Tag tag);
- void resetVersionHistory(SessionContext context, Id itemId, Id versionId, String changeRef);
+ void resetVersionHistory(SessionContext context, Id itemId, Id versionId, String version);
+
+ void publishVersion(SessionContext context, Id itemId, Id versionId, String message);
+
+ void syncVersion(SessionContext context, Id itemId, Id versionId);
+
+ void forceSyncVersion(SessionContext context, Id itemId, Id versionId);
Optional<ElementInfo> getElementInfo(SessionContext context, ElementContext elementContext,
Id elementId);
@@ -43,38 +67,39 @@
Optional<Element> getElement(SessionContext context, ElementContext elementContext,
String elementId); // TODO: 4/3/2017 change to Id
- Optional<Element> getElementByName(
- SessionContext context, ElementContext elementContext, Id parentElementId,
- String elementName);
+ Optional<Element> getElementByName(SessionContext context, ElementContext elementContext,
+ Id parentElementId, String elementName);
- Collection<ElementInfo> listElements(SessionContext context,
- ElementContext elementContext,
+ Collection<ElementInfo> listElements(SessionContext context, ElementContext elementContext,
Id parentElementId);
- Collection<Element> listElementData(SessionContext context,
- ElementContext elementContext,
+ Collection<Element> listElementData(SessionContext context, ElementContext elementContext,
Id parentElementId);
/**
- * Lists the sub elements of the element named <elementName> which is a sub element of <parentElementId>
- * @param context
- * @param elementContext
- * @param parentElementId
- * @param elementName
- * @return
+ * Lists the sub elements of the element named elementName which is a sub element of
+ * parentElementId
*/
- Collection<ElementInfo> listElementsByName(
- SessionContext context, ElementContext elementContext, Id parentElementId,
- String elementName);
+ Collection<ElementInfo> listElementsByName(SessionContext context, ElementContext elementContext,
+ Id parentElementId, String elementName);
- Optional<ElementInfo> getElementInfoByName(
- SessionContext context, ElementContext elementContext, Id parentElementId,
- String elementName);
+ Optional<ElementInfo> getElementInfoByName(SessionContext context, ElementContext elementContext,
+ Id parentElementId, String elementName);
- Optional<Element> saveElement(SessionContext context, ElementContext elementContext,
- ZusammenElement element, String message);
+ Optional<ElementConflict> getElementConflict(SessionContext context,
+ ElementContext elementContext, Id elementId);
+
+ Element saveElement(SessionContext context, ElementContext elementContext,
+ ZusammenElement element, String message);
+
+ void resolveElementConflict(SessionContext context, ElementContext elementContext,
+ ZusammenElement element, Resolution resolution);
Collection<HealthInfo> checkHealth(SessionContext context);
- String getVersion(SessionContext sessionContext);
+ String getVersion(SessionContext context);
+
+ void revert(SessionContext sessionContext, String itemId, String versionId, String revisionId);
+
+ List<Revision> listRevisions(SessionContext sessionContext, String itemId, String versionId);
}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenUtil.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenUtil.java
index 3df6151..623f958 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenUtil.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenUtil.java
@@ -1,40 +1,40 @@
package org.openecomp.core.zusammen.api;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
+import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.SessionContext;
import com.amdocs.zusammen.datatypes.UserInfo;
import com.amdocs.zusammen.datatypes.item.Action;
import com.amdocs.zusammen.datatypes.item.Info;
-import com.amdocs.zusammen.datatypes.item.ItemVersionData;
+import org.openecomp.sdc.common.session.SessionContextProviderFactory;
+import org.openecomp.sdc.datatypes.model.ElementType;
+import org.openecomp.types.ElementPropertyName;
public class ZusammenUtil {
- // TODO: 3/19/2017 add user and tenant args
+
public static SessionContext createSessionContext() {
+ org.openecomp.sdc.common.session.SessionContext asdcSessionContext =
+ SessionContextProviderFactory.getInstance().createInterface().get();
+
SessionContext sessionContext = new SessionContext();
- sessionContext.setUser(new UserInfo("GLOBAL_USER"));
- sessionContext.setTenant("dox");
+ sessionContext.setUser(new UserInfo(asdcSessionContext.getUser().getUserId()));
+ sessionContext.setTenant(asdcSessionContext.getTenant());
return sessionContext;
}
- public static ZusammenElement buildStructuralElement(String structureElementName,
- Action action) {
- ZusammenElement element = new ZusammenElement();
+ public static ZusammenElement buildStructuralElement(ElementType elementType, Action action) {
+ ZusammenElement element = buildElement(null, action);
Info info = new Info();
- info.setName(structureElementName);
+ info.setName(elementType.name());
+ info.addProperty(ElementPropertyName.elementType.name(), elementType.name());
element.setInfo(info);
- if (action != null) {
- element.setAction(action);
- }
return element;
}
- // TODO: 4/24/2017 remove upon working with more than one single version
- public static ItemVersionData createFirstVersionData() {
- Info info = new Info();
- info.setName("main version");
- ItemVersionData itemVersionData = new ItemVersionData();
- itemVersionData.setInfo(info);
- return itemVersionData;
+ public static ZusammenElement buildElement(Id elementId, Action action) {
+ ZusammenElement element = new ZusammenElement();
+ element.setElementId(elementId);
+ element.setAction(action);
+ return element;
}
-
}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/types/AsdcElement.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/types/AsdcElement.java
new file mode 100644
index 0000000..ae9c1fc
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/types/AsdcElement.java
@@ -0,0 +1,131 @@
+package org.openecomp.types;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.item.Action;
+import com.amdocs.zusammen.datatypes.item.Info;
+import com.amdocs.zusammen.datatypes.item.Relation;
+import com.amdocs.zusammen.utils.fileutils.FileUtils;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+
+public class AsdcElement implements Element {
+
+ private String type;
+ private String name;
+ private String description;
+
+ private Map<String, Object> properties;
+ private byte[] data;
+ private Collection<Relation> relations;
+ private Collection<Element> subElements = new ArrayList<>();
+ private Action action;
+ private Id elementId;
+
+ @Override
+ public Action getAction() {
+ return this.action;
+ }
+
+ @Override
+ public Id getElementId() {
+ return this.elementId;
+ }
+
+ @Override
+ public Info getInfo() {
+ Info info = new Info();
+ info.setProperties(this.properties);
+ info.addProperty(ElementPropertyName.elementType.name(), this.type != null ? this.type : this.name);
+ info.setName(this.name);
+ info.setDescription(this.description);
+
+ return info;
+ }
+
+ @Override
+ public Collection<Relation> getRelations() {
+ return this.relations;
+ }
+
+ @Override
+ public InputStream getData() {
+ return FileUtils.toInputStream(this.data);
+ }
+
+ @Override
+ public InputStream getSearchableData() {
+ return null;
+ }
+
+ @Override
+ public InputStream getVisualization() {
+ return null;
+ }
+
+
+ @Override
+ public Collection<Element> getSubElements() {
+ return this.subElements;
+ }
+
+ public void setElementId(Id elementId) {
+ this.elementId = elementId;
+ }
+
+ public void setData(InputStream data) {
+ this.data = FileUtils.toByteArray(data);
+ }
+
+ public void setRelations(Collection<Relation> relations) {
+ this.relations = relations;
+ }
+
+ public void setSubElements(Collection<Element> subElements) {
+ this.subElements = subElements;
+ }
+
+ public void setAction(Action action) {
+ this.action = action;
+ }
+
+ public AsdcElement addSubElement(Element element) {
+ this.subElements.add(element);
+ return this;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Map<String, Object> getProperties() {
+ return properties;
+ }
+
+ public void setProperties(Map<String, Object> properties) {
+ this.properties = properties;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/types/ElementPropertyName.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/types/ElementPropertyName.java
new file mode 100644
index 0000000..ddbef7d
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/types/ElementPropertyName.java
@@ -0,0 +1,6 @@
+package org.openecomp.types;
+
+public enum ElementPropertyName {
+ elementType,
+ compositionData
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/ZusammenConnector.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/ZusammenConnector.java
index 6381b2e..9005bb8 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/ZusammenConnector.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/ZusammenConnector.java
@@ -1,7 +1,9 @@
package org.openecomp.core.zusammen.db;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementConflict;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ItemVersionConflict;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
import com.amdocs.zusammen.commons.health.data.HealthInfo;
import com.amdocs.zusammen.datatypes.Id;
@@ -11,22 +13,31 @@
import com.amdocs.zusammen.datatypes.item.Item;
import com.amdocs.zusammen.datatypes.item.ItemVersion;
import com.amdocs.zusammen.datatypes.item.ItemVersionData;
+import com.amdocs.zusammen.datatypes.item.ItemVersionStatus;
+import com.amdocs.zusammen.datatypes.item.Resolution;
+import com.amdocs.zusammen.datatypes.itemversion.ItemVersionRevisions;
import com.amdocs.zusammen.datatypes.itemversion.Tag;
-import com.amdocs.zusammen.datatypes.response.Response;
import java.util.Collection;
-import java.util.Optional;
public interface ZusammenConnector {
+ Collection<HealthInfo> checkHealth(SessionContext sessionContext);
+
+ String getVersion(SessionContext sessionContext);
+
Collection<Item> listItems(SessionContext context);
+ Item getItem(SessionContext context, Id itemId);
+
Id createItem(SessionContext context, Info info);
void updateItem(SessionContext context, Id itemId, Info info);
- Collection<ItemVersion> listVersions(SessionContext context, Id itemId);
+ Collection<ItemVersion> listPublicVersions(SessionContext context, Id itemId);
+
+ ItemVersion getPublicVersion(SessionContext context, Id itemId, Id versionId);
Id createVersion(SessionContext context, Id itemId, Id baseVersionId,
ItemVersionData itemVersionData);
@@ -34,23 +45,42 @@
void updateVersion(SessionContext context, Id itemId, Id versionId,
ItemVersionData itemVersionData);
+ ItemVersion getVersion(SessionContext context, Id itemId, Id versionId);
+
+ ItemVersionStatus getVersionStatus(SessionContext context, Id itemId, Id versionId);
+
void tagVersion(SessionContext context, Id itemId, Id versionId, Tag tag);
- void resetVersionHistory(SessionContext context, Id itemId, Id versionId, String changeRef);
+ void resetVersionRevision(SessionContext context, Id itemId, Id versionId, Id revisionId);
+
+ void revertVersionRevision(SessionContext context, Id itemId, Id versionId, Id revisionId);
+
+ ItemVersionRevisions listVersionRevisions(SessionContext context, Id itemId, Id versionId);
+
+ void publishVersion(SessionContext context, Id itemId, Id versionId, String message);
+
+ void syncVersion(SessionContext context, Id itemId, Id versionId);
+
+ void forceSyncVersion(SessionContext context, Id itemId, Id versionId);
+
+ ItemVersionConflict getVersionConflict(SessionContext context, Id itemId, Id versionId);
Collection<ElementInfo> listElements(SessionContext context, ElementContext elementContext,
Id parentElementId);
- Response<ElementInfo> getElementInfo(SessionContext context, ElementContext elementContext, Id
- elementId);
+ ElementInfo getElementInfo(SessionContext context, ElementContext elementContext, Id elementId);
- Response<Element> getElement(SessionContext context, ElementContext elementContext, Id elementId);
+ Element getElement(SessionContext context, ElementContext elementContext, Id elementId);
- Optional<Element> saveElement(SessionContext context, ElementContext elementContext,
- ZusammenElement element, String message);
+ ElementConflict getElementConflict(SessionContext context, ElementContext elementContext,
+ Id elementId);
- Collection<HealthInfo> checkHealth(SessionContext sessionContext);
+ Element saveElement(SessionContext context, ElementContext elementContext,
+ ZusammenElement element, String message);
- String getVersion(SessionContext sessionContext);
+ void resolveElementConflict(SessionContext context, ElementContext elementContext,
+ ZusammenElement element, Resolution resolution);
+
+ void resetVersionHistory(SessionContext context, Id itemId, Id versionId, String changeRef);
}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/impl/ZusammenConnectorImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/impl/ZusammenConnectorImpl.java
index deb5ffd..1d387b9 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/impl/ZusammenConnectorImpl.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/impl/ZusammenConnectorImpl.java
@@ -1,11 +1,14 @@
package org.openecomp.core.zusammen.db.impl;
+import com.amdocs.zusammen.adaptor.inbound.api.health.HealthAdaptorFactory;
import com.amdocs.zusammen.adaptor.inbound.api.item.ElementAdaptorFactory;
import com.amdocs.zusammen.adaptor.inbound.api.item.ItemAdaptorFactory;
import com.amdocs.zusammen.adaptor.inbound.api.item.ItemVersionAdaptorFactory;
-import com.amdocs.zusammen.adaptor.inbound.api.health.HealthAdaptorFactory;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementConflict;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ItemVersionConflict;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.MergeResult;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
import com.amdocs.zusammen.commons.health.data.HealthInfo;
import com.amdocs.zusammen.datatypes.Id;
@@ -16,6 +19,9 @@
import com.amdocs.zusammen.datatypes.item.Item;
import com.amdocs.zusammen.datatypes.item.ItemVersion;
import com.amdocs.zusammen.datatypes.item.ItemVersionData;
+import com.amdocs.zusammen.datatypes.item.ItemVersionStatus;
+import com.amdocs.zusammen.datatypes.item.Resolution;
+import com.amdocs.zusammen.datatypes.itemversion.ItemVersionRevisions;
import com.amdocs.zusammen.datatypes.itemversion.Tag;
import com.amdocs.zusammen.datatypes.response.Response;
import com.amdocs.zusammen.datatypes.response.ReturnCode;
@@ -28,14 +34,18 @@
import org.openecomp.sdc.logging.types.LoggerErrorCode;
import java.util.Collection;
-import java.util.Optional;
public class ZusammenConnectorImpl implements ZusammenConnector {
+ private static final String GET_ELEMENT_ERR_MSG =
+ "Failed to get element. Item Id: %s, version Id: %s, element Id: %s message: %s";
+ private static final String GET_ELEMENT_IN_REV_ERR_MSG =
+ "Failed to get element. Item Id: %s, version Id: %s, revision Id: %s, element Id: %s message: %s";
private ItemAdaptorFactory itemAdaptorFactory;
private ItemVersionAdaptorFactory versionAdaptorFactory;
private ElementAdaptorFactory elementAdaptorFactory;
private HealthAdaptorFactory healthAdaptorFactory;
+
public ZusammenConnectorImpl(
ItemAdaptorFactory itemAdaptorFactory,
ItemVersionAdaptorFactory versionAdaptorFactory,
@@ -69,14 +79,23 @@
}
@Override
+ public Item getItem(SessionContext context, Id itemId) {
+ Response<Item> response = itemAdaptorFactory.createInterface(context).get(context, itemId);
+ if (!response.isSuccessful()) {
+ throw new RuntimeException(
+ "Failed to get Item. message:" + response.getReturnCode().toString());
+ }
+ return response.getValue();
+ }
+
+ @Override
public Id createItem(SessionContext context, Info info) {
Response<Id> response = itemAdaptorFactory.createInterface(context).create(context, info);
- if (response.isSuccessful()) {
- return response.getValue();
- } else {
+ if (!response.isSuccessful()) {
throw new RuntimeException(
- "failed to create Item. message:" + response.getReturnCode().toString());
+ "Failed to create Item. message:" + response.getReturnCode().toString());
}
+ return response.getValue();
}
@Override
@@ -91,18 +110,30 @@
}
@Override
- public Collection<ItemVersion> listVersions(SessionContext context, Id itemId) {
+ public Collection<ItemVersion> listPublicVersions(SessionContext context, Id itemId) {
Response<Collection<ItemVersion>> versions =
- versionAdaptorFactory.createInterface(context).list(context, Space.PRIVATE, itemId);
+ versionAdaptorFactory.createInterface(context).list(context, Space.PUBLIC, itemId);
if (!versions.isSuccessful()) {
logErrorMessageToMdc(ItemElementLoggerTargetServiceName.ITEM_VERSION_RETRIEVAL, versions
.getReturnCode());
- throw new RuntimeException(versions.getReturnCode().toString()); // TODO: 3/26/2017
+ throw new RuntimeException(versions.getReturnCode().toString());
}
return versions.getValue();
}
@Override
+ public ItemVersion getPublicVersion(SessionContext context, Id itemId, Id versionId) {
+ Response<ItemVersion> response = versionAdaptorFactory.createInterface(context)
+ .get(context, Space.PUBLIC, itemId, versionId);
+ if (!response.isSuccessful()) {
+ throw new RuntimeException(
+ String.format("failed to get public Item Version. ItemId: %s, versionId: %s, message: %s",
+ itemId.getValue(), versionId.getValue(), response.getReturnCode().toString()));
+ }
+ return response.getValue();
+ }
+
+ @Override
public Id createVersion(SessionContext context, Id itemId, Id baseVersionId,
ItemVersionData itemVersionData) {
Response<Id> response = versionAdaptorFactory.createInterface(context).create(context, itemId,
@@ -110,10 +141,9 @@
if (response.isSuccessful()) {
return response.getValue();
} else {
- throw new RuntimeException("failed to create Item Version. ItemId:" + itemId + " based " +
- "on:" + baseVersionId +
- " message:" + response
- .getReturnCode().toString());
+ throw new RuntimeException(String.format(
+ "failed to create Item Version. ItemId: %s, base versionId: %s, message: %s",
+ itemId.getValue(), baseVersionId.getValue(), response.getReturnCode().toString()));
}
}
@@ -124,77 +154,233 @@
.update(context, itemId, versionId, itemVersionData);
if (!response.isSuccessful()) {
throw new RuntimeException(
- String.format("failed to create Item Version. ItemId: %s, versionId: %s, message: %s",
+ String.format("failed to update Item Version. ItemId: %s, versionId: %s, message: %s",
itemId.getValue(), versionId.getValue(), response.getReturnCode().toString()));
}
}
@Override
+ public ItemVersion getVersion(SessionContext context, Id itemId, Id versionId) {
+ Response<ItemVersion> response = versionAdaptorFactory.createInterface(context)
+ .get(context, Space.PRIVATE, itemId, versionId);
+ if (!response.isSuccessful()) {
+ throw new RuntimeException(
+ String.format("failed to get Item Version. ItemId: %s, versionId: %s, message: %s",
+ itemId.getValue(), versionId.getValue(), response.getReturnCode().toString()));
+ }
+ return response.getValue();
+ }
+
+ @Override
+ public ItemVersionStatus getVersionStatus(SessionContext context, Id itemId, Id versionId) {
+ Response<ItemVersionStatus> response =
+ versionAdaptorFactory.createInterface(context).getStatus(context, itemId, versionId);
+ if (!response.isSuccessful()) {
+ throw new RuntimeException(
+ String.format("failed to get Item Version status. ItemId: %s, versionId: %s, message: %s",
+ itemId.getValue(), versionId.getValue(), response.getReturnCode().toString()));
+ }
+ return response.getValue();
+ }
+
+ @Override
public void tagVersion(SessionContext context, Id itemId, Id versionId, Tag tag) {
Response<Void> response = versionAdaptorFactory.createInterface(context)
.tag(context, itemId, versionId, null, tag);
if (!response.isSuccessful()) {
throw new RuntimeException(String.format(
"failed to tag Item Version with tag %s. ItemId: %s, versionId: %s, message: %s",
- tag.getName(), itemId.getValue(), versionId.getValue(), response.getReturnCode()
- .getMessage()));
+ tag.getName(), itemId.getValue(), versionId.getValue(),
+ response.getReturnCode().toString()));
}
}
@Override
- public void resetVersionHistory(SessionContext context, Id itemId, Id versionId,
- String changeRef) {
+ public void resetVersionRevision(SessionContext context, Id itemId, Id versionId,
+ Id revisionId) {
Response<Void> response = versionAdaptorFactory.createInterface(context)
- .resetHistory(context, itemId, versionId, changeRef);
+ .resetRevision(context, itemId, versionId, revisionId);
if (!response.isSuccessful()) {
throw new RuntimeException(String.format(
- "failed to reset Item Version back to %s. ItemId: %s, versionId: %s, message: %s",
- changeRef, itemId.getValue(), versionId.getValue(),
+ "failed to reset Item Version back to revision: %s. ItemId: %s, versionId: %s, message:" +
+ " %s",
+ revisionId.getValue(), itemId.getValue(), versionId.getValue(),
response.getReturnCode().toString()));
}
}
@Override
+ public void revertVersionRevision(SessionContext context, Id itemId, Id versionId,
+ Id revisionId) {
+ Response<Void> response = versionAdaptorFactory.createInterface(context)
+ .revertRevision(context, itemId, versionId, revisionId);
+ if (!response.isSuccessful()) {
+ throw new RuntimeException(String.format(
+ "failed to revert Item Version back to revision: %s. ItemId: %s, versionId: %s, " +
+ "message: %s",
+ revisionId.getValue(), itemId.getValue(), versionId.getValue(),
+ response.getReturnCode().toString()));
+ }
+ }
+
+ @Override
+ public ItemVersionRevisions listVersionRevisions(SessionContext context, Id itemId,
+ Id versionId) {
+ Response<ItemVersionRevisions> response =
+ versionAdaptorFactory.createInterface(context)
+ .listRevisions(context, itemId, versionId);
+ if (!response.isSuccessful()) {
+ throw new RuntimeException(String.format(
+ "failed to list revisions of Item Version. ItemId: %s, versionId: %s, message: %s",
+ itemId.getValue(), versionId.getValue(), response.getReturnCode().toString()));
+ }
+ return response.getValue();
+ }
+
+
+ @Override
+ public void publishVersion(SessionContext context, Id itemId, Id versionId, String message) {
+ Response<Void> response =
+ versionAdaptorFactory.createInterface(context).publish(context, itemId, versionId, message);
+ if (!response.isSuccessful()) {
+ throw new RuntimeException(String.format(
+ "failed to publish item Version. ItemId: %s, versionId: %s, message: %s",
+ itemId.getValue(), versionId.getValue(), response.getReturnCode().toString()));
+ }
+ }
+
+ @Override
+ public void syncVersion(SessionContext context, Id itemId, Id versionId) {
+ Response<MergeResult> response =
+ versionAdaptorFactory.createInterface(context).sync(context, itemId, versionId);
+ if (!response.isSuccessful()) {
+ throw new RuntimeException(String.format(
+ "failed to sync item Version. ItemId: %s, versionId: %s, message: %s",
+ itemId.getValue(), versionId.getValue(), response.getReturnCode().toString()));
+ }
+ }
+
+ @Override
+ public void forceSyncVersion(SessionContext context, Id itemId, Id versionId) {
+ Response<MergeResult> response =
+ versionAdaptorFactory.createInterface(context).forceSync(context, itemId, versionId);
+ if (!response.isSuccessful()) {
+ throw new RuntimeException(String.format(
+ "failed to force sync item Version. ItemId: %s, versionId: %s, message: %s",
+ itemId.getValue(), versionId.getValue(), response.getReturnCode().toString()));
+ }
+ }
+
+ @Override
+ public ItemVersionConflict getVersionConflict(SessionContext context, Id itemId, Id versionId) {
+ Response<ItemVersionConflict> response =
+ versionAdaptorFactory.createInterface(context).getConflict(context, itemId, versionId);
+ if (!response.isSuccessful()) {
+ throw new RuntimeException(String
+ .format("failed to get Item Version conflict. ItemId: %s, versionId: %s, message: %s",
+ itemId.getValue(), versionId.getValue(), response.getReturnCode().toString()));
+ }
+ return response.getValue();
+ }
+
+ @Override
public Collection<ElementInfo> listElements(SessionContext context,
ElementContext elementContext,
Id parentElementId) {
- Response<Collection<ElementInfo>> elementInfosResponse = elementAdaptorFactory
+ Response<Collection<ElementInfo>> response = elementAdaptorFactory
.createInterface(context).list(context, elementContext, parentElementId);
- if (elementInfosResponse.isSuccessful()) {
- return elementInfosResponse.getValue();
+ if (response.isSuccessful()) {
+ return response.getValue();
} else {
logErrorMessageToMdc(ItemElementLoggerTargetServiceName.ELEMENT_GET_BY_PROPERTY,
- elementInfosResponse.getReturnCode());
- throw new RuntimeException(elementInfosResponse.getReturnCode().toString());
+ response.getReturnCode());
+ throw new RuntimeException(response.getReturnCode().toString());
}
}
- @Override
- public Response<ElementInfo> getElementInfo(SessionContext context, ElementContext elementContext,
- Id elementId) {
- return elementAdaptorFactory.createInterface(context)
- .getInfo(context, elementContext, elementId);
- }
-
@Override
- public Response<Element> getElement(SessionContext context, ElementContext elementContext,
- Id elementId) {
- return elementAdaptorFactory.createInterface(context).get(context, elementContext, elementId);
+ public ElementInfo getElementInfo(SessionContext context, ElementContext elementContext,
+ Id elementId) {
+ Response<ElementInfo> response =
+ elementAdaptorFactory.createInterface(context).getInfo(context, elementContext, elementId);
+ if (!response.isSuccessful()) {
+ throw buildGetElementException(elementContext, elementId,
+ response.getReturnCode().toString());
+
+ }
+ return response.getValue();
}
@Override
- public Optional<Element> saveElement(SessionContext context, ElementContext elementContext,
- ZusammenElement element, String message) {
+ public Element getElement(SessionContext context, ElementContext elementContext,
+ Id elementId) {
+ Response<Element> response =
+ elementAdaptorFactory.createInterface(context).get(context, elementContext, elementId);
+ if (!response.isSuccessful()) {
+ throw buildGetElementException(elementContext, elementId,
+ response.getReturnCode().toString());
+ }
+ return response.getValue();
+ }
+
+ @Override
+ public ElementConflict getElementConflict(SessionContext context, ElementContext elementContext,
+ Id elementId) {
+ Response<ElementConflict> response = elementAdaptorFactory.createInterface(context)
+ .getConflict(context, elementContext, elementId);
+ if (!response.isSuccessful()) {
+ throw new RuntimeException(String.format(
+ "Failed to get element conflict. Item Id: %s, version Id: %s, element Id: %s message: %s",
+ elementContext.getItemId().getValue(), elementContext.getVersionId().getValue(),
+ elementId.getValue(), response.getReturnCode().toString()));
+ }
+ return response.getValue();
+ }
+
+ @Override
+ public Element saveElement(SessionContext context, ElementContext elementContext,
+ ZusammenElement element, String message) {
Response<Element> response = elementAdaptorFactory.createInterface(context)
.save(context, elementContext, element, message);
if (!response.isSuccessful()) {
throw new RuntimeException(String
- .format("Failed to save element %s. ItemId: %s, versionId: %s, message: %s",
+ .format("Failed to create element %s. ItemId: %s, versionId: %s, message: %s",
element.getElementId().getValue(), elementContext.getItemId().getValue(),
elementContext.getVersionId().getValue(), response.getReturnCode().toString()));
}
- return Optional.of(response.getValue());
+ return response.getValue();
+ }
+
+ @Override
+ public void resolveElementConflict(SessionContext context, ElementContext elementContext,
+ ZusammenElement element,
+ Resolution resolution) {
+ Response<Void> response = elementAdaptorFactory.createInterface(context)
+ .resolveConflict(context, elementContext, element, resolution);
+ if (!response.isSuccessful()) {
+ throw new RuntimeException(
+ "Failed to resolve conflict. message:" + response.getReturnCode().toString());
+ }
+ }
+
+ @Override
+ public void resetVersionHistory(SessionContext context, Id itemId, Id versionId,
+ String revision_id) {
+
+ }
+
+ private RuntimeException buildGetElementException(ElementContext elementContext, Id elementId,
+ String zusammenErrorMessage) {
+ if (elementContext.getRevisionId() == null) {
+ return new RuntimeException(String.format(GET_ELEMENT_ERR_MSG,
+ elementContext.getItemId().getValue(), elementContext.getVersionId().getValue(),
+ elementId.getValue(), zusammenErrorMessage));
+ }
+ return new RuntimeException(String.format(GET_ELEMENT_IN_REV_ERR_MSG,
+ elementContext.getItemId().getValue(), elementContext.getVersionId().getValue(),
+ elementContext.getRevisionId().getValue(),
+ elementId.getValue(), zusammenErrorMessage));
}
private void logErrorMessageToMdc(ItemElementLoggerTargetServiceName
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/impl/ZusammenAdaptorImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/impl/ZusammenAdaptorImpl.java
index 41ce028..9bdbfd6 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/impl/ZusammenAdaptorImpl.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/impl/ZusammenAdaptorImpl.java
@@ -1,24 +1,30 @@
package org.openecomp.core.zusammen.impl;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementConflict;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ItemVersionConflict;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
import com.amdocs.zusammen.commons.health.data.HealthInfo;
import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.SessionContext;
-import com.amdocs.zusammen.datatypes.item.*;
+import com.amdocs.zusammen.datatypes.item.Action;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import com.amdocs.zusammen.datatypes.item.Info;
+import com.amdocs.zusammen.datatypes.item.Item;
+import com.amdocs.zusammen.datatypes.item.ItemVersion;
+import com.amdocs.zusammen.datatypes.item.ItemVersionData;
+import com.amdocs.zusammen.datatypes.item.ItemVersionStatus;
+import com.amdocs.zusammen.datatypes.item.Resolution;
+import com.amdocs.zusammen.datatypes.itemversion.ItemVersionRevisions;
import com.amdocs.zusammen.datatypes.itemversion.Tag;
-import com.amdocs.zusammen.datatypes.response.Response;
-import com.amdocs.zusammen.datatypes.response.ReturnCode;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
import org.openecomp.core.zusammen.db.ZusammenConnector;
-import org.openecomp.sdc.datatypes.error.ErrorLevel;
-import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
-import org.openecomp.sdc.logging.types.LoggerConstants;
-import org.openecomp.sdc.logging.types.LoggerErrorCode;
+import org.openecomp.sdc.versioning.dao.types.Revision;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.function.Predicate;
@@ -33,30 +39,15 @@
}
@Override
- public Optional<ItemVersion> getFirstVersion(SessionContext context, Id itemId) {
- Collection<ItemVersion> versions = connector.listVersions(context, itemId);
- if(versions == null || versions.size()==0) {
- return Optional.empty();
- }
- List<ItemVersion> itemVersions = new ArrayList<>(versions);
- sortItemVersionListByModificationTimeDescOrder(itemVersions);
- ItemVersion itemVersion = itemVersions.iterator().next();
-
- return Optional.ofNullable(itemVersion);
- }
-
- @Override
public Optional<ElementInfo> getElementInfo(SessionContext context, ElementContext elementContext,
Id elementId) {
- Response<ElementInfo> response = connector.getElementInfo(context, elementContext, elementId);
- return response.isSuccessful() ? Optional.ofNullable(response.getValue()) : Optional.empty();
+ return Optional.ofNullable(connector.getElementInfo(context, elementContext, elementId));
}
@Override
public Optional<Element> getElement(SessionContext context, ElementContext elementContext,
String elementId) {
- Response<Element> response = connector.getElement(context, elementContext, new Id(elementId));
- return response.isSuccessful() ? Optional.ofNullable(response.getValue()) : Optional.empty();
+ return Optional.ofNullable(connector.getElement(context, elementContext, new Id(elementId)));
}
@Override
@@ -82,16 +73,14 @@
public Collection<Element> listElementData(SessionContext context,
ElementContext elementContext,
Id parentElementId) {
-
Collection<ElementInfo> elementInfoList = connector.listElements(context, elementContext,
parentElementId);
- if (elementInfoList != null) {
- return elementInfoList.stream().map(elementInfo -> connector.getElement(context,
- elementContext, elementInfo.getId()).getValue()).collect(Collectors.toList());
- }
- return new ArrayList<>();
-
+ return elementInfoList == null
+ ? new ArrayList<>()
+ : elementInfoList.stream()
+ .map(elementInfo -> connector.getElement(context, elementContext, elementInfo.getId()))
+ .collect(Collectors.toList());
}
@@ -119,12 +108,24 @@
}
@Override
- public Optional<Element> saveElement(SessionContext context, ElementContext elementContext,
- ZusammenElement element, String message) {
+ public Optional<ElementConflict> getElementConflict(SessionContext context, ElementContext elementContext,
+ Id elementId) {
+ return Optional.ofNullable(connector.getElementConflict(context, elementContext, elementId));
+ }
+
+ @Override
+ public Element saveElement(SessionContext context, ElementContext elementContext,
+ ZusammenElement element, String message) {
enrichElementHierarchyRec(context, elementContext, null, element);
return connector.saveElement(context, elementContext, element, message);
}
+ @Override
+ public void resolveElementConflict(SessionContext context, ElementContext elementContext,
+ ZusammenElement element, Resolution resolution) {
+ connector.resolveElementConflict(context, elementContext, element, resolution);
+ }
+
private void enrichElementHierarchyRec(SessionContext context, ElementContext
elementContext, Id parentElementId, ZusammenElement element) {
if (element.getAction() == Action.CREATE) {
@@ -160,20 +161,14 @@
.findFirst();
}
- private void logErrorMessageToMdc(ItemElementLoggerTargetServiceName
- itemElementLoggerTargetServiceName,
- ReturnCode returnCode) {
- logErrorMessageToMdc(itemElementLoggerTargetServiceName, returnCode.toString());
+ @Override
+ public Collection<Item> listItems(SessionContext context) {
+ return connector.listItems(context);
}
- private void logErrorMessageToMdc(ItemElementLoggerTargetServiceName
- itemElementLoggerTargetServiceName,
- String message) {
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- itemElementLoggerTargetServiceName.getDescription(),
- ErrorLevel.ERROR.name(),
- LoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode(),
- message);
+ @Override
+ public Item getItem(SessionContext context, Id itemId) {
+ return connector.getItem(context, itemId);
}
@Override
@@ -182,15 +177,52 @@
}
@Override
- public Id createVersion(SessionContext context, Id itemId, Id baseVersionId, ItemVersionData
- itemVersionData) {
- return connector.createVersion(context, itemId, baseVersionId, itemVersionData);
-
+ public void updateItem(SessionContext context, Id itemId, Info info) {
+ connector.updateItem(context, itemId, info);
}
@Override
- public Collection<Item> listItems(SessionContext context) {
- return connector.listItems(context);
+ public Optional<ItemVersion> getFirstVersion(SessionContext context, Id itemId) {
+ Collection<ItemVersion> versions = connector.listPublicVersions(context, itemId);
+ if (versions == null || versions.size() == 0) {
+ return Optional.empty();
+ }
+ List<ItemVersion> itemVersions = new ArrayList<>(versions);
+ sortItemVersionListByModificationTimeDescOrder(itemVersions);
+ ItemVersion itemVersion = itemVersions.iterator().next();
+
+ return Optional.ofNullable(itemVersion);
+ }
+
+ @Override
+ public Collection<ItemVersion> listPublicVersions(SessionContext context, Id itemId) {
+ return connector.listPublicVersions(context, itemId);
+ }
+
+ @Override
+ public ItemVersion getPublicVersion(SessionContext context, Id itemId, Id versionId) {
+ return connector.getPublicVersion(context, itemId, versionId);
+ }
+
+ @Override
+ public ItemVersion getVersion(SessionContext context, Id itemId, Id versionId) {
+ return connector.getVersion(context, itemId, versionId);
+ }
+
+ @Override
+ public ItemVersionStatus getVersionStatus(SessionContext context, Id itemId, Id versionId) {
+ return connector.getVersionStatus(context, itemId, versionId);
+ }
+
+ @Override
+ public ItemVersionConflict getVersionConflict(SessionContext context, Id itemId, Id versionId) {
+ return connector.getVersionConflict(context, itemId, versionId);
+ }
+
+ @Override
+ public Id createVersion(SessionContext context, Id itemId, Id baseVersionId, ItemVersionData
+ itemVersionData) {
+ return connector.createVersion(context, itemId, baseVersionId, itemVersionData);
}
@Override
@@ -210,25 +242,96 @@
connector.resetVersionHistory(context, itemId, versionId, changeRef);
}
+ /*@Override
+ public void revertVersionToRevision(SessionContext context, Id itemId, Id versionId,
+ Id revisionId) {
+ connector.resetVersionRevision(context, itemId, versionId, revisionId);
+ }*/
+
+ /*@Override
+ public ItemVersionRevisions listVersionRevisions(SessionContext context, Id itemId, Id
+ versionId) {
+ return connector.listVersionRevisions(context, itemId, versionId);
+ }*/
+
@Override
- public void updateItem(SessionContext context, Id itemId, Info info) {
- connector.updateItem(context, itemId, info);
+ public void publishVersion(SessionContext context, Id itemId, Id versionId, String message) {
+ connector.publishVersion(context, itemId, versionId, message);
}
+ @Override
+ public void syncVersion(SessionContext context, Id itemId, Id versionId) {
+ connector.syncVersion(context, itemId, versionId);
+ }
+
+ @Override
+ public void forceSyncVersion(SessionContext context, Id itemId, Id versionId) {
+ connector.forceSyncVersion(context, itemId, versionId);
+ }
@Override
public Collection<HealthInfo> checkHealth(SessionContext context) {
return connector.checkHealth(context);
}
- private static void sortItemVersionListByModificationTimeDescOrder(
- List<ItemVersion> itemVersions) {
- itemVersions.sort((o1, o2) -> ((Integer)o2.getId().getValue().length())
- .compareTo( (o1.getId().getValue().length())));
- }
-
@Override
public String getVersion(SessionContext sessionContext) {
return connector.getVersion(sessionContext);
}
+
+ @Override
+ public void revert(SessionContext sessionContext, String itemId, String versionId,
+ String revisionId) {
+ connector.revertVersionRevision(sessionContext, new Id(itemId), new Id(versionId),
+ new Id(revisionId));
+ }
+
+ @Override
+ public List<Revision> listRevisions(SessionContext sessionContext, String itemId,
+ String versionId) {
+ List<Revision> revisions = new ArrayList<>();
+ ItemVersionRevisions itemVersionRevisions =
+ connector.listVersionRevisions(sessionContext, new Id(itemId), new Id
+ (versionId));
+ if(itemVersionRevisions == null || itemVersionRevisions.getItemVersionRevisions()==null ||
+ itemVersionRevisions.getItemVersionRevisions().size()==0) {
+ return revisions;
+ }
+ else{
+ revisions = itemVersionRevisions.getItemVersionRevisions().stream().map
+ (revision -> {
+ Revision rev = new Revision();
+ rev.setId(revision.getRevisionId().getValue());
+ rev.setTime(revision.getTime());
+ rev.setUser(revision.getUser());
+ rev.setMessage(revision.getMessage());
+ return rev;
+ }).collect(Collectors.toList());
+ revisions.sort(new Comparator<Revision>() {
+ @Override
+ public int compare(Revision o1, Revision o2) {
+ if(o1.getTime().before(o2.getTime())) return 1;
+ else return -1;
+ }
+ });
+ // when creating a new item an initial version is created with
+ // invalid data. this revision is not an applicable revision.
+ //the logic of identifying this revision is:
+ //1- only the first version of item has this issue
+ //2- only in the first item version there are 2 revisions created
+ //3- the second revision is in format "Initial {vlm/vsp}: {name of the vlm/vsp}
+ //4- only if a revision in this format exists we remove the first revision.
+ if(revisions.size()>1 && revisions.get(revisions.size()-2).getMessage().matches("Initial " +
+ ".*:.*")){
+ revisions.remove(revisions.size()-1);
+ }
+ return revisions;
+ }
+ }
+
+ private static void sortItemVersionListByModificationTimeDescOrder(
+ List<ItemVersion> itemVersions) {
+ itemVersions.sort((o1, o2) -> ((Integer) o2.getId().getValue().length())
+ .compareTo((o1.getId().getValue().length())));
+ }
}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/pom.xml b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/pom.xml
index fba7d56..f8cfcfd 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/pom.xml
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/pom.xml
@@ -33,5 +33,32 @@
<artifactId>zusammen-state-store-cassandra-plugin</artifactId>
<version>${zusammen-state-store.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>${testng.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>${mockito.all.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.amdocs.zusammen</groupId>
+ <artifactId>zusammen-commons-utils</artifactId>
+ <version>${zusammen.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-facade-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-session-lib</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
</project>
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/ZusammenPluginUtil.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/ZusammenPluginUtil.java
index 59afa70..a973590 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/ZusammenPluginUtil.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/ZusammenPluginUtil.java
@@ -19,13 +19,30 @@
import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.SessionContext;
import com.amdocs.zusammen.datatypes.Space;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
+import com.amdocs.zusammen.datatypes.item.Action;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import com.amdocs.zusammen.datatypes.item.ItemVersion;
+import com.amdocs.zusammen.datatypes.item.ItemVersionChange;
+import com.amdocs.zusammen.datatypes.item.ItemVersionData;
+import com.amdocs.zusammen.datatypes.item.ItemVersionDataConflict;
import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElement;
+import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElementChange;
+import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElementConflict;
+import com.amdocs.zusammen.sdk.state.types.StateElement;
+import com.amdocs.zusammen.sdk.types.ElementDescriptor;
import com.amdocs.zusammen.utils.fileutils.FileUtils;
+import com.amdocs.zusammen.utils.fileutils.json.JsonUtil;
import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
+import org.openecomp.core.zusammen.plugin.dao.types.VersionEntity;
import java.io.ByteArrayInputStream;
import java.nio.ByteBuffer;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Base64;
+import java.util.Date;
+
+import static org.openecomp.core.zusammen.plugin.ZusammenPluginConstants.ROOT_ELEMENTS_PARENT_ID;
public class ZusammenPluginUtil {
@@ -34,7 +51,7 @@
case PUBLIC:
return ZusammenPluginConstants.PUBLIC_SPACE;
case PRIVATE:
- return ZusammenPluginUtil.getPrivateSpaceName(context);
+ return getPrivateSpaceName(context);
default:
throw new IllegalArgumentException(String.format("Space %s is not supported.", space));
}
@@ -44,14 +61,54 @@
return context.getUser().getUserName();
}
- public static ElementEntity getElementEntity(CollaborationElement element) {
+ public static ElementContext getPrivateElementContext(ElementContext elementContext) {
+ return new ElementContext(elementContext.getItemId(),elementContext.getVersionId(),Id.ZERO);
+ }
+
+
+ public static VersionEntity convertToVersionEntity(Id versionId, Id baseVersionId,
+ Date creationTime,
+ Date modificationTime) {
+
+ return convertToVersionEntity(versionId, null, baseVersionId,
+ creationTime, modificationTime);
+ }
+
+ public static VersionEntity convertToVersionEntity(Id versionId, Id revisionId, Id baseVersionId,
+ Date creationTime,
+ Date modificationTime) {
+ VersionEntity version = new VersionEntity(versionId);
+ version.setBaseId(baseVersionId);
+ version.setCreationTime(creationTime);
+ version.setModificationTime(modificationTime);
+ return version;
+ }
+
+ public static ItemVersion convertToItemVersion(VersionEntity versionEntity,
+ ItemVersionData itemVersionData) {
+ ItemVersion itemVersion = new ItemVersion();
+ itemVersion.setId(versionEntity.getId());
+
+ itemVersion.setBaseId(versionEntity.getBaseId());
+ itemVersion.setCreationTime(versionEntity.getCreationTime());
+ itemVersion.setModificationTime(versionEntity.getModificationTime());
+ itemVersion.setData(itemVersionData);
+ return itemVersion;
+ }
+
+ public static ElementEntity convertToElementEntity(CollaborationElement element) {
+
ElementEntity elementEntity = new ElementEntity(element.getId());
elementEntity.setNamespace(element.getNamespace());
elementEntity.setParentId(element.getParentId() == null
- ? ZusammenPluginConstants.ROOT_ELEMENTS_PARENT_ID
+ ? ROOT_ELEMENTS_PARENT_ID
: element.getParentId());
+
+
elementEntity.setInfo(element.getInfo());
+
elementEntity.setRelations(element.getRelations());
+
if (element.getData() != null) {
elementEntity.setData(ByteBuffer.wrap(FileUtils.toByteArray(element.getData())));
}
@@ -63,21 +120,29 @@
elementEntity.setVisualization(
ByteBuffer.wrap(FileUtils.toByteArray(element.getVisualization())));
}
+ elementEntity.setElementHash(new Id(calculateElementHash(elementEntity)));
+
return elementEntity;
}
- public static CollaborationElement getCollaborationElement(
- ElementEntityContext elementEntityContext, ElementEntity elementEntity) {
- Id parentId =
- ZusammenPluginConstants.ROOT_ELEMENTS_PARENT_ID.equals(elementEntity.getParentId())
- ? null
- : elementEntity.getParentId();
- CollaborationElement element = new CollaborationElement(elementEntityContext.getItemId(),
- elementEntityContext.getVersionId(), elementEntity.getNamespace(), elementEntity.getId());
+ public static ElementDescriptor convertToElementDescriptor(
+ ElementContext elementContext, ElementEntity elementEntity) {
+ if (elementEntity == null) {
+ return null;
+ }
+ ElementDescriptor element = new ElementDescriptor(elementContext.getItemId(),
+ elementContext.getVersionId(), elementEntity.getNamespace(), elementEntity.getId());
- element.setParentId(parentId);
- element.setInfo(elementEntity.getInfo());
- element.setRelations(elementEntity.getRelations());
+ mapElementEntityToDescriptor(elementEntity, element);
+ return element;
+ }
+
+ public static CollaborationElement convertToCollaborationElement(
+ ElementContext elementContext, ElementEntity elementEntity) {
+ CollaborationElement element = new CollaborationElement(elementContext.getItemId(),
+ elementContext.getVersionId(), elementEntity.getNamespace(), elementEntity.getId());
+
+ mapElementEntityToDescriptor(elementEntity, element);
if (elementEntity.getData() != null) {
element.setData(new ByteArrayInputStream(elementEntity.getData().array()));
@@ -89,7 +154,134 @@
if (elementEntity.getVisualization() != null) {
element.setVisualization(new ByteArrayInputStream(elementEntity.getVisualization().array()));
}
+ return element;
+ }
+
+ public static CollaborationElementChange convertToElementChange(
+ ElementContext changedElementContext, ElementEntity changedElement, Action action) {
+ CollaborationElementChange elementChange = new CollaborationElementChange();
+ elementChange.setElement(convertToCollaborationElement(changedElementContext, changedElement));
+ elementChange.setAction(action);
+ return elementChange;
+ }
+
+ public static ItemVersionChange convertToVersionChange(ElementContext elementContext,
+ ElementEntity versionDataElement,
+ Action action) {
+ ItemVersionChange versionChange = new ItemVersionChange();
+
+ ItemVersion itemVersion = new ItemVersion();
+ itemVersion.setId(elementContext.getVersionId());
+
+ itemVersion.setData(convertToVersionData(versionDataElement));
+
+ versionChange.setItemVersion(itemVersion);
+ versionChange.setAction(action);
+ return versionChange;
+ }
+
+ public static ItemVersionDataConflict getVersionConflict(ElementEntity localVesionData,
+ ElementEntity remoteVersionData) {
+ ItemVersionDataConflict versionConflict = new ItemVersionDataConflict();
+ versionConflict.setLocalData(convertToVersionData(localVesionData));
+ versionConflict.setRemoteData(convertToVersionData(remoteVersionData));
+ return versionConflict;
+ }
+
+ public static CollaborationElementConflict getElementConflict(ElementContext elementContext,
+ ElementEntity localElement,
+ ElementEntity remoteElement) {
+ CollaborationElementConflict elementConflict = new CollaborationElementConflict();
+ elementConflict
+ .setLocalElement(convertToCollaborationElement(elementContext, localElement));
+ elementConflict.setRemoteElement(
+ convertToCollaborationElement(elementContext, remoteElement));
+ return elementConflict;
+ }
+
+ public static ItemVersionData convertToVersionData(ElementEntity versionDataElement) {
+ ItemVersionData versionData = new ItemVersionData();
+ versionData.setInfo(versionDataElement.getInfo());
+ versionData.setRelations(versionDataElement.getRelations());
+ return versionData;
+ }
+
+ private static void mapElementEntityToDescriptor(ElementEntity elementEntity,
+ ElementDescriptor elementDescriptor) {
+ Id parentId = ROOT_ELEMENTS_PARENT_ID.equals(elementEntity.getParentId())
+ ? null
+ : elementEntity.getParentId();
+
+ elementDescriptor.setParentId(parentId);
+ elementDescriptor.setInfo(elementEntity.getInfo());
+ elementDescriptor.setRelations(elementEntity.getRelations());
+ elementDescriptor.setSubElements(elementEntity.getSubElementIds());
+ }
+
+ public static String calculateElementHash(ElementEntity elementEntity) {
+ StringBuffer elementHash = new StringBuffer();
+ if (elementEntity.getData() != null) {
+ elementHash.append(calculateSHA1(elementEntity.getData().array()));
+ } else {
+ elementHash.append("0");
+ }
+ elementHash.append("_");
+ if (elementEntity.getVisualization() != null) {
+ elementHash.append(calculateSHA1(elementEntity.getVisualization().array()));
+ } else {
+ elementHash.append("0");
+ }
+ elementHash.append("_");
+
+ if (elementEntity.getSearchableData() != null) {
+ elementHash.append(calculateSHA1(elementEntity.getSearchableData().array()));
+ } else {
+ elementHash.append("0");
+ }
+ elementHash.append("_");
+
+ if (elementEntity.getInfo() != null) {
+ elementHash.append(calculateSHA1(JsonUtil.object2Json(elementEntity.getInfo()).getBytes()));
+ } else {
+ elementHash.append("0");
+ }
+ elementHash.append("_");
+
+ if (elementEntity.getRelations() != null) {
+ elementHash
+ .append(calculateSHA1(JsonUtil.object2Json(elementEntity.getRelations()).getBytes()));
+ } else {
+ elementHash.append("0");
+ }
+
+ return elementHash.toString();
+ }
+
+ private static String calculateSHA1(byte[] content2Convert) {
+ MessageDigest md = null;
+ try {
+ md = MessageDigest.getInstance("SHA-1");
+ } catch (NoSuchAlgorithmException e) {
+ throw new RuntimeException(e);
+ }
+ return Base64.getEncoder().encodeToString(md.digest(content2Convert));
+ }
+
+
+ public static StateElement getStateElement(ElementContext elementContext, ElementEntity
+ elementEntity) {
+ Id parentId = ROOT_ELEMENTS_PARENT_ID.equals(elementEntity.getParentId())
+ ? null
+ : elementEntity.getParentId();
+ StateElement element = new StateElement(elementContext.getItemId(),
+ elementContext.getVersionId(), elementEntity.getNamespace(), elementEntity.getId());
+
+ element.setParentId(parentId);
+ element.setInfo(elementEntity.getInfo());
+ element.setRelations(elementEntity.getRelations());
element.setSubElements(elementEntity.getSubElementIds());
return element;
}
+
+
}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/CommitStagingService.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/CommitStagingService.java
new file mode 100644
index 0000000..45d5769
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/CommitStagingService.java
@@ -0,0 +1,100 @@
+package org.openecomp.core.zusammen.plugin.collaboration;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
+import org.openecomp.core.zusammen.plugin.dao.types.StageEntity;
+import org.openecomp.core.zusammen.plugin.dao.types.VersionEntity;
+
+import java.util.Collection;
+import java.util.Optional;
+
+public class CommitStagingService {
+
+ private VersionPrivateStore versionPrivateStore;
+ private VersionStageStore versionStageStore;
+ private ElementPrivateStore elementPrivateStore;
+ private ElementStageStore elementStageStore;
+
+ public CommitStagingService(VersionPrivateStore versionPrivateStore,
+ VersionStageStore versionStageStore,
+ ElementPrivateStore elementPrivateStore,
+ ElementStageStore elementStageStore) {
+ this.versionPrivateStore = versionPrivateStore;
+ this.versionStageStore = versionStageStore;
+ this.elementPrivateStore = elementPrivateStore;
+ this.elementStageStore = elementStageStore;
+ }
+
+ public void commitStaging(SessionContext context, Id itemId, Id versionId) {
+ Optional<StageEntity<VersionEntity>> versionStage =
+ versionStageStore.get(context, itemId, new VersionEntity(versionId));
+
+ final ElementContext elementContext = new ElementContext(itemId, versionId, Id.ZERO);
+ Collection<ElementEntity> stagedElementIds = elementStageStore.listIds(context, elementContext);
+
+ if ((!versionStage.isPresent() && stagedElementIds.isEmpty()) ||
+ elementStageStore.hasConflicts(context, elementContext)) {
+ return;
+ }
+
+ versionStage.ifPresent(verStage -> commitVersionStage(context, itemId, verStage));
+ commitElementsStage(context, elementContext, stagedElementIds);
+ }
+
+ private void commitVersionStage(SessionContext context, Id itemId,
+ StageEntity<VersionEntity> versionStage) {
+ switch (versionStage.getAction()) {
+ case CREATE:
+ versionPrivateStore.commitStagedCreate(context, itemId, versionStage.getEntity(),
+ versionStage.getPublishTime());
+ break;
+ case UPDATE:
+ versionPrivateStore.commitStagedUpdate(context, itemId, versionStage.getEntity(),
+ versionStage.getPublishTime());
+ break;
+ case IGNORE:
+ versionPrivateStore.commitStagedIgnore(context, itemId, versionStage.getEntity(),
+ versionStage.getPublishTime());
+ break;
+ default:
+ throw new UnsupportedOperationException(
+ "Version change other then Create/Update/Ignore is not supported");
+ }
+
+ versionStageStore.delete(context, itemId, versionStage.getEntity());
+ }
+
+ private void commitElementsStage(SessionContext context, ElementContext elementContext,
+ Collection<ElementEntity> stagedElementIds) {
+ for (ElementEntity stagedElementId : stagedElementIds) {
+ StageEntity<ElementEntity> stagedElement =
+ elementStageStore.get(context, elementContext, stagedElementId)
+ .orElseThrow(
+ () -> new IllegalStateException("Element id returned by list must exist"));
+ switch (stagedElement.getAction()) {
+ case CREATE:
+ elementPrivateStore.commitStagedCreate(context, elementContext, stagedElement.getEntity(),
+ stagedElement.getPublishTime());
+ break;
+ case UPDATE:
+ elementPrivateStore.commitStagedUpdate(context, elementContext, stagedElement.getEntity(),
+ stagedElement.getPublishTime());
+ break;
+ case DELETE:
+ elementPrivateStore
+ .commitStagedDelete(context, elementContext, stagedElement.getEntity());
+ break;
+ case IGNORE:
+ elementPrivateStore.commitStagedIgnore(context, elementContext, stagedElement.getEntity(),
+ stagedElement.getPublishTime());
+ break;
+ default:
+ throw new UnsupportedOperationException(
+ "Element change other then Create/Update/Delete/Ignore is not supported");
+ }
+ elementStageStore.delete(context, elementContext, stagedElement.getEntity());
+ }
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/ElementCollaborationStore.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/ElementCollaborationStore.java
deleted file mode 100644
index ac103c0..0000000
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/ElementCollaborationStore.java
+++ /dev/null
@@ -1,119 +0,0 @@
-package org.openecomp.core.zusammen.plugin.collaboration;
-
-import com.amdocs.zusammen.datatypes.Id;
-import com.amdocs.zusammen.datatypes.SessionContext;
-import com.amdocs.zusammen.datatypes.item.ElementContext;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
-import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElement;
-import org.openecomp.core.zusammen.plugin.ZusammenPluginConstants;
-import org.openecomp.core.zusammen.plugin.ZusammenPluginUtil;
-import org.openecomp.core.zusammen.plugin.dao.ElementRepository;
-import org.openecomp.core.zusammen.plugin.dao.ElementRepositoryFactory;
-import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Optional;
-
-import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.getCollaborationElement;
-import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.getSpaceName;
-
-
-public class ElementCollaborationStore {
-
- private static final String SUB_ELEMENT_NOT_EXIST_ERROR_MSG =
- "List sub elements error: item %s, version %s - " +
- "element %s, which appears as sub element of element %s, does not exist";
-
- public Collection<CollaborationElement> listElements(SessionContext context,
- ElementContext elementContext,
- Id elementId) {
- ElementEntityContext elementEntityContext =
- new ElementEntityContext(ZusammenPluginUtil.getPrivateSpaceName(context), elementContext);
-
- if (elementId == null) {
- elementId = ZusammenPluginConstants.ROOT_ELEMENTS_PARENT_ID;
- }
-
- ElementRepository elementRepository = getElementRepository(context);
- String elementIdValue = elementId.getValue();
- String versionIdValue = elementContext.getChangeRef() == null
- ? elementContext.getVersionId().getValue()
- : elementContext.getChangeRef();
- Collection<CollaborationElement> subElements = new ArrayList<>();
-
- Optional<ElementEntity> element =
- elementRepository.get(context, elementEntityContext, new ElementEntity(elementId));
- if (element.isPresent() && element.get().getSubElementIds() != null) {
- for (Id subElementId : element.get().getSubElementIds()) {
- ElementEntity subElement =
- elementRepository.get(context, elementEntityContext, new ElementEntity(subElementId))
- .orElseThrow(
- () -> new IllegalStateException(String.format(SUB_ELEMENT_NOT_EXIST_ERROR_MSG,
- elementContext.getItemId().getValue(), versionIdValue,
- subElementId.getValue(), elementIdValue)));
- subElements.add(getCollaborationElement(elementEntityContext, subElement));
- }
- }
- return subElements;
- }
-
- public CollaborationElement getElement(SessionContext context, ElementContext elementContext,
- Id elementId) {
- ElementEntityContext elementEntityContext =
- new ElementEntityContext(ZusammenPluginUtil.getPrivateSpaceName(context), elementContext);
- return getElementRepository(context)
- .get(context, elementEntityContext, new ElementEntity(elementId))
- .map(elementEntity -> getCollaborationElement(elementEntityContext, elementEntity))
- .orElse(null);
- }
-
- public void createElement(SessionContext context, CollaborationElement element) {
- getElementRepository(context)
- .create(context,
- new ElementEntityContext(getSpaceName(context, element.getSpace()),
- element.getItemId(), element.getVersionId()),
- ZusammenPluginUtil.getElementEntity(element));
- }
-
- public void updateElement(SessionContext context, CollaborationElement element) {
- getElementRepository(context)
- .update(context,
- new ElementEntityContext(getSpaceName(context, element.getSpace()),
- element.getItemId(), element.getVersionId()),
- ZusammenPluginUtil.getElementEntity(element));
- }
-
- public void deleteElement(SessionContext context, CollaborationElement element) {
- deleteElementHierarchy(getElementRepository(context),
- context,
- new ElementEntityContext(getSpaceName(context, element.getSpace()),
- element.getItemId(), element.getVersionId()),
- ZusammenPluginUtil.getElementEntity(element));
- }
-
- public boolean checkHealth(SessionContext sessionContext) {
- return getElementRepository(sessionContext).checkHealth(sessionContext);
- }
-
- private void deleteElementHierarchy(ElementRepository elementRepository, SessionContext context,
- ElementEntityContext elementEntityContext,
- ElementEntity elementEntity) {
- Optional<ElementEntity> retrieved =
- elementRepository.get(context, elementEntityContext, elementEntity);
- if (!retrieved.isPresent()) {
- return;
- }
- retrieved.get().getSubElementIds().stream()
- .map(ElementEntity::new)
- .forEach(subElementEntity -> deleteElementHierarchy(
- elementRepository, context, elementEntityContext, subElementEntity));
-
- // only for the first one the parentId will populated (so it'll be removed from its parent)
- elementRepository.delete(context, elementEntityContext, elementEntity);
- }
-
- protected ElementRepository getElementRepository(SessionContext context) {
- return ElementRepositoryFactory.getInstance().createInterface(context);
- }
-}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/ElementPrivateStore.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/ElementPrivateStore.java
new file mode 100644
index 0000000..045def2
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/ElementPrivateStore.java
@@ -0,0 +1,48 @@
+package org.openecomp.core.zusammen.plugin.collaboration;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
+import org.openecomp.core.zusammen.plugin.dao.types.SynchronizationStateEntity;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.Map;
+import java.util.Optional;
+
+public interface ElementPrivateStore extends ElementStore {
+
+ Map<Id, Id> listIds(SessionContext context, ElementContext elementContext);
+
+ Collection<ElementEntity> listSubs(SessionContext context, ElementContext elementContext,
+ Id elementId);
+
+ Optional<SynchronizationStateEntity> getSynchronizationState(SessionContext context,
+ ElementContext elementContext,
+ Id elementId);
+
+ void create(SessionContext context, ElementContext elementContext, ElementEntity element);
+
+ boolean update(SessionContext context, ElementContext elementContext, ElementEntity element);
+
+ void delete(SessionContext context, ElementContext elementContext, ElementEntity element);
+
+ void markAsPublished(SessionContext context, ElementContext elementContext, Id elementId,
+ Date publishTime);
+
+ void markDeletionAsPublished(SessionContext context, ElementContext elementContext, Id elementId,
+ Date publishTime);
+
+ void commitStagedCreate(SessionContext context, ElementContext elementContext,
+ ElementEntity element, Date publishTime);
+
+ void commitStagedUpdate(SessionContext context, ElementContext elementContext,
+ ElementEntity element, Date publishTime);
+
+ void commitStagedDelete(SessionContext context, ElementContext elementContext,
+ ElementEntity element);
+
+ void commitStagedIgnore(SessionContext context, ElementContext elementContext,
+ ElementEntity element, Date publishTime);
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/ElementPublicStore.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/ElementPublicStore.java
new file mode 100644
index 0000000..0f1790a
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/ElementPublicStore.java
@@ -0,0 +1,23 @@
+package org.openecomp.core.zusammen.plugin.collaboration;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
+
+import java.util.Date;
+import java.util.Map;
+
+public interface ElementPublicStore extends ElementStore {
+
+ void create(SessionContext context, ElementContext elementContext, ElementEntity element,
+ Date publishTime);
+
+ void update(SessionContext context, ElementContext elementContext, ElementEntity element,
+ Date publishTime);
+
+ void delete(SessionContext context, ElementContext elementContext, ElementEntity element,
+ Date publishTime);
+
+ Map<Id,Id> listIds(SessionContext context, ElementContext elementContext);
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/ElementStageStore.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/ElementStageStore.java
new file mode 100644
index 0000000..a923624
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/ElementStageStore.java
@@ -0,0 +1,35 @@
+package org.openecomp.core.zusammen.plugin.collaboration;
+
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import com.amdocs.zusammen.datatypes.item.Resolution;
+import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
+import org.openecomp.core.zusammen.plugin.dao.types.StageEntity;
+
+import java.util.Collection;
+import java.util.Optional;
+
+public interface ElementStageStore {
+
+ Collection<ElementEntity> listIds(SessionContext context, ElementContext elementContext);
+
+ boolean hasConflicts(SessionContext context, ElementContext elementContext);
+
+ Collection<StageEntity<ElementEntity>> listConflictedDescriptors(SessionContext context,
+ ElementContext elementContext);
+
+ Optional<StageEntity<ElementEntity>> get(SessionContext context, ElementContext elementContext,
+ ElementEntity element);
+
+ Optional<StageEntity<ElementEntity>> getConflicted(SessionContext context,
+ ElementContext elementContext,
+ ElementEntity element);
+
+ void create(SessionContext context, ElementContext elementContext,
+ StageEntity<ElementEntity> elementStage);
+
+ void delete(SessionContext context, ElementContext elementContext, ElementEntity element);
+
+ void resolveConflict(SessionContext context, ElementContext elementContext, ElementEntity element,
+ Resolution resolution);
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/ElementStore.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/ElementStore.java
new file mode 100644
index 0000000..1c26a81
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/ElementStore.java
@@ -0,0 +1,20 @@
+package org.openecomp.core.zusammen.plugin.collaboration;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
+import org.openecomp.core.zusammen.plugin.dao.types.SynchronizationStateEntity;
+
+import java.util.Collection;
+import java.util.Optional;
+
+public interface ElementStore {
+ Optional<ElementEntity> get(SessionContext context, ElementContext elementContext, Id elementId);
+
+ Optional<ElementEntity> getDescriptor(SessionContext context, ElementContext elementContext,
+ Id elementId);
+
+ Collection<SynchronizationStateEntity> listSynchronizationStates(SessionContext context,
+ ElementContext elementContext);
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/ErrorCode.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/ErrorCode.java
new file mode 100644
index 0000000..3d09100
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/ErrorCode.java
@@ -0,0 +1,5 @@
+package org.openecomp.core.zusammen.plugin.collaboration;
+
+public class ErrorCode {
+ public static final int NO_CHANGES_TO_PUBLISH = 60000;
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/Message.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/Message.java
new file mode 100644
index 0000000..2816974
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/Message.java
@@ -0,0 +1,6 @@
+package org.openecomp.core.zusammen.plugin.collaboration;
+
+public class Message {
+ public static final String NO_CHANGES_TO_PUBLISH =
+ "Item Id %s, version Id %s: There are no changes to publish.";
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/PublishService.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/PublishService.java
new file mode 100644
index 0000000..7b043c8
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/PublishService.java
@@ -0,0 +1,201 @@
+package org.openecomp.core.zusammen.plugin.collaboration;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.Action;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import com.amdocs.zusammen.datatypes.response.ReturnCode;
+import com.amdocs.zusammen.datatypes.response.ZusammenException;
+import com.amdocs.zusammen.sdk.collaboration.types.CollaborationMergeChange;
+import com.amdocs.zusammen.sdk.collaboration.types.CollaborationPublishResult;
+import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
+import org.openecomp.core.zusammen.plugin.dao.types.SynchronizationStateEntity;
+import org.openecomp.core.zusammen.plugin.dao.types.VersionEntity;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.Map;
+import java.util.Optional;
+import java.util.UUID;
+
+import static com.amdocs.zusammen.datatypes.response.Module.ZCSP;
+import static org.openecomp.core.zusammen.plugin.ZusammenPluginConstants.ROOT_ELEMENTS_PARENT_ID;
+import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.convertToElementChange;
+import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.convertToVersionChange;
+import static org.openecomp.core.zusammen.plugin.collaboration.ErrorCode.NO_CHANGES_TO_PUBLISH;
+
+public class PublishService {
+ // TODO: 6/29/2017 throw ZusammenException with ReturnCode when needed.
+ private static final String PUSH_NON_EXISTING_VERSION =
+ "Item Id %s, version Id %s: Non existing version cannot be pushed.";
+
+ private VersionPublicStore versionPublicStore;
+ private VersionPrivateStore versionPrivateStore;
+ private ElementPublicStore elementPublicStore;
+ private ElementPrivateStore elementPrivateStore;
+
+ public PublishService(VersionPublicStore versionPublicStore,
+ VersionPrivateStore versionPrivateStore,
+ ElementPublicStore elementPublicStore,
+ ElementPrivateStore elementPrivateStore) {
+ this.versionPublicStore = versionPublicStore;
+ this.versionPrivateStore = versionPrivateStore;
+ this.elementPublicStore = elementPublicStore;
+ this.elementPrivateStore = elementPrivateStore;
+ }
+
+ public CollaborationPublishResult publish(SessionContext context, Id itemId, Id versionId,
+ String message) {
+ CollaborationPublishResult result = new CollaborationPublishResult();
+ result.setChange(new CollaborationMergeChange());
+
+ Date publishTime = new Date();
+ Id revisionId = new Id(UUID.randomUUID().toString());
+ boolean versionFirstPublication = publishVersion(context, itemId, versionId, revisionId,
+ publishTime,message);
+ if (versionFirstPublication) {
+ publishAllElements(context, new ElementContext(itemId, versionId, revisionId), publishTime,
+ result);
+ } else {
+ publishDirtyElements(context, new ElementContext(itemId, versionId, revisionId), publishTime,
+ result);
+ }
+ return result;
+ }
+
+ private boolean publishVersion(SessionContext context, Id itemId, Id versionId, Id revisionId,
+ Date publishTime, String message) {
+ SynchronizationStateEntity privateVersionSyncState =
+ versionPrivateStore.getSynchronizationState(context, itemId, versionId)
+ .orElseThrow(() -> new IllegalArgumentException(
+ String.format(PUSH_NON_EXISTING_VERSION, itemId.toString(), versionId.toString())));
+
+ if (!privateVersionSyncState.isDirty()) {
+ throw new ZusammenException(new ReturnCode(NO_CHANGES_TO_PUBLISH, ZCSP,
+ String.format(Message.NO_CHANGES_TO_PUBLISH, itemId, versionId), null));
+ }
+
+ Optional<SynchronizationStateEntity> publicVersionSyncState =
+ versionPublicStore.getSynchronizationState(context, itemId, versionId);
+
+ // private must be synced with public (if public exists)
+ if (publicVersionSyncState.isPresent() &&
+ !privateVersionSyncState.getPublishTime()
+ .equals(publicVersionSyncState.get().getPublishTime())) {
+ // should not happen as it is validated in zusammen-core
+ throw new UnsupportedOperationException("Out of sync item version can not be publish");
+ }
+
+ boolean versionFirstPublication;
+ Map<Id, Id> versionElementIds =
+ elementPublicStore.listIds(context, new ElementContext(itemId,
+ versionId));
+ if (publicVersionSyncState.isPresent()) {
+ versionPublicStore.update(context, itemId, new VersionEntity(versionId), revisionId,
+ versionElementIds,publishTime,message);
+ versionFirstPublication = false;
+ } else {
+ VersionEntity privateVersion = versionPrivateStore.get(context, itemId, versionId)
+ .orElseThrow(() -> new IllegalArgumentException(
+ String.format(PUSH_NON_EXISTING_VERSION, itemId.toString(), versionId.toString())));
+ versionPublicStore.create(context, itemId, privateVersion, revisionId,versionElementIds,
+ publishTime,message);
+ versionFirstPublication = true;
+ }
+ versionPrivateStore.markAsPublished(context, itemId, versionId, publishTime);
+ return versionFirstPublication;
+ }
+
+ private void publishAllElements(SessionContext context, ElementContext elementContext,
+ Date publishTime, CollaborationPublishResult result) {
+ Collection<SynchronizationStateEntity> privateElementSyncStates =
+ elementPrivateStore.listSynchronizationStates(context, elementContext);
+
+ for (SynchronizationStateEntity privateElementSyncState : privateElementSyncStates) {
+ Optional<ElementEntity> privateElement =
+ elementPrivateStore.get(context, elementContext, privateElementSyncState.getId());
+
+ if (!privateElement.isPresent()) {
+ continue;
+ }
+ ElementEntity elementToPublish = privateElement.get();
+
+ elementPublicStore.create(context, elementContext, elementToPublish,
+ privateElementSyncState.isDirty() ? publishTime
+ : privateElementSyncState.getPublishTime());
+
+ if (privateElementSyncState.isDirty()) {
+ elementPrivateStore
+ .markAsPublished(context, elementContext, privateElementSyncState.getId(), publishTime);
+ }
+ updateResult(elementContext, elementToPublish, Action.CREATE,
+ ROOT_ELEMENTS_PARENT_ID.equals(privateElementSyncState.getId()), result);
+ }
+ }
+
+ private void publishDirtyElements(SessionContext context, ElementContext elementContext,
+ Date publishTime, CollaborationPublishResult result) {
+
+ Id revisionId = elementContext.getRevisionId();
+ elementContext.setRevisionId(revisionId);
+ ElementContext privateElementContext = new ElementContext(elementContext.getItemId(),
+ elementContext.getVersionId(),Id.ZERO);
+ Collection<SynchronizationStateEntity> privateElementSyncStates =
+ elementPrivateStore.listSynchronizationStates(context, elementContext);
+
+ Collection<SynchronizationStateEntity> publicElementSyncStates =
+ elementPublicStore.listSynchronizationStates(context, elementContext);
+
+ for (SynchronizationStateEntity privateElementSyncState : privateElementSyncStates) {
+ if (!privateElementSyncState.isDirty()) {
+ continue;
+ }
+
+ Optional<ElementEntity> privateElement =
+ elementPrivateStore.get(context, privateElementContext, privateElementSyncState.getId());
+
+ ElementEntity elementToPublish;
+ Action actionOnPublic;
+ if (privateElement.isPresent()) {
+ elementToPublish = privateElement.get();
+
+ if (publicElementSyncStates.contains(privateElementSyncState)) {
+
+ elementPublicStore.update(context, elementContext, elementToPublish, publishTime);
+ actionOnPublic = Action.UPDATE;
+ } else {
+ elementPublicStore.create(context, elementContext, elementToPublish, publishTime);
+ actionOnPublic = Action.CREATE;
+ }
+
+ elementPrivateStore
+ .markAsPublished(context, privateElementContext, privateElementSyncState.getId(), publishTime);
+ } else {
+ elementToPublish =
+ elementPublicStore.get(context, elementContext, privateElementSyncState.getId())
+ .orElseThrow(() -> new IllegalStateException(
+ "Element that should be deleted from public must exist there"));
+ elementPublicStore.delete(context, elementContext, elementToPublish, publishTime);
+ actionOnPublic = Action.DELETE;
+
+ elementPrivateStore
+ .markDeletionAsPublished(context, privateElementContext, privateElementSyncState.getId(),
+ publishTime);
+ }
+
+ updateResult(elementContext, elementToPublish, actionOnPublic,
+ ROOT_ELEMENTS_PARENT_ID.equals(privateElementSyncState.getId()), result);
+ }
+ }
+
+ private void updateResult(ElementContext elementContext, ElementEntity element,
+ Action action, boolean versionDataElement,
+ CollaborationPublishResult result) {
+ if (versionDataElement) {
+ result.getChange().setChangedVersion(convertToVersionChange(elementContext, element, action));
+ } else {
+ result.getChange().getChangedElements()
+ .add(convertToElementChange(elementContext, element, action));
+ }
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/RevertService.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/RevertService.java
new file mode 100644
index 0000000..0d2ea2c
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/RevertService.java
@@ -0,0 +1,161 @@
+package org.openecomp.core.zusammen.plugin.collaboration;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
+import org.openecomp.core.zusammen.plugin.dao.types.SynchronizationStateEntity;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+public class RevertService {
+
+ private ElementPublicStore elementPublicStore;
+ private ElementPrivateStore elementPrivateStore;
+
+ public RevertService(ElementPublicStore elementPublicStore,
+ ElementPrivateStore elementPrivateStore) {
+ this.elementPublicStore = elementPublicStore;
+ this.elementPrivateStore = elementPrivateStore;
+ }
+
+ public void revert(SessionContext context, Id itemId, Id versionId, Id revisionId) {
+ ElementContext targetContext = new ElementContext(itemId, versionId);
+ ElementContext sourceContext = new ElementContext(itemId, versionId, revisionId);
+ copyElementsFromPublic(context, sourceContext, targetContext);
+ }
+
+ private void copyElementsFromPublic(SessionContext context, ElementContext sourceContext,
+ ElementContext targetContext) {
+ Collection<RevertElementAction> revertElementActions =
+ evaluateRevertElementActions(context, sourceContext, targetContext);
+
+ revertElementActions.forEach(revertElementAction -> revertElementAction.run(context));
+ }
+
+ private Collection<RevertElementAction> evaluateRevertElementActions(SessionContext context,
+ ElementContext sourceContext,
+ ElementContext targetContext) {
+
+ Map<Id, Id> sourceElements = elementPublicStore.listIds(context, sourceContext);
+ Map<Id, Id> targetPublicElements = elementPublicStore.listIds(context, targetContext);
+ Collection<SynchronizationStateEntity> synchronizationStateEntities =
+ elementPrivateStore.listSynchronizationStates(context, targetContext);
+
+ Map<Id, Id> targetElements =
+ evaluateTargetElements(targetPublicElements, synchronizationStateEntities);
+
+
+ Collection<RevertElementAction> revertElementActions = new ArrayList<>();
+
+ sourceElements.entrySet().forEach(entry -> {
+ Id sourceElementId = entry.getKey();
+ Id sourceElementRevisionId = entry.getValue();
+
+ if (!targetElements.containsKey(sourceElementId)) {
+ revertElementActions
+ .add(new RevertElementAction(sourceContext, sourceElementId, commands[CREATE]));
+ } else if (!targetElements.get(sourceElementId).equals(sourceElementRevisionId)) {
+ revertElementActions
+ .add(new RevertElementAction(sourceContext, sourceElementId, commands[UPDATE]));
+ }
+ });
+
+ targetElements.entrySet().forEach(entry -> {
+ Id targetElementId = entry.getKey();
+ if (!sourceElements.containsKey(targetElementId)) {
+ revertElementActions
+ .add(new RevertElementAction(targetContext, targetElementId, commands[DELETE]));
+ }
+ });
+
+ return revertElementActions;
+ }
+
+ private Map<Id, Id> evaluateTargetElements(Map<Id, Id> targetPublicElements,
+ Collection<SynchronizationStateEntity> syncStates) {
+ Map<Id, Id> targetElements = new HashMap<>(targetPublicElements);
+ syncStates.stream()
+ .filter(SynchronizationStateEntity::isDirty)
+ .forEach(syncState -> targetElements.put(syncState.getId(), Id.ZERO));
+ return targetElements;
+ }
+
+ private static class RevertElementAction {
+ private ElementContext elementContext;
+ private Id elementId;
+ private ActionCommand command;
+
+ private RevertElementAction(ElementContext elementContext, Id elementId,
+ ActionCommand command) {
+ this.elementContext = elementContext;
+ this.elementId = elementId;
+ this.command = command;
+ }
+
+ public ElementContext getElementContext() {
+ return elementContext;
+ }
+
+ public Id getElementId() {
+ return elementId;
+ }
+
+ public void run(SessionContext context) {
+ command.run(context, elementContext, elementId);
+ }
+ }
+
+ private interface ActionCommand {
+ void run(SessionContext context, ElementContext elementContext, Id elementId);
+ }
+
+ private static int CREATE = 0;
+ private static int UPDATE = 1;
+ private static int DELETE = 2;
+
+ private ActionCommand[] commands = {new ActionCommand() {
+ @Override
+ public void run(SessionContext context, ElementContext elementContext, Id elementId) {
+ //create
+ Optional<ElementEntity> element = elementPublicStore.get(context, elementContext, elementId);
+ if (!element.isPresent()) {
+ throw getMissingElementException(elementContext, elementId);
+ }
+ elementPrivateStore.create(context, elementContext, element.get());
+ }
+ }, new ActionCommand() {
+ @Override
+ public void run(SessionContext context, ElementContext elementContext, Id elementId) {
+ //update
+ Optional<ElementEntity> element = elementPublicStore.get(context, elementContext, elementId);
+ if (!element.isPresent()) {
+ throw getMissingElementException(elementContext, elementId);
+ }
+ elementPrivateStore.update(context, elementContext, element.get());
+ }
+ }, new ActionCommand() {
+ @Override
+ public void run(SessionContext context, ElementContext elementContext, Id elementId) {
+ //delete
+ Optional<ElementEntity> element = elementPrivateStore.get(context, elementContext, elementId);
+ if (!element.isPresent()) {
+ return; // deleted by parent when hierarchy was deleted
+ }
+ elementPrivateStore.delete(context, elementContext, element.get());
+ }
+ }};
+
+ private RuntimeException getMissingElementException(ElementContext elementContext,
+ Id elementId) {
+ return new IllegalStateException(
+ String.format("Item Id %s, version Id %s, revision Id %s: Missing element with Id %s",
+ elementContext.getItemId().getValue(), elementContext.getVersionId().getValue(),
+ elementContext.getRevisionId().getValue(), elementId.getValue())
+ );
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/SyncService.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/SyncService.java
new file mode 100644
index 0000000..04a7e9f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/SyncService.java
@@ -0,0 +1,384 @@
+package org.openecomp.core.zusammen.plugin.collaboration;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.Action;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import com.amdocs.zusammen.sdk.collaboration.types.CollaborationMergeChange;
+import com.amdocs.zusammen.sdk.collaboration.types.CollaborationMergeConflict;
+import com.amdocs.zusammen.sdk.collaboration.types.CollaborationMergeResult;
+import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
+import org.openecomp.core.zusammen.plugin.dao.types.StageEntity;
+import org.openecomp.core.zusammen.plugin.dao.types.SynchronizationStateEntity;
+import org.openecomp.core.zusammen.plugin.dao.types.VersionEntity;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.function.Function;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+
+import static org.openecomp.core.zusammen.plugin.ZusammenPluginConstants.ROOT_ELEMENTS_PARENT_ID;
+
+public class SyncService {
+ private static final String PULL_NON_EXISTING_VERSION =
+ "Item Id %s, version Id %s: Non existing version cannot be synced.";
+ private static final String PUBLIC_SYNC_STATE_EXISTS_WITHOUT_ELEMENT =
+ "Item Id %s, version Id %s: Sync state of element with Id %s " +
+ "exists in public space while the element does not";
+ private static final String PRIVATE_UNPUBLISHED_SYNC_STATE_EXISTS_WITHOUT_ELEMENT =
+ "Item Id %s, version Id %s: Sync state of unpublished element with Id %s " +
+ "exists in private space while the element does not";
+
+ private VersionPublicStore versionPublicStore;
+ private VersionPrivateStore versionPrivateStore;
+ private VersionStageStore versionStageStore;
+ private ElementPublicStore elementPublicStore;
+ private ElementPrivateStore elementPrivateStore;
+ private ElementStageStore elementStageStore;
+
+ public SyncService(VersionPublicStore versionPublicStore,
+ VersionPrivateStore versionPrivateStore,
+ VersionStageStore versionStageStore,
+ ElementPublicStore elementPublicStore,
+ ElementPrivateStore elementPrivateStore,
+ ElementStageStore elementStageStore) {
+ this.versionPublicStore = versionPublicStore;
+ this.versionPrivateStore = versionPrivateStore;
+ this.versionStageStore = versionStageStore;
+ this.elementPublicStore = elementPublicStore;
+ this.elementPrivateStore = elementPrivateStore;
+ this.elementStageStore = elementStageStore;
+ }
+
+ public CollaborationMergeResult sync(SessionContext context, Id itemId, Id versionId,
+ boolean force) {
+ SynchronizationStateEntity publicVersionSyncState =
+ versionPublicStore.getSynchronizationState(context, itemId, versionId)
+ .orElseThrow(() -> new IllegalStateException(
+ String.format(PULL_NON_EXISTING_VERSION, itemId.toString(), versionId.toString())));
+
+ Date publishTime = publicVersionSyncState.getPublishTime();
+
+ Optional<SynchronizationStateEntity> privateVersionSyncState =
+ versionPrivateStore.getSynchronizationState(context, itemId, versionId);
+
+ if (force || !privateVersionSyncState.isPresent() ||
+ !publishTime.equals(privateVersionSyncState.get().getPublishTime())) {
+ ElementContext elementContext =
+ new ElementContext(itemId, versionId, publicVersionSyncState.getRevisionId());
+
+ Collection<SynchronizationStateEntity> publicSyncStates =
+ elementPublicStore.listSynchronizationStates(context, elementContext);
+ Collection<SynchronizationStateEntity> privateSyncStates =
+ elementPrivateStore.listSynchronizationStates(context, elementContext);
+ Map<Id, SynchronizationStateEntity> publicSyncStateById = toMapById(publicSyncStates);
+
+ Set<Id> syncedElements = new HashSet<>();
+ if (force) {
+ List<SynchronizationStateEntity> dirtyPrivateSyncStates = privateSyncStates.stream()
+ .filter(SynchronizationStateEntity::isDirty)
+ .collect(Collectors.toList());
+
+ forceSyncDirtyElements(context, elementContext, dirtyPrivateSyncStates, publicSyncStateById,
+ syncedElements);
+ }
+
+ if (!privateVersionSyncState.isPresent() ||
+ !publishTime.equals(privateVersionSyncState.get().getPublishTime())) {
+ syncVersion(context, itemId, versionId, publishTime, privateVersionSyncState.isPresent());
+ syncElements(context, elementContext,
+ privateVersionSyncState.map(SynchronizationStateEntity::getPublishTime).orElse(null),
+ publicSyncStates, privateSyncStates, publicSyncStateById, syncedElements);
+ }
+ }
+
+ return createResult();
+ }
+
+ private CollaborationMergeResult createResult() {
+ CollaborationMergeResult result = new CollaborationMergeResult();
+ result.setChange(new CollaborationMergeChange());
+ result.setConflict(new CollaborationMergeConflict());
+ return result;
+ }
+
+ private void syncVersion(SessionContext context, Id itemId, Id versionId, Date publishTime,
+ boolean versionExistOnPrivate) {
+ if (versionExistOnPrivate) {
+ stageVersion(context, itemId, new VersionEntity(versionId), Action.UPDATE, publishTime);
+ } else {
+ stageVersion(context, itemId, versionPublicStore.get(context, itemId, versionId)
+ .orElseThrow(() -> new IllegalArgumentException(String
+ .format(PULL_NON_EXISTING_VERSION, itemId.toString(), versionId.toString()))),
+ Action.CREATE, publishTime);
+ }
+ }
+
+ private void syncElements(SessionContext context, ElementContext elementContext,
+ Date previousSyncedPublishTime,
+ Collection<SynchronizationStateEntity> publicSyncStates,
+ Collection<SynchronizationStateEntity> privateSyncStates,
+ Map<Id, SynchronizationStateEntity> publicSyncStateById,
+ Set<Id> syncedElements) {
+ Map<Id, SynchronizationStateEntity> privateSyncStateById = toMapById(privateSyncStates);
+
+ Collection<SynchronizationStateEntity> updatedPublicSyncStates =
+ previousSyncedPublishTime == null
+ ? publicSyncStates
+ : publicSyncStates.stream()
+ .filter(syncState -> syncState.getPublishTime().after(previousSyncedPublishTime))
+ .collect(Collectors.toList());
+
+ syncPublicUpdatedElements(context, elementContext, updatedPublicSyncStates,
+ publicSyncStateById, privateSyncStateById, syncedElements);
+
+ List<SynchronizationStateEntity> onlyOnPrivatePublishedSyncStates =
+ privateSyncStates.stream()
+ .filter(syncState -> !publicSyncStateById.containsKey(syncState.getId()) &&
+ syncState.getPublishTime() != null)
+ .collect(Collectors.toList());
+
+ syncPublicDeletedElements(context, elementContext, onlyOnPrivatePublishedSyncStates,
+ publicSyncStateById, privateSyncStateById, syncedElements);
+ }
+
+ private void syncPublicUpdatedElements(SessionContext context, ElementContext elementContext,
+ Collection<SynchronizationStateEntity> updatedPublicSyncStates,
+ Map<Id, SynchronizationStateEntity> publicSyncStateById,
+ Map<Id, SynchronizationStateEntity> privateSyncStateById,
+ Set<Id> syncedElements) {
+ for (SynchronizationStateEntity publicSyncState : updatedPublicSyncStates) {
+ if (syncedElements.contains(publicSyncState.getId())) {
+ continue;
+ }
+
+ ElementEntity publicElement =
+ elementPublicStore.get(context, elementContext, publicSyncState.getId()).orElseThrow(
+ () -> new IllegalStateException(String
+ .format(PUBLIC_SYNC_STATE_EXISTS_WITHOUT_ELEMENT,
+ elementContext.getItemId().getValue(),
+ elementContext.getVersionId().getValue(),
+ publicSyncState.getId().getValue())));
+
+ SynchronizationStateEntity privateSyncState =
+ privateSyncStateById.get(publicSyncState.getId());
+
+ if (privateSyncState != null) {
+ if (!privateSyncState.isDirty()) {
+ // not changed on private
+ stageElement(context, elementContext, publicElement,
+ publicSyncState.getPublishTime(),
+ Action.UPDATE, false, null);
+ syncedElements.add(publicSyncState.getId());
+ } else {
+ Optional<ElementEntity> privateElement =
+ elementPrivateStore.get(context, elementContext, publicSyncState.getId());
+
+ if (privateElement.isPresent()) {
+ // updated on private - conflict if it has different hash
+ stageElement(context, elementContext, publicElement,
+ publicSyncState.getPublishTime(), Action.UPDATE,
+ !publicElement.getElementHash().equals(privateElement.get().getElementHash()),
+ null);
+
+ syncedElements.add(publicSyncState.getId());
+ } else {
+ // deleted on private - conflict tree
+ Set<Id> changeTreeElementIds =
+ stagePublicElementTree(context, elementContext, publicElement, publicSyncStateById,
+ (treeElementIds) -> true);
+ syncedElements.addAll(changeTreeElementIds);
+ }
+ }
+ } else {
+ // not existing on private - new creation on public
+ Set<Id> changeTreeElementIds =
+ stagePublicElementTree(context, elementContext, publicElement, publicSyncStateById,
+ (treeElementIds) -> containsDirty(treeElementIds, privateSyncStateById));
+ syncedElements.addAll(changeTreeElementIds);
+ }
+ }
+ }
+
+ private void syncPublicDeletedElements(
+ SessionContext context, ElementContext elementContext,
+ Collection<SynchronizationStateEntity> onlyOnPrivatePublishedSyncStates,
+ Map<Id, SynchronizationStateEntity> publicSyncStateById,
+ Map<Id, SynchronizationStateEntity> privateSyncStateById,
+ Set<Id> syncedElements) {
+ for (SynchronizationStateEntity privateSyncState : onlyOnPrivatePublishedSyncStates) {
+ if (syncedElements.contains(privateSyncState.getId())) {
+ continue;
+ }
+
+ Optional<ElementEntity> privateElement =
+ elementPrivateStore.get(context, elementContext, privateSyncState.getId());
+
+ if (!privateElement.isPresent()) {
+ // deleted on private as well
+ stageElement(context, elementContext, new ElementEntity(privateSyncState.getId()),
+ null, Action.DELETE, false, null);
+ syncedElements.add(privateSyncState.getId());
+ } else {
+ Set<Id> changeTreeElementIds =
+ stageElementTree(context, elementContext, privateElement.get(),
+ elementPrivateStore, publicSyncStateById::containsKey,
+ (treeElementIds) -> containsDirty(treeElementIds, privateSyncStateById),
+ (elementId) -> null, Action.DELETE);
+ syncedElements.addAll(changeTreeElementIds);
+ }
+ }
+ }
+
+ private void forceSyncDirtyElements(SessionContext context, ElementContext elementContext,
+ List<SynchronizationStateEntity> dirtyPrivateSyncStates,
+ Map<Id, SynchronizationStateEntity> publicSyncStateById,
+ Set<Id> syncedElements) {
+ for (SynchronizationStateEntity privateSyncState : dirtyPrivateSyncStates) {
+ Optional<ElementEntity> privateElement =
+ elementPrivateStore.get(context, elementContext, privateSyncState.getId());
+ if (privateSyncState.getPublishTime() == null) {
+ stageElement(context, elementContext,
+ privateElement.orElseThrow(() -> new IllegalStateException(
+ String.format(PRIVATE_UNPUBLISHED_SYNC_STATE_EXISTS_WITHOUT_ELEMENT,
+ elementContext.getItemId().getValue(),
+ elementContext.getVersionId().getValue(),
+ privateSyncState.getId().getValue()))),
+ null, Action.DELETE, false, null);
+ } else {
+ SynchronizationStateEntity publicSyncState =
+ publicSyncStateById.get(privateSyncState.getId());
+ if (publicSyncState != null) {
+ ElementEntity publicElement =
+ elementPublicStore.get(context, elementContext, privateSyncState.getId()).orElseThrow(
+ () -> new IllegalStateException(String
+ .format(PUBLIC_SYNC_STATE_EXISTS_WITHOUT_ELEMENT,
+ elementContext.getItemId().getValue(),
+ elementContext.getVersionId().getValue(),
+ privateSyncState.getId().getValue())));
+
+ stageElement(context, elementContext, publicElement, publicSyncState.getPublishTime(),
+ privateElement.isPresent() ? Action.UPDATE : Action.CREATE, false, null);
+ } else {
+ stageElement(context, elementContext, privateElement.isPresent()
+ ? privateElement.get()
+ : new ElementEntity(privateSyncState.getId()),
+ null, Action.DELETE, false, null);
+ }
+ }
+ syncedElements.add(privateSyncState.getId());
+ }
+ }
+
+ private Set<Id> stagePublicElementTree(SessionContext context,
+ ElementContext elementContext,
+ ElementEntity publicElement,
+ Map<Id, SynchronizationStateEntity> publicSyncStateById,
+ Predicate<Set<Id>> isElementTreeConflicted) {
+
+
+ return stageElementTree(context, elementContext, publicElement,
+ elementPublicStore,
+ (elementId) -> elementPrivateStore.getDescriptor(context, elementContext, elementId)
+ .isPresent(),
+ isElementTreeConflicted,
+ (elementId) -> publicSyncStateById.get(elementId).getPublishTime(),
+ Action.CREATE);
+ }
+
+ private Set<Id> stageElementTree(SessionContext context, ElementContext elementContext,
+ ElementEntity element,
+ ElementStore elementStore,
+ Predicate<Id> isElementExist,
+ Predicate<Set<Id>> isElementTreeConflicted,
+ Function<Id, Date> stagePublishTimeGetter,
+ Action stageAction) {
+ ElementEntity elementTreeRoot = findRootElementOfChange(context, elementContext,
+ elementStore, isElementExist, element);
+
+ Set<Id> elementTreeIds = new HashSet<>();
+ elementTreeIds.add(elementTreeRoot.getId());
+
+ Set<Id> subElementIds = stageElementSubs(context, elementContext, elementStore, elementTreeRoot,
+ stagePublishTimeGetter, stageAction);
+ elementTreeIds.addAll(subElementIds);
+
+ boolean conflicted = isElementTreeConflicted.test(elementTreeIds);
+ stageElement(context, elementContext, elementTreeRoot,
+ stagePublishTimeGetter.apply(elementTreeRoot.getId()), stageAction, conflicted,
+ conflicted ? subElementIds : null);
+ return elementTreeIds;
+ }
+
+ private ElementEntity findRootElementOfChange(SessionContext context,
+ ElementContext elementContext,
+ ElementStore elementStore,
+ Predicate<Id> isElementExistOnOppositeStore,
+ ElementEntity element) {
+ return element.getId().equals(ROOT_ELEMENTS_PARENT_ID) ||
+ isElementExistOnOppositeStore.test(element.getParentId())
+ ? element
+ : findRootElementOfChange(context, elementContext, elementStore,
+ isElementExistOnOppositeStore,
+ elementStore.get(context, elementContext, element.getParentId())
+ .orElseThrow(() -> new IllegalStateException(
+ String.format("Element %s exists while its parent element %s does not",
+ element.getId(), element.getParentId()))));
+ }
+
+ private boolean containsDirty(Set<Id> elementIds,
+ Map<Id, SynchronizationStateEntity> syncStateById) {
+ return elementIds.stream().anyMatch(elementId -> {
+ SynchronizationStateEntity privateSyncState = syncStateById.get(elementId);
+ return privateSyncState != null && privateSyncState.isDirty();
+ });
+ }
+
+ private Set<Id> stageElementSubs(SessionContext context, ElementContext elementContext,
+ ElementStore elementStore, ElementEntity parentElement,
+ Function<Id, Date> stagePublishTimeGetter, Action stageAction) {
+ Set<Id> elementTreeIds = new HashSet<>();
+ for (Id elementId : parentElement.getSubElementIds()) {
+ ElementEntity element = elementStore.get(context, elementContext, elementId).get();
+
+ stageElement(context, elementContext, element, stagePublishTimeGetter.apply(elementId),
+ stageAction, false, null);
+
+ elementTreeIds.add(elementId);
+ elementTreeIds.addAll(
+ stageElementSubs(context, elementContext, elementStore, element, stagePublishTimeGetter,
+ stageAction));
+ }
+ return elementTreeIds;
+ }
+
+ private void stageElement(SessionContext context, ElementContext elementContext,
+ ElementEntity element, Date publishTime, Action action,
+ boolean conflicted, Set<Id> conflictDependents) {
+ StageEntity<ElementEntity> elementStage =
+ new StageEntity<>(element, publishTime, action, conflicted);
+ if (conflictDependents != null) {
+ elementStage.setConflictDependents(
+ conflictDependents.stream().map(ElementEntity::new).collect(Collectors.toSet()));
+ }
+ elementStageStore.create(context, elementContext, elementStage);
+ }
+
+ private void stageVersion(SessionContext context, Id itemId, VersionEntity stageVersion,
+ Action stageAction, Date publishTime) {
+ versionStageStore
+ .create(context, itemId, new StageEntity<>(stageVersion, publishTime, stageAction, false));
+ }
+
+ private Map<Id, SynchronizationStateEntity> toMapById(
+ Collection<SynchronizationStateEntity> syncStates) {
+ return syncStates.stream()
+ .collect(Collectors.toMap(SynchronizationStateEntity::getId, Function.identity()));
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/VersionCollaborationStore.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/VersionCollaborationStore.java
deleted file mode 100644
index db3066c..0000000
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/VersionCollaborationStore.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package org.openecomp.core.zusammen.plugin.collaboration;
-
-import com.amdocs.zusammen.datatypes.Id;
-import com.amdocs.zusammen.datatypes.SessionContext;
-import com.amdocs.zusammen.datatypes.Space;
-import com.amdocs.zusammen.datatypes.item.Action;
-import com.amdocs.zusammen.datatypes.itemversion.Tag;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
-import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElementChange;
-import com.amdocs.zusammen.sdk.collaboration.types.CollaborationMergeChange;
-import org.openecomp.core.zusammen.plugin.ZusammenPluginUtil;
-import org.openecomp.core.zusammen.plugin.dao.ElementRepository;
-import org.openecomp.core.zusammen.plugin.dao.ElementRepositoryFactory;
-import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.stream.Collectors;
-
-import static org.openecomp.core.zusammen.plugin.ZusammenPluginConstants.ROOT_ELEMENTS_PARENT_ID;
-import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.getSpaceName;
-
-public class VersionCollaborationStore {
-
- public void tagItemVersion(SessionContext context, Id itemId, Id versionId, Id changeId,
- Tag tag) {
- if (changeId != null) {
- throw new UnsupportedOperationException(
- "In this plugin implementation tag is supported only on versionId");
- }
- String space = getSpaceName(context, Space.PRIVATE);
- ElementEntityContext targetContext = new ElementEntityContext(space, itemId, versionId);
- targetContext.setChangeRef(tag.getName());
- copyElements(context, new ElementEntityContext(space, itemId, versionId), targetContext,
- getElementRepository(context));
- }
-
- public CollaborationMergeChange resetItemVersionHistory(SessionContext context, Id itemId,
- Id versionId, String changeRef) {
- ElementRepository elementRepository = getElementRepository(context);
-
- String spaceName = getSpaceName(context, Space.PRIVATE);
- ElementEntityContext versionContext = new ElementEntityContext(spaceName, itemId, versionId);
-
- Collection<ElementEntity> deletedElements =
- deleteElements(context, versionContext, elementRepository);
-
- ElementEntityContext changeRefContext = new ElementEntityContext(spaceName, itemId, versionId);
- changeRefContext.setChangeRef(changeRef);
-
- Collection<ElementEntity> createdElements =
- copyElements(context, changeRefContext, versionContext, elementRepository);
-
- // TODO: 4/19/2017 version change...
- return createCollaborationMergeChange(versionContext, deletedElements, createdElements);
- }
-
- private Collection<ElementEntity> deleteElements(SessionContext context,
- ElementEntityContext elementContext,
- ElementRepository elementRepository) {
- Collection<ElementEntity> elements = elementRepository.list(context, elementContext);
- elements.forEach(element -> elementRepository
- .delete(context, elementContext, new ElementEntity(element.getId())));
- elementRepository.delete(context, elementContext, new ElementEntity(ROOT_ELEMENTS_PARENT_ID));
- return elements;
- }
-
- private Collection<ElementEntity> copyElements(SessionContext context,
- ElementEntityContext sourceElementContext,
- ElementEntityContext targetElementContext,
- ElementRepository elementRepository) {
- Collection<ElementEntity> elements = elementRepository.list(context, sourceElementContext);
- elements.forEach(elementEntity ->
- elementRepository.create(context, targetElementContext, elementEntity));
- return elements;
- }
-
- private CollaborationMergeChange createCollaborationMergeChange(
- ElementEntityContext versionContext,
- Collection<ElementEntity> deletedElements,
- Collection<ElementEntity> createdElements) {
- CollaborationMergeChange mergeChange = new CollaborationMergeChange();
- mergeChange.getChangedElements().addAll(
- convertToCollaborationElementChanges(versionContext, deletedElements, Action.DELETE));
- mergeChange.getChangedElements().addAll(
- convertToCollaborationElementChanges(versionContext, createdElements, Action.CREATE));
- return mergeChange;
- }
-
- private List<CollaborationElementChange> convertToCollaborationElementChanges(
- ElementEntityContext elementContext, Collection<ElementEntity> changedElements,
- Action action) {
- return changedElements.stream()
- .map(element -> convertToCollaborationElementChange(element, elementContext, action))
- .collect(Collectors.toList());
- }
-
- private CollaborationElementChange convertToCollaborationElementChange(
- ElementEntity elementEntity, ElementEntityContext elementContext, Action action) {
- CollaborationElementChange elementChange = new CollaborationElementChange();
- elementChange
- .setElement(ZusammenPluginUtil.getCollaborationElement(elementContext, elementEntity));
- elementChange.setAction(action);
- return elementChange;
- }
-
- protected ElementRepository getElementRepository(SessionContext context) {
- return ElementRepositoryFactory.getInstance().createInterface(context);
- }
-}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/VersionPrivateStore.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/VersionPrivateStore.java
new file mode 100644
index 0000000..a024327
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/VersionPrivateStore.java
@@ -0,0 +1,38 @@
+package org.openecomp.core.zusammen.plugin.collaboration;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import org.openecomp.core.zusammen.plugin.dao.types.SynchronizationStateEntity;
+import org.openecomp.core.zusammen.plugin.dao.types.VersionEntity;
+
+import java.util.Date;
+import java.util.Optional;
+
+public interface VersionPrivateStore {
+ Optional<VersionEntity> get(SessionContext context, Id itemId, Id versionId);
+
+ Optional<SynchronizationStateEntity> getSynchronizationState(SessionContext context, Id itemId,
+ Id versionId);
+
+ void create(SessionContext context, Id itemId, VersionEntity version);
+
+ void update(SessionContext context, Id itemId, VersionEntity version);
+
+ void update(SessionContext context, Id itemId, VersionEntity version, Date publishTime,
+ boolean dirty);
+
+ void delete(SessionContext context, Id itemId, VersionEntity version);
+
+ void markAsPublished(SessionContext context, Id itemId, Id versionId, Date publishTime);
+
+ void commitStagedCreate(SessionContext context, Id itemId, VersionEntity version,
+ Date publishTime);
+
+ void commitStagedUpdate(SessionContext context, Id itemId, VersionEntity version,
+ Date publishTime);
+
+ void commitStagedIgnore(SessionContext context, Id itemId, VersionEntity version,
+ Date publishTime);
+
+
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/VersionPublicStore.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/VersionPublicStore.java
new file mode 100644
index 0000000..c86db0e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/VersionPublicStore.java
@@ -0,0 +1,29 @@
+package org.openecomp.core.zusammen.plugin.collaboration;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.itemversion.ItemVersionRevisions;
+import org.openecomp.core.zusammen.plugin.dao.types.SynchronizationStateEntity;
+import org.openecomp.core.zusammen.plugin.dao.types.VersionEntity;
+
+import java.util.Date;
+import java.util.Map;
+import java.util.Optional;
+
+public interface VersionPublicStore {
+
+ Optional<VersionEntity> get(SessionContext context, Id itemId, Id versionId);
+
+ Optional<SynchronizationStateEntity> getSynchronizationState(SessionContext context,
+ Id itemId, Id versionId);
+
+ void create(SessionContext context, Id itemId, VersionEntity version, Id revisionId,
+ Map<Id, Id> versionElementIds, Date publishTime, String message);
+
+ void update(SessionContext context, Id itemId, VersionEntity version, Id revisionId,
+ Map<Id, Id> versionElementIds, Date publishTime, String message);
+
+ boolean checkHealth(SessionContext context);
+
+ ItemVersionRevisions listItemVersionRevisions(SessionContext context, Id itemId, Id versionId);
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/VersionStageStore.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/VersionStageStore.java
new file mode 100644
index 0000000..5058a26
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/VersionStageStore.java
@@ -0,0 +1,18 @@
+package org.openecomp.core.zusammen.plugin.collaboration;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import org.openecomp.core.zusammen.plugin.dao.types.StageEntity;
+import org.openecomp.core.zusammen.plugin.dao.types.VersionEntity;
+
+import java.util.Optional;
+
+public interface VersionStageStore {
+
+ Optional<StageEntity<VersionEntity>> get(SessionContext context, Id itemId,
+ VersionEntity versionEntity);
+
+ void create(SessionContext context, Id itemId, StageEntity<VersionEntity> versionStage);
+
+ void delete(SessionContext context, Id itemId, VersionEntity version);
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/impl/ElementPrivateStoreImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/impl/ElementPrivateStoreImpl.java
new file mode 100644
index 0000000..9f54ee3
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/impl/ElementPrivateStoreImpl.java
@@ -0,0 +1,269 @@
+package org.openecomp.core.zusammen.plugin.collaboration.impl;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
+import org.openecomp.core.zusammen.plugin.ZusammenPluginConstants;
+import org.openecomp.core.zusammen.plugin.collaboration.ElementPrivateStore;
+import org.openecomp.core.zusammen.plugin.dao.ElementRepository;
+import org.openecomp.core.zusammen.plugin.dao.ElementRepositoryFactory;
+import org.openecomp.core.zusammen.plugin.dao.ElementSynchronizationStateRepository;
+import org.openecomp.core.zusammen.plugin.dao.ElementSynchronizationStateRepositoryFactory;
+import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
+import org.openecomp.core.zusammen.plugin.dao.types.SynchronizationStateEntity;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.getPrivateElementContext;
+import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.getPrivateSpaceName;
+
+public class ElementPrivateStoreImpl implements ElementPrivateStore {
+ private static final Id REVISION_ID = Id.ZERO; // the private revision id is Id.ZERO 0000000...
+
+ @Override
+ public Map<Id, Id> listIds(SessionContext context, ElementContext elementContext) {
+ return getElementRepository(context)
+ .listIds(context, new ElementEntityContext(getPrivateSpaceName(context), elementContext));
+ }
+
+ @Override
+ public Collection<ElementEntity> listSubs(SessionContext context, ElementContext elementContext,
+ Id elementId) {
+ if (elementId == null) {
+ elementId = ZusammenPluginConstants.ROOT_ELEMENTS_PARENT_ID;
+ }
+
+ ElementRepository elementRepository = getElementRepository(context);
+ ElementEntityContext privateContext =
+ new ElementEntityContext(getPrivateSpaceName(context), elementContext);
+ privateContext.setRevisionId(REVISION_ID);
+ return elementRepository.get(context, privateContext, new ElementEntity(elementId))
+ .map(ElementEntity::getSubElementIds).orElse(new HashSet<>()).stream()
+ .map(subElementId -> elementRepository
+ .get(context, privateContext, new ElementEntity(subElementId)).get())
+ .filter(Objects::nonNull)
+ .collect(Collectors.toList());
+ }
+
+ @Override
+ public Optional<ElementEntity> get(SessionContext context, ElementContext elementContext,
+ Id elementId) {
+ ElementEntityContext privateElementContext =
+ new ElementEntityContext(getPrivateSpaceName(context), elementContext);
+ privateElementContext.setRevisionId(REVISION_ID);
+ return getElementRepository(context)
+ .get(context, privateElementContext,
+ new ElementEntity(elementId));
+ }
+
+ @Override
+ public Optional<ElementEntity> getDescriptor(SessionContext context,
+ ElementContext elementContext, Id elementId) {
+ return getElementRepository(context)
+ .getDescriptor(context,
+ new ElementEntityContext(getPrivateSpaceName(context), getPrivateElementContext
+ (elementContext)),
+ new ElementEntity(elementId));
+ }
+
+ @Override
+ public Collection<SynchronizationStateEntity> listSynchronizationStates(SessionContext context,
+ ElementContext elementContext) {
+ ElementEntityContext privateElementContext =
+ new ElementEntityContext(getPrivateSpaceName(context), elementContext);
+ return getElementSyncStateRepository(context)
+ .list(context, privateElementContext);
+ }
+
+ @Override
+ public Optional<SynchronizationStateEntity> getSynchronizationState(SessionContext context,
+ ElementContext elementContext,
+ Id elementId) {
+
+ ElementEntityContext privateElementContext =
+ new ElementEntityContext(getPrivateSpaceName(context), getPrivateElementContext
+ (elementContext));
+ return getElementSyncStateRepository(context)
+ .get(context, privateElementContext,
+ new SynchronizationStateEntity(elementId, REVISION_ID));
+ }
+
+ @Override
+ public void create(SessionContext context, ElementContext elementContext, ElementEntity element) {
+ create(context, elementContext, element, true, null);
+ }
+
+ @Override
+ public boolean update(SessionContext context, ElementContext elementContext,
+ ElementEntity element) {
+ ElementEntityContext privateContext =
+ new ElementEntityContext(getPrivateSpaceName(context), elementContext);
+ privateContext.setRevisionId(REVISION_ID);
+
+ if (!isElementChanged(context, privateContext, element)) {
+ return false;
+ }
+
+ getElementRepository(context).update(context, privateContext, element);
+ getElementSyncStateRepository(context).markAsDirty(context, privateContext,
+ new SynchronizationStateEntity(element.getId(), REVISION_ID));
+ return true;
+ }
+
+ @Override
+ public void delete(SessionContext context, ElementContext elementContext, ElementEntity element) {
+
+ ElementEntityContext privateElementContext =
+ new ElementEntityContext(getPrivateSpaceName(context), elementContext);
+ privateElementContext.setRevisionId(REVISION_ID);
+ deleteElementHierarchy(context, getElementRepository(context),
+ getElementSyncStateRepository(context),
+ privateElementContext, element);
+ }
+
+ @Override
+ public void markAsPublished(SessionContext context, ElementContext elementContext, Id elementId,
+ Date publishTime) {
+ ElementEntityContext privateContext =
+ new ElementEntityContext(getPrivateSpaceName(context), elementContext);
+ privateContext.setRevisionId(REVISION_ID);
+ getElementSyncStateRepository(context).update(context,
+ privateContext,
+ new SynchronizationStateEntity(elementId, REVISION_ID, publishTime, false));
+ }
+
+ @Override
+ public void markDeletionAsPublished(SessionContext context, ElementContext elementContext,
+ Id elementId, Date publishTime) {
+
+ ElementEntityContext privateContext =
+ new ElementEntityContext(getPrivateSpaceName(context), elementContext);
+ privateContext.setRevisionId(REVISION_ID);
+ getElementSyncStateRepository(context).delete(context,
+ privateContext,
+ new SynchronizationStateEntity(elementId, REVISION_ID));
+ }
+
+ @Override
+ public void commitStagedCreate(SessionContext context, ElementContext elementContext,
+ ElementEntity element, Date publishTime) {
+ create(context, elementContext, element, false, publishTime);
+ }
+
+ @Override
+ public void commitStagedUpdate(SessionContext context, ElementContext elementContext,
+ ElementEntity element, Date publishTime) {
+ ElementEntityContext privateContext =
+ new ElementEntityContext(getPrivateSpaceName(context), elementContext);
+ privateContext.setRevisionId(REVISION_ID);
+
+ getElementRepository(context).update(context, privateContext, element);
+ // Currently Resolution='Other' is not supported so this is invoked after conflict was
+ // resolved with Resolution='Theirs' so dirty flag should be turned off.
+ // (if there was no conflict it's off anyway)
+ getElementSyncStateRepository(context).update(context, privateContext,
+ new SynchronizationStateEntity(element.getId(), REVISION_ID, publishTime, false));
+ }
+
+ @Override
+ public void commitStagedDelete(SessionContext context, ElementContext elementContext,
+ ElementEntity element) {
+ ElementEntityContext privateContext =
+ new ElementEntityContext(getPrivateSpaceName(context), elementContext);
+ privateContext.setRevisionId(REVISION_ID);
+ getElementRepository(context).delete(context, privateContext, element);
+ getElementSyncStateRepository(context)
+ .delete(context, privateContext,
+ new SynchronizationStateEntity(element.getId(), REVISION_ID));
+ }
+
+ @Override
+ public void commitStagedIgnore(SessionContext context, ElementContext elementContext,
+ ElementEntity element, Date publishTime) {
+ // publish time - updated to mark that this element was already synced with this publish time
+ // (even though the local data was preferred) and to prevent this conflict again.
+ // dirty - turned on because the local data which is different than the public one was
+ // preferred. It will enable future publication of this data.
+ getElementSyncStateRepository(context).update(context,
+ new ElementEntityContext(getPrivateSpaceName(context), elementContext),
+ new SynchronizationStateEntity(element.getId(), REVISION_ID, publishTime, true));
+ }
+
+ private void create(SessionContext context, ElementContext elementContext,
+ ElementEntity element, boolean dirty, Date publishTime) {
+ ElementEntityContext privateContext =
+ new ElementEntityContext(getPrivateSpaceName(context), elementContext);
+ privateContext.setRevisionId(REVISION_ID);
+ getElementRepository(context).create(context, privateContext, element);
+ getElementSyncStateRepository(context).create(context, privateContext,
+ new SynchronizationStateEntity(element.getId(), REVISION_ID, publishTime, dirty));
+ }
+
+
+ private void deleteElementHierarchy(
+ SessionContext context, ElementRepository elementRepository,
+ ElementSynchronizationStateRepository elementSyncStateRepository,
+ ElementEntityContext elementContext, ElementEntity element) {
+
+ Optional<ElementEntity> retrieved = elementRepository.get(context, elementContext, element);
+ if (!retrieved.isPresent()) {
+ return;
+ }
+ retrieved.get().getSubElementIds().stream()
+ .map(ElementEntity::new)
+ .forEach(subElementEntity -> deleteElementHierarchy(
+ context, elementRepository, elementSyncStateRepository, elementContext,
+ subElementEntity));
+
+ // only for the first one the parentId will populated (so it'll be removed from its parent)
+ elementRepository.delete(context, elementContext, element);
+ handleDeletedElementSyncState(context, elementSyncStateRepository, elementContext, element);
+ }
+
+ private void handleDeletedElementSyncState(SessionContext context,
+ ElementSynchronizationStateRepository elementSyncStateRepository,
+ ElementEntityContext elementContext,
+ ElementEntity element) {
+ SynchronizationStateEntity elementSyncState = new SynchronizationStateEntity(element.getId(),
+ REVISION_ID);
+ if (elementSyncStateRepository.get(context, elementContext, elementSyncState).
+ orElseThrow(
+ () -> new IllegalStateException("Synchronization state must exist for an element"))
+ .getPublishTime() == null) {
+ elementSyncStateRepository.delete(context, elementContext, elementSyncState);
+ } else {
+ elementSyncStateRepository.markAsDirty(context, elementContext, elementSyncState);
+ }
+ }
+
+ private boolean isElementChanged(SessionContext context,
+ ElementEntityContext elementContext,
+ ElementEntity newElement) {
+ return getElementHash(context, elementContext, new ElementEntity(newElement.getId()))
+ .map(existingHash -> !newElement.getElementHash().equals(existingHash))
+ .orElse(true);
+ }
+
+ private Optional<Id> getElementHash(SessionContext context,
+ ElementEntityContext elementEntityContext,
+ ElementEntity element) {
+ return getElementRepository(context).getHash(context, elementEntityContext, element);
+ }
+
+ protected ElementRepository getElementRepository(SessionContext context) {
+ return ElementRepositoryFactory.getInstance().createInterface(context);
+ }
+
+ protected ElementSynchronizationStateRepository getElementSyncStateRepository(
+ SessionContext context) {
+ return ElementSynchronizationStateRepositoryFactory.getInstance().createInterface(context);
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/impl/ElementPublicStoreImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/impl/ElementPublicStoreImpl.java
new file mode 100644
index 0000000..d946a52
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/impl/ElementPublicStoreImpl.java
@@ -0,0 +1,189 @@
+package org.openecomp.core.zusammen.plugin.collaboration.impl;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.Space;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
+import org.openecomp.core.zusammen.plugin.collaboration.ElementPublicStore;
+import org.openecomp.core.zusammen.plugin.dao.ElementRepository;
+import org.openecomp.core.zusammen.plugin.dao.ElementRepositoryFactory;
+import org.openecomp.core.zusammen.plugin.dao.ElementSynchronizationStateRepository;
+import org.openecomp.core.zusammen.plugin.dao.ElementSynchronizationStateRepositoryFactory;
+import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
+import org.openecomp.core.zusammen.plugin.dao.types.SynchronizationStateEntity;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Optional;
+
+import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.getSpaceName;
+
+public class ElementPublicStoreImpl implements ElementPublicStore {
+
+ @Override
+ public Optional<ElementEntity> get(SessionContext context,
+ ElementContext elementContext, Id elementId) {
+ return getElementRepository(context)
+ .get(context, new ElementEntityContext(getSpaceName(context, Space.PUBLIC), elementContext),
+ new ElementEntity(elementId));
+ }
+
+ @Override
+ public Optional<ElementEntity> getDescriptor(SessionContext context,
+ ElementContext elementContext, Id elementId) {
+ return getElementRepository(context).getDescriptor(context,
+ new ElementEntityContext(getSpaceName(context, Space.PUBLIC), elementContext),
+ new ElementEntity(elementId));
+ }
+
+ @Override
+ public Collection<SynchronizationStateEntity> listSynchronizationStates(
+ SessionContext context, ElementContext elementContext) {
+ ElementEntityContext entityContext = new ElementEntityContext(getSpaceName
+ (context, Space.PUBLIC), elementContext);
+
+ ElementSynchronizationStateRepository elementSyncStateRepository =
+ getElementSyncStateRepository(context);
+ Map<Id, Id> ids = getElementRepository(context).listIds(context, entityContext);
+
+ Collection<SynchronizationStateEntity> synchronizationStateEntities = new HashSet<>();
+ for (Map.Entry<Id, Id> elementEntry : ids.entrySet()) {
+ Optional<SynchronizationStateEntity> synchronizationStateEntity = elementSyncStateRepository.
+ get(context, entityContext, new SynchronizationStateEntity(elementEntry.getKey(),
+ elementEntry.getValue()));
+ if (synchronizationStateEntity.isPresent()) {
+ synchronizationStateEntities.add(synchronizationStateEntity.get());
+ } else {
+ /*throw new IllegalStateException(String.format(
+ "list Synchronization States error: " + "element %s revision %s, which appears as an " +
+ "element of " +
+ "item" +
+ " %s version %s, does not exist",
+ elementEntry.getKey(), elementEntry.getValue(), elementContext.getItemId().getValue(),
+ elementContext.getVersionId().getValue()));*/
+ }
+ }
+
+ return synchronizationStateEntities;
+ }
+
+ @Override
+ public void create(SessionContext context, ElementContext elementContext,
+ ElementEntity element, Date publishTime) {
+ ElementEntityContext publicContext =
+ new ElementEntityContext(getSpaceName(context, Space.PUBLIC), elementContext);
+
+
+ if (element.getParentId() != null) {
+ createParentElement(context, elementContext, element.getParentId(), publishTime);
+ }
+ getElementRepository(context).create(context, publicContext, element);
+ getElementSyncStateRepository(context).create(context, publicContext,
+ new SynchronizationStateEntity(element.getId(), elementContext.getRevisionId(),
+ publishTime, false));
+ }
+
+ @Override
+ public void update(SessionContext context, ElementContext elementContext,
+ ElementEntity element, Date publishTime) {
+ //todo - update in public should be create new entry with new revision_id in public - this is a
+ // new revision
+ ElementEntityContext publicContext =
+ new ElementEntityContext(getSpaceName(context, Space.PUBLIC), elementContext);
+
+ Optional<ElementEntity> publicElement = getElementRepository(context).get(context,
+ publicContext, new ElementEntity(element.getId()));
+ if (publicElement.isPresent()) {
+ getElementRepository(context).update(context, publicContext, element);
+ } else {
+ publicElement = get(context,new ElementContext(publicContext.getItemId(),publicContext
+ .getVersionId()),element.getId());
+ element.setSubElementIds(publicElement.get().getSubElementIds());
+ getElementRepository(context).create(context, publicContext, element);
+ }
+ getElementSyncStateRepository(context).update(context, publicContext,
+ new SynchronizationStateEntity(element.getId(), elementContext.getRevisionId(), publishTime,
+ false));
+ }
+
+ @Override
+ public void delete(SessionContext context, ElementContext elementContext,
+ ElementEntity element, Date publishTime) {
+ ElementEntityContext publicContext =
+ new ElementEntityContext(getSpaceName(context, Space.PUBLIC), elementContext);
+
+ if (element.getParentId() != null) {
+ Optional<ElementEntity> parentElement = get(context, elementContext, element.getParentId());
+ if (parentElement.isPresent()) {
+ createParentElement(context, elementContext, element.getParentId(), publishTime);
+ }
+ }
+
+ getElementRepository(context).delete(context, publicContext, element);
+ getElementSyncStateRepository(context)
+ .delete(context, publicContext, new SynchronizationStateEntity(element.getId(),
+ elementContext.getRevisionId()));
+ }
+
+ @Override
+ public Map<Id, Id> listIds(SessionContext context, ElementContext elementContext) {
+
+ return getElementRepository(context)
+ .listIds(context,
+ new ElementEntityContext(getSpaceName(context, Space.PUBLIC), elementContext));
+
+ }
+
+ private void createParentElement(SessionContext context, ElementContext elementContext,
+ Id parentElementId, Date publishTime
+ ) {
+ ElementEntityContext publicContext =
+ new ElementEntityContext(getSpaceName(context, Space.PUBLIC), elementContext);
+
+ Optional<ElementEntity> parentElement =
+ getElementRepository(context).get(context, new ElementEntityContext
+ (publicContext.getSpace(), publicContext.getItemId(), publicContext.getVersionId(),
+ elementContext.getRevisionId()),
+ new ElementEntity(parentElementId));
+ if(parentElement.isPresent()) {
+ update(context, elementContext, parentElement.get(), publishTime);
+ }
+
+
+ /* Id elementRevisionId = getElementRevision(context, publicContext, elementContext.getRevisionId()
+ , parentElementId);
+
+ if (elementRevisionId != null && !elementRevisionId.equals(elementContext.getRevisionId())) {
+ Optional<ElementEntity> parentElement =
+ getElementRepository(context).get(context, new ElementEntityContext
+ (publicContext.getSpace(), publicContext.getItemId(), publicContext.getVersionId(),
+ elementContext.getRevisionId()),
+ new ElementEntity(parentElementId));
+ elementRevisionId = getElementRevision(context, publicContext, elementContext.getRevisionId()
+ , parentElement.get().getId());
+ if (elementRevisionId != null) {
+ update(context, elementContext, parentElement.get(), publishTime);
+ } else {
+ create(context, elementContext, parentElement.get(), publishTime);
+ }
+
+ }*/
+ }
+
+
+
+
+ protected ElementRepository getElementRepository(SessionContext context) {
+ return ElementRepositoryFactory.getInstance().createInterface(context);
+ }
+
+ protected ElementSynchronizationStateRepository getElementSyncStateRepository(
+ SessionContext context) {
+ return ElementSynchronizationStateRepositoryFactory.getInstance().createInterface(context);
+ }
+
+
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/impl/ElementStageStoreImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/impl/ElementStageStoreImpl.java
new file mode 100644
index 0000000..f6c2943
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/impl/ElementStageStoreImpl.java
@@ -0,0 +1,133 @@
+package org.openecomp.core.zusammen.plugin.collaboration.impl;
+
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.Action;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import com.amdocs.zusammen.datatypes.item.Resolution;
+import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
+import org.openecomp.core.zusammen.plugin.collaboration.ElementStageStore;
+import org.openecomp.core.zusammen.plugin.dao.ElementStageRepository;
+import org.openecomp.core.zusammen.plugin.dao.ElementStageRepositoryFactory;
+import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
+import org.openecomp.core.zusammen.plugin.dao.types.StageEntity;
+
+import java.util.Collection;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.getPrivateElementContext;
+import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.getPrivateSpaceName;
+
+public class ElementStageStoreImpl implements ElementStageStore {
+
+ @Override
+ public Collection<ElementEntity> listIds(SessionContext context, ElementContext elementContext) {
+ return getElementStageRepository(context)
+ .listIds(context, new ElementEntityContext(getPrivateSpaceName(context),
+ getPrivateElementContext(elementContext)));
+ }
+
+ @Override
+ public Optional<StageEntity<ElementEntity>> get(SessionContext context,
+ ElementContext elementContext,
+ ElementEntity element) {
+ return getElementStageRepository(context).get(context,
+ new ElementEntityContext(getPrivateSpaceName(context),
+ getPrivateElementContext(elementContext)),
+ element);
+ }
+
+ @Override
+ public Optional<StageEntity<ElementEntity>> getConflicted(SessionContext context,
+ ElementContext elementContext,
+ ElementEntity element) {
+ return get(context, elementContext, element).filter(StageEntity::isConflicted);
+ }
+
+ @Override
+ public boolean hasConflicts(SessionContext context, ElementContext elementContext) {
+ return !getElementStageRepository(context).listConflictedIds(context,
+ new ElementEntityContext(getPrivateSpaceName(context), getPrivateElementContext(elementContext))).isEmpty();
+ }
+
+ @Override
+ public Collection<StageEntity<ElementEntity>> listConflictedDescriptors(SessionContext context,
+ ElementContext elementContext) {
+ ElementEntityContext privateContext =
+ new ElementEntityContext(getPrivateSpaceName(context), getPrivateElementContext
+ (elementContext));
+ ElementStageRepository elementStageRepository = getElementStageRepository(context);
+
+ return elementStageRepository.listConflictedIds(context, privateContext).stream()
+ .map(conflictedElement -> elementStageRepository
+ .getDescriptor(context, privateContext, conflictedElement).get())
+ .collect(Collectors.toList());
+ }
+
+ @Override
+ public void create(SessionContext context, ElementContext elementContext,
+ StageEntity<ElementEntity> elementStage) {
+ getElementStageRepository(context)
+ .create(context,
+ new ElementEntityContext(getPrivateSpaceName(context), getPrivateElementContext(elementContext)),
+ elementStage);
+ }
+
+ @Override
+ public void delete(SessionContext context, ElementContext elementContext, ElementEntity element) {
+ getElementStageRepository(context)
+ .delete(context,
+ new ElementEntityContext(getPrivateSpaceName(context), getPrivateElementContext(elementContext)),
+ element);
+ }
+
+
+ @Override
+ public void resolveConflict(SessionContext context, ElementContext elementContext,
+ ElementEntity element, Resolution resolution) {
+ Optional<StageEntity<ElementEntity>> stagedElement =
+ getConflicted(context, elementContext, element);
+ if (!stagedElement.isPresent()) {
+ return;
+ }
+
+ ElementEntityContext privateContext =
+ new ElementEntityContext(getPrivateSpaceName(context), getPrivateElementContext
+ (elementContext));
+
+ switch (resolution) {
+ case YOURS:
+ resolveConflictByYours(context, privateContext, stagedElement.get());
+ break;
+ case THEIRS:
+ resolveConflictByTheirs(context, privateContext, stagedElement.get());
+ break;
+ case OTHER: // other = data updates only? no data deletions? if so, then:
+ // conflicted = false
+ // element = the input of resolve
+ // action = update
+ throw new UnsupportedOperationException("'Other' conflict resolution is not yet supported");
+ default:
+ break;
+ }
+ }
+
+ private void resolveConflictByYours(SessionContext context, ElementEntityContext privateContext,
+ StageEntity<ElementEntity> stagedElement) {
+ getElementStageRepository(context)
+ .markAsNotConflicted(context, privateContext, stagedElement.getEntity(), Action.IGNORE);
+ stagedElement.getConflictDependents().forEach(conflictDependant ->
+ getElementStageRepository(context)
+ .markAsNotConflicted(context, privateContext, conflictDependant, Action.IGNORE));
+ }
+
+ private void resolveConflictByTheirs(SessionContext context, ElementEntityContext privateContext,
+ StageEntity<ElementEntity> stagedElement) {
+ getElementStageRepository(context)
+ .markAsNotConflicted(context, privateContext, stagedElement.getEntity());
+ }
+
+ protected ElementStageRepository getElementStageRepository(SessionContext context) {
+ return ElementStageRepositoryFactory.getInstance().createInterface(context);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/impl/VersionPrivateStoreImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/impl/VersionPrivateStoreImpl.java
new file mode 100644
index 0000000..11e61ab
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/impl/VersionPrivateStoreImpl.java
@@ -0,0 +1,117 @@
+package org.openecomp.core.zusammen.plugin.collaboration.impl;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import org.openecomp.core.zusammen.plugin.collaboration.VersionPrivateStore;
+import org.openecomp.core.zusammen.plugin.dao.VersionDao;
+import org.openecomp.core.zusammen.plugin.dao.VersionDaoFactory;
+import org.openecomp.core.zusammen.plugin.dao.VersionSynchronizationStateRepository;
+import org.openecomp.core.zusammen.plugin.dao.VersionSynchronizationStateRepositoryFactory;
+import org.openecomp.core.zusammen.plugin.dao.types.SynchronizationStateEntity;
+import org.openecomp.core.zusammen.plugin.dao.types.VersionContext;
+import org.openecomp.core.zusammen.plugin.dao.types.VersionEntity;
+
+import java.util.Date;
+import java.util.Optional;
+
+import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.getPrivateSpaceName;
+
+public class VersionPrivateStoreImpl implements VersionPrivateStore {
+
+ Id revisionId = Id.ZERO;
+
+ @Override
+ public Optional<VersionEntity> get(SessionContext context, Id itemId, Id versionId) {
+ return getVersionDao(context).get(context, getPrivateSpaceName(context), itemId, versionId);
+ }
+
+ @Override
+ public Optional<SynchronizationStateEntity> getSynchronizationState(SessionContext context,
+ Id itemId, Id versionId) {
+
+ return getVersionSyncStateRepository(context)
+ .get(context, new VersionContext(getPrivateSpaceName(context), itemId),
+ new SynchronizationStateEntity(versionId, revisionId));
+ }
+
+ @Override
+ public void create(SessionContext context, Id itemId, VersionEntity version) {
+ String privateSpace = getPrivateSpaceName(context);
+
+
+ getVersionDao(context).create(context, privateSpace, itemId, version);
+ getVersionSyncStateRepository(context).create(context, new VersionContext(privateSpace,
+ itemId),
+ new SynchronizationStateEntity(version.getId(), revisionId, null, true));
+ }
+
+ @Override
+ public void update(SessionContext context, Id itemId, VersionEntity version) {
+
+ getVersionDao(context)
+ .updateModificationTime(context, getPrivateSpaceName(context), itemId, version.getId(),
+ version.getModificationTime());
+ }
+
+ @Override
+ public void update(SessionContext context, Id itemId, VersionEntity version, Date publishTime,
+ boolean dirty) {
+ getVersionSyncStateRepository(context).updatePublishTime(context,
+ new VersionContext(getPrivateSpaceName(context), itemId),
+ new SynchronizationStateEntity(version.getId(), revisionId, publishTime, dirty));
+ }
+
+ @Override
+ public void delete(SessionContext context, Id itemId, VersionEntity version) {
+ String privateSpace = getPrivateSpaceName(context);
+
+ getVersionDao(context).delete(context, privateSpace, itemId, version.getId());
+ getVersionSyncStateRepository(context).delete(context, new VersionContext(privateSpace,
+ itemId),
+ new SynchronizationStateEntity(version.getId(), revisionId));
+ }
+
+ @Override
+ public void markAsPublished(SessionContext context, Id itemId, Id versionId, Date publishTime) {
+ getVersionSyncStateRepository(context)
+ .updatePublishTime(context, new VersionContext(getPrivateSpaceName(context), itemId),
+ new SynchronizationStateEntity(versionId, revisionId, publishTime, false));
+ }
+
+ @Override
+ public void commitStagedCreate(SessionContext context, Id itemId, VersionEntity version,
+ Date publishTime) {
+ String privateSpace = getPrivateSpaceName(context);
+
+ getVersionDao(context).create(context, privateSpace, itemId, version);
+ getVersionSyncStateRepository(context).create(context, new VersionContext(privateSpace,
+ itemId),
+ new SynchronizationStateEntity(version.getId(), revisionId, publishTime, false));
+ }
+
+ @Override
+ public void commitStagedUpdate(SessionContext context, Id itemId, VersionEntity version,
+ Date publishTime) {
+ update(context, itemId, version, publishTime, false);
+ }
+
+ @Override
+ public void commitStagedIgnore(SessionContext context, Id itemId, VersionEntity version,
+ Date publishTime) {
+ getVersionSyncStateRepository(context).updatePublishTime(context,
+ new VersionContext(getPrivateSpaceName(context), itemId),
+ new SynchronizationStateEntity(version.getId(), revisionId, publishTime, false));
+ }
+
+
+
+
+ protected VersionDao getVersionDao(SessionContext context) {
+ return VersionDaoFactory.getInstance().createInterface(context);
+ }
+
+ protected VersionSynchronizationStateRepository getVersionSyncStateRepository(
+ SessionContext context) {
+ return VersionSynchronizationStateRepositoryFactory.getInstance().createInterface(context);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/impl/VersionPublicStoreImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/impl/VersionPublicStoreImpl.java
new file mode 100644
index 0000000..aa628eb
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/impl/VersionPublicStoreImpl.java
@@ -0,0 +1,135 @@
+package org.openecomp.core.zusammen.plugin.collaboration.impl;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.Space;
+import com.amdocs.zusammen.datatypes.itemversion.ItemVersionRevisions;
+import com.amdocs.zusammen.datatypes.itemversion.Revision;
+import org.openecomp.core.zusammen.plugin.collaboration.VersionPublicStore;
+import org.openecomp.core.zusammen.plugin.dao.VersionDao;
+import org.openecomp.core.zusammen.plugin.dao.VersionDaoFactory;
+import org.openecomp.core.zusammen.plugin.dao.VersionSynchronizationStateRepository;
+import org.openecomp.core.zusammen.plugin.dao.VersionSynchronizationStateRepositoryFactory;
+import org.openecomp.core.zusammen.plugin.dao.types.SynchronizationStateEntity;
+import org.openecomp.core.zusammen.plugin.dao.types.VersionContext;
+import org.openecomp.core.zusammen.plugin.dao.types.VersionEntity;
+
+import java.util.Comparator;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.getSpaceName;
+
+public class VersionPublicStoreImpl implements VersionPublicStore {
+ @Override
+ public Optional<VersionEntity> get(SessionContext context, Id itemId, Id versionId) {
+ return getVersionDao(context)
+ .get(context, getSpaceName(context, Space.PUBLIC), itemId, versionId);
+ }
+
+ @Override
+ public Optional<SynchronizationStateEntity> getSynchronizationState(SessionContext context,
+ Id itemId, Id versionId) {
+ Id revisionId = getLastItemVersionRevision(context, itemId,
+ versionId);
+ if (revisionId == null) {
+ return Optional.empty();
+ }
+
+ return getVersionSyncStateRepository(context)
+ .get(context, new VersionContext(getSpaceName(context, Space.PUBLIC), itemId),
+ new SynchronizationStateEntity(versionId, revisionId));
+ }
+
+
+ @Override
+ public void create(SessionContext context, Id itemId, VersionEntity version, Id revisionId,
+ Map<Id, Id> versionElementIds, Date
+ publishTime, String message) {
+ String publicSpace = getSpaceName(context, Space.PUBLIC);
+
+ getVersionDao(context).create(context, publicSpace, itemId, version);
+
+ getVersionDao(context).createVersionElements(context, publicSpace, itemId, version.getId(),
+ revisionId, versionElementIds, publishTime,message);
+
+ getVersionSyncStateRepository(context).create(context, new VersionContext(publicSpace,
+ itemId),
+ new SynchronizationStateEntity(version.getId(), revisionId, publishTime, false));
+ }
+
+ @Override
+ public void update(SessionContext context, Id itemId, VersionEntity version,
+ Id revisionId, Map<Id, Id> versionElementIds, Date publishTime, String message) {
+ String publicSpace = getSpaceName(context, Space.PUBLIC);
+
+ getVersionDao(context).
+ createVersionElements(context, publicSpace, itemId, version.getId(),
+ revisionId, versionElementIds, publishTime,message);
+
+ getVersionSyncStateRepository(context).
+ updatePublishTime(context, new VersionContext(publicSpace, itemId),
+ new SynchronizationStateEntity(version.getId(), revisionId, publishTime, false));
+ }
+
+ @Override
+ public boolean checkHealth(SessionContext context) {
+ return getVersionDao(context).checkHealth(context);
+ }
+
+ @Override
+ public ItemVersionRevisions listItemVersionRevisions(SessionContext context, Id itemId,
+ Id versionId) {
+ VersionContext entityContext = new VersionContext(getSpaceName(context, Space.PUBLIC), itemId);
+ List<SynchronizationStateEntity> versionRevisions = getVersionSyncStateRepository(context)
+ .list(context, entityContext, new VersionEntity(versionId));
+
+ if (versionRevisions == null || versionRevisions.size() == 0) {
+ return null;
+ }
+
+ versionRevisions.sort(new Comparator<SynchronizationStateEntity>() {
+ @Override
+ public int compare(SynchronizationStateEntity o1, SynchronizationStateEntity o2) {
+ if (o1.getPublishTime().after(o2.getPublishTime())) {
+ return -1;
+ } else {
+ return 1;
+ }
+ }
+ });
+ ItemVersionRevisions itemVersionRevisions = new ItemVersionRevisions();
+ versionRevisions.forEach(synchronizationStateEntity -> itemVersionRevisions.addChange
+ (convertSyncState2Revision(synchronizationStateEntity)));
+ return itemVersionRevisions;
+ }
+
+ private Revision convertSyncState2Revision(
+ SynchronizationStateEntity synchronizationStateEntity) {
+ Revision revision = new Revision();
+ revision.setRevisionId(synchronizationStateEntity.getRevisionId());
+ revision.setTime(synchronizationStateEntity.getPublishTime());
+ revision.setMessage(synchronizationStateEntity.getMessage());
+ revision.setUser(synchronizationStateEntity.getUser());
+ return revision;
+ }
+
+
+ private Id getLastItemVersionRevision(SessionContext context, Id itemId, Id versionId) {
+
+ ItemVersionRevisions versionRevisions = listItemVersionRevisions(context, itemId, versionId);
+ if(versionRevisions ==null ) return null;
+ return versionRevisions.getItemVersionRevisions().get(0).getRevisionId();
+ }
+
+ protected VersionDao getVersionDao(SessionContext context) {
+ return VersionDaoFactory.getInstance().createInterface(context);
+ }
+
+ protected VersionSynchronizationStateRepository getVersionSyncStateRepository(
+ SessionContext context) {
+ return VersionSynchronizationStateRepositoryFactory.getInstance().createInterface(context);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/impl/VersionStageStoreImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/impl/VersionStageStoreImpl.java
new file mode 100644
index 0000000..dac9d25
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/collaboration/impl/VersionStageStoreImpl.java
@@ -0,0 +1,39 @@
+package org.openecomp.core.zusammen.plugin.collaboration.impl;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import org.openecomp.core.zusammen.plugin.collaboration.VersionStageStore;
+import org.openecomp.core.zusammen.plugin.dao.VersionStageRepository;
+import org.openecomp.core.zusammen.plugin.dao.VersionStageRepositoryFactory;
+import org.openecomp.core.zusammen.plugin.dao.types.StageEntity;
+import org.openecomp.core.zusammen.plugin.dao.types.VersionContext;
+import org.openecomp.core.zusammen.plugin.dao.types.VersionEntity;
+
+import java.util.Optional;
+
+import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.getPrivateSpaceName;
+
+public class VersionStageStoreImpl implements VersionStageStore {
+ @Override
+ public Optional<StageEntity<VersionEntity>> get(SessionContext context, Id itemId,
+ VersionEntity versionEntity) {
+ return getVersionStageRepository(context)
+ .get(context, new VersionContext(getPrivateSpaceName(context), itemId), versionEntity);
+ }
+
+ @Override
+ public void create(SessionContext context, Id itemId, StageEntity<VersionEntity> versionStage) {
+ getVersionStageRepository(context)
+ .create(context, new VersionContext(getPrivateSpaceName(context), itemId), versionStage);
+ }
+
+ @Override
+ public void delete(SessionContext context, Id itemId, VersionEntity version) {
+ getVersionStageRepository(context)
+ .delete(context, new VersionContext(getPrivateSpaceName(context), itemId), version);
+ }
+
+ protected VersionStageRepository getVersionStageRepository(SessionContext context) {
+ return VersionStageRepositoryFactory.getInstance().createInterface(context);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/ElementRepository.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/ElementRepository.java
index 967814c..7681327 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/ElementRepository.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/ElementRepository.java
@@ -1,15 +1,18 @@
package org.openecomp.core.zusammen.plugin.dao;
+import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.SessionContext;
import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
-import java.util.Collection;
+import java.util.Map;
import java.util.Optional;
public interface ElementRepository {
- Collection<ElementEntity> list(SessionContext context, ElementEntityContext elementContext);
+ Map<Id,Id> listIds(SessionContext context, ElementEntityContext elementContext);
+
+/* void createVersionData(SessionContext context, ElementEntityContext elementContext, VersionDataElement element);*/
void create(SessionContext context, ElementEntityContext elementContext, ElementEntity element);
@@ -20,8 +23,28 @@
Optional<ElementEntity> get(SessionContext context, ElementEntityContext elementContext,
ElementEntity element);
+ Optional<ElementEntity> getDescriptor(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element);
+
void createNamespace(SessionContext context, ElementEntityContext elementContext,
ElementEntity element);
- boolean checkHealth(SessionContext context);
+ Optional<Id> getHash(SessionContext context, ElementEntityContext elementEntityContext,
+ ElementEntity element);
+
+
+
+
+/* Collection<SynchronizationStateEntity> listSynchronizationStates(SessionContext context,
+ ElementEntityContext elementContext);
+
+ void updateSynchronizationState(SessionContext context, ElementEntityContext elementContext,
+ SynchronizationStateEntity elementSyncState);
+
+ void markAsDirty(SessionContext context, ElementEntityContext elementContext,
+ SynchronizationStateEntity elementSyncState);
+
+ Optional<SynchronizationStateEntity> getSynchronizationState(SessionContext context,
+ ElementEntityContext elementContext,
+ SynchronizationStateEntity elementSyncState);*/
}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/ElementStageRepository.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/ElementStageRepository.java
new file mode 100644
index 0000000..ac3dc4e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/ElementStageRepository.java
@@ -0,0 +1,34 @@
+package org.openecomp.core.zusammen.plugin.dao;
+
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.Action;
+import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
+import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
+import org.openecomp.core.zusammen.plugin.dao.types.StageEntity;
+
+import java.util.Collection;
+import java.util.Optional;
+
+public interface ElementStageRepository
+ extends StageRepository<ElementEntityContext, ElementEntity> {
+
+ Optional<StageEntity<ElementEntity>> getDescriptor(SessionContext context,
+ ElementEntityContext elementContext,
+ ElementEntity element);
+
+ Collection<ElementEntity> listIds(SessionContext context,
+ ElementEntityContext elementContext);
+
+ Collection<ElementEntity> listConflictedIds(SessionContext context,
+ ElementEntityContext elementContext);
+
+ void markAsNotConflicted(SessionContext context, ElementEntityContext entityContext,
+ ElementEntity entity, Action action);
+
+ void markAsNotConflicted(SessionContext context, ElementEntityContext entityContext,
+ ElementEntity entity);
+
+ void update(SessionContext context, ElementEntityContext entityContext, ElementEntity entity,
+ Action action, boolean conflicted);
+
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/ElementStageRepositoryFactory.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/ElementStageRepositoryFactory.java
new file mode 100644
index 0000000..1e41308
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/ElementStageRepositoryFactory.java
@@ -0,0 +1,14 @@
+package org.openecomp.core.zusammen.plugin.dao;
+
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.utils.facade.api.AbstractComponentFactory;
+import com.amdocs.zusammen.utils.facade.api.AbstractFactory;
+
+public abstract class ElementStageRepositoryFactory
+ extends AbstractComponentFactory<ElementStageRepository> {
+ public static ElementStageRepositoryFactory getInstance() {
+ return AbstractFactory.getInstance(ElementStageRepositoryFactory.class);
+ }
+
+ public abstract ElementStageRepository createInterface(SessionContext context);
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/ElementSynchronizationStateRepository.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/ElementSynchronizationStateRepository.java
new file mode 100644
index 0000000..53c029b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/ElementSynchronizationStateRepository.java
@@ -0,0 +1,21 @@
+package org.openecomp.core.zusammen.plugin.dao;
+
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
+import org.openecomp.core.zusammen.plugin.dao.types.SynchronizationStateEntity;
+
+import java.util.Collection;
+
+public interface ElementSynchronizationStateRepository
+ extends SynchronizationStateRepository<ElementEntityContext> {
+
+ Collection<SynchronizationStateEntity> list(SessionContext context,
+ ElementEntityContext elementContext);
+
+ void update(SessionContext context, ElementEntityContext entityContext,
+ SynchronizationStateEntity syncStateEntity);
+
+ void markAsDirty(SessionContext context, ElementEntityContext entityContext,
+ SynchronizationStateEntity syncStateEntity);
+
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/ElementSynchronizationStateRepositoryFactory.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/ElementSynchronizationStateRepositoryFactory.java
new file mode 100644
index 0000000..26f3bb4
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/ElementSynchronizationStateRepositoryFactory.java
@@ -0,0 +1,14 @@
+package org.openecomp.core.zusammen.plugin.dao;
+
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.utils.facade.api.AbstractComponentFactory;
+import com.amdocs.zusammen.utils.facade.api.AbstractFactory;
+
+public abstract class ElementSynchronizationStateRepositoryFactory
+ extends AbstractComponentFactory<ElementSynchronizationStateRepository> {
+ public static ElementSynchronizationStateRepositoryFactory getInstance() {
+ return AbstractFactory.getInstance(ElementSynchronizationStateRepositoryFactory.class);
+ }
+
+ public abstract ElementSynchronizationStateRepository createInterface(SessionContext context);
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/StageRepository.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/StageRepository.java
new file mode 100644
index 0000000..98b0d82
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/StageRepository.java
@@ -0,0 +1,15 @@
+package org.openecomp.core.zusammen.plugin.dao;
+
+import com.amdocs.zusammen.datatypes.SessionContext;
+import org.openecomp.core.zusammen.plugin.dao.types.StageEntity;
+
+import java.util.Optional;
+
+public interface StageRepository<C, E> {
+
+ Optional<StageEntity<E>> get(SessionContext context, C entityContext, E entity);
+
+ void create(SessionContext context, C entityContext, StageEntity<E> stageEntity);
+
+ void delete(SessionContext context, C entityContext, E entity);
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/SynchronizationStateRepository.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/SynchronizationStateRepository.java
new file mode 100644
index 0000000..f227b0c
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/SynchronizationStateRepository.java
@@ -0,0 +1,16 @@
+package org.openecomp.core.zusammen.plugin.dao;
+
+import com.amdocs.zusammen.datatypes.SessionContext;
+import org.openecomp.core.zusammen.plugin.dao.types.SynchronizationStateEntity;
+
+import java.util.Optional;
+
+public interface SynchronizationStateRepository<C> {
+
+ void create(SessionContext context, C entityContext, SynchronizationStateEntity syncStateEntity);
+
+ void delete(SessionContext context, C entityContext, SynchronizationStateEntity syncStateEntity);
+
+ Optional<SynchronizationStateEntity> get(SessionContext context, C entityContext,
+ SynchronizationStateEntity syncStateEntity);
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/VersionDao.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/VersionDao.java
new file mode 100644
index 0000000..f8ad040
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/VersionDao.java
@@ -0,0 +1,29 @@
+package org.openecomp.core.zusammen.plugin.dao;
+
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import org.openecomp.core.zusammen.plugin.dao.types.VersionEntity;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.Map;
+import java.util.Optional;
+
+public interface VersionDao {
+ Collection<VersionEntity> list(SessionContext context, String space, Id itemId);
+
+ Optional<VersionEntity> get(SessionContext context, String space, Id itemId, Id versionId);
+
+ void create(SessionContext context, String space, Id itemId, VersionEntity version);
+
+ void updateModificationTime(SessionContext context, String space, Id itemId, Id versionId, Date modificationTime);
+
+ void delete(SessionContext context, String space, Id itemId, Id versionId);
+
+ boolean checkHealth(SessionContext context);
+
+ void createVersionElements(SessionContext context, String publicSpace, Id itemId, Id versionId,
+ Id revisionId, Map<Id, Id> versionElementIds, Date publishTime,
+ String message);
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/VersionDaoFactory.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/VersionDaoFactory.java
new file mode 100644
index 0000000..2847959
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/VersionDaoFactory.java
@@ -0,0 +1,13 @@
+package org.openecomp.core.zusammen.plugin.dao;
+
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.utils.facade.api.AbstractComponentFactory;
+import com.amdocs.zusammen.utils.facade.api.AbstractFactory;
+
+public abstract class VersionDaoFactory extends AbstractComponentFactory<VersionDao> {
+ public static VersionDaoFactory getInstance() {
+ return AbstractFactory.getInstance(VersionDaoFactory.class);
+ }
+
+ public abstract VersionDao createInterface(SessionContext context);
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/VersionStageRepository.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/VersionStageRepository.java
new file mode 100644
index 0000000..568e0c9
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/VersionStageRepository.java
@@ -0,0 +1,9 @@
+package org.openecomp.core.zusammen.plugin.dao;
+
+
+import org.openecomp.core.zusammen.plugin.dao.types.VersionContext;
+import org.openecomp.core.zusammen.plugin.dao.types.VersionEntity;
+
+public interface VersionStageRepository extends StageRepository<VersionContext, VersionEntity> {
+
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/VersionStageRepositoryFactory.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/VersionStageRepositoryFactory.java
new file mode 100644
index 0000000..fc9e772
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/VersionStageRepositoryFactory.java
@@ -0,0 +1,13 @@
+package org.openecomp.core.zusammen.plugin.dao;
+
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.utils.facade.api.AbstractComponentFactory;
+import com.amdocs.zusammen.utils.facade.api.AbstractFactory;
+
+public abstract class VersionStageRepositoryFactory extends AbstractComponentFactory<VersionStageRepository> {
+ public static VersionStageRepositoryFactory getInstance() {
+ return AbstractFactory.getInstance(VersionStageRepositoryFactory.class);
+ }
+
+ public abstract VersionStageRepository createInterface(SessionContext context);
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/VersionSynchronizationStateRepository.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/VersionSynchronizationStateRepository.java
new file mode 100644
index 0000000..9134392
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/VersionSynchronizationStateRepository.java
@@ -0,0 +1,18 @@
+package org.openecomp.core.zusammen.plugin.dao;
+
+import com.amdocs.zusammen.datatypes.SessionContext;
+import org.openecomp.core.zusammen.plugin.dao.types.SynchronizationStateEntity;
+import org.openecomp.core.zusammen.plugin.dao.types.VersionContext;
+import org.openecomp.core.zusammen.plugin.dao.types.VersionEntity;
+
+import java.util.List;
+
+public interface VersionSynchronizationStateRepository
+ extends SynchronizationStateRepository<VersionContext> {
+
+ void updatePublishTime(SessionContext context, VersionContext entityContext,
+ SynchronizationStateEntity syncStateEntity);
+
+ List<SynchronizationStateEntity> list(SessionContext context, VersionContext entityContext,
+ VersionEntity versionEntity);
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/VersionSynchronizationStateRepositoryFactory.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/VersionSynchronizationStateRepositoryFactory.java
new file mode 100644
index 0000000..dfedb58
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/VersionSynchronizationStateRepositoryFactory.java
@@ -0,0 +1,14 @@
+package org.openecomp.core.zusammen.plugin.dao;
+
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.utils.facade.api.AbstractComponentFactory;
+import com.amdocs.zusammen.utils.facade.api.AbstractFactory;
+
+public abstract class VersionSynchronizationStateRepositoryFactory
+ extends AbstractComponentFactory<VersionSynchronizationStateRepository> {
+ public static VersionSynchronizationStateRepositoryFactory getInstance() {
+ return AbstractFactory.getInstance(VersionSynchronizationStateRepositoryFactory.class);
+ }
+
+ public abstract VersionSynchronizationStateRepository createInterface(SessionContext context);
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraElementRepository.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraElementRepository.java
deleted file mode 100644
index 6cc1350..0000000
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraElementRepository.java
+++ /dev/null
@@ -1,375 +0,0 @@
-/*
- * Copyright © 2016-2017 European Support Limited
- *
- * 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.
- */
-
-package org.openecomp.core.zusammen.plugin.dao.impl;
-
-import com.amdocs.zusammen.datatypes.Id;
-import com.amdocs.zusammen.datatypes.Namespace;
-import com.amdocs.zusammen.datatypes.SessionContext;
-import com.amdocs.zusammen.datatypes.item.Info;
-import com.amdocs.zusammen.datatypes.item.Relation;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
-import com.amdocs.zusammen.utils.fileutils.json.JsonUtil;
-import com.datastax.driver.core.ResultSet;
-import com.datastax.driver.core.Row;
-import com.datastax.driver.mapping.annotations.Accessor;
-import com.datastax.driver.mapping.annotations.Param;
-import com.datastax.driver.mapping.annotations.Query;
-import com.google.gson.reflect.TypeToken;
-import org.openecomp.core.zusammen.plugin.dao.ElementRepository;
-import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
-
-import java.lang.reflect.Type;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Optional;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-public class CassandraElementRepository implements ElementRepository {
-
- private static final String VERSION_ELEMENT_NOT_EXIST_ERROR_MSG =
- "List version elements error: " +
- "element %s, which appears as an element of item %s version %s, does not exist";
-
- @Override
- public Collection<ElementEntity> list(SessionContext context,
- ElementEntityContext elementContext) {
- Set<String> elementIds = getVersionElementIds(context, elementContext);
-
- Collection<ElementEntity> elements = new ArrayList<>();
- for (String elementId : elementIds) {
- elements.add(get(context, elementContext, new ElementEntity(new Id(elementId)))
- .orElseThrow(
- () -> new IllegalStateException(String.format(VERSION_ELEMENT_NOT_EXIST_ERROR_MSG,
- elementId, elementContext.getItemId().getValue(),
- getVersionId(elementContext)))));
- }
- return elements;
- }
-
- @Override
- public void create(SessionContext context, ElementEntityContext elementContext,
- ElementEntity element) {
- createElement(context, elementContext, element);
- addElementToParent(context, elementContext, element);
- }
-
- @Override
- public void update(SessionContext context, ElementEntityContext elementContext,
- ElementEntity element) {
- updateElement(context, elementContext, element);
- }
-
- @Override
- public void delete(SessionContext context, ElementEntityContext elementContext,
- ElementEntity element) {
- removeElementFromParent(context, elementContext, element);
- deleteElement(context, elementContext, element);
- }
-
- @Override
- public Optional<ElementEntity> get(SessionContext context, ElementEntityContext elementContext,
- ElementEntity element) {
- Row row = getElementAccessor(context).get(
- elementContext.getSpace(),
- elementContext.getItemId().toString(),
- getVersionId(elementContext),
- element.getId().toString()).one();
-
- return row == null ? Optional.empty() : Optional.of(getElementEntity(element, row));
- }
-
- @Override
- public void createNamespace(SessionContext context, ElementEntityContext elementContext,
- ElementEntity element) {
- getElementNamespaceAccessor(context).create(
- elementContext.getSpace(),
- elementContext.getItemId().toString(),
- element.getId().toString(),
- element.getNamespace().toString());
- }
-
- @Override
- public boolean checkHealth(SessionContext context) {
- ResultSet resultSet = getVersionElementsAccessor(context).checkHealth();
- return resultSet.getColumnDefinitions().contains("element_ids");
- }
-
- private String getVersionId(ElementEntityContext elementContext) {
- return elementContext.getChangeRef() == null
- ? elementContext.getVersionId().toString()
- : elementContext.getChangeRef();
- }
-
- private ElementNamespaceAccessor getElementNamespaceAccessor(SessionContext context) {
- return CassandraDaoUtils.getAccessor(context, ElementNamespaceAccessor.class);
- }
-
- private ElementAccessor getElementAccessor(SessionContext context) {
- return CassandraDaoUtils.getAccessor(context, ElementAccessor.class);
- }
-
- private VersionElementsAccessor getVersionElementsAccessor(SessionContext context) {
- return CassandraDaoUtils.getAccessor(context, VersionElementsAccessor.class);
- }
-
- private void createElement(SessionContext context, ElementEntityContext elementContext,
- ElementEntity element) {
- Set<String> subElementIds =
- element.getSubElementIds().stream().map(Id::toString).collect(Collectors.toSet());
- String versionId = getVersionId(elementContext);
-
- getElementAccessor(context).create(
- elementContext.getSpace(),
- elementContext.getItemId().toString(),
- versionId,
- element.getId().toString(),
- element.getParentId().toString(),
- element.getNamespace().toString(),
- JsonUtil.object2Json(element.getInfo()),
- JsonUtil.object2Json(element.getRelations()),
- element.getData(),
- element.getSearchableData(),
- element.getVisualization(),
- subElementIds);
-
- getVersionElementsAccessor(context).addElements(
- Collections.singleton(element.getId().toString()),
- elementContext.getSpace(),
- elementContext.getItemId().toString(),
- versionId);
- }
-
- private void updateElement(SessionContext context, ElementEntityContext elementContext,
- ElementEntity element) {
- getElementAccessor(context).update(
- JsonUtil.object2Json(element.getInfo()),
- JsonUtil.object2Json(element.getRelations()),
- element.getData(),
- element.getSearchableData(),
- element.getVisualization(),
- elementContext.getSpace(),
- elementContext.getItemId().toString(),
- elementContext.getVersionId().toString(),
- element.getId().toString());
- }
-
- private void deleteElement(SessionContext context, ElementEntityContext elementContext,
- ElementEntity element) {
- String versionId = getVersionId(elementContext);
-
- getElementAccessor(context).delete(
- elementContext.getSpace(),
- elementContext.getItemId().toString(),
- versionId,
- element.getId().toString());
-
- getVersionElementsAccessor(context).removeElements(
- Collections.singleton(element.getId().toString()),
- elementContext.getSpace(),
- elementContext.getItemId().toString(),
- versionId);
- }
-
- private void addElementToParent(SessionContext context, ElementEntityContext elementContext,
- ElementEntity element) {
- getElementAccessor(context).addSubElements(
- Collections.singleton(element.getId().toString()),
- elementContext.getSpace(),
- elementContext.getItemId().toString(),
- getVersionId(elementContext),
- element.getParentId().toString());
- }
-
- private void removeElementFromParent(SessionContext context, ElementEntityContext elementContext,
- ElementEntity element) {
- if (element.getParentId() == null) {
- return;
- }
- getElementAccessor(context).removeSubElements(
- Collections.singleton(element.getId().toString()),
- elementContext.getSpace(),
- elementContext.getItemId().toString(),
- getVersionId(elementContext),
- element.getParentId().toString());
- }
-
- private ElementEntity getElementEntity(ElementEntity element, Row row) {
- element.setNamespace(getNamespace(row.getString(ElementField.NAMESPACE)));
- element.setParentId(new Id(row.getString(ElementField.PARENT_ID)));
- element.setInfo(json2Object(row.getString(ElementField.INFO), Info.class));
- element.setRelations(
- json2Object(row.getString(ElementField.RELATIONS), new TypeToken<ArrayList<Relation>>() {
- }.getType()));
- element.setData(row.getBytes(ElementField.DATA));
- element.setSearchableData(row.getBytes(ElementField.SEARCHABLE_DATA));
- element.setVisualization(row.getBytes(ElementField.VISUALIZATION));
- element.setSubElementIds(row.getSet(ElementField.SUB_ELEMENT_IDS, String.class)
- .stream().map(Id::new).collect(Collectors.toSet()));
- return element;
- }
-
- private Namespace getNamespace(String namespaceStr) {
- Namespace namespace = new Namespace();
- if (namespaceStr != null) {
- namespace.setValue(namespaceStr);
- }
- return namespace;
- }
-
- private static <T> T json2Object(String json, Type typeOfT) {
- return json == null ? null : JsonUtil.json2Object(json, typeOfT);
- }
-
- private Set<String> getVersionElementIds(SessionContext context,
- ElementEntityContext elementContext) {
- Row row = getVersionElementsAccessor(context).get(
- elementContext.getSpace(),
- elementContext.getItemId().toString(),
- getVersionId(elementContext)).one();
- return row == null
- ? new HashSet<>()
- : row.getSet(CassandraElementRepository.VersionElementsField.ELEMENT_IDS, String.class);
- }
-
- /*
-CREATE TABLE IF NOT EXISTS element_namespace (
- space text,
- item_id text,
- element_id text,
- namespace text,
- PRIMARY KEY (( space, item_id, element_id ))
-);
- */
- @Accessor
- interface ElementNamespaceAccessor {
- @Query(
- "UPDATE element_namespace SET namespace=:ns " +
- "WHERE space=:space AND item_id=:item AND element_id=:id ")
- void create(@Param("space") String space,
- @Param("item") String itemId,
- @Param("id") String elementId,
- @Param("ns") String namespace);
- }
-
- /*
-CREATE TABLE IF NOT EXISTS element (
- space text,
- item_id text,
- version_id text,
- element_id text,
- parent_id text,
- namespace text,
- info text,
- relations text,
- data blob,
- searchable_data blob,
- visualization blob,
- sub_element_ids set<text>,
- PRIMARY KEY (( space, item_id, version_id, element_id ))
-);
- */
- @Accessor
- interface ElementAccessor {
- @Query(
- "UPDATE element SET parent_id=:parentId, namespace=:ns, info=:info, relations=:rels, " +
- "data=:data, searchable_data=:searchableData, visualization=:visualization, " +
- "sub_element_ids=sub_element_ids+:subs " +
- "WHERE space=:space AND item_id=:item AND version_id=:ver AND element_id=:id ")
- void create(@Param("space") String space,
- @Param("item") String itemId,
- @Param("ver") String versionId,
- @Param("id") String elementId,
- @Param("parentId") String parentElementId,
- @Param("ns") String namespace,
- @Param("info") String info,
- @Param("rels") String relations,
- @Param("data") ByteBuffer data,
- @Param("searchableData") ByteBuffer searchableData,
- @Param("visualization") ByteBuffer visualization,
- @Param("subs") Set<String> subElementIds);
-
- @Query("UPDATE element SET info=?, relations=?, data=?, searchable_data=?, visualization=?" +
- " WHERE space=? AND item_id=? AND version_id=? AND element_id=? ")
- void update(String info, String relations, ByteBuffer data, ByteBuffer searchableData,
- ByteBuffer visualization, String space, String itemId, String versionId,
- String elementId);
-
- @Query("DELETE FROM element WHERE space=? AND item_id=? AND version_id=? AND element_id=?")
- void delete(String space, String itemId, String versionId, String elementId);
-
- @Query("SELECT parent_id, namespace, info, relations, data, searchable_data, visualization, " +
- "sub_element_ids FROM element " +
- "WHERE space=? AND item_id=? AND version_id=? AND element_id=? ")
- ResultSet get(String space, String itemId, String versionId, String elementId);
-
- @Query("UPDATE element SET sub_element_ids=sub_element_ids+? " +
- " WHERE space=? AND item_id=? AND version_id=? AND element_id=? ")
- void addSubElements(Set<String> subElementIds, String space, String itemId, String versionId,
- String elementId);
-
- @Query("UPDATE element SET sub_element_ids=sub_element_ids-? " +
- " WHERE space=? AND item_id=? AND version_id=? AND element_id=? ")
- void removeSubElements(Set<String> subElementIds, String space, String itemId, String versionId,
- String elementId);
- }
-
- private static final class ElementField {
- private static final String NAMESPACE = "namespace";
- private static final String PARENT_ID = "parent_id";
- private static final String INFO = "info";
- private static final String RELATIONS = "relations";
- private static final String DATA = "data";
- private static final String SEARCHABLE_DATA = "searchable_data";
- private static final String VISUALIZATION = "visualization";
- private static final String SUB_ELEMENT_IDS = "sub_element_ids";
- }
-
- /*
- CREATE TABLE IF NOT EXISTS version_elements (
- space text,
- item_id text,
- version_id text,
- element_ids set<text>,
- PRIMARY KEY (( space, item_id, version_id ))
- );
- */
- @Accessor
- interface VersionElementsAccessor {
-
- @Query("UPDATE version_elements SET element_ids=element_ids+? " +
- "WHERE space=? AND item_id=? AND version_id=?")
- void addElements(Set<String> elementIds, String space, String itemId, String versionId);
-
- @Query("UPDATE version_elements SET element_ids=element_ids-? " +
- "WHERE space=? AND item_id=? AND version_id=?")
- void removeElements(Set<String> elementIds, String space, String itemId, String versionId);
-
- @Query("SELECT element_ids FROM version_elements WHERE space=? AND item_id=? AND version_id=?")
- ResultSet get(String space, String itemId, String versionId);
-
- @Query("SELECT element_ids FROM version_elements LIMIT 1")
- ResultSet checkHealth();
- }
-
- private static final class VersionElementsField {
- private static final String ELEMENT_IDS = "element_ids";
- }
-}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraDaoUtils.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/CassandraDaoUtils.java
similarity index 93%
rename from openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraDaoUtils.java
rename to openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/CassandraDaoUtils.java
index 20a1e18..b6cb9e4 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraDaoUtils.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/CassandraDaoUtils.java
@@ -1,9 +1,9 @@
-package org.openecomp.core.zusammen.plugin.dao.impl;
+package org.openecomp.core.zusammen.plugin.dao.impl.cassandra;
-import com.datastax.driver.core.Session;
import com.amdocs.zusammen.commons.db.api.cassandra.CassandraConnectorFactory;
import com.amdocs.zusammen.commons.db.api.cassandra.types.CassandraContext;
import com.amdocs.zusammen.datatypes.SessionContext;
+import com.datastax.driver.core.Session;
class CassandraDaoUtils {
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraElementRepositoryFactory.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/ElementRepositoryFactoryImpl.java
similarity index 80%
rename from openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraElementRepositoryFactory.java
rename to openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/ElementRepositoryFactoryImpl.java
index f3072a6..8540816 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraElementRepositoryFactory.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/ElementRepositoryFactoryImpl.java
@@ -14,15 +14,15 @@
* limitations under the License.
*/
-package org.openecomp.core.zusammen.plugin.dao.impl;
+package org.openecomp.core.zusammen.plugin.dao.impl.cassandra;
import com.amdocs.zusammen.datatypes.SessionContext;
import org.openecomp.core.zusammen.plugin.dao.ElementRepository;
import org.openecomp.core.zusammen.plugin.dao.ElementRepositoryFactory;
-public class CassandraElementRepositoryFactory extends ElementRepositoryFactory {
+public class ElementRepositoryFactoryImpl extends ElementRepositoryFactory {
- private static final ElementRepository INSTANCE = new CassandraElementRepository();
+ private static final ElementRepository INSTANCE = new ElementRepositoryImpl();
@Override
public ElementRepository createInterface(SessionContext context) {
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/ElementRepositoryImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/ElementRepositoryImpl.java
new file mode 100644
index 0000000..bb3b1cf
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/ElementRepositoryImpl.java
@@ -0,0 +1,565 @@
+/*
+ * Copyright © 2016-2017 European Support Limited
+ *
+ * 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.
+ */
+
+package org.openecomp.core.zusammen.plugin.dao.impl.cassandra;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.Namespace;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.Info;
+import com.amdocs.zusammen.datatypes.item.Relation;
+import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
+import com.amdocs.zusammen.utils.fileutils.json.JsonUtil;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+import com.datastax.driver.mapping.annotations.Accessor;
+import com.datastax.driver.mapping.annotations.Param;
+import com.datastax.driver.mapping.annotations.Query;
+import com.google.gson.reflect.TypeToken;
+import org.openecomp.core.zusammen.plugin.ZusammenPluginConstants;
+import org.openecomp.core.zusammen.plugin.dao.ElementRepository;
+import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
+
+import java.lang.reflect.Type;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.stream.Collectors;
+
+public class ElementRepositoryImpl implements ElementRepository {
+
+ @Override
+ public Map<Id, Id> listIds(SessionContext context, ElementEntityContext elementContext) {
+
+ if (elementContext.getRevisionId() == null) {
+ String revisionId = calculateLastRevisionId(context, elementContext);
+ if (revisionId == null) {
+ return new HashMap<>();
+ }
+
+ elementContext.setRevisionId(new Id(revisionId));
+ }
+ return getVersionElementIds(context, elementContext).entrySet().stream().collect(Collectors
+ .toMap(entry -> new Id(entry.getKey()), entry -> new Id(entry.getValue())));
+
+ /* return getVersionElementIds(context, elementContext).stream()
+ .map(Id::new)
+ .collect(Collectors.toList());*/
+
+ }
+
+ @Override
+ public void create(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element) {
+ createElement(context, elementContext, element);
+ addElementToParent(context, elementContext, element);
+ }
+
+ @Override
+ public void update(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element) {
+
+ Id elementRevisionId = getElementRevision(context, elementContext, element.getId());
+ if (elementRevisionId.equals(elementContext.getRevisionId())) {
+ updateElement(context, elementContext, element);
+ } else {
+ createElement(context, elementContext, element);
+ }
+ }
+
+ @Override
+ public void delete(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element) {
+ removeElementFromParent(context, elementContext, element);
+ deleteElement(context, elementContext, element);
+ }
+
+ @Override
+ public Optional<ElementEntity> get(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element) {
+ String revisionId = calculateElementRevisionId(context, elementContext, element);
+ if (revisionId == null) {
+ return Optional.empty();
+ }
+
+ Row row = getElementAccessor(context).get(
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().toString(),
+ element.getId().toString(),
+ revisionId).one();
+
+ return row == null ? Optional.empty() : Optional.of(getElementEntity(element, row));
+ }
+
+ @Override
+ public Optional<ElementEntity> getDescriptor(SessionContext context,
+ ElementEntityContext elementContext,
+ ElementEntity element) {
+ String revisionId = calculateElementRevisionId(context, elementContext, element);
+ if (revisionId == null) {
+ return Optional.empty();
+ }
+
+ Row row = getElementAccessor(context).getDescriptor(
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().toString(),
+ element.getId().toString(),
+ revisionId).one();
+
+ return row == null ? Optional.empty() : Optional.of(getElementEntityDescriptor(element, row));
+ }
+
+ @Override
+ public void createNamespace(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element) {
+ getElementNamespaceAccessor(context).create(elementContext.getItemId().toString(),
+ element.getId().toString(),
+ element.getNamespace().toString());
+ }
+
+ @Override
+ public Optional<Id> getHash(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element) {
+ String revisionId = calculateElementRevisionId(context, elementContext, element);
+ if (revisionId == null) {
+ return Optional.empty();
+ }
+
+ Row row = getElementAccessor(context).getHash(
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().getValue(),
+ element.getId().toString(),
+ revisionId).one();
+
+ return row == null ? Optional.empty() : Optional.of(getElementHash(row));
+ }
+
+ private String calculateElementRevisionId(SessionContext context,
+ ElementEntityContext elementContext,
+ ElementEntity element) {
+
+ if (elementContext.getSpace().equals(ZusammenPluginConstants.PUBLIC_SPACE)) {
+
+ String versionRevision;
+ if (elementContext.getRevisionId() == null) {
+ versionRevision = calculateLastRevisionId(context, elementContext);
+ } else {
+ versionRevision = elementContext.getRevisionId().getValue();
+ }
+
+ elementContext.setRevisionId(new Id(versionRevision));
+ Map<String, String> elementIds = getVersionElementIds(context, elementContext);
+ if (elementIds.containsKey(element.getId().getValue())) {
+ return elementIds.get(element.getId().getValue());
+ } else {
+ return null;
+ }
+
+ } else {
+ return Id.ZERO.getValue();
+ }
+ }
+
+ private String calculateLastRevisionId(SessionContext context, ElementEntityContext
+ elementContext) {
+ List<Row> rows = getVersionElementsAccessor(context).listRevisions(elementContext.getSpace(),
+ elementContext
+ .getItemId().toString(), elementContext.getVersionId().toString()).all();
+ if (rows == null || rows.size() == 0) {
+ return null;
+ }
+ rows.sort((o1, o2) -> o1.getDate(VersionElementsField.PUBLISH_TIME)
+ .after(o2.getDate(VersionElementsField.PUBLISH_TIME)) ? -1 : 1);
+ return rows.get(0).getString(VersionElementsField.REVISION_ID);
+ }
+
+ /*private static String getVersionId(ElementEntityContext elementContext) {
+ return elementContext.getRevisionId() == null
+ ? elementContext.getVersionId().toString()
+ : elementContext.getRevisionId().getValue();
+ }*/
+
+ private ElementNamespaceAccessor getElementNamespaceAccessor(SessionContext context) {
+ return CassandraDaoUtils.getAccessor(context, ElementNamespaceAccessor.class);
+ }
+
+ private ElementAccessor getElementAccessor(SessionContext context) {
+ return CassandraDaoUtils.getAccessor(context, ElementAccessor.class);
+ }
+
+ private VersionElementsAccessor getVersionElementsAccessor(SessionContext context) {
+ return CassandraDaoUtils.getAccessor(context, VersionElementsAccessor.class);
+ }
+
+ private void createElement(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element) {
+ createElementRow(context, elementContext, element);
+
+ Map<String, String> elementIds = new TreeMap<>();
+ elementIds.put(element.getId().toString(), elementContext.getRevisionId().getValue());
+ getVersionElementsAccessor(context).addElements(
+ elementIds,
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().getValue(),
+ elementContext.getRevisionId().getValue());
+ }
+
+ private void createElementRow(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element) {
+ Set<String> subElementIds =
+ element.getSubElementIds().stream().map(Id::toString).collect(Collectors.toSet());
+
+ getElementAccessor(context).create(
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().getValue(),
+ element.getId().toString(),
+ elementContext.getRevisionId().getValue(),
+ element.getParentId() == null ? null : element.getParentId().toString(),
+ element.getNamespace() == null ? null : element.getNamespace().toString(),
+ JsonUtil.object2Json(element.getInfo()),
+ JsonUtil.object2Json(element.getRelations()),
+ element.getData(),
+ element.getSearchableData(),
+ element.getVisualization(),
+ subElementIds,
+ element.getElementHash().getValue());
+ }
+
+ private void updateElement(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element) {
+
+
+ if (element.getParentId() == null) {
+ getElementAccessor(context).update(
+ JsonUtil.object2Json(element.getInfo()),
+ JsonUtil.object2Json(element.getRelations()),
+ element.getData(),
+ element.getSearchableData(),
+ element.getVisualization(),
+ element.getElementHash().getValue(),
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().toString(),
+ element.getId().toString(),
+ elementContext.getRevisionId().getValue());
+ } else {
+ getElementAccessor(context).update(
+ JsonUtil.object2Json(element.getInfo()),
+ JsonUtil.object2Json(element.getRelations()),
+ element.getData(),
+ element.getSearchableData(),
+ element.getVisualization(),
+ element.getElementHash().getValue(),
+ element.getParentId().getValue(),
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().toString(),
+ element.getId().getValue(),
+ elementContext.getRevisionId().getValue());
+ }
+
+ Map<String, String> elementIds = new TreeMap<>();
+ elementIds.put(element.getId().getValue(), elementContext.getRevisionId().getValue());
+ getVersionElementsAccessor(context).addElements(
+ elementIds,
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().getValue(),
+ elementContext.getRevisionId().getValue());
+ }
+
+ private void deleteElement(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element) {
+
+
+ getElementAccessor(context).delete(
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().toString(),
+ element.getId().toString(),
+ elementContext.getRevisionId().getValue());
+
+ getVersionElementsAccessor(context).removeElements(
+ Collections.singleton(element.getId().toString()),
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().toString(),
+ elementContext.getRevisionId().getValue());
+ }
+
+ private void addElementToParent(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element) {
+ if (element.getParentId() == null) {
+ return;
+ }
+
+
+ getElementAccessor(context).addSubElements(
+ Collections.singleton(element.getId().toString()),
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().toString(),
+ element.getParentId().toString(),
+ elementContext.getRevisionId().getValue());
+
+ Map<String, String> elementIds = new TreeMap<>();
+ elementIds.put(element.getParentId().toString(), elementContext.getRevisionId().getValue());
+ getVersionElementsAccessor(context).addElements(elementIds, elementContext.getSpace(),
+ elementContext.getItemId().getValue(), elementContext.getVersionId().getValue(),
+ elementContext.getRevisionId().getValue());
+ }
+
+ private void removeElementFromParent(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element) {
+
+ if (element.getParentId() == null) {
+ return;
+ }
+
+ Optional<ElementEntity> parentElement =
+ get(context, elementContext, new ElementEntity(element.getParentId()));
+ if (!parentElement.isPresent()) {
+ return;
+ }
+ getElementAccessor(context).removeSubElements(
+ Collections.singleton(element.getId().toString()),
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().toString(),
+ element.getParentId().toString(),
+ elementContext.getRevisionId().getValue());
+
+ getVersionElementsAccessor(context)
+ .removeElements(Collections.singleton(element.getId().toString()),
+ elementContext.getSpace(),
+ elementContext.getItemId().getValue(), elementContext.getVersionId().getValue(),
+ elementContext.getRevisionId().getValue());
+
+ Map<String, String> elementIds = new TreeMap<>();
+ elementIds.put(element.getParentId().toString(), elementContext.getRevisionId().getValue());
+ getVersionElementsAccessor(context).addElements(elementIds, elementContext.getSpace(),
+ elementContext.getItemId().getValue(), elementContext.getVersionId().getValue(),
+ elementContext.getRevisionId().getValue());
+ }
+
+ static ElementEntity getElementEntityDescriptor(ElementEntity element, Row row) {
+ element.setNamespace(getNamespace(row.getString(ElementField.NAMESPACE)));
+ element.setParentId(getParentId(row.getString(ElementField.PARENT_ID)));
+ element.setInfo(json2Object(row.getString(ElementField.INFO), Info.class));
+ element.setRelations(
+ json2Object(row.getString(ElementField.RELATIONS), new TypeToken<ArrayList<Relation>>() {
+ }.getType()));
+
+ element.setSubElementIds(row.getSet(ElementField.SUB_ELEMENT_IDS, String.class)
+ .stream().map(Id::new).collect(Collectors.toSet()));
+ return element;
+ }
+
+ static ElementEntity getElementEntity(ElementEntity element, Row row) {
+ getElementEntityDescriptor(element, row);
+
+ element.setData(row.getBytes(ElementField.DATA));
+ element.setSearchableData(row.getBytes(ElementField.SEARCHABLE_DATA));
+ element.setVisualization(row.getBytes(ElementField.VISUALIZATION));
+ element.setElementHash(new Id(row.getString(ElementField.ELEMENT_HASH)));
+ return element;
+ }
+
+ private Id getElementHash(Row row) {
+ return new Id(row.getString(ElementField.ELEMENT_HASH));
+ }
+
+ private static Id getParentId(String parentIdStr) {
+ return parentIdStr == null ? null : new Id(parentIdStr);
+ }
+
+ private static Namespace getNamespace(String namespaceStr) {
+ Namespace namespace = new Namespace();
+ if (namespaceStr != null) {
+ namespace.setValue(namespaceStr);
+ }
+ return namespace;
+ }
+
+ private static <T> T json2Object(String json, Type typeOfT) {
+ return json == null ? null : JsonUtil.json2Object(json, typeOfT);
+ }
+
+ private Map<String, String> getVersionElementIds(SessionContext context,
+ ElementEntityContext elementContext) {
+ Row row = getVersionElementsAccessor(context).get(
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().getValue(),
+ elementContext.getRevisionId().getValue()).one();
+ return row == null
+ ? new HashMap<>()
+ : row.getMap(ElementRepositoryImpl.VersionElementsField.ELEMENT_IDS, String.class, String
+ .class);
+ }
+
+ private Id getElementRevision(SessionContext context, ElementEntityContext elementContext
+ , Id elementId) {
+ Map<Id, Id> versionElementIds =
+ listIds(context, new ElementEntityContext
+ (elementContext.getSpace(), elementContext.getItemId(), elementContext.getVersionId(),
+ elementContext.getRevisionId()));
+ return versionElementIds.get(elementId);
+
+ }
+
+
+ /*
+CREATE TABLE IF NOT EXISTS element_namespace (
+ item_id text,
+ element_id text,
+ namespace text,
+ PRIMARY KEY (( item_id, element_id ))
+);
+ */
+ @Accessor
+ interface ElementNamespaceAccessor {
+ @Query("UPDATE element_namespace SET namespace=:ns " +
+ "WHERE item_id=:item AND element_id=:id ")
+ void create(@Param("item") String itemId,
+ @Param("id") String elementId,
+ @Param("ns") String namespace);
+ }
+
+ @Accessor
+ interface ElementAccessor {
+ @Query(
+ "UPDATE element SET parent_id=:parentId, namespace=:ns, info=:info, relations=:rels, " +
+ "data=:data, searchable_data=:searchableData, visualization=:visualization, " +
+ "sub_element_ids=sub_element_ids+:subs , element_hash=:elementHash " +
+ " WHERE space=:space AND item_id=:item AND version_id=:ver AND element_id=:id AND " +
+ "revision_id=:rev ")
+ void create(@Param("space") String space,
+ @Param("item") String itemId,
+ @Param("ver") String versionId,
+ @Param("id") String elementId,
+ @Param("rev") String revisionId,
+ @Param("parentId") String parentElementId,
+ @Param("ns") String namespace,
+ @Param("info") String info,
+ @Param("rels") String relations,
+ @Param("data") ByteBuffer data,
+ @Param("searchableData") ByteBuffer searchableData,
+ @Param("visualization") ByteBuffer visualization,
+ @Param("subs") Set<String> subElementIds,
+ @Param("elementHash") String elementHash);
+
+
+ @Query("UPDATE element SET info=?, relations=?, data=?, searchable_data=?, visualization=? ," +
+ "element_hash=? , parent_id=? " +
+ " WHERE space=? AND item_id=? AND version_id=? AND element_id=? AND revision_id=? ")
+ void update(String info, String relations, ByteBuffer data, ByteBuffer searchableData,
+ ByteBuffer visualization, String elementHash, String parentId, String space, String
+ itemId, String
+ versionId, String elementId, String revisionId);
+
+ @Query("UPDATE element SET info=?, relations=?, data=?, searchable_data=?, visualization=? ," +
+ "element_hash=? " +
+ " WHERE space=? AND item_id=? AND version_id=? AND element_id=? AND revision_id=? ")
+ void update(String info, String relations, ByteBuffer data, ByteBuffer searchableData,
+ ByteBuffer visualization, String elementHash, String space, String
+ itemId, String
+ versionId, String elementId, String revisionId);
+
+ @Query(
+ "DELETE FROM element WHERE space=? AND item_id=? AND version_id=? AND element_id=? AND revision_id=? ")
+ void delete(String space, String itemId, String versionId, String elementId, String revisionId);
+
+ @Query("SELECT parent_id, namespace, info, relations, data, searchable_data, visualization, " +
+ "sub_element_ids,element_hash FROM element " +
+ "WHERE space=? AND item_id=? AND version_id=? AND element_id=? AND revision_id=? ")
+ ResultSet get(String space, String itemId, String versionId, String elementId, String
+ revisionId);
+
+ @Query("SELECT parent_id, namespace, info, relations, sub_element_ids FROM element " +
+ "WHERE space=? AND item_id=? AND version_id=? AND element_id=? AND revision_id=? ")
+ ResultSet getDescriptor(String space, String itemId, String versionId, String elementId,
+ String revisionId);
+
+ @Query("UPDATE element SET sub_element_ids=sub_element_ids+? " +
+ " WHERE space=? AND item_id=? AND version_id=? AND element_id=? AND revision_id=? ")
+ void addSubElements(Set<String> subElementIds, String space, String itemId, String versionId,
+ String elementId, String revisionId);
+
+ @Query("UPDATE element SET sub_element_ids=sub_element_ids-? " +
+ " WHERE space=? AND item_id=? AND version_id=? AND element_id=? AND revision_id=? ")
+ void removeSubElements(Set<String> subElementIds, String space, String itemId, String versionId,
+ String elementId, String revisionId);
+
+ @Query("SELECT element_hash FROM element " +
+ "WHERE space=? AND item_id=? AND version_id=? AND element_id=? AND revision_id=? ")
+ ResultSet getHash(String space, String itemId, String versionId, String elementId, String
+ revisionId);
+ }
+
+ private static final class ElementField {
+ private static final String NAMESPACE = "namespace";
+ private static final String PARENT_ID = "parent_id";
+ private static final String INFO = "info";
+ private static final String RELATIONS = "relations";
+ private static final String DATA = "data";
+ private static final String SEARCHABLE_DATA = "searchable_data";
+ private static final String VISUALIZATION = "visualization";
+ private static final String SUB_ELEMENT_IDS = "sub_element_ids";
+ private static final String ELEMENT_HASH = "element_hash";
+ }
+
+ @Accessor
+ interface VersionElementsAccessor {
+
+ @Query("UPDATE version_elements SET element_ids=element_ids+ ? " +
+ "WHERE space=? AND item_id=? AND version_id=? AND revision_id=? ")
+ void addElements(Map<String, String> elementIds, String space, String itemId, String versionId,
+ String versionRevisionId);
+
+ @Query("UPDATE version_elements SET element_ids=element_ids-? " +
+ "WHERE space=? AND item_id=? AND version_id=? AND revision_id=?")
+ void removeElements(Set<String> elementIds, String space, String itemId, String versionId,
+ String revisionId);
+
+ @Query(
+ "SELECT element_ids FROM version_elements WHERE space=? AND item_id=? AND version_id=? AND revision_id=? ")
+ ResultSet get(String space, String itemId, String versionId, String revisionId);
+
+ @Query(
+ "SELECT revision_id,publish_time FROM version_elements WHERE space=? AND item_id=? AND " +
+ "version_id=? ")
+ ResultSet listRevisions(String space, String itemId, String versionId);
+
+ }
+
+ private static final class VersionElementsField {
+ private static final String ELEMENT_IDS = "element_ids";
+ private static final String REVISION_ID = "revision_id";
+ private static final String PUBLISH_TIME = "publish_time";
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraElementRepositoryFactory.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/ElementStageRepositoryFactoryImpl.java
similarity index 60%
copy from openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraElementRepositoryFactory.java
copy to openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/ElementStageRepositoryFactoryImpl.java
index f3072a6..02bec12 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/CassandraElementRepositoryFactory.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/ElementStageRepositoryFactoryImpl.java
@@ -14,18 +14,18 @@
* limitations under the License.
*/
-package org.openecomp.core.zusammen.plugin.dao.impl;
+package org.openecomp.core.zusammen.plugin.dao.impl.cassandra;
import com.amdocs.zusammen.datatypes.SessionContext;
-import org.openecomp.core.zusammen.plugin.dao.ElementRepository;
-import org.openecomp.core.zusammen.plugin.dao.ElementRepositoryFactory;
+import org.openecomp.core.zusammen.plugin.dao.ElementStageRepository;
+import org.openecomp.core.zusammen.plugin.dao.ElementStageRepositoryFactory;
-public class CassandraElementRepositoryFactory extends ElementRepositoryFactory {
+public class ElementStageRepositoryFactoryImpl extends ElementStageRepositoryFactory {
- private static final ElementRepository INSTANCE = new CassandraElementRepository();
+ private static final ElementStageRepository INSTANCE = new ElementStageRepositoryImpl();
@Override
- public ElementRepository createInterface(SessionContext context) {
+ public ElementStageRepository createInterface(SessionContext context) {
return INSTANCE;
}
}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/ElementStageRepositoryImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/ElementStageRepositoryImpl.java
new file mode 100644
index 0000000..c215f82
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/ElementStageRepositoryImpl.java
@@ -0,0 +1,423 @@
+/*
+ * Copyright © 2016-2017 European Support Limited
+ *
+ * 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.
+ */
+
+package org.openecomp.core.zusammen.plugin.dao.impl.cassandra;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.Action;
+import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
+import com.amdocs.zusammen.utils.fileutils.json.JsonUtil;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+import com.datastax.driver.mapping.annotations.Accessor;
+import com.datastax.driver.mapping.annotations.Param;
+import com.datastax.driver.mapping.annotations.Query;
+import org.openecomp.core.zusammen.plugin.dao.ElementStageRepository;
+import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
+import org.openecomp.core.zusammen.plugin.dao.types.StageEntity;
+
+import java.nio.ByteBuffer;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+public class ElementStageRepositoryImpl implements ElementStageRepository {
+
+ @Override
+ public Collection<ElementEntity> listIds(SessionContext context,
+ ElementEntityContext elementContext) {
+ return getElements(getStageElementIds(context, elementContext));
+ }
+
+ @Override
+ public Collection<ElementEntity> listConflictedIds(SessionContext context,
+ ElementEntityContext elementContext) {
+ return getElements(getConflictedElementIds(context, elementContext));
+ }
+
+ @Override
+ public void create(SessionContext context, ElementEntityContext elementContext,
+ StageEntity<ElementEntity> elementStage) {
+ createElement(context, elementContext, elementStage);
+ addElementToParent(context, elementContext, elementStage.getEntity());
+ }
+
+ @Override
+ public void markAsNotConflicted(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element, Action action) {
+ getElementStageAccessor(context).updateState(action, false,
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().toString(),
+ element.getId().toString());
+
+ getStageElementsAccessor(context).removeConflictElements(
+ Collections.singleton(element.getId().toString()),
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().toString(),
+ elementContext.getRevisionId().getValue());
+ }
+
+ @Override
+ public void markAsNotConflicted(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element) {
+ getElementStageAccessor(context).markAsNotConflicted(
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().toString(),
+ element.getId().toString());
+
+ getStageElementsAccessor(context).removeConflictElements(
+ Collections.singleton(element.getId().toString()),
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().toString(),
+ elementContext.getRevisionId().getValue());
+ }
+
+ @Override
+ public void update(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element, Action action, boolean conflicted) {
+ getElementStageAccessor(context).update(
+ JsonUtil.object2Json(element.getInfo()),
+ JsonUtil.object2Json(element.getRelations()),
+ element.getData(),
+ element.getSearchableData(),
+ element.getVisualization(),
+ element.getElementHash().getValue(),
+ action,
+ conflicted,
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().toString(),
+ element.getId().toString());
+
+ if (!conflicted) {
+ getStageElementsAccessor(context).removeConflictElements(
+ Collections.singleton(element.getId().toString()),
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().toString(),
+ elementContext.getRevisionId().getValue());
+ }
+ }
+
+ @Override
+ public void delete(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element) {
+ removeElementFromParent(context, elementContext, element);
+ deleteElement(context, elementContext, element);
+ }
+
+ @Override
+ public Optional<StageEntity<ElementEntity>> get(SessionContext context,
+ ElementEntityContext elementContext,
+ ElementEntity element) {
+ Row row = getElementStageAccessor(context).get(
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().getValue(),
+ element.getId().toString()).one();
+
+ return row == null ? Optional.empty() : Optional.of(getStageElement(row));
+ }
+
+ @Override
+ public Optional<StageEntity<ElementEntity>> getDescriptor(SessionContext context,
+ ElementEntityContext elementContext,
+ ElementEntity element) {
+ Row row = getElementStageAccessor(context).getDescriptor(
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().getValue(),
+ element.getId().toString()).one();
+
+ return row == null ? Optional.empty() : Optional.of(getStageElementDescriptor(row));
+ }
+
+
+
+ private Collection<ElementEntity> getElements(Set<String> elementIds) {
+ return elementIds.stream()
+ .map(id -> new ElementEntity(new Id(id)))
+ .collect(Collectors.toList());
+ }
+
+ private void createElement(SessionContext context, ElementEntityContext elementContext,
+ StageEntity<ElementEntity> elementStage) {
+
+
+ ElementEntity element = elementStage.getEntity();
+ Set<String> subElementIds =
+ element.getSubElementIds().stream().map(Id::toString).collect(Collectors.toSet());
+ Set<String> conflictDependents = elementStage.getConflictDependents().stream()
+ .map(conflictDependent -> conflictDependent.getId().getValue())
+ .collect(Collectors.toSet());
+
+ getElementStageAccessor(context).create(
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().getValue(),
+ element.getId().toString(),
+ element.getParentId() == null ? null : element.getParentId().toString(),
+ element.getNamespace() == null ? null : element.getNamespace().toString(),
+ JsonUtil.object2Json(element.getInfo()),
+ JsonUtil.object2Json(element.getRelations()),
+ element.getData(),
+ element.getSearchableData(),
+ element.getVisualization(),
+ subElementIds,
+ element.getElementHash() == null ? null : element.getElementHash().getValue(),
+ elementStage.getPublishTime(),
+ elementStage.getAction(),
+ elementStage.isConflicted(),
+ conflictDependents);
+
+ getStageElementsAccessor(context).add(
+ Collections.singleton(element.getId().toString()),
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().getValue(),
+ elementContext.getRevisionId().getValue());
+
+ if (elementStage.isConflicted()) {
+ getStageElementsAccessor(context).addConflictElements(
+ Collections.singleton(element.getId().toString()),
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().getValue(),
+ elementContext.getRevisionId().getValue());
+ }
+ }
+
+ private void deleteElement(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element) {
+
+
+ getElementStageAccessor(context).delete(
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().getValue(),
+ element.getId().toString());
+
+ getStageElementsAccessor(context).remove(
+ Collections.singleton(element.getId().toString()),
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().getValue(),
+ elementContext.getRevisionId().getValue());
+ }
+
+ private void addElementToParent(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element) {
+ if (element.getParentId() == null) {
+ return;
+ }
+ getElementStageAccessor(context).addSubElements(
+ Collections.singleton(element.getId().toString()),
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().getValue(),
+ element.getParentId().toString());
+ }
+
+ private void removeElementFromParent(SessionContext context, ElementEntityContext elementContext,
+ ElementEntity element) {
+ if (element.getParentId() == null) {
+ return;
+ }
+ getElementStageAccessor(context).removeSubElements(
+ Collections.singleton(element.getId().toString()),
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().getValue(),
+ element.getParentId().toString());
+ }
+
+ private StageEntity<ElementEntity> getStageElementDescriptor(Row row) {
+ return buildStageElement(ElementRepositoryImpl.getElementEntityDescriptor(
+ new ElementEntity(new Id(row.getString(ElementStageField.ID))), row), row);
+ }
+
+ private StageEntity<ElementEntity> getStageElement(Row row) {
+ return buildStageElement(ElementRepositoryImpl.getElementEntity(
+ new ElementEntity(new Id(row.getString(ElementStageField.ID))), row), row);
+ }
+
+
+ private StageEntity<ElementEntity> buildStageElement(ElementEntity element, Row row) {
+ StageEntity<ElementEntity> elementStage =
+ new StageEntity<>(element, row.getDate(ElementStageField.PUBLISH_TIME));
+ elementStage.setAction(Action.valueOf(row.getString(ElementStageField.ACTION)));
+ elementStage.setConflicted(row.getBool(ElementStageField.CONFLICTED));
+ elementStage.setConflictDependents(
+ row.getSet(ElementStageField.CONFLICT_DEPENDENTS, String.class).stream()
+ .map(conflictDependentId -> new ElementEntity(new Id(conflictDependentId)))
+ .collect(Collectors.toSet()));
+ return elementStage;
+ }
+
+ private Set<String> getStageElementIds(SessionContext context,
+ ElementEntityContext elementContext) {
+ Row row = getStageElementsAccessor(context).get(
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().getValue(),
+ elementContext.getRevisionId().getValue()).one();
+ return row == null ? new HashSet<>()
+ : row.getSet(StageElementsField.STAGE_ELEMENT_IDS, String.class);
+ }
+
+ private Set<String> getConflictedElementIds(SessionContext context,
+ ElementEntityContext elementContext) {
+ Row row = getStageElementsAccessor(context).getConflicted(
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().getValue(),
+ elementContext.getRevisionId().getValue()).one();
+ return row == null ? new HashSet<>()
+ : row.getSet(StageElementsField.CONFLICT_ELEMENT_IDS, String.class);
+ }
+
+ private ElementStageAccessor getElementStageAccessor(SessionContext context) {
+ return CassandraDaoUtils.getAccessor(context, ElementStageAccessor.class);
+ }
+
+ private StageElementsAccessor getStageElementsAccessor(SessionContext context) {
+ return CassandraDaoUtils.getAccessor(context, StageElementsAccessor.class);
+ }
+
+ @Accessor
+ interface ElementStageAccessor {
+ @Query(
+ "UPDATE element_stage SET parent_id=:parentId, namespace=:ns, info=:info, relations=:rels, " +
+ "data=:data, searchable_data=:searchableData, visualization=:visualization, " +
+ "publish_time=:publishTime, action=:action, " +
+ "conflicted=:conflicted, conflict_dependent_ids=:conflictDependents, " +
+ "sub_element_ids=sub_element_ids+:subs, element_hash=:elementHash " +
+ "WHERE space=:space AND item_id=:item AND version_id=:ver AND element_id=:id ")
+ void create(@Param("space") String space,
+ @Param("item") String itemId,
+ @Param("ver") String versionId,
+ @Param("id") String elementId,
+ @Param("parentId") String parentElementId,
+ @Param("ns") String namespace,
+ @Param("info") String info,
+ @Param("rels") String relations,
+ @Param("data") ByteBuffer data,
+ @Param("searchableData") ByteBuffer searchableData,
+ @Param("visualization") ByteBuffer visualization,
+ @Param("subs") Set<String> subElementIds,
+ @Param("elementHash") String elementHash,
+ @Param("publishTime") Date publishTime,
+ @Param("action") Action action,
+ @Param("conflicted") boolean conflicted,
+ @Param("conflictDependents") Set<String> conflictDependents);
+
+ @Query("UPDATE element_stage SET info=?, relations=?, data=?, searchable_data=?, " +
+ "visualization=?,element_hash=?, action=?, conflicted=? " +
+ " WHERE space=? AND item_id=? AND version_id=? AND element_id=? ")
+ void update(String info, String relations, ByteBuffer data, ByteBuffer searchableData,
+ ByteBuffer visualization, String elementHash, Action action, boolean conflicted,
+ String space,
+ String itemId, String versionId, String elementId);
+
+ @Query("UPDATE element_stage SET action=?, conflicted=? " +
+ " WHERE space=? AND item_id=? AND version_id=? AND element_id=? ")
+ void updateState(Action action, boolean conflicted, String space, String itemId,
+ String versionId, String elementId);
+
+ @Query("UPDATE element_stage SET conflicted=false " +
+ " WHERE space=? AND item_id=? AND version_id=? AND element_id=? ")
+ void markAsNotConflicted(String space, String itemId, String versionId, String elementId);
+
+ @Query(
+ "DELETE FROM element_stage WHERE space=? AND item_id=? AND version_id=? AND element_id=?")
+ void delete(String space, String itemId, String versionId, String elementId);
+
+ @Query("SELECT element_id, parent_id, namespace, info, relations, data, searchable_data, " +
+ "visualization, sub_element_ids,element_hash, publish_time, action, " +
+ "conflicted, conflict_dependent_ids FROM element_stage " +
+ "WHERE space=? AND item_id=? AND version_id=? AND element_id=? ")
+ ResultSet get(String space, String itemId, String versionId, String elementId);
+
+ @Query("SELECT element_id, parent_id, namespace, info, relations, " +
+ "sub_element_ids, publish_time, action, conflicted, conflict_dependent_ids " +
+ "FROM element_stage WHERE space=? AND item_id=? AND version_id=? AND element_id=? ")
+ ResultSet getDescriptor(String space, String itemId, String versionId, String elementId);
+
+ @Query("UPDATE element_stage SET sub_element_ids=sub_element_ids+? " +
+ " WHERE space=? AND item_id=? AND version_id=? AND element_id=? ")
+ void addSubElements(Set<String> subElementIds, String space, String itemId, String versionId,
+ String elementId);
+
+ @Query("UPDATE element_stage SET sub_element_ids=sub_element_ids-? " +
+ " WHERE space=? AND item_id=? AND version_id=? AND element_id=? ")
+ void removeSubElements(Set<String> subElementIds, String space, String itemId, String versionId,
+ String elementId);
+ }
+
+ private static final class ElementStageField {
+ private static final String ID = "element_id";
+ private static final String PUBLISH_TIME = "publish_time";
+ private static final String ACTION = "action";
+ private static final String CONFLICTED = "conflicted";
+ private static final String CONFLICT_DEPENDENTS = "conflict_dependent_ids";
+ }
+
+ @Accessor
+ interface StageElementsAccessor {
+
+ @Query("UPDATE version_elements SET stage_element_ids=stage_element_ids+? " +
+ "WHERE space=? AND item_id=? AND version_id=? AND revision_id=? ")
+ void add(Set<String> elementIds, String space, String itemId, String versionId, String
+ revisionId);
+
+ @Query("UPDATE version_elements SET stage_element_ids=stage_element_ids-? " +
+ "WHERE space=? AND item_id=? AND version_id=? AND revision_id=? ")
+ void remove(Set<String> elementIds, String space, String itemId, String versionId, String
+ revisionId);
+
+ @Query("SELECT stage_element_ids FROM version_elements " +
+ "WHERE space=? AND item_id=? AND version_id=? AND revision_id=?")
+ ResultSet get(String space, String itemId, String versionId, String revisionId);
+
+ @Query("UPDATE version_elements SET conflict_element_ids=conflict_element_ids+? " +
+ "WHERE space=? AND item_id=? AND version_id=? AND revision_id=? ")
+ void addConflictElements(Set<String> elementIds, String space, String itemId, String
+ versionId, String revisionId);
+
+ @Query("UPDATE version_elements SET conflict_element_ids=conflict_element_ids-? " +
+ "WHERE space=? AND item_id=? AND version_id=? AND revision_id=? ")
+ void removeConflictElements(Set<String> elementIds, String space, String itemId,
+ String versionId, String revisionId);
+
+ @Query("SELECT conflict_element_ids FROM version_elements " +
+ "WHERE space=? AND item_id=? AND version_id=? AND revision_id=? ")
+ ResultSet getConflicted(String space, String itemId, String versionId, String revisionId);
+ }
+
+ private static final class StageElementsField {
+ private static final String STAGE_ELEMENT_IDS = "stage_element_ids";
+ private static final String CONFLICT_ELEMENT_IDS = "conflict_element_ids";
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/ElementSynchronizationStateRepositoryFactoryImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/ElementSynchronizationStateRepositoryFactoryImpl.java
new file mode 100644
index 0000000..ec7e1c3
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/ElementSynchronizationStateRepositoryFactoryImpl.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright © 2016-2017 European Support Limited
+ *
+ * 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.
+ */
+
+package org.openecomp.core.zusammen.plugin.dao.impl.cassandra;
+
+import com.amdocs.zusammen.datatypes.SessionContext;
+import org.openecomp.core.zusammen.plugin.dao.ElementSynchronizationStateRepository;
+import org.openecomp.core.zusammen.plugin.dao.ElementSynchronizationStateRepositoryFactory;
+
+public class ElementSynchronizationStateRepositoryFactoryImpl
+ extends ElementSynchronizationStateRepositoryFactory {
+
+ private static final ElementSynchronizationStateRepository INSTANCE =
+ new ElementSynchronizationStateRepositoryImpl();
+
+ @Override
+ public ElementSynchronizationStateRepository createInterface(SessionContext context) {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/ElementSynchronizationStateRepositoryImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/ElementSynchronizationStateRepositoryImpl.java
new file mode 100644
index 0000000..d41d3d7
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/ElementSynchronizationStateRepositoryImpl.java
@@ -0,0 +1,209 @@
+package org.openecomp.core.zusammen.plugin.dao.impl.cassandra;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+import com.datastax.driver.mapping.annotations.Accessor;
+import com.datastax.driver.mapping.annotations.Query;
+import org.openecomp.core.zusammen.plugin.dao.ElementSynchronizationStateRepository;
+import org.openecomp.core.zusammen.plugin.dao.types.SynchronizationStateEntity;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+public class ElementSynchronizationStateRepositoryImpl
+ implements ElementSynchronizationStateRepository {
+
+ @Override
+ public Collection<SynchronizationStateEntity> list(SessionContext context,
+ ElementEntityContext elementContext) {
+ List<Row> rows = getAccessor(context)
+ .list(elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().toString()).all();
+ return rows == null ? new HashSet<>()
+ : rows.stream().map(this::getSynchronizationStateEntity).collect(Collectors.toSet());
+
+ }
+
+ @Override
+ public void create(SessionContext context, ElementEntityContext elementContext,
+ SynchronizationStateEntity elementSyncState) {
+ update(context, elementContext.getSpace(),
+ elementContext.getItemId(),
+ elementContext.getVersionId(),
+ elementContext.getRevisionId(),
+ elementSyncState.getRevisionId(),
+ elementSyncState.getId(),
+ elementSyncState.getPublishTime(),
+ elementSyncState.isDirty()
+
+ );
+ }
+
+ @Override
+ public void update(SessionContext context, ElementEntityContext elementContext,
+ SynchronizationStateEntity elementSyncState) {
+ update(context, elementContext.getSpace(),
+ elementContext.getItemId(),
+ elementContext.getVersionId(),
+ elementContext.getRevisionId(),
+ elementSyncState.getRevisionId(),
+ elementSyncState.getId(),
+ elementSyncState.getPublishTime(),
+ elementSyncState.isDirty()
+
+ );
+ }
+
+ @Override
+ public void markAsDirty(SessionContext context, ElementEntityContext elementContext,
+ SynchronizationStateEntity elementSyncState) {
+
+
+ getAccessor(context).updateDirty(true,
+ elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().toString(),
+ elementSyncState.getId().toString(),
+ elementContext.getRevisionId().getValue());
+
+ getVersionElementsAccessor(context).addDirtyElements(
+ Collections.singleton(elementSyncState.getId().toString()), elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().toString(),
+ elementContext.getRevisionId().getValue());
+ }
+
+ @Override
+ public void delete(SessionContext context, ElementEntityContext elementContext,
+ SynchronizationStateEntity elementSyncState) {
+ getAccessor(context).delete(elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().toString(),
+ elementSyncState.getId().toString(),
+ elementContext.getRevisionId().getValue());
+
+ getVersionElementsAccessor(context).removeDirtyElements(
+ Collections.singleton(elementSyncState.getId().toString()), elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().toString(),
+ elementContext.getRevisionId().getValue());
+ }
+
+ @Override
+ public Optional<SynchronizationStateEntity> get(SessionContext context,
+ ElementEntityContext elementContext,
+ SynchronizationStateEntity elementSyncState) {
+
+ Row row = getAccessor(context)
+ .get(elementContext.getSpace(),
+ elementContext.getItemId().toString(),
+ elementContext.getVersionId().toString(),
+ elementSyncState.getId().toString(),
+ elementSyncState.getRevisionId().getValue()).one();
+
+ return row == null ? Optional.empty() : Optional.of(getSynchronizationStateEntity(row));
+ }
+
+ private void update(SessionContext context, String space, Id itemId, Id versionId, Id
+ versionRevisionId,Id elementRevisionId,Id elementId, Date publishTime, boolean isDirty) {
+ getAccessor(context).update(publishTime,
+ isDirty,
+ space,
+ itemId.toString(),
+ versionId.toString(),
+ elementId.toString(),
+ elementRevisionId.getValue());
+
+ if (isDirty) {
+ getVersionElementsAccessor(context).addDirtyElements(
+ Collections.singleton(elementId.toString()), space,
+ itemId.toString(),
+ versionId.toString(),
+ versionRevisionId.getValue());
+ } else {
+ getVersionElementsAccessor(context).removeDirtyElements(
+ Collections.singleton(elementId.toString()), space,
+ itemId.toString(),
+ versionId.toString(),
+ versionRevisionId.getValue());
+ }
+ }
+
+
+ private SynchronizationStateEntity getSynchronizationStateEntity(Row row) {
+ SynchronizationStateEntity entity =
+ new SynchronizationStateEntity(new Id(row.getString(SynchronizationStateField.ID)),
+ new Id(row.getString(SynchronizationStateField.REVISION_ID)),
+ row.getDate(SynchronizationStateField.PUBLISH_TIME),
+ row.getBool(SynchronizationStateField.DIRTY));
+ entity.setRevisionId(new Id(row.getString(SynchronizationStateField.REVISION_ID)));
+
+ return entity;
+
+ }
+
+ private ElementSynchronizationStateAccessor getAccessor(SessionContext context) {
+ return CassandraDaoUtils.getAccessor(context, ElementSynchronizationStateAccessor.class);
+ }
+
+ private VersionElementsAccessor getVersionElementsAccessor(SessionContext context) {
+ return CassandraDaoUtils.getAccessor(context, VersionElementsAccessor.class);
+ }
+
+ @Accessor
+ interface ElementSynchronizationStateAccessor {
+ @Query("UPDATE element_synchronization_state SET publish_time=?, dirty=? " +
+ "WHERE space=? AND item_id=? AND version_id=? AND element_id=? AND revision_id = ? ")
+ void update(Date publishTime, boolean dirty, String space, String itemId, String versionId,
+ String elementId, String revisionId);
+
+ @Query("UPDATE element_synchronization_state SET dirty=? " +
+ "WHERE space=? AND item_id=? AND version_id=? AND element_id=? AND revision_id = ? ")
+ void updateDirty(boolean dirty, String space, String itemId, String versionId,
+ String elementId, String revisionId);
+
+ @Query("DELETE FROM element_synchronization_state " +
+ "WHERE space=? AND item_id=? AND version_id=? AND element_id=? AND revision_id = ? ")
+ void delete(String space, String itemId, String versionId, String elementId, String revisionId);
+
+ @Query("SELECT element_id,revision_id, publish_time, dirty FROM element_synchronization_state" +
+ " WHERE space=? AND item_id=? AND version_id=?")
+ ResultSet list(String space, String itemId, String versionId);
+
+ @Query("SELECT element_id,revision_id, publish_time, dirty FROM element_synchronization_state" +
+ " WHERE space=? AND item_id=? AND version_id=? AND element_id=? AND revision_id = ? ")
+ ResultSet get(String space, String itemId, String versionId, String elementId, String
+ revisionId);
+ }
+
+ private static final class SynchronizationStateField {
+ private static final String ID = "element_id";
+ private static final String PUBLISH_TIME = "publish_time";
+ private static final String DIRTY = "dirty";
+ private static final String REVISION_ID = "revision_id";
+ }
+
+ @Accessor
+ interface VersionElementsAccessor {
+
+ @Query("UPDATE version_elements SET dirty_element_ids=dirty_element_ids+? " +
+ "WHERE space=? AND item_id=? AND version_id=? AND revision_id=?")
+ void addDirtyElements(Set<String> elementIds, String space, String itemId, String versionId,
+ String revisionId);
+
+ @Query("UPDATE version_elements SET dirty_element_ids=dirty_element_ids-? " +
+ "WHERE space=? AND item_id=? AND version_id=? AND revision_id=? ")
+ void removeDirtyElements(Set<String> elementIds, String space, String itemId, String
+ versionId, String revisionId);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/VersionDaoFactoryImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/VersionDaoFactoryImpl.java
new file mode 100644
index 0000000..60dc9d17
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/VersionDaoFactoryImpl.java
@@ -0,0 +1,15 @@
+package org.openecomp.core.zusammen.plugin.dao.impl.cassandra;
+
+import com.amdocs.zusammen.datatypes.SessionContext;
+import org.openecomp.core.zusammen.plugin.dao.VersionDao;
+import org.openecomp.core.zusammen.plugin.dao.VersionDaoFactory;
+
+public class VersionDaoFactoryImpl extends VersionDaoFactory {
+
+ private static final VersionDao INSTANCE = new VersionDaoImpl();
+
+ @Override
+ public VersionDao createInterface(SessionContext context) {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/VersionDaoImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/VersionDaoImpl.java
new file mode 100644
index 0000000..bba2ddf
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/VersionDaoImpl.java
@@ -0,0 +1,185 @@
+package org.openecomp.core.zusammen.plugin.dao.impl.cassandra;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+import com.datastax.driver.mapping.annotations.Accessor;
+import com.datastax.driver.mapping.annotations.Query;
+import org.openecomp.core.zusammen.plugin.dao.VersionDao;
+import org.openecomp.core.zusammen.plugin.dao.types.VersionEntity;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+import static java.util.stream.Collectors.toMap;
+
+public class VersionDaoImpl implements VersionDao {
+
+ @Override
+ public void create(SessionContext context, String space, Id itemId, VersionEntity version) {
+ String baseVersion = version.getBaseId() != null ? version.getBaseId().toString() : null;
+
+ getAccessor(context)
+ .create(space, itemId.toString(), version.getId().toString(),
+ baseVersion,
+ version.getCreationTime(), version.getModificationTime());
+
+ }
+
+ @Override
+ public void delete(SessionContext context, String space, Id itemId, Id versionId) {
+
+ getAccessor(context).delete(space, itemId.toString(), versionId.toString());
+ }
+
+ @Override
+ public void updateModificationTime(SessionContext context, String space, Id itemId,
+ Id versionId, Date modificationTime) {
+ getAccessor(context)
+ .updateModificationTime(modificationTime, space, itemId.toString(), versionId.toString());
+ }
+
+
+ @Override
+ public Collection<VersionEntity> list(SessionContext context, String space, Id itemId) {
+ List<Row> rows = getAccessor(context).list(space, itemId.toString()).all();
+ return rows == null ? new ArrayList<>() :
+ rows.stream().map(VersionDaoImpl::convertToVersionEntity).collect(Collectors.toList());
+ }
+
+
+ @Override
+ public Optional<VersionEntity> get(SessionContext context, String space, Id itemId,
+ Id versionId) {
+ Row row;
+
+ row = getAccessor(context).get(space, itemId.toString(), versionId.toString()).one();
+
+
+ return row == null ? Optional.empty() : Optional.of(convertToVersionEntity(row));
+ }
+
+ @Override
+ public boolean checkHealth(SessionContext context) {
+ return getAccessor(context).checkHealth().getColumnDefinitions()
+ .contains(VersionField.VERSION_ID);
+ }
+
+ @Override
+ public void createVersionElements(SessionContext context, String space, Id itemId,
+ Id versionId, Id revisionId, Map<Id, Id> versionElementIds,
+ Date publishTime, String message) {
+ Map<String, String> elementIds = versionElementIds==null?null:versionElementIds.
+ entrySet().
+ stream().
+ collect(toMap((Map.Entry<Id, Id>entry)->entry.getKey().getValue(),
+ (Map.Entry<Id, Id>entry)->entry.getValue().getValue()));
+
+ getVersionElementsAccessor(context).create(space,itemId.toString(),versionId.toString(),
+ revisionId.getValue(),elementIds,publishTime,message,context.getUser().getUserName());
+ }
+
+
+ private static VersionEntity convertToVersionEntity(Row row) {
+
+ /*Id revisionId = row.getColumnDefinitions().contains("revision_id")?new Id(row.getString
+ (VersionField.REVISION_ID)):null;*/
+
+ VersionEntity version = new VersionEntity(new Id(row.getString(VersionField.VERSION_ID)));
+ return enrichVersionEntity(version, row);
+ }
+
+ static VersionEntity enrichVersionEntity(VersionEntity version, Row row) {
+ version.setBaseId(new Id(row.getString(VersionField.BASE_VERSION_ID)));
+ version.setCreationTime(row.getDate(VersionField.CREATION_TIME));
+ version.setModificationTime(row.getDate(VersionField.MODIFICATION_TIME));
+ return version;
+ }
+
+ private VersionAccessor getAccessor(SessionContext context) {
+ return CassandraDaoUtils.getAccessor(context, VersionAccessor.class);
+ }
+
+ private VersionElementsAccessor getVersionElementsAccessor(SessionContext context) {
+ return CassandraDaoUtils.getAccessor(context, VersionElementsAccessor.class);
+ }
+
+ @Accessor
+ interface VersionAccessor {
+
+ @Query(
+ "INSERT INTO version (space, item_id, version_id, base_version_id, " +
+ "creation_time, " +
+ "modification_time) " +
+ "VALUES (?, ?, ?, ?, ?, ?)")
+ void create(String space, String itemId, String versionId, String baseVersionId,
+ Date creationTime, Date modificationTime);
+
+ @Query("UPDATE version SET modification_time=? WHERE space=? AND item_id=? AND version_id=? ")
+ void updateModificationTime(Date modificationTime, String space, String itemId,
+ String versionId);
+
+ @Query("DELETE FROM version WHERE space=? AND item_id=? AND version_id=? ")
+ void delete(String space, String itemId, String versionId);
+
+ @Query("SELECT version_id, base_version_id, creation_time, modification_time " +
+ "FROM version WHERE space=? AND item_id=? AND version_id=? ")
+ ResultSet get(String space, String itemId, String versionId);
+
+ /*@Query("SELECT version_id, base_version_id, creation_time, modification_time " +
+ "FROM version WHERE space=? AND item_id=? AND version_id=? ")
+ ResultSet get(String space, String itemId, String versionId);*/
+
+
+ @Query("SELECT version_id, base_version_id, creation_time, modification_time " +
+ "FROM version WHERE space=? AND item_id=?")
+ ResultSet list(String space, String itemId);
+
+ @Query("SELECT version_id FROM version LIMIT 1")
+ ResultSet checkHealth();
+ }
+
+ private static final class VersionField {
+ private static final String VERSION_ID = "version_id";
+ private static final String BASE_VERSION_ID = "base_version_id";
+ private static final String CREATION_TIME = "creation_time";
+ private static final String MODIFICATION_TIME = "modification_time";
+ //private static final String REVISION_ID = "revision_id";
+ }
+
+ @Accessor
+ interface VersionElementsAccessor {
+
+ @Query("INSERT INTO version_elements (space,item_id,version_id,revision_id,element_ids," +
+ "publish_time,message,user) " +
+ "VALUES (?,?,?,?,?,?,?,?)")
+ void create(String space,
+ String itemId,
+ String versionId,
+ String versionRevisionId,
+ Map<String,String> elementIds,
+ Date publishTime,
+ String message,
+ String user);
+
+
+
+ }
+
+ /* public static final class VersionElementsField {
+ private static final String SPACE = "space";
+ private static final String ITEM_ID = "item_id";
+ private static final String VERSION_ID = "version_id";
+ private static final String ELEMENT_IDS = "element_ids";
+ private static final String REVISION_ID = "revision_id";
+
+ }*/
+
+
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/VersionStageRepositoryFactoryImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/VersionStageRepositoryFactoryImpl.java
new file mode 100644
index 0000000..547bf6a
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/VersionStageRepositoryFactoryImpl.java
@@ -0,0 +1,15 @@
+package org.openecomp.core.zusammen.plugin.dao.impl.cassandra;
+
+import com.amdocs.zusammen.datatypes.SessionContext;
+import org.openecomp.core.zusammen.plugin.dao.VersionStageRepository;
+import org.openecomp.core.zusammen.plugin.dao.VersionStageRepositoryFactory;
+
+public class VersionStageRepositoryFactoryImpl extends VersionStageRepositoryFactory {
+
+ private static final VersionStageRepository INSTANCE = new VersionStageRepositoryImpl();
+
+ @Override
+ public VersionStageRepository createInterface(SessionContext context) {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/VersionStageRepositoryImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/VersionStageRepositoryImpl.java
new file mode 100644
index 0000000..353f37b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/VersionStageRepositoryImpl.java
@@ -0,0 +1,82 @@
+package org.openecomp.core.zusammen.plugin.dao.impl.cassandra;
+
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.Action;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+import com.datastax.driver.mapping.annotations.Accessor;
+import com.datastax.driver.mapping.annotations.Query;
+import org.openecomp.core.zusammen.plugin.dao.VersionStageRepository;
+import org.openecomp.core.zusammen.plugin.dao.types.StageEntity;
+import org.openecomp.core.zusammen.plugin.dao.types.VersionContext;
+import org.openecomp.core.zusammen.plugin.dao.types.VersionEntity;
+
+import java.util.Date;
+import java.util.Optional;
+
+public class VersionStageRepositoryImpl implements VersionStageRepository {
+
+ @Override
+ public Optional<StageEntity<VersionEntity>> get(SessionContext context,
+ VersionContext entityContext,
+ VersionEntity entity) {
+ Row row = getAccessor(context)
+ .get(entityContext.getSpace(), entityContext.getItemId().toString(),
+ entity.getId().toString()).one();
+ return row == null ? Optional.empty() : Optional.of(convertToVersionStage(entity, row));
+ }
+
+ @Override
+ public void create(SessionContext context, VersionContext entityContext,
+ StageEntity<VersionEntity> stageEntity) {
+ VersionEntity entity = stageEntity.getEntity();
+ getAccessor(context).create(entityContext.getSpace(),
+ entityContext.getItemId().toString(),
+ entity.getId().toString(),
+ entity.getBaseId() == null ? null : entity.getBaseId().toString(),
+ entity.getCreationTime() == null ? null : entity.getCreationTime(),
+ entity.getModificationTime() == null ? null : entity.getModificationTime(),
+ stageEntity.getPublishTime(),
+ stageEntity.getAction());
+ }
+
+ @Override
+ public void delete(SessionContext context, VersionContext entityContext, VersionEntity entity) {
+ getAccessor(context).delete(entityContext.getSpace(), entityContext.getItemId().toString(),
+ entity.getId().toString());
+ }
+
+ private StageEntity<VersionEntity> convertToVersionStage(VersionEntity version, Row row) {
+ StageEntity<VersionEntity> versionStage =
+ new StageEntity<>(VersionDaoImpl.enrichVersionEntity(version, row),
+ row.getDate(VersionStageField.PUBLISH_TIME));
+ versionStage.setAction(Action.valueOf(row.getString(VersionStageField.ACTION)));
+ return versionStage;
+ }
+
+ private VersionStageAccessor getAccessor(SessionContext context) {
+ return CassandraDaoUtils.getAccessor(context, VersionStageAccessor.class);
+ }
+
+ @Accessor
+ interface VersionStageAccessor {
+
+ @Query("INSERT INTO version_stage (space, item_id, version_id, base_version_id, " +
+ "creation_time, modification_time, publish_time, action) " +
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?)")
+ void create(String space, String itemId, String versionId, String baseVersionId,
+ Date creationTime, Date modificationTime, Date publishTime, Action action);
+
+ @Query("DELETE FROM version_stage WHERE space=? AND item_id=? AND version_id=?")
+ void delete(String space, String itemId, String versionId);
+
+ @Query("SELECT base_version_id, creation_time, modification_time, publish_time, action " +
+ "FROM version_stage WHERE space=? AND item_id=? AND version_id=?")
+ ResultSet get(String space, String itemId, String versionId);
+ }
+
+ private static final class VersionStageField {
+ private static final String PUBLISH_TIME = "publish_time";
+ private static final String ACTION = "action";
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/VersionSynchronizationStateRepositoryFactoryImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/VersionSynchronizationStateRepositoryFactoryImpl.java
new file mode 100644
index 0000000..95c3ec2
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/VersionSynchronizationStateRepositoryFactoryImpl.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright © 2016-2017 European Support Limited
+ *
+ * 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.
+ */
+
+package org.openecomp.core.zusammen.plugin.dao.impl.cassandra;
+
+import com.amdocs.zusammen.datatypes.SessionContext;
+import org.openecomp.core.zusammen.plugin.dao.VersionSynchronizationStateRepository;
+import org.openecomp.core.zusammen.plugin.dao.VersionSynchronizationStateRepositoryFactory;
+
+public class VersionSynchronizationStateRepositoryFactoryImpl
+ extends VersionSynchronizationStateRepositoryFactory {
+
+ private static final VersionSynchronizationStateRepository INSTANCE =
+ new VersionSynchronizationStateRepositoryImpl();
+
+ @Override
+ public VersionSynchronizationStateRepository createInterface(SessionContext context) {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/VersionSynchronizationStateRepositoryImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/VersionSynchronizationStateRepositoryImpl.java
new file mode 100644
index 0000000..5fb9779
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/impl/cassandra/VersionSynchronizationStateRepositoryImpl.java
@@ -0,0 +1,137 @@
+package org.openecomp.core.zusammen.plugin.dao.impl.cassandra;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+import com.datastax.driver.mapping.annotations.Accessor;
+import com.datastax.driver.mapping.annotations.Query;
+import org.openecomp.core.zusammen.plugin.dao.VersionSynchronizationStateRepository;
+import org.openecomp.core.zusammen.plugin.dao.types.SynchronizationStateEntity;
+import org.openecomp.core.zusammen.plugin.dao.types.VersionContext;
+import org.openecomp.core.zusammen.plugin.dao.types.VersionEntity;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+public class VersionSynchronizationStateRepositoryImpl
+ implements VersionSynchronizationStateRepository {
+
+ @Override
+ public void create(SessionContext context, VersionContext entityContext,
+ SynchronizationStateEntity syncStateEntity) {
+ updatePublishTime(context, entityContext, syncStateEntity);
+ }
+
+ @Override
+ public void updatePublishTime(SessionContext context, VersionContext entityContext,
+ SynchronizationStateEntity syncStateEntity) {
+ getAccessor(context)
+ .updatePublishTime(syncStateEntity.getPublishTime(), entityContext.getSpace(),
+ entityContext.getItemId().toString(), syncStateEntity.getId().toString(),
+ syncStateEntity.getRevisionId().getValue());
+ }
+
+ @Override
+ public List<SynchronizationStateEntity> list(SessionContext context, VersionContext
+ entityContext, VersionEntity versionEntity) {
+
+ List<Row> rows = getAccessor(context).list(entityContext.getSpace(), entityContext.getItemId().toString
+ (),versionEntity.getId().toString()).all();
+ return rows == null ? new ArrayList<>():
+ rows.stream().map(VersionSynchronizationStateRepositoryImpl::getSynchronizationStateEntity).collect(Collectors.toList());
+ }
+
+
+
+ /*@Override
+ public List<SynchronizationStateEntity> listRevisions(SessionContext context,
+ VersionContext entityContext,
+ SynchronizationStateEntity syncStateEntity) {
+ List<Row> rows = getAccessor(context).list(entityContext.getSpace(), entityContext.getItemId()
+ .toString(), syncStateEntity.getId().toString()).all();
+ return rows == null ? new ArrayList<>() :rows.stream()
+ .map(VersionSynchronizationStateRepositoryImpl::getSynchronizationStateEntity)
+ .collect(Collectors.toList());
+
+
+
+
+ //forEach(row -> getSynchronizationStateEntity(syncStateEntity.getId(), row));
+
+
+ }*/
+
+
+ @Override
+ public void delete(SessionContext context, VersionContext entityContext,
+ SynchronizationStateEntity syncStateEntity) {
+ // done by version dao
+ }
+
+ @Override
+ public Optional<SynchronizationStateEntity> get(SessionContext context,
+ VersionContext entityContext,
+ SynchronizationStateEntity syncStateEntity) {
+ Row row =
+ getAccessor(context).get(entityContext.getSpace(), entityContext.getItemId().toString(),
+ syncStateEntity.getId().toString(), syncStateEntity.getRevisionId().getValue()).one();
+
+ return row == null ? Optional.empty()
+ : Optional.of(getSynchronizationStateEntity(syncStateEntity.getId(), row));
+ }
+
+ private SynchronizationStateEntity getSynchronizationStateEntity(Id entityId, Row row) {
+ SynchronizationStateEntity syncStateEntity = new SynchronizationStateEntity(entityId,
+ new Id(row.getString(REVISION_ID_FIELD)));
+ syncStateEntity.setPublishTime(row.getDate(PUBLISH_TIME_FIELD));
+ syncStateEntity.setDirty(!row.getSet(DIRTY_ELEMENT_FIELD, String.class).isEmpty());
+ return syncStateEntity;
+ }
+
+ private static SynchronizationStateEntity getSynchronizationStateEntity(Row row) {
+ Id entityId = new Id(row.getColumnDefinitions().contains("version_id") ? row.getString
+ ("version_id") : row.getString("element_id"));
+ SynchronizationStateEntity syncStateEntity = new SynchronizationStateEntity(entityId,
+ new Id(row.getString(REVISION_ID_FIELD)));
+ syncStateEntity.setPublishTime(row.getDate(PUBLISH_TIME_FIELD));
+ syncStateEntity.setDirty(!row.getSet(DIRTY_ELEMENT_FIELD, String.class).isEmpty());
+ syncStateEntity.setRevisionId(new Id(row.getString(REVISION_ID_FIELD)));
+ syncStateEntity.setUser(row.getString(USER));
+ syncStateEntity.setMessage(row.getString(MESSAGE));
+ return syncStateEntity;
+ }
+
+ private VersionSyncStateAccessor getAccessor(SessionContext context) {
+ return CassandraDaoUtils.getAccessor(context, VersionSyncStateAccessor.class);
+ }
+
+ @Accessor
+ interface VersionSyncStateAccessor {
+ @Query(
+ "UPDATE version_elements SET publish_time=? WHERE space=? AND item_id=? AND version_id=? " +
+ "AND revision_id=? ")
+ void updatePublishTime(Date publishTime, String space, String itemId, String versionId, String
+ revisionId);
+
+ @Query("SELECT version_id,revision_id,publish_time, dirty_element_ids FROM version_elements " +
+ "WHERE space=? AND item_id=? AND version_id=? AND revision_id=? ")
+ ResultSet get(String space, String itemId, String versionId, String revisionId);
+
+ @Query("SELECT version_id,revision_id,publish_time,user,message, dirty_element_ids FROM " +
+ "version_elements " +
+ "WHERE space=? AND item_id=? AND version_id=? ")
+ ResultSet list(String space, String itemId, String versionId);
+
+ }
+
+
+ private static final String PUBLISH_TIME_FIELD = "publish_time";
+ private static final String DIRTY_ELEMENT_FIELD = "dirty_element_ids";
+ private static final String REVISION_ID_FIELD = "revision_id";
+ private static final String USER = "user";
+ private static final String MESSAGE = "message";
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/types/ElementEntity.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/types/ElementEntity.java
index 1663d83..1cd1510 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/types/ElementEntity.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/types/ElementEntity.java
@@ -30,6 +30,7 @@
private Id id;
private Id parentId;
private Namespace namespace;
+ private Id elementHash;
private Info info;
private Collection<Relation> relations = Collections.emptyList();
private ByteBuffer data;
@@ -41,6 +42,10 @@
this.id = id;
}
+ public Id getId() {
+ return id;
+ }
+
public Id getParentId() {
return parentId;
}
@@ -49,14 +54,6 @@
this.parentId = parentId;
}
- public Id getId() {
- return id;
- }
-
- public void setId(Id id) {
- this.id = id;
- }
-
public Namespace getNamespace() {
return namespace;
}
@@ -127,8 +124,17 @@
return id.equals(that.id);
}
+ public Id getElementHash() {
+ return elementHash;
+ }
+
+ public void setElementHash(Id elementHash) {
+ this.elementHash = elementHash;
+ }
+
@Override
public int hashCode() {
return id.hashCode();
}
+
}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/types/StageEntity.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/types/StageEntity.java
new file mode 100644
index 0000000..58ac0a9
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/types/StageEntity.java
@@ -0,0 +1,60 @@
+package org.openecomp.core.zusammen.plugin.dao.types;
+
+import com.amdocs.zusammen.datatypes.item.Action;
+
+import java.util.Collections;
+import java.util.Date;
+import java.util.Set;
+
+public class StageEntity<E> {
+ private E entity;
+ private Date publishTime;
+ private Action action = Action.IGNORE;
+ private boolean conflicted;
+ private Set<E> conflictDependents = Collections.emptySet();
+
+ // used by sync on stage creation
+ public StageEntity(E entity, Date publishTime) {
+ this.entity = entity;
+ this.publishTime = publishTime;
+ }
+
+ public StageEntity(E entity, Date publishTime, Action action, boolean conflicted) {
+ this.entity = entity;
+ this.publishTime = publishTime;
+ this.action = action;
+ this.conflicted = conflicted;
+ }
+
+ public E getEntity() {
+ return entity;
+ }
+
+ public Date getPublishTime() {
+ return publishTime;
+ }
+
+ public Action getAction() {
+ return action;
+ }
+
+ public void setAction(Action action) {
+ this.action = action;
+ }
+
+ public boolean isConflicted() {
+ return conflicted;
+ }
+
+ public void setConflicted(boolean conflicted) {
+ this.conflicted = conflicted;
+ }
+
+ public Set<E> getConflictDependents() {
+ return conflictDependents;
+ }
+
+ public void setConflictDependents(Set<E> conflictDependents) {
+ this.conflictDependents = conflictDependents;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/types/SynchronizationStateEntity.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/types/SynchronizationStateEntity.java
new file mode 100644
index 0000000..510cef8
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/types/SynchronizationStateEntity.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright © 2016-2017 European Support Limited
+ *
+ * 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.
+ */
+
+package org.openecomp.core.zusammen.plugin.dao.types;
+
+import com.amdocs.zusammen.datatypes.Id;
+
+import java.util.Date;
+
+/**
+ * Synchronization state of an entity:
+ * <ul>
+ * <li>On private entity edit (create/update/delete): marked as dirty</li>
+ * <li>On entity publication:
+ * <ul>
+ * <li>if the private entity exists - updated with the publish time, marked as not dirty</li>
+ * <li>Otherwise - deleted</li>
+ * </ul>
+ * </li>
+ * </ul>
+ */
+public class SynchronizationStateEntity {
+ private Id id;
+ private Id revisionId;
+ private Date publishTime;
+ private boolean dirty;
+ private String user;
+ private String message;
+
+ public SynchronizationStateEntity(Id id,Id revisionId) {
+ this.id = id;
+ this.revisionId = revisionId;
+ }
+
+ public SynchronizationStateEntity(Id id,Id revisionId, Date publishTime, boolean dirty) {
+ this(id,revisionId);
+ this.publishTime = publishTime;
+ this.dirty = dirty;
+ }
+
+ public Id getId() {
+ return id;
+ }
+
+ public Date getPublishTime() {
+ return publishTime;
+ }
+
+ public void setPublishTime(Date publishTime) {
+ this.publishTime = publishTime;
+ }
+
+ public boolean isDirty() {
+ return dirty;
+ }
+
+ public void setDirty(boolean dirty) {
+ this.dirty = dirty;
+ }
+
+ public Id getRevisionId() {
+ return revisionId;
+ }
+
+ public void setRevisionId(Id revisionId) {
+ this.revisionId = revisionId;
+ }
+
+ public String getUser() {
+ return user;
+ }
+
+ public void setUser(String user) {
+ this.user = user;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ SynchronizationStateEntity that = (SynchronizationStateEntity) o;
+
+ return id.equals(that.id);
+ }
+
+ @Override
+ public int hashCode() {
+ return id.hashCode();
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/types/VersionContext.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/types/VersionContext.java
new file mode 100644
index 0000000..41a3e66
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/types/VersionContext.java
@@ -0,0 +1,23 @@
+package org.openecomp.core.zusammen.plugin.dao.types;
+
+import com.amdocs.zusammen.datatypes.Id;
+
+public class VersionContext {
+ private String space;
+ private Id itemId;
+
+
+ public VersionContext(String space, Id itemId) {
+ this.space = space;
+ this.itemId = itemId;
+ }
+
+ public String getSpace() {
+ return space;
+ }
+
+ public Id getItemId() {
+ return itemId;
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/types/VersionDataElement.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/types/VersionDataElement.java
new file mode 100644
index 0000000..48a52c0
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/types/VersionDataElement.java
@@ -0,0 +1,21 @@
+package org.openecomp.core.zusammen.plugin.dao.types;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.item.ItemVersionData;
+import org.openecomp.core.zusammen.plugin.ZusammenPluginConstants;
+
+import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.calculateElementHash;
+
+public class VersionDataElement extends ElementEntity {
+
+ public VersionDataElement() {
+ super(ZusammenPluginConstants.ROOT_ELEMENTS_PARENT_ID);
+ }
+
+ public VersionDataElement(ItemVersionData itemVersionData) {
+ this();
+ setInfo(itemVersionData.getInfo());
+ setRelations(itemVersionData.getRelations());
+ setElementHash(new Id(calculateElementHash(this)));
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/types/VersionEntity.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/types/VersionEntity.java
new file mode 100644
index 0000000..aeed998
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/dao/types/VersionEntity.java
@@ -0,0 +1,45 @@
+package org.openecomp.core.zusammen.plugin.dao.types;
+
+import com.amdocs.zusammen.datatypes.Id;
+
+import java.util.Date;
+
+public class VersionEntity {
+ private Id id;
+ private Id baseId;
+ private Date creationTime;
+ private Date modificationTime;
+
+ public VersionEntity(Id id) {
+ this.id = id;
+ }
+
+ public Id getId() {
+ return id;
+ }
+
+ public Id getBaseId() {
+ return baseId;
+ }
+
+ public void setBaseId(Id baseId) {
+ this.baseId = baseId;
+ }
+
+ public Date getCreationTime() {
+ return creationTime;
+ }
+
+ public void setCreationTime(Date creationTime) {
+ this.creationTime = creationTime;
+ }
+
+ public Date getModificationTime() {
+ return modificationTime;
+ }
+
+ public void setModificationTime(Date modificationTime) {
+ this.modificationTime = modificationTime;
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/main/CassandraCollaborationStorePluginImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/main/CassandraCollaborationStorePluginImpl.java
index 90fd336..f9b6522 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/main/CassandraCollaborationStorePluginImpl.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/main/CassandraCollaborationStorePluginImpl.java
@@ -21,132 +21,297 @@
import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.Namespace;
import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.Space;
+import com.amdocs.zusammen.datatypes.item.Action;
import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.datatypes.item.Info;
+import com.amdocs.zusammen.datatypes.item.ItemVersion;
import com.amdocs.zusammen.datatypes.item.ItemVersionData;
-import com.amdocs.zusammen.datatypes.itemversion.ItemVersionHistory;
+import com.amdocs.zusammen.datatypes.item.ItemVersionDataConflict;
+import com.amdocs.zusammen.datatypes.item.ItemVersionStatus;
+import com.amdocs.zusammen.datatypes.item.Resolution;
+import com.amdocs.zusammen.datatypes.itemversion.ItemVersionRevisions;
+import com.amdocs.zusammen.datatypes.itemversion.Revision;
import com.amdocs.zusammen.datatypes.itemversion.Tag;
+import com.amdocs.zusammen.datatypes.response.ErrorCode;
+import com.amdocs.zusammen.datatypes.response.Module;
import com.amdocs.zusammen.datatypes.response.Response;
+import com.amdocs.zusammen.datatypes.response.ReturnCode;
import com.amdocs.zusammen.datatypes.response.ZusammenException;
import com.amdocs.zusammen.sdk.collaboration.CollaborationStore;
import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElement;
+import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElementChange;
+import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElementConflict;
+import com.amdocs.zusammen.sdk.collaboration.types.CollaborationItemVersionConflict;
import com.amdocs.zusammen.sdk.collaboration.types.CollaborationMergeChange;
import com.amdocs.zusammen.sdk.collaboration.types.CollaborationMergeResult;
import com.amdocs.zusammen.sdk.collaboration.types.CollaborationPublishResult;
-import org.openecomp.core.zusammen.plugin.collaboration.ElementCollaborationStore;
-import org.openecomp.core.zusammen.plugin.collaboration.VersionCollaborationStore;
+import com.amdocs.zusammen.sdk.types.ElementConflictDescriptor;
+import com.amdocs.zusammen.sdk.types.ElementDescriptor;
+import org.openecomp.core.zusammen.plugin.ZusammenPluginUtil;
+import org.openecomp.core.zusammen.plugin.collaboration.CommitStagingService;
+import org.openecomp.core.zusammen.plugin.collaboration.ElementPrivateStore;
+import org.openecomp.core.zusammen.plugin.collaboration.ElementPublicStore;
+import org.openecomp.core.zusammen.plugin.collaboration.ElementStageStore;
+import org.openecomp.core.zusammen.plugin.collaboration.PublishService;
+import org.openecomp.core.zusammen.plugin.collaboration.RevertService;
+import org.openecomp.core.zusammen.plugin.collaboration.SyncService;
+import org.openecomp.core.zusammen.plugin.collaboration.VersionPrivateStore;
+import org.openecomp.core.zusammen.plugin.collaboration.VersionPublicStore;
+import org.openecomp.core.zusammen.plugin.collaboration.VersionStageStore;
+import org.openecomp.core.zusammen.plugin.collaboration.impl.ElementPrivateStoreImpl;
+import org.openecomp.core.zusammen.plugin.collaboration.impl.ElementPublicStoreImpl;
+import org.openecomp.core.zusammen.plugin.collaboration.impl.ElementStageStoreImpl;
+import org.openecomp.core.zusammen.plugin.collaboration.impl.VersionPrivateStoreImpl;
+import org.openecomp.core.zusammen.plugin.collaboration.impl.VersionPublicStoreImpl;
+import org.openecomp.core.zusammen.plugin.collaboration.impl.VersionStageStoreImpl;
+import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
+import org.openecomp.core.zusammen.plugin.dao.types.StageEntity;
+import org.openecomp.core.zusammen.plugin.dao.types.SynchronizationStateEntity;
+import org.openecomp.core.zusammen.plugin.dao.types.VersionDataElement;
+import org.openecomp.core.zusammen.plugin.dao.types.VersionEntity;
import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+import static com.amdocs.zusammen.datatypes.item.SynchronizationStatus.MERGING;
+import static com.amdocs.zusammen.datatypes.item.SynchronizationStatus.OUT_OF_SYNC;
+import static com.amdocs.zusammen.datatypes.item.SynchronizationStatus.UP_TO_DATE;
+import static org.openecomp.core.zusammen.plugin.ZusammenPluginConstants.ROOT_ELEMENTS_PARENT_ID;
+import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.convertToCollaborationElement;
+import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.convertToElementChange;
+import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.convertToElementDescriptor;
+import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.convertToElementEntity;
+import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.convertToItemVersion;
+import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.convertToVersionData;
+import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.convertToVersionEntity;
public class CassandraCollaborationStorePluginImpl implements CollaborationStore {
+ // TODO: 8/15/2017 inject
- private VersionCollaborationStore versionCollaborationStore = new VersionCollaborationStore();
- private ElementCollaborationStore elementCollaborationStore = new ElementCollaborationStore();
+ private VersionPrivateStore versionPrivateStore = new VersionPrivateStoreImpl();
+ private VersionPublicStore versionPublicStore = new VersionPublicStoreImpl();
+ private VersionStageStore versionStageStore = new VersionStageStoreImpl();
+
+ private ElementPrivateStore elementPrivateStore = new ElementPrivateStoreImpl();
+ private ElementPublicStore elementPublicStore = new ElementPublicStoreImpl();
+ private ElementStageStore elementStageStore = new ElementStageStoreImpl();
+
+ // TODO: 9/4/2017
+ private CommitStagingService commitStagingService =
+ new CommitStagingService(versionPrivateStore, versionStageStore, elementPrivateStore,
+ elementStageStore);
+ private PublishService publishService =
+ new PublishService(versionPublicStore, versionPrivateStore, elementPublicStore,
+ elementPrivateStore);
+ private SyncService syncService =
+ new SyncService(versionPublicStore, versionPrivateStore, versionStageStore,
+ elementPublicStore, elementPrivateStore, elementStageStore);
+
+ private RevertService revertService =
+ new RevertService(elementPublicStore, elementPrivateStore);
@Override
- public Response<Void> createItem(SessionContext context, Id id, Info info) {
+ public Response<Void> createItem(SessionContext context, Id itemId, Info info) {
// done by state store
return new Response(Void.TYPE);
}
@Override
- public Response<Void> deleteItem(SessionContext context, Id id) {
+ public Response<Void> deleteItem(SessionContext context, Id itemId) {
// done by state store
return new Response(Void.TYPE);
}
@Override
- public Response<Void> createItemVersion(SessionContext context, Id itemId, Id versionId, Id id2,
- ItemVersionData itemVersionData) {
- // done by state store
+ public Response<Void> createItemVersion(SessionContext context, Id itemId, Id baseVersionId,
+ Id versionId, ItemVersionData itemVersionData) {
+ Date creationTime = new Date();
+ versionPrivateStore.create(context, itemId,
+ convertToVersionEntity(versionId, baseVersionId, creationTime, creationTime));
+
+ ElementContext elementContext = new ElementContext(itemId, versionId);
+ VersionDataElement versionData = new VersionDataElement(itemVersionData);
+
+ if (baseVersionId == null) {
+ elementPrivateStore.create(context, elementContext, versionData);
+ } else {
+ copyElements(context, new ElementContext(itemId, baseVersionId), elementContext);
+ elementPrivateStore.update(context, elementContext, versionData);
+ }
+
return new Response(Void.TYPE);
}
@Override
public Response<Void> updateItemVersion(SessionContext context, Id itemId, Id versionId,
ItemVersionData itemVersionData) {
- // done by state store
+
+ if (elementPrivateStore.update(context, new ElementContext(itemId, versionId),
+ new VersionDataElement(itemVersionData))) {
+
+ VersionEntity version = new VersionEntity(versionId);
+ version.setModificationTime(new Date());
+ versionPrivateStore.update(context, itemId, version);
+ }
+
return new Response(Void.TYPE);
}
@Override
public Response<Void> deleteItemVersion(SessionContext context, Id itemId, Id versionId) {
- // done by state store
+ elementPrivateStore
+ .delete(context, new ElementContext(itemId, versionId), new VersionDataElement());
+
+ versionPrivateStore.delete(context, itemId, new VersionEntity(versionId));
return new Response(Void.TYPE);
}
@Override
- public Response<Void> tagItemVersion(SessionContext context, Id itemId, Id versionId, Id changeId,
+ public Response<ItemVersionStatus> getItemVersionStatus(SessionContext context, Id itemId,
+ Id versionId) {
+ if (versionStageStore.get(context, itemId, new VersionEntity(versionId)).isPresent()) {
+ return new Response<>(new ItemVersionStatus(MERGING, true));
+ }
+
+ Optional<SynchronizationStateEntity> publicSyncState =
+ versionPublicStore.getSynchronizationState(context, itemId, versionId);
+
+ if (!publicSyncState.isPresent()) {
+ return new Response<>(new ItemVersionStatus(UP_TO_DATE, true));
+ }
+
+ SynchronizationStateEntity privateSyncState =
+ versionPrivateStore.getSynchronizationState(context, itemId, versionId)
+ // TODO: 7/18/2017 ?
+ .orElseThrow(() -> new IllegalStateException("private version must exist"));
+
+ return new Response<>(new ItemVersionStatus(
+ privateSyncState.getPublishTime().equals(publicSyncState.get().getPublishTime())
+ ? UP_TO_DATE
+ : OUT_OF_SYNC,
+ privateSyncState.isDirty()));
+ }
+
+ @Override
+ public Response<Void> tagItemVersion(SessionContext context, Id itemId, Id versionId,
+ Id revisionId,
Tag tag) {
- versionCollaborationStore.tagItemVersion(context, itemId, versionId, changeId, tag);
+ /* if (revisionId != null) {
+ throw new UnsupportedOperationException(
+ "In this plugin implementation tag is supported only on versionId");
+ }
+
+ copyElements(context,
+ new ElementContext(itemId, versionId),
+ new ElementContext(itemId, versionId, tag.getName()));*/
+
return new Response(Void.TYPE);
}
@Override
public Response<CollaborationPublishResult> publishItemVersion(SessionContext context,
Id itemId, Id versionId,
- String s) {
- throw new UnsupportedOperationException("publishItemVersion");
+ String message) {
+ try {
+ return new Response<>(publishService.publish(context, itemId, versionId, message));
+ } catch (ZusammenException ze) {
+ return new Response<>(
+ new ReturnCode(ErrorCode.CL_ITEM_VERSION_PUBLISH, Module.ZCSP, null, ze.getReturnCode()));
+ }
}
@Override
- public Response<CollaborationMergeResult> syncItemVersion(SessionContext context, Id id,
- Id id1) {
- throw new UnsupportedOperationException("syncItemVersion");
+ public Response<CollaborationMergeResult> syncItemVersion(SessionContext context, Id itemId,
+ Id versionId) {
+ CollaborationMergeResult result = syncService.sync(context, itemId, versionId, false);
+ commitStagingService.commitStaging(context, itemId, versionId);
+
+ return new Response<>(result);
}
@Override
- public Response<CollaborationMergeResult> mergeItemVersion(SessionContext context, Id id,
- Id id1, Id id2) {
+ public Response<CollaborationMergeResult> forceSyncItemVersion(SessionContext context, Id itemId,
+ Id versionId) {
+ CollaborationMergeResult result = syncService.sync(context, itemId, versionId, true);
+ commitStagingService.commitStaging(context, itemId, versionId);
+
+ return new Response<>(result);
+ }
+
+ @Override
+ public Response<CollaborationMergeResult> mergeItemVersion(SessionContext context, Id itemId,
+ Id versionId, Id sourceVersionId) {
throw new UnsupportedOperationException("mergeItemVersion");
}
@Override
- public Response<ItemVersionHistory> listItemVersionHistory(SessionContext context, Id id,
- Id id1) {
- throw new UnsupportedOperationException("listItemVersionHistory");
+ public Response<CollaborationItemVersionConflict> getItemVersionConflict(SessionContext context,
+ Id itemId,
+ Id versionId) {
+ ElementContext elementContext = new ElementContext(itemId, versionId, Id.ZERO);
+
+ Collection<StageEntity<ElementEntity>> conflictedStagedElementDescriptors =
+ elementStageStore.listConflictedDescriptors(context, elementContext);
+
+ CollaborationItemVersionConflict result = new CollaborationItemVersionConflict();
+ for (StageEntity<ElementEntity> stagedElementDescriptor : conflictedStagedElementDescriptors) {
+ if (ROOT_ELEMENTS_PARENT_ID.equals(stagedElementDescriptor.getEntity().getId())) {
+ result.setVersionDataConflict(
+ getVersionDataConflict(context, elementContext, stagedElementDescriptor));
+ } else {
+ result.getElementConflictDescriptors()
+ .add(getElementConflictDescriptor(context, elementContext, stagedElementDescriptor));
+ }
+ }
+ return new Response<>(result);
}
@Override
- public Response<CollaborationMergeChange> resetItemVersionHistory(SessionContext context,
- Id itemId, Id versionId,
- String changeRef) {
- return new Response<>(versionCollaborationStore.resetItemVersionHistory(context, itemId, versionId, changeRef));
+ public Response<ItemVersionRevisions> listItemVersionRevisions(SessionContext context, Id itemId,
+ Id versionId) {
+ return new Response<>(versionPublicStore.listItemVersionRevisions(context, itemId, versionId));
}
@Override
- public Response<Collection<CollaborationElement>> listElements(SessionContext context,
- ElementContext elementContext,
- Namespace namespace,
- Id elementId) {
- return new Response<>(
- elementCollaborationStore.listElements(context, elementContext, elementId));
+ public Response<Revision> getItemVersionRevision(SessionContext context, Id itemId, Id versionId,
+ Id revisionId) {
+ throw new UnsupportedOperationException(
+ "get revision is not supported in the current cassandra plugin");
}
@Override
- public Response<CollaborationElement> getElement(SessionContext context,
- ElementContext elementContext,
- Namespace namespace, Id elementId) {
- return new Response<>(elementCollaborationStore.getElement(context, elementContext, elementId));
+ public Response<CollaborationMergeChange> resetItemVersionRevision(SessionContext context,
+ Id itemId, Id versionId,
+ Id revisionId) {
+ throw new UnsupportedOperationException("resetItemVersionRevision function not supported");
+
}
@Override
- public Response<Void> createElement(SessionContext context, CollaborationElement element) {
- elementCollaborationStore.createElement(context, element);
- return new Response(Void.TYPE);
+ public Response<CollaborationMergeChange> revertItemVersionRevision(SessionContext context,
+ Id itemId, Id versionId,
+ Id revisionId) {
+ Optional<ItemVersion> itemVersion = getItemVersion(context, itemId, versionId, revisionId);
+ if (!itemVersion.isPresent()) {
+ throw new RuntimeException(String
+ .format("Item %s, version %s: Cannot revert to revision %s since it is not found",
+ itemId, versionId, revisionId));
+ }
+
+ // TODO: 12/4/2017 force sync is done in order to clear dirty element on private
+ // this is temp solution that should be fixed.
+ forceSyncItemVersion(context, itemId, versionId);
+
+ //updateItemVersion(context, itemId, versionId, itemVersion.get().getData());
+ revertService.revert(context, itemId, versionId, revisionId);
+
+ return new Response<>(new CollaborationMergeChange());
}
- @Override
- public Response<Void> updateElement(SessionContext context, CollaborationElement element) {
- elementCollaborationStore.updateElement(context, element);
- return new Response(Void.TYPE);
- }
-
- @Override
- public Response<Void> deleteElement(SessionContext context, CollaborationElement element) {
- elementCollaborationStore.deleteElement(context, element);
- return new Response(Void.TYPE);
- }
@Override
public Response<Void> commitElements(SessionContext context, Id itemId, Id versionId, String s) {
@@ -155,16 +320,202 @@
}
@Override
- public Response<HealthInfo> checkHealth(SessionContext sessionContext) throws ZusammenException {
+ public Response<Collection<CollaborationElement>> listElements(SessionContext context,
+ ElementContext elementContext,
+ Namespace namespace,
+ Id elementId) {
+ return new Response<>(elementPrivateStore.listSubs(context, elementContext, elementId).stream()
+ .map(elementEntity -> convertToCollaborationElement(elementContext, elementEntity))
+ .collect(Collectors.toList()));
+ }
- boolean health = elementCollaborationStore.checkHealth(sessionContext);
- HealthInfo healthInfo ;
- if (health){
- healthInfo = new HealthInfo("Collaboration", HealthStatus.UP,"");
- } else {
- healthInfo = new HealthInfo("Collaboration", HealthStatus.DOWN,"No Schema Available");
+ @Override
+ public Response<CollaborationElement> getElement(SessionContext context,
+ ElementContext elementContext,
+ Namespace namespace, Id elementId) {
+ return new Response<>(elementPrivateStore.get(context, elementContext, elementId)
+ .map(elementEntity -> convertToCollaborationElement(elementContext, elementEntity))
+ .orElse(null));
+ }
+
+ @Override
+ public Response<CollaborationElementConflict> getElementConflict(SessionContext context,
+ ElementContext elementContext,
+ Namespace namespace,
+ Id elementId) {
+ Optional<StageEntity<ElementEntity>> conflictedStagedElement =
+ elementStageStore
+ .getConflicted(context, elementContext, new ElementEntity(elementId));
+
+ return new Response<>(conflictedStagedElement
+ .map(stagedElement -> getElementConflict(context, elementContext, stagedElement))
+ .orElse(null));
+ }
+
+ @Override
+ public Response<Void> createElement(SessionContext context, CollaborationElement element) {
+ elementPrivateStore.create(context,
+ new ElementContext(element.getItemId(), element.getVersionId()),
+ convertToElementEntity(element));
+ return new Response(Void.TYPE);
+ }
+
+ @Override
+ public Response<Void> updateElement(SessionContext context, CollaborationElement element) {
+ elementPrivateStore.update(context,
+ new ElementContext(element.getItemId(), element.getVersionId()),
+ convertToElementEntity(element));
+ return new Response(Void.TYPE);
+ }
+
+ @Override
+ public Response<Void> deleteElement(SessionContext context, CollaborationElement element) {
+ elementPrivateStore
+ .delete(context, new ElementContext(element.getItemId(), element.getVersionId()),
+ convertToElementEntity(element));
+
+ return new Response(Void.TYPE);
+ }
+
+ @Override
+ public Response<CollaborationMergeResult> resolveElementConflict(SessionContext context,
+ CollaborationElement element,
+ Resolution resolution) {
+ ElementContext elementContext = new ElementContext(element.getItemId(), element.getVersionId());
+ elementStageStore
+ .resolveConflict(context, elementContext, convertToElementEntity(element), resolution);
+ commitStagingService.commitStaging(context, element.getItemId(), element.getVersionId());
+
+ return new Response<>(new CollaborationMergeResult());
+ }
+
+ @Override
+ public Response<ItemVersion> getItemVersion(SessionContext context, Space space, Id itemId,
+ Id versionId, Id revisionId) {
+ return new Response<>(getItemVersion(context, itemId, versionId, revisionId).orElse(null));
+ }
+
+ @Override
+ public Response<HealthInfo> checkHealth(SessionContext context) throws ZusammenException {
+ HealthInfo healthInfo = versionPublicStore.checkHealth(context)
+ ? new HealthInfo(Module.ZCSP.getDescription(), HealthStatus.UP, "")
+ : new HealthInfo(Module.ZCSP.getDescription(), HealthStatus.DOWN, "No Schema Available");
+
+ return new Response<>(healthInfo);
+ }
+
+ private Optional<ItemVersion> getItemVersion(SessionContext context, Id itemId, Id versionId,
+ Id revisionId) {
+ // since revisions are kept only on public - get from there
+ Optional<VersionEntity> versionEntity = versionPublicStore.get(context, itemId, versionId);
+ if (!versionEntity.isPresent()) {
+ return Optional.empty();
}
- return new Response<HealthInfo>(healthInfo);
+ return elementPublicStore
+ .getDescriptor(context, new ElementContext(itemId, versionId, revisionId),
+ ROOT_ELEMENTS_PARENT_ID)
+ .map(ZusammenPluginUtil::convertToVersionData)
+ .map(itemVersionData -> convertToItemVersion(versionEntity.get(), itemVersionData));
+ }
+
+ private List<ElementEntity> listVersionElements(SessionContext context,
+ ElementContext elementContext) {
+ return elementPrivateStore.listIds(context, elementContext).entrySet().stream() // TODO:
+ // 9/5/2017 parallel
+ .map(entry -> elementPrivateStore.get(context, elementContext, entry.getKey()).get())
+ .collect(Collectors.toList());
+ }
+
+ private void copyElements(SessionContext context,
+ ElementContext sourceContext, ElementContext targetContext) {
+ listVersionElements(context, sourceContext).forEach(element -> {
+ // publishTime copied as is and dirty is off
+ Date publishTime =
+ elementPrivateStore.getSynchronizationState(context, sourceContext, element.getId())
+ .get().getPublishTime();
+ elementPrivateStore.commitStagedCreate(context, targetContext, element, publishTime);
+ });
+ }
+
+ private ItemVersionDataConflict getVersionDataConflict(SessionContext context,
+ ElementContext elementContext,
+ StageEntity<ElementEntity> stagedElementDescriptor) {
+ ItemVersionDataConflict versionConflict = new ItemVersionDataConflict();
+ versionConflict.setRemoteData(convertToVersionData(stagedElementDescriptor.getEntity()));
+ if (stagedElementDescriptor.getAction() == Action.UPDATE) {
+ versionConflict.setLocalData(getPrivateVersionData(context, elementContext));
+ }
+ return versionConflict;
+ }
+
+ private ItemVersionData getPrivateVersionData(SessionContext context,
+ ElementContext elementContext) {
+ return elementPrivateStore.getDescriptor(context, elementContext, ROOT_ELEMENTS_PARENT_ID)
+ .map(ZusammenPluginUtil::convertToVersionData)
+ .orElseThrow(() -> new IllegalStateException("Version must have data"));
+ }
+
+ private ElementConflictDescriptor getElementConflictDescriptor(SessionContext context,
+ ElementContext elementContext,
+ StageEntity<ElementEntity> stagedElementDescriptor) {
+ ElementDescriptor elementDescriptorFromStage =
+ convertToElementDescriptor(elementContext, (stagedElementDescriptor.getEntity()));
+
+ ElementConflictDescriptor conflictDescriptor = new ElementConflictDescriptor();
+ switch (stagedElementDescriptor.getAction()) {
+ case CREATE:
+ conflictDescriptor.setRemoteElementDescriptor(elementDescriptorFromStage);
+ break;
+ case UPDATE:
+ conflictDescriptor.setRemoteElementDescriptor(elementDescriptorFromStage);
+ conflictDescriptor.setLocalElementDescriptor(convertToElementDescriptor(elementContext,
+ elementPrivateStore
+ .getDescriptor(context, elementContext, stagedElementDescriptor.getEntity().getId())
+ .orElse(null)));// updated on public while deleted from private
+ break;
+ case DELETE:
+ conflictDescriptor.setLocalElementDescriptor(elementDescriptorFromStage);
+ break;
+ default:
+ break;
+ }
+ return conflictDescriptor;
+ }
+
+ private void addElementsToChangedElements(ElementContext elementContext,
+ Collection<ElementEntity> elements,
+ Collection<CollaborationElementChange> changedElements,
+ Action action) {
+ elements.stream()
+ .map(elementEntity -> convertToElementChange(elementContext, elementEntity, action))
+ .forEach(changedElements::add);
+ }
+
+ private CollaborationElementConflict getElementConflict(SessionContext context,
+ ElementContext entityContext,
+ StageEntity<ElementEntity> stagedElement) {
+ CollaborationElement elementFromStage =
+ convertToCollaborationElement(entityContext, (stagedElement.getEntity()));
+
+ CollaborationElementConflict conflict = new CollaborationElementConflict();
+ switch (stagedElement.getAction()) {
+ case CREATE:
+ conflict.setRemoteElement(elementFromStage);
+ break;
+ case UPDATE:
+ conflict.setRemoteElement(elementFromStage);
+ conflict.setLocalElement(
+ elementPrivateStore.get(context, entityContext, stagedElement.getEntity().getId())
+ .map(element -> convertToCollaborationElement(entityContext, element))
+ .orElse(null));// updated on public while deleted from private
+ break;
+ case DELETE:
+ conflict.setLocalElement(elementFromStage);
+ break;
+ default:
+ break;
+ }
+ return conflict;
}
}
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/main/CassandraStateStorePluginImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/main/CassandraStateStorePluginImpl.java
index b4767b2..3ed668e 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/main/CassandraStateStorePluginImpl.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/main/CassandraStateStorePluginImpl.java
@@ -17,18 +17,87 @@
package org.openecomp.core.zusammen.plugin.main;
+import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.Space;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import com.amdocs.zusammen.datatypes.item.ItemVersion;
+import com.amdocs.zusammen.datatypes.item.ItemVersionData;
import com.amdocs.zusammen.datatypes.response.Response;
import com.amdocs.zusammen.plugin.statestore.cassandra.StateStoreImpl;
import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
import com.amdocs.zusammen.sdk.state.types.StateElement;
+import org.openecomp.core.zusammen.plugin.ZusammenPluginUtil;
+import org.openecomp.core.zusammen.plugin.collaboration.ElementPrivateStore;
+import org.openecomp.core.zusammen.plugin.collaboration.impl.ElementPrivateStoreImpl;
+import org.openecomp.core.zusammen.plugin.dao.ElementRepository;
import org.openecomp.core.zusammen.plugin.dao.ElementRepositoryFactory;
+import org.openecomp.core.zusammen.plugin.dao.VersionDao;
+import org.openecomp.core.zusammen.plugin.dao.VersionDaoFactory;
import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
+import org.openecomp.core.zusammen.plugin.dao.types.VersionDataElement;
+import org.openecomp.core.zusammen.plugin.dao.types.VersionEntity;
+import java.util.Collection;
+import java.util.Date;
+import java.util.stream.Collectors;
+
+import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.convertToItemVersion;
import static org.openecomp.core.zusammen.plugin.ZusammenPluginUtil.getSpaceName;
public class CassandraStateStorePluginImpl extends StateStoreImpl {
+ private ElementPrivateStore elementPrivateStore = new ElementPrivateStoreImpl();
+
+ @Override
+ public Response<Collection<ItemVersion>> listItemVersions(SessionContext context, Space space,
+ Id itemId) {
+ String spaceName = getSpaceName(context, space);
+ return new Response<>(getVersionDao(context).list(context, spaceName, itemId).stream()
+ .map(versionEntity -> getItemVersion(context, spaceName, itemId, versionEntity))
+ .collect(Collectors.toList()));
+ }
+
+ @Override
+ public Response<Boolean> isItemVersionExist(SessionContext context, Space space, Id itemId,
+ Id versionId) {
+ return new Response<>(
+ getVersionDao(context).get(context, getSpaceName(context, space), itemId, versionId)
+ .isPresent());
+ }
+
+ @Override
+ public Response<ItemVersion> getItemVersion(SessionContext context, Space space, Id itemId,
+ Id versionId) {
+ String spaceName = getSpaceName(context, space);
+ return new Response<>(getVersionDao(context).get(context, spaceName, itemId, versionId)
+ .map(versionEntity -> getItemVersion(context, spaceName, itemId, versionEntity))
+ .orElse(null));
+ }
+
+ @Override
+ public Response<Void> createItemVersion(SessionContext context, Space space, Id itemId,
+ Id baseVersionId, Id versionId, ItemVersionData data,
+ Date creationTime) {
+ // done by collaboration store
+ return new Response(Void.TYPE);
+ }
+
+ @Override
+ public Response<Void> updateItemVersion(SessionContext context, Space space, Id itemId,
+ Id versionId, ItemVersionData data,
+ Date modificationTime) {
+ // done by collaboration store
+ return new Response(Void.TYPE);
+ }
+
+ @Override
+ public Response<Void> deleteItemVersion(SessionContext context, Space space, Id itemId,
+ Id versionId) {
+ // done by collaboration store
+ return new Response(Void.TYPE);
+ }
+
@Override
public Response<Void> createElement(SessionContext context, StateElement element) {
ElementEntity elementEntity = new ElementEntity(element.getId());
@@ -37,8 +106,7 @@
ElementRepositoryFactory.getInstance().createInterface(context)
.createNamespace(context,
new ElementEntityContext(getSpaceName(context, element.getSpace()),
- element.getItemId(), element.getVersionId()),
- elementEntity);
+ element.getItemId(), element.getVersionId()), elementEntity);
// create element is done by collaboration store
return new Response(Void.TYPE);
}
@@ -55,4 +123,46 @@
return new Response(Void.TYPE);
}
+ @Override
+ public Response<Collection<StateElement>> listElements(SessionContext context,
+ ElementContext elementContext,
+ Id elementId) {
+ return new Response(elementPrivateStore.listSubs(context, elementContext, elementId).stream()
+ .map(elementEntity -> ZusammenPluginUtil.getStateElement(elementContext, elementEntity))
+ .collect(Collectors.toList()));
+
+ }
+
+ @Override
+ public Response<StateElement> getElement(SessionContext context, ElementContext elementContext,
+ Id elementId) {
+
+ return new Response(elementPrivateStore.get(context, elementContext, elementId)
+ .map(elementEntity -> ZusammenPluginUtil
+ .getStateElement(elementContext, elementEntity))
+ .orElse
+ (null));
+
+
+ }
+
+ private ItemVersion getItemVersion(SessionContext context, String spaceName, Id itemId,
+ VersionEntity versionEntity) {
+
+ ItemVersionData itemVersionData = getElementRepository(context)
+ .get(context, new ElementEntityContext(spaceName, itemId, versionEntity.getId(), null),
+ new VersionDataElement())
+ .map(ZusammenPluginUtil::convertToVersionData)
+ .orElseThrow(() -> new IllegalStateException("Version must have data"));
+
+ return convertToItemVersion(versionEntity, itemVersionData);
+ }
+
+ protected VersionDao getVersionDao(SessionContext context) {
+ return VersionDaoFactory.getInstance().createInterface(context);
+ }
+
+ protected ElementRepository getElementRepository(SessionContext context) {
+ return ElementRepositoryFactory.getInstance().createInterface(context);
+ }
}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/resources/factoryConfiguration.json b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/resources/factoryConfiguration.json
index cd1e293..841e005 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/resources/factoryConfiguration.json
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/resources/factoryConfiguration.json
@@ -1,3 +1,8 @@
{
- "org.openecomp.core.zusammen.plugin.dao.ElementRepositoryFactory": "org.openecomp.core.zusammen.plugin.dao.impl.CassandraElementRepositoryFactory"
+ "org.openecomp.core.zusammen.plugin.dao.VersionDaoFactory": "org.openecomp.core.zusammen.plugin.dao.impl.cassandra.VersionDaoFactoryImpl",
+ "org.openecomp.core.zusammen.plugin.dao.ElementRepositoryFactory": "org.openecomp.core.zusammen.plugin.dao.impl.cassandra.ElementRepositoryFactoryImpl",
+ "org.openecomp.core.zusammen.plugin.dao.VersionSynchronizationStateRepositoryFactory": "org.openecomp.core.zusammen.plugin.dao.impl.cassandra.VersionSynchronizationStateRepositoryFactoryImpl",
+ "org.openecomp.core.zusammen.plugin.dao.ElementSynchronizationStateRepositoryFactory": "org.openecomp.core.zusammen.plugin.dao.impl.cassandra.ElementSynchronizationStateRepositoryFactoryImpl",
+ "org.openecomp.core.zusammen.plugin.dao.VersionStageRepositoryFactory": "org.openecomp.core.zusammen.plugin.dao.impl.cassandra.VersionStageRepositoryFactoryImpl",
+ "org.openecomp.core.zusammen.plugin.dao.ElementStageRepositoryFactory": "org.openecomp.core.zusammen.plugin.dao.impl.cassandra.ElementStageRepositoryFactoryImpl"
}
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/test/java/org/openecomp/core/zusammen/plugin/collaboration/TestUtils.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/test/java/org/openecomp/core/zusammen/plugin/collaboration/TestUtils.java
new file mode 100644
index 0000000..79e918c
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/test/java/org/openecomp/core/zusammen/plugin/collaboration/TestUtils.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright © 2016-2017 European Support Limited
+ *
+ * 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.
+ */
+
+package org.openecomp.core.zusammen.plugin.collaboration;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.UserInfo;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import com.amdocs.zusammen.datatypes.item.Info;
+import com.amdocs.zusammen.datatypes.item.ItemVersion;
+import com.amdocs.zusammen.datatypes.item.ItemVersionData;
+import com.amdocs.zusammen.datatypes.item.Relation;
+
+import java.util.Arrays;
+
+public class TestUtils {
+
+ public static SessionContext createSessionContext(UserInfo user, String tenant) {
+ SessionContext context = new SessionContext();
+ context.setUser(user);
+ context.setTenant(tenant);
+ return context;
+ }
+
+ public static ElementContext createElementContext(Id itemId, Id versionId) {
+ ElementContext elementContext = new ElementContext();
+ elementContext.setItemId(itemId);
+ elementContext.setVersionId(versionId);
+ return elementContext;
+ }
+
+ public static Info createInfo(String value) {
+ Info info = new Info();
+ info.setName(value);
+ info.addProperty("Name", "name_" + value);
+ info.addProperty("Desc", "desc_" + value);
+ return info;
+ }
+
+ public static ItemVersion createItemVersion(Id id, Id baseId, String name, boolean dirty) {
+ ItemVersion version = new ItemVersion();
+ version.setId(id);
+ version.setBaseId(baseId);
+ ItemVersionData data = new ItemVersionData();
+ data.setInfo(TestUtils.createInfo(name));
+ data.setRelations(Arrays.asList(new Relation(), new Relation()));
+ version.setData(data);
+ return version;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/test/java/org/openecomp/core/zusammen/plugin/collaboration/VersionCollaborationStoreTest.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/test/java/org/openecomp/core/zusammen/plugin/collaboration/VersionCollaborationStoreTest.java
new file mode 100644
index 0000000..4c4621e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/test/java/org/openecomp/core/zusammen/plugin/collaboration/VersionCollaborationStoreTest.java
@@ -0,0 +1,237 @@
+package org.openecomp.core.zusammen.plugin.collaboration;
+
+public class VersionCollaborationStoreTest {/*
+ private static final String TENANT = "test";
+ private static final String USER = "ItemStateStoreTest_user";
+ private static final SessionContext context =
+ TestUtils.createSessionContext(new UserInfo(USER), TENANT);
+
+ @Mock
+ private VersionDao versionDaoMock;
+ @Mock
+ private ElementStore elementCollaborationStore;
+ @Spy
+ @InjectMocks
+ private VersionStore versionCollaborationStore;
+
+ @BeforeMethod
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ when(versionCollaborationStore.getVersionDao(anyObject())).thenReturn(versionDaoMock);
+ }
+*//*
+ @Test
+ public void testListPrivateItemVersions() throws Exception {
+ testListItemVersions(Space.PRIVATE, USER);
+ }
+
+ @Test
+ public void testListPublicItemVersions() throws Exception {
+ testListItemVersions(Space.PUBLIC, ZusammenPluginConstants.PUBLIC_SPACE);
+ }
+
+ @Test
+ public void testIsPrivateItemVersionExist() throws Exception {
+ testIsItemVersionExist(Space.PRIVATE, USER);
+ }
+
+ @Test
+ public void testIsPublicItemVersionExist() throws Exception {
+ testIsItemVersionExist(Space.PUBLIC, ZusammenPluginConstants.PUBLIC_SPACE);
+ }
+
+ @Test
+ public void testIsItemVersionExistWhenNot() throws Exception {
+ Id itemId = new Id();
+ Id versionId = new Id();
+ doReturn(Optional.empty()).when(versionDaoMock).get(context, USER, itemId, versionId);
+
+ boolean itemExist =
+ versionCollaborationStore.isItemVersionExist(context, Space.PRIVATE, itemId, versionId);
+ Assert.assertFalse(itemExist);
+ }
+
+ @Test
+ public void testGetPrivateItemVersion() throws Exception {
+ testGetItemVersion(Space.PRIVATE, USER);
+ }
+
+ @Test
+ public void testGetPublicItemVersion() throws Exception {
+ testGetItemVersion(Space.PUBLIC, ZusammenPluginConstants.PUBLIC_SPACE);
+ }
+
+
+ @Test
+ public void testGetNonExistingItemVersion() throws Exception {
+ Id itemId = new Id();
+ Id versionId = new Id();
+ doReturn(Optional.empty()).when(versionDaoMock).get(context, USER, itemId, versionId);
+
+ ItemVersion itemVersion =
+ versionCollaborationStore.getItemVersion(context, Space.PRIVATE, itemId, versionId);
+ Assert.assertNull(itemVersion);
+ }*//*
+
+ @Test
+ public void testCreatePrivateItemVersion() throws Exception {
+ testCreateItemVersion(Space.PRIVATE, USER, null);
+ }
+
+ @Test
+ public void testCreatePrivateItemVersionBasedOn() throws Exception {
+ testCreateItemVersion(Space.PRIVATE, USER, new Id());
+ }
+
+ @Test
+ public void testCreatePublicItemVersion() throws Exception {
+ testCreateItemVersion(Space.PUBLIC, ZusammenPluginConstants.PUBLIC_SPACE, null);
+ }
+
+ @Test
+ public void testCreatePublicItemVersionBasedOn() throws Exception {
+ testCreateItemVersion(Space.PUBLIC, ZusammenPluginConstants.PUBLIC_SPACE, new Id());
+ }
+
+ @Test
+ public void testUpdatePrivateItemVersion() throws Exception {
+ testUpdateItemVersion(Space.PRIVATE, USER);
+ }
+
+ @Test
+ public void testUpdatePublicItemVersion() throws Exception {
+ testUpdateItemVersion(Space.PUBLIC, ZusammenPluginConstants.PUBLIC_SPACE);
+ }
+
+ @Test
+ public void testDeletePrivateItemVersion() throws Exception {
+ testDeleteItemVersion(Space.PRIVATE, USER);
+ }
+
+ @Test
+ public void testDeletePublicItemVersion() throws Exception {
+ testDeleteItemVersion(Space.PUBLIC, ZusammenPluginConstants.PUBLIC_SPACE);
+ }
+
+ @Test
+ public void testPublishItemVersionWhenNotDirty() throws Exception {
+ Id itemId = new Id();
+ ItemVersion version = TestUtils.createItemVersion(new Id(), null, "v1", false);
+ doReturn(Optional.of(version)).when(versionDaoMock).get(context, USER, itemId, version.getId());
+
+ versionCollaborationStore.publishItemVersion(context, itemId, version.getId(), "message");
+
+ }
+*//*
+ private void testIsItemVersionExist(Space space, String spaceName) {
+ Id itemId = new Id();
+ ItemVersion retrievedVersion = TestUtils.createItemVersion(new Id(), null, "v1");
+ doReturn(Optional.of(retrievedVersion)).when(versionDaoMock)
+ .get(context, spaceName, itemId, retrievedVersion.getId());
+
+ boolean itemExist =
+ versionCollaborationStore
+ .isItemVersionExist(context, space, itemId, retrievedVersion.getId());
+ Assert.assertTrue(itemExist);
+ }
+
+ private void testGetItemVersion(Space space, String spaceName) throws Exception {
+ Id itemId = new Id();
+ ItemVersion retrievedVersion = TestUtils.createItemVersion(new Id(), null, "v1");
+ doReturn(Optional.of(retrievedVersion)).when(versionDaoMock)
+ .get(context, spaceName, itemId, retrievedVersion.getId());
+
+ ItemVersion itemVersion =
+ versionCollaborationStore.getItemVersion(context, space, itemId, retrievedVersion.getId());
+ Assert.assertEquals(itemVersion, retrievedVersion);
+ }
+
+ private void testListItemVersions(Space space, String spaceName) {
+ Id itemId = new Id();
+ ItemVersion v1 = TestUtils.createItemVersion(new Id(), null, "v1");
+ ItemVersion v2 = TestUtils.createItemVersion(new Id(), v1.getId(), "v2");
+ ItemVersion v3 = TestUtils.createItemVersion(new Id(), v2.getId(), "v3");
+ List<ItemVersion> retrievedVersions = Arrays.asList(v1, v2, v3);
+ doReturn(retrievedVersions).when(versionDaoMock).list(context, spaceName, itemId);
+
+ Collection<ItemVersion> itemVersions =
+ versionCollaborationStore.listItemVersions(context, space, itemId);
+ Assert.assertEquals(itemVersions, retrievedVersions);
+ }*//*
+
+ private void testCreateItemVersion(Space space, String spaceName, Id baseId) {
+ Id itemId = new Id();
+ ItemVersion v1 = TestUtils.createItemVersion(new Id(), baseId, "v1", false);
+ List<ElementEntity> baseVersionElements = mockVersionElements(spaceName, itemId, baseId);
+
+ ArgumentCaptor<ItemVersion> versionCaptor = ArgumentCaptor.forClass(ItemVersion.class);
+
+ Date creationTime = new Date();
+ versionCollaborationStore
+ .createItemVersion(context, space, itemId, baseId, v1.getId(), v1.getData(), creationTime);
+
+ verify(versionDaoMock).create(eq(context), eq(spaceName), eq(itemId), versionCaptor.capture());
+ //baseId, v1.getId(),v1.getData(), creationTime);
+
+ ItemVersion capturedVersion = versionCaptor.getValue();
+ Assert.assertEquals(baseId, capturedVersion.getBaseId());
+ Assert.assertEquals(v1.getId(), capturedVersion.getId());
+ Assert.assertEquals(v1.getData(), capturedVersion.getData());
+ Assert.assertEquals(creationTime, capturedVersion.getCreationTime());
+*//* verify(versionDaoMock)
+ .create(anyObject(), anyObject(), anyObject(), anyObject(), anyObject(), anyObject(),
+ anyObject());*//*
+
+*//* if (baseId != null) {
+ baseVersionElements.forEach(element ->
+ verify(elementCollaborationStore).create(eq(context),
+ eq(new ElementEntityContext(spaceName, itemId, v1.getId())),
+ eq(element)));
+ } else {
+ verifyZeroInteractions(elementCollaborationStore);
+ }*//*
+ }
+
+ private void testUpdateItemVersion(Space space, String spaceName) {
+ Id itemId = new Id();
+ ItemVersion retrievedVersion = TestUtils.createItemVersion(new Id(), null, "v1", false);
+ doReturn(Optional.of(retrievedVersion)).when(versionDaoMock)
+ .get(context, spaceName, itemId, retrievedVersion.getId());
+
+ ItemVersionData updatedData = new ItemVersionData();
+ updatedData.setInfo(TestUtils.createInfo("v1 updated"));
+ updatedData.setRelations(
+ Arrays.asList(new Relation(), new Relation(), new Relation(), new Relation()));
+ versionCollaborationStore.updateItemVersion(
+ context, space, itemId, retrievedVersion.getId(), updatedData, new Date());
+
+ *//*verify(versionDaoMock)
+ .update(context, spaceName, itemId, retrievedVersion.getId(), updatedData, modificationTime);*//*
+ verify(versionDaoMock)
+ .update(anyObject(), anyObject(), anyObject(), anyObject());
+
+ }
+
+ private void testDeleteItemVersion(Space space, String spaceName) {
+ Id itemId = new Id();
+ Id versionId = new Id();
+
+ List<ElementEntity> versionElements = mockVersionElements(spaceName, itemId, versionId);
+ versionCollaborationStore.deleteItemVersion(context, space, itemId, versionId);
+
+*//* versionElements.forEach(element ->
+ verify(elementCollaborationStore).delete(eq(context),
+ eq(new ElementEntityContext(spaceName, itemId, versionId)),
+ eq(element)));*//*
+ verify(versionDaoMock).delete(context, spaceName, itemId, versionId);
+ }
+
+ private List<ElementEntity> mockVersionElements(String spaceName, Id itemId, Id versionId) {
+ ElementEntity elm1 = new ElementEntity(new Id());
+ ElementEntity elm2 = new ElementEntity(new Id());
+ List<ElementEntity> baseVersionElements = Arrays.asList(elm1, elm2);
+*//* doReturn(baseVersionElements).when(elementCollaborationStore)
+ .list(eq(context), eq(new ElementEntityContext(spaceName, itemId, versionId)));*//*
+ return baseVersionElements;
+ }*/
+}
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/test/java/org/openecomp/core/zusammen/plugin/collaboration/impl/ElementStageStoreImplTest.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/test/java/org/openecomp/core/zusammen/plugin/collaboration/impl/ElementStageStoreImplTest.java
new file mode 100644
index 0000000..7f137b0
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/test/java/org/openecomp/core/zusammen/plugin/collaboration/impl/ElementStageStoreImplTest.java
@@ -0,0 +1,167 @@
+package org.openecomp.core.zusammen.plugin.collaboration.impl;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.UserInfo;
+import com.amdocs.zusammen.datatypes.item.Action;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import com.amdocs.zusammen.datatypes.item.Resolution;
+import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.mockito.Spy;
+import org.openecomp.core.zusammen.plugin.collaboration.TestUtils;
+import org.openecomp.core.zusammen.plugin.dao.ElementStageRepository;
+import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
+import org.openecomp.core.zusammen.plugin.dao.types.StageEntity;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Optional;
+import java.util.Set;
+
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Matchers.same;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class ElementStageStoreImplTest {
+ private static final UserInfo USER = new UserInfo("user");
+ private static final SessionContext context = TestUtils.createSessionContext(USER, "test");
+ private static final ElementContext elementContext =
+ TestUtils.createElementContext(new Id(), new Id());
+
+ @Mock
+ private ElementStageRepository elementStageRepositoryMock;
+ @Spy
+ private ElementStageStoreImpl elementStageStore;
+
+ @BeforeMethod
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ when(elementStageStore.getElementStageRepository(anyObject()))
+ .thenReturn(elementStageRepositoryMock);
+ }
+
+ @Test
+ public void testListIds() throws Exception {
+
+ }
+
+ @Test
+ public void testGet() throws Exception {
+
+ }
+
+ @Test
+ public void testGetConflicted() throws Exception {
+
+ }
+
+ @Test
+ public void testHasConflicts() throws Exception {
+
+ }
+
+ @Test
+ public void testListConflictedDescriptors() throws Exception {
+
+ }
+
+ @Test
+ public void testCreate() throws Exception {
+
+ }
+
+ @Test
+ public void testDelete() throws Exception {
+
+ }
+
+ @Test
+ public void testResolveConflictWhenNotStaged() throws Exception {
+ doReturn(Optional.empty())
+ .when(elementStageRepositoryMock).get(anyObject(), anyObject(), anyObject());
+ elementStageStore
+ .resolveConflict(context, elementContext, new ElementEntity(new Id()), Resolution.YOURS);
+ }
+
+ @Test
+ public void testResolveConflictWhenNotConflicted() throws Exception {
+ Id elementId = new Id();
+ StageEntity<ElementEntity> stagedElement =
+ new StageEntity<>(new ElementEntity(elementId), new Date());
+ doReturn(Optional.of(stagedElement))
+ .when(elementStageRepositoryMock).get(anyObject(), anyObject(), anyObject());
+ elementStageStore
+ .resolveConflict(context, elementContext, new ElementEntity(elementId), Resolution.YOURS);
+ }
+
+ @Test
+ public void testResolveConflictByYours() throws Exception {
+ Id elementId = new Id();
+ StageEntity<ElementEntity> stagedElement =
+ new StageEntity<>(new ElementEntity(elementId), new Date());
+ stagedElement.setAction(Action.UPDATE);
+ stagedElement.setConflicted(true);
+
+ doReturn(Optional.of(stagedElement))
+ .when(elementStageRepositoryMock).get(anyObject(), anyObject(), anyObject());
+
+ elementStageStore
+ .resolveConflict(context, elementContext, new ElementEntity(elementId), Resolution.YOURS);
+
+ verify(elementStageRepositoryMock).markAsNotConflicted(same(context),
+ eq(new ElementEntityContext(USER.getUserName(), elementContext)),
+ same(stagedElement.getEntity()), same(Action.IGNORE));
+ }
+
+ @Test
+ public void testResolveConflictByYoursWithRelated() throws Exception {
+ Id elementId = new Id();
+ StageEntity<ElementEntity> stagedElement =
+ new StageEntity<>(new ElementEntity(elementId), new Date());
+ stagedElement.setAction(Action.UPDATE);
+ stagedElement.setConflicted(true);
+ ElementEntity relatedElement1 = new ElementEntity(new Id());
+ ElementEntity relatedElement2 = new ElementEntity(new Id());
+ ElementEntity relatedElement3 = new ElementEntity(new Id());
+ Set<ElementEntity> relatedElements = new HashSet<>();
+ relatedElements.add(relatedElement1);
+ relatedElements.add(relatedElement2);
+ relatedElements.add(relatedElement3);
+ stagedElement.setConflictDependents(relatedElements);
+
+ doReturn(Optional.of(stagedElement))
+ .when(elementStageRepositoryMock).get(anyObject(), anyObject(), anyObject());
+
+ elementStageStore
+ .resolveConflict(context, elementContext, new ElementEntity(elementId), Resolution.YOURS);
+
+ ElementEntityContext elementEntityContext =
+ new ElementEntityContext(USER.getUserName(), elementContext);
+ verify(elementStageRepositoryMock).markAsNotConflicted(same(context), eq(elementEntityContext),
+ same(stagedElement.getEntity()), same(Action.IGNORE));
+ verify(elementStageRepositoryMock).markAsNotConflicted(same(context), eq(elementEntityContext),
+ same(relatedElement1), same(Action.IGNORE));
+ verify(elementStageRepositoryMock).markAsNotConflicted(same(context), eq(elementEntityContext),
+ same(relatedElement2), same(Action.IGNORE));
+ verify(elementStageRepositoryMock).markAsNotConflicted(same(context), eq(elementEntityContext),
+ same(relatedElement3), same(Action.IGNORE));
+ }
+
+ @Test
+ public void testResolveConflictByTheirs() throws Exception {
+
+ }
+
+ @Test
+ public void testResolveConflictByTheirsWithRelated() throws Exception {
+
+ }
+
+}
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-core-lib/pom.xml b/openecomp-be/lib/openecomp-core-lib/pom.xml
index 3784593..51faa10 100644
--- a/openecomp-be/lib/openecomp-core-lib/pom.xml
+++ b/openecomp-be/lib/openecomp-core-lib/pom.xml
@@ -20,5 +20,6 @@
<module>/openecomp-utilities-lib</module>
<module>/openecomp-config-lib</module>
<module>/openecomp-zusammen-lib</module>
+ <module>/openecomp-session-lib</module>
</modules>
</project>
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/pom.xml b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/pom.xml
index 2900785..fa3533f 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/pom.xml
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/pom.xml
@@ -14,6 +14,23 @@
<dependencies>
<dependency>
+ <groupId>org.openecomp.sdc.common</groupId>
+ <artifactId>openecomp-configuration-management-core</artifactId>
+ <version>${openecomp.sdc.common.version}</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.common</groupId>
+ <artifactId>openecomp-configuration-management-api</artifactId>
+ <version>${openecomp.sdc.common.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.openecomp.sdc.core</groupId>
<artifactId>openecomp-facade-core</artifactId>
<version>${project.version}</version>
@@ -33,6 +50,11 @@
<artifactId>openecomp-sdc-versioning-api</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-item-permissions-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
</project>
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/api/HealingManager.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/api/HealingManager.java
index 211d9a2..ca0a3c7 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/api/HealingManager.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/api/HealingManager.java
@@ -20,16 +20,24 @@
package org.openecomp.sdc.healing.api;
+import org.openecomp.sdc.datatypes.model.ItemType;
import org.openecomp.sdc.healing.types.HealCode;
+import org.openecomp.sdc.healing.types.HealerType;
+import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.Map;
import java.util.Optional;
/**
* Created by Talio on 11/29/2016.
*/
public interface HealingManager {
- Object heal(HealCode code, Map<String, Object> healParameters);
- Optional<String> healAll(Map<String, Object> healParameters);
+ /**
+ * @return healed version, if healing was not performed - Optional.empty.
+ */
+ Optional<Version> healItemVersion(String itemId, Version version, ItemType itemType,
+ boolean force);
+
+ Object heal(String itemId, Version version, HealerType healerType, HealCode code,
+ ItemType itemType);
}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/dao/HealingDao.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/dao/HealingDao.java
new file mode 100644
index 0000000..b766bd8
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/dao/HealingDao.java
@@ -0,0 +1,13 @@
+package org.openecomp.sdc.healing.dao;
+
+import java.util.Optional;
+
+/**
+ * Created by ayalaben on 10/17/2017
+ */
+public interface HealingDao {
+
+ Optional<Boolean> getItemHealingFlag(String space, String itemId, String versionId);
+
+ void setItemHealingFlag(boolean healingNeededFlag, String space, String itemId, String versionId);
+}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/factory/HealingManagerFactory.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/factory/HealingManagerFactory.java
index 8e8d633..5e375ee 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/factory/HealingManagerFactory.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/factory/HealingManagerFactory.java
@@ -20,9 +20,9 @@
package org.openecomp.sdc.healing.factory;
-import org.openecomp.sdc.healing.api.HealingManager;
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
+import org.openecomp.sdc.healing.api.HealingManager;
/**
* Created by Talio on 11/29/2016.
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/interfaces/Healer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/interfaces/Healer.java
index eb2f9a7..38afd13 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/interfaces/Healer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/interfaces/Healer.java
@@ -20,11 +20,11 @@
package org.openecomp.sdc.healing.interfaces;
-import java.util.Map;
+import org.openecomp.sdc.versioning.dao.types.Version;
/**
* Created by Talio on 11/29/2016.
*/
public interface Healer {
- Object heal(Map<String, Object> healingParams) throws Exception;
+ Object heal(String itemId, Version version) throws Exception;
}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/types/ConfigConstants.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/types/ConfigConstants.java
new file mode 100644
index 0000000..0630127
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/types/ConfigConstants.java
@@ -0,0 +1,5 @@
+package org.openecomp.sdc.healing.types;
+
+public class ConfigConstants {
+ public static final String HEALING_NAMESPACE = "healing";
+}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/types/HealerType.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/types/HealerType.java
new file mode 100644
index 0000000..3355a3c
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/types/HealerType.java
@@ -0,0 +1,6 @@
+package org.openecomp.sdc.healing.types;
+
+public enum HealerType {
+ data,
+ structure
+}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/types/HealingContext.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/types/HealingContext.java
deleted file mode 100644
index 2ad143a..0000000
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/types/HealingContext.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package org.openecomp.sdc.healing.types;
-import org.openecomp.sdc.versioning.dao.types.Version;
-
-/**
- * Created by TALIO on 7/3/2017.
- */
-public class HealingContext {
- private String vspId;
- private Version version;
- private String user;
-
- public HealingContext(String vspId, Version version, String user) {
- this.vspId = vspId;
- this.version = version;
- this.user = user;
- }
-
- public String getVspId() {
- return vspId;
- }
-
- public void setVspId(String vspId) {
- this.vspId = vspId;
- }
-
- public Version getVersion() {
- return version;
- }
-
- public void setVersion(Version version) {
- this.version = version;
- }
-
- public String getUser() {
- return user;
- }
-
- public void setUser(String user) {
- this.user = user;
- }
-}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/dao/impl/HealingDaoImpl.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/dao/impl/HealingDaoImpl.java
new file mode 100644
index 0000000..921f418
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/dao/impl/HealingDaoImpl.java
@@ -0,0 +1,46 @@
+package org.openecomp.sdc.healing.dao.impl;
+
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.mapping.annotations.Accessor;
+import com.datastax.driver.mapping.annotations.Query;
+import org.openecomp.core.nosqldb.api.NoSqlDb;
+import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
+import org.openecomp.sdc.healing.dao.HealingDao;
+
+import java.util.Optional;
+
+/**
+ * Created by ayalaben on 10/17/2017
+ */
+public class HealingDaoImpl implements HealingDao {
+
+ private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
+ private static HealingAccessor accessor =
+ noSqlDb.getMappingManager().createAccessor(HealingAccessor.class);
+
+ @Override
+ public Optional<Boolean> getItemHealingFlag(String space, String itemId, String versionId) {
+ ResultSet result = accessor.getItemHealingFlag(space, itemId, versionId);
+ return result.getAvailableWithoutFetching() < 1
+ ? Optional.empty()
+ : Optional.of(result.one().getBool("healing_needed"));
+ }
+
+ @Override
+ public void setItemHealingFlag(boolean healingNeededFlag, String space, String itemId,
+ String versionId) {
+ accessor.setItemHealingFlag(healingNeededFlag, space, itemId, versionId);
+ }
+
+
+ @Accessor
+ interface HealingAccessor {
+
+ @Query("SELECT healing_needed FROM healing WHERE space=? AND item_id=? AND version_id=?")
+ ResultSet getItemHealingFlag(String space, String itemId, String versionId);
+
+ @Query("UPDATE healing SET healing_needed=? WHERE space=? AND item_id=? AND version_id=?")
+ void setItemHealingFlag(boolean flag, String space, String itemId, String versionId);
+
+ }
+}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerFactoryImpl.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerFactoryImpl.java
index 84aff43..5a283f9 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerFactoryImpl.java
@@ -21,15 +21,17 @@
package org.openecomp.sdc.healing.impl;
import org.openecomp.sdc.healing.api.HealingManager;
+import org.openecomp.sdc.healing.dao.impl.HealingDaoImpl;
import org.openecomp.sdc.healing.factory.HealingManagerFactory;
+import org.openecomp.sdc.versioning.VersioningManagerFactory;
/**
* Created by Talio on 11/29/2016.
*/
public class HealingManagerFactoryImpl extends HealingManagerFactory {
-
@Override
public HealingManager createInterface() {
- return new HealingManagerImpl();
+ return new HealingManagerImpl(
+ VersioningManagerFactory.getInstance().createInterface(), new HealingDaoImpl());
}
}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java
index 1c895ff..59c6732 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java
@@ -24,34 +24,147 @@
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.sdc.common.errors.Messages;
+import org.openecomp.sdc.common.session.SessionContextProviderFactory;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.datatypes.model.ItemType;
import org.openecomp.sdc.healing.api.HealingManager;
+import org.openecomp.sdc.healing.dao.HealingDao;
import org.openecomp.sdc.healing.interfaces.Healer;
import org.openecomp.sdc.healing.types.HealCode;
+import org.openecomp.sdc.healing.types.HealerType;
import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
import org.openecomp.sdc.logging.types.LoggerConstants;
import org.openecomp.sdc.logging.types.LoggerErrorCode;
import org.openecomp.sdc.logging.types.LoggerErrorDescription;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+import org.openecomp.sdc.versioning.VersioningManager;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.dao.types.VersionStatus;
+import org.openecomp.sdc.versioning.types.VersionCreationMethod;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Optional;
+import java.util.stream.Collectors;
/**
* Created by Talio on 11/29/2016.
*/
public class HealingManagerImpl implements HealingManager {
- private static String HEALING_CONF_FILE = "healingConfiguration.json";
- private static Map<String, String> healerCodeToImplClass = initHealers();
+
+ private static final String HEALERS_BY_ENTITY_TYPE_FILE = "entityHealingConfiguration.json";
+ private static final String HEALING_USER_SUFFIX = "_healer";
+ private static final String PUBLIC_USER = "public";
+
+ private HealingDao healingDao;
+ private VersioningManager versioningManager;
+
+ public HealingManagerImpl(VersioningManager versioningManager, HealingDao healingDao) {
+ this.versioningManager = versioningManager;
+ this.healingDao = healingDao;
+ }
@Override
- public Object heal(HealCode code, Map<String, Object> healParameters) {
+ public Optional<Version> healItemVersion(String itemId, Version version, ItemType itemType,
+ boolean force) {
+ String user = getUser();
+ if (force || isPrivateHealingNeededByFlag(itemId, version.getId(), user)) {
+ version = versioningManager.get(itemId, version);
+ Version origVersion = version;
+ if (version.getStatus() == VersionStatus.Certified) {
+ Optional<Version> newVersion = createNewVersion(itemId, version);
+ if (!newVersion.isPresent()) {
+ // do NOT turn off flag here (in thought of saving version calculate performance next
+ // time) because maybe next time the next version will be available (due to deletion of
+ // the taken one)
+ return Optional.empty();
+ }
+ version = newVersion.get();
+ }
+
+ doHeal(itemId, version, origVersion, itemType, user, force);
+ return Optional.of(version);
+ }
+ return Optional.empty();
+ }
+
+ private void doHeal(String itemId, Version version, Version origVersion,
+ ItemType itemType, String user, boolean force) {
+ Optional<String> privateFailureMessages =
+ healPrivate(itemId, version, origVersion, getItemHealers(itemType), user);
+
+ Optional<String> publicFailureMessages =
+ force || origVersion.getStatus() == VersionStatus.Certified ||
+ isPublicHealingNeededByFlag(itemId, origVersion.getId())
+ ? healPublic(itemId, version, origVersion, getItemHealers(itemType), user)
+ : Optional.empty();
+
+ if (privateFailureMessages.isPresent() || publicFailureMessages.isPresent()) {
+ throw new RuntimeException(
+ publicFailureMessages.orElse("") + " " + privateFailureMessages.orElse(""));
+ }
+ }
+
+ private Optional<String> healPrivate(String itemId, Version version, Version origVersion,
+ Map<String, Map<String, String>> itemHealers, String user) {
+ if (origVersion.getStatus() != VersionStatus.Certified) {
+ itemHealers.remove(HealerType.structure.name());
+ }
+
+ Optional<String> privateHealingFailureMessages = executeHealers(itemId, version, itemHealers);
+ markAsHealed(itemId, origVersion.getId(), user);
+ return privateHealingFailureMessages;
+ }
+
+ private Optional<String> healPublic(String itemId, Version version, Version origVersion,
+ Map<String, Map<String, String>> itemHealers, String user) {
+ Optional<String> healingFailureMessages = origVersion.getStatus() == VersionStatus.Certified
+ ? Optional.empty()
+ : healPublic(itemId, version, itemHealers, user);
+
+ markAsHealed(itemId, origVersion.getId(), PUBLIC_USER);
+ return healingFailureMessages;
+ }
+
+ private Optional<String> healPublic(String itemId, Version version,
+ Map<String, Map<String, String>> itemHealers, String user) {
+ SessionContextProviderFactory.getInstance().createInterface()
+ .create(user + HEALING_USER_SUFFIX);
+
+ versioningManager.sync(itemId, version);
+
+ Optional<String> healingFailureMessages = executeHealers(itemId, version, itemHealers);
+ Version publicVersion = versioningManager.get(itemId, version);
+
+ if (Objects.nonNull(publicVersion.getState()) && publicVersion.getState().isDirty()) {
+ versioningManager.publish(itemId, version, "Healing vsp");
+ }
+
+ SessionContextProviderFactory.getInstance().createInterface().create(user);
+ return healingFailureMessages;
+ }
+
+ private Optional<Version> createNewVersion(String itemId, Version version) {
+ Version newVersion = new Version();
+ newVersion.setBaseId(version.getId());
+ try {
+ return Optional.of(versioningManager.create(itemId, newVersion, VersionCreationMethod.major));
+ } catch (Exception e) {
+ return Optional.empty();
+ }
+ }
+
+ @Override
+ public Object heal(String itemId, Version version, HealerType healerType, HealCode code,
+ ItemType itemType) {
+ String healerClassName = getItemHealers(itemType).get(healerType.name()).get(code.name());
ArrayList<String> healingFailureMessages = new ArrayList<>();
- Object result =
- heal(healParameters, healerCodeToImplClass.get(code.name()), healingFailureMessages);
+ Object result = executeHealer(itemId, version, healerClassName, healingFailureMessages);
if (!healingFailureMessages.isEmpty()) {
throw new RuntimeException(CommonMethods.listToSeparatedString(healingFailureMessages, '\n'));
@@ -59,46 +172,77 @@
return result;
}
- @Override
- public Optional<String> healAll(Map<String, Object> healParameters) {
- ArrayList<String> healingFailureMessages = new ArrayList<>();
+ private Optional<String> executeHealers(String itemId, Version version,
+ Map<String, Map<String, String>> itemHealers) {
+ List<String> healers = itemHealers.values().stream()
+ .map(Map::values)
+ .flatMap(Collection::stream)
+ .collect(Collectors.toList());
- for (String implClassName : healerCodeToImplClass.values()) {
- heal(healParameters, implClassName, healingFailureMessages);
+ List<String> healingFailureMessages = new ArrayList<>();
+ for (String implClassName : healers) {
+ executeHealer(itemId, version, implClassName, healingFailureMessages);
}
- return healingFailureMessages.isEmpty() ? Optional.empty()
+ return healingFailureMessages.isEmpty()
+ ? Optional.empty()
: Optional.of(CommonMethods.listToSeparatedString(healingFailureMessages, '\n'));
}
- private Object heal(Map<String, Object> healParameters, String healerImplClassName,
- ArrayList<String> healingFailureMessages) {
- Healer healerImpl;
+
+ private Object executeHealer(String itemId, Version version, String healerClassName,
+ List<String> healingFailureMessages) {
+ Healer healer;
try {
- healerImpl = getHealerImplInstance(healerImplClassName);
+ healer = getHealerImplInstance(healerClassName);
} catch (Exception e) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.SELF_HEALING, ErrorLevel.ERROR.name(), LoggerErrorCode
.DATA_ERROR.getErrorCode(), LoggerErrorDescription.CANT_HEAL);
healingFailureMessages
.add(String.format(Messages.CANT_LOAD_HEALING_CLASS.getErrorMessage(),
- healerImplClassName));
+ healerClassName));
return null;
}
try {
- return healerImpl.heal(healParameters);
+ return healer.heal(itemId, version);
} catch (Exception e) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.SELF_HEALING, ErrorLevel.ERROR.name(), LoggerErrorCode
.DATA_ERROR.getErrorCode(), LoggerErrorDescription.CANT_HEAL);
- healingFailureMessages.add(e.getMessage() + " ,healer name :" + healerImplClassName);
+ healingFailureMessages.add(e.getMessage() + " ,healer name :" + healerClassName);
}
return null;
}
- private static Map<String, String> initHealers() {
- return FileUtils.readViaInputStream(HEALING_CONF_FILE, stream -> JsonUtil.json2Object(stream, Map.class));
+ private boolean isPrivateHealingNeededByFlag(String itemId, String version, String user) {
+ Optional<Boolean> userHealingFlag = getHealingFlag(itemId, version, user);
+ return userHealingFlag.isPresent()
+ ? userHealingFlag.get()
+ : isPublicHealingNeededByFlag(itemId, version);
+ }
+
+ private boolean isPublicHealingNeededByFlag(String itemId, String versionId) {
+ Optional<Boolean> publicHealingFlag = getHealingFlag(itemId, versionId, PUBLIC_USER);
+ return publicHealingFlag.isPresent() && publicHealingFlag.get();
+ }
+
+ private Optional<Boolean> getHealingFlag(String itemId, String version, String user) {
+ return healingDao.getItemHealingFlag(user, itemId, version);
+ }
+
+ private void markAsHealed(String itemId, String versionId, String user) {
+ healingDao.setItemHealingFlag(false, user, itemId, versionId);
+ }
+
+ private Map<String, Map<String, String>> getItemHealers(ItemType itemType) {
+ // TODO: 11/29/2017 create objects to hold this configuration +
+ // load once from the json file and use the relevant healers (by itemType, healerType) as needed.
+ Map healingConfig = FileUtils
+ .readViaInputStream(HEALERS_BY_ENTITY_TYPE_FILE,
+ stream -> JsonUtil.json2Object(stream, Map.class));
+ return (Map<String, Map<String, String>>) healingConfig.get(itemType.name());
}
private Healer getHealerImplInstance(String implClassName)
@@ -106,4 +250,9 @@
NoSuchMethodException, ClassNotFoundException {
return (Healer) Class.forName(implClassName).getConstructor().newInstance();
}
+
+ private String getUser() {
+ return SessionContextProviderFactory.getInstance().createInterface().get().getUser()
+ .getUserId();
+ }
}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/resources/entityHealingConfiguration.json b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/resources/entityHealingConfiguration.json
new file mode 100644
index 0000000..ab8a1df
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/resources/entityHealingConfiguration.json
@@ -0,0 +1,12 @@
+{
+ "vsp": {
+ "structure": {
+ "ownerHealer": "org.openecomp.sdc.healing.healers.OwnerHealer"
+ }
+ },
+ "vlm": {
+ "structure": {
+ "ownerHealer": "org.openecomp.sdc.healing.healers.OwnerHealer"
+ }
+ }
+}
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/resources/healingConfiguration.json b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/resources/healingConfiguration.json
index 4e1b0df..85eec77 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/resources/healingConfiguration.json
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/resources/healingConfiguration.json
@@ -1,13 +1,19 @@
{
- "FILE_DATA_STRUCTURE_HEALER" : "org.openecomp.sdc.healing.healers.FileDataStructureHealer",
- "QUESTIONNAIRE_HEALER" : "org.openecomp.sdc.healing.healers.VspQuestionnaireHealer",
- "COMPOSITION_DATA_HEALER" : "org.openecomp.sdc.healing.healers.CompositionDataHealer",
- "SUB_ENTITIES_HEALER" : "org.openecomp.sdc.healing.healers.SubEntitiesQuestionnaireHealer",
- "ONBOARDING_METHOD_HEALER" : "org.openecomp.sdc.healing.healers.VspOnboardingMethodHealer",
- "NIC_DATA_HEALER" : "org.openecomp.sdc.healing.healers.NicDataHealer",
- "COMPONENT_QUESTIONNAIRE_HEALER" : "org.openecomp.sdc.healing.healers.ComponentQuestionnaireHealer",
- "HEAT_TOSCA_TRANSLATION_HEALER" : "org.openecomp.sdc.healing.healers.HeatToToscaTranslationHealer",
- "VLM_VERSION_HEALER" : "org.openecomp.sdc.healing.healers.VlmVersionHealer",
- "VALIDATION_STRUCTURE_HEALER" : "org.openecomp.sdc.healing.healers.ValidationStructureHealer",
- "FORWARDER_CAPABILITY_HEALER" : "org.openecomp.sdc.healing.healers.ForwarderCapabilityHealer"
+ "VendorSoftwareProduct" : {
+ "VSP_OWNER_HEALER" : "org.openecomp.sdc.healing.healers.VspOwnerHealer",
+ "FILE_DATA_STRUCTURE_HEALER" : "org.openecomp.sdc.healing.healers.FileDataStructureHealer",
+ "QUESTIONNAIRE_HEALER" : "org.openecomp.sdc.healing.healers.VspQuestionnaireHealer",
+ "COMPOSITION_DATA_HEALER" : "org.openecomp.sdc.healing.healers.CompositionDataHealer",
+ "SUB_ENTITIES_HEALER" : "org.openecomp.sdc.healing.healers.SubEntitiesQuestionnaireHealer",
+ "ONBOARDING_METHOD_HEALER" : "org.openecomp.sdc.healing.healers.VspOnboardingMethodHealer",
+ "NIC_DATA_HEALER" : "org.openecomp.sdc.healing.healers.NicDataHealer",
+ "COMPONENT_QUESTIONNAIRE_HEALER" : "org.openecomp.sdc.healing.healers.ComponentQuestionnaireHealer",
+ "HEAT_TOSCA_TRANSLATION_HEALER" : "org.openecomp.sdc.healing.healers.HeatToToscaTranslationHealer",
+ "VLM_VERSION_HEALER" : "org.openecomp.sdc.healing.healers.VlmVersionHealer",
+ "VALIDATION_STRUCTURE_HEALER" : "org.openecomp.sdc.healing.healers.ValidationStructureHealer",
+ "FORWARDER_CAPABILITY_HEALER" : "org.openecomp.sdc.healing.healers.ForwarderCapabilityHealer"
+ },
+ "VendorLicenseModel" : {
+ "VLM_OWNER_HEALER" : "org.openecomp.sdc.healing.healers.VlmOwnerHealer"
+ }
}
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/pom.xml b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/pom.xml
index c54f724..1359e69 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/pom.xml
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/pom.xml
@@ -39,6 +39,11 @@
<artifactId>openecomp-sdc-vendor-license-api</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-item-permissions-impl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ComponentQuestionnaireHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ComponentQuestionnaireHealer.java
index 50e7678..83395e0 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ComponentQuestionnaireHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ComponentQuestionnaireHealer.java
@@ -4,7 +4,6 @@
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.apache.commons.lang3.StringUtils;
-import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.healing.interfaces.Healer;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
@@ -19,7 +18,6 @@
import org.openecomp.sdc.versioning.dao.types.Version;
import java.util.Collection;
-import java.util.Map;
import java.util.Objects;
@@ -57,11 +55,9 @@
}
@Override
- public Object heal(Map<String, Object> healingParams) throws Exception {
- mdcDataDebugMessage.debugEntryMessage("VSP ID",
- (String) healingParams.get(SdcCommon.VSP_ID));
- String vspId = (String) healingParams.get(SdcCommon.VSP_ID);
- Version version = (Version) healingParams.get(SdcCommon.VERSION);
+ public Object heal(String vspId, Version version) throws Exception {
+ mdcDataDebugMessage.debugEntryMessage("VSP ID", vspId);
+
Collection<ComponentEntity> componentEntities =
componentDao.list(new ComponentEntity(vspId, version, null));
componentEntities.forEach(componentEntity -> {
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/CompositionDataHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/CompositionDataHealer.java
index 6fc8cfe..e7a5e30 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/CompositionDataHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/CompositionDataHealer.java
@@ -31,7 +31,6 @@
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.sdc.common.utils.CommonUtil;
-import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.healing.interfaces.Healer;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
@@ -57,7 +56,7 @@
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadDataEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionDataExtractorFactory;
import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionEntityDataManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionDataExtractor;
@@ -69,7 +68,6 @@
import java.io.IOException;
import java.util.Collection;
-import java.util.Map;
import java.util.Objects;
import java.util.Optional;
@@ -102,14 +100,10 @@
}
@Override
- public Optional<CompositionData> heal(Map<String, Object> healingParams) throws IOException {
+ public Optional<CompositionData> heal(String vspId,
+ Version version) throws IOException {
mdcDataDebugMessage.debugEntryMessage(null);
- String vspId = (String) healingParams.get(SdcCommon.VSP_ID);
- Version version = VERSION00.equals(healingParams.get(SdcCommon.VERSION))
- ? VERSION01
- : (Version) healingParams.get(SdcCommon.VERSION);
-
Collection<ComponentEntity> componentEntities =
componentDao.list(new ComponentEntity(vspId, version, null));
Collection<NicEntity> nicEntities = nicDao.listByVsp(vspId, version);
@@ -131,7 +125,7 @@
serviceModels.get()) : null;
}
- if(serviceModels.isPresent()) {
+ if (serviceModels.isPresent()) {
compositionData =
getCompositionDataForHealing(vspId, version, serviceModels.get());
HealNfodData(vspId, version, compositionData);
@@ -150,16 +144,16 @@
if (CollectionUtils.isEmpty(computeEntities) && CollectionUtils.isEmpty(imageEntities)) {
for (Component component : compositionData.getComponents()) {
String componentId = null;
- for (ComponentEntity componentEntity:componentEntities) {
+ for (ComponentEntity componentEntity : componentEntities) {
if (componentEntity.getComponentCompositionData().getName().equals(component.getData()
.getName())) {
componentId = componentEntity.getId();
break;
}
}
- compositionEntityDataManager.saveComputesFlavorByComponent(vspId,version,component,
+ compositionEntityDataManager.saveComputesFlavorByComponent(vspId, version, component,
componentId);
- compositionEntityDataManager.saveImagesByComponent(vspId,version,component,
+ compositionEntityDataManager.saveImagesByComponent(vspId, version, component,
componentId);
}
@@ -228,13 +222,15 @@
}
private Optional<Pair<ToscaServiceModel, ToscaServiceModel>> getServiceModelForHealing(String
- vspId, Version
+ vspId,
+ Version
version)
throws IOException {
mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
- UploadDataEntity uploadData =
- orchestrationTemplateDataDao.getOrchestrationTemplate(vspId, version);
+ /*OrchestrationTemplateEntity uploadData =
+ vendorSoftwareProductDao.getUploadData(new OrchestrationTemplateEntity(vspId, version));*/
+ OrchestrationTemplateEntity uploadData = orchestrationTemplateDataDao.get(vspId, version);
if (Objects.isNull(uploadData) || Objects.isNull(uploadData.getContentData())) {
return Optional.empty();
@@ -259,7 +255,7 @@
.getNonUnifiedToscaServiceModel()));
}
- private TranslatorOutput getTranslatorOutputForHealing(UploadDataEntity uploadData) {
+ private TranslatorOutput getTranslatorOutputForHealing(OrchestrationTemplateEntity uploadData) {
FileContentHandler fileContentHandler;
try {
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/FileDataStructureHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/FileDataStructureHealer.java
index 4a0a5f9..6e49c9a 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/FileDataStructureHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/FileDataStructureHealer.java
@@ -24,33 +24,23 @@
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.sdc.common.utils.CommonUtil;
-import org.openecomp.sdc.common.utils.SdcCommon;
-import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.healing.interfaces.Healer;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadDataEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.factory.CandidateServiceFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService;
import org.openecomp.sdc.vendorsoftwareproduct.services.utils.CandidateEntityBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure;
import org.openecomp.sdc.versioning.dao.types.Version;
import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
import java.util.Optional;
public class FileDataStructureHealer implements Healer {
- private static final OrchestrationTemplateDao orchestrationTemplateDataDao =
- OrchestrationTemplateDaoFactory.getInstance().createInterface();
- private static CandidateService candidateService =
- CandidateServiceFactory.getInstance().createInterface();
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
@@ -59,64 +49,55 @@
}
@Override
- public Optional<FilesDataStructure> heal(Map<String, Object> healingParams) throws Exception {
-
-
+ public Optional<FilesDataStructure> heal(String vspId,
+ Version version) throws Exception {
mdcDataDebugMessage.debugEntryMessage(null);
- Optional<FilesDataStructure> healingResult = Optional.empty();
- String vspId = (String) healingParams.get(SdcCommon.VSP_ID);
- Version version = (Version) healingParams.get(SdcCommon.VERSION);
- String user = (String) healingParams.get(SdcCommon.USER);
+ OrchestrationTemplateCandidateDao candidateDao =
+ OrchestrationTemplateCandidateDaoFactory.getInstance().createInterface();
- UploadDataEntity uploadData =
- orchestrationTemplateDataDao.getOrchestrationTemplate(vspId,version);
- if (uploadData == null || uploadData.getContentData() == null) {
- FilesDataStructure emptyFilesDataStructure = new FilesDataStructure();
- return Optional.of(emptyFilesDataStructure);
+ OrchestrationTemplateCandidateData candidateData = candidateDao.get(vspId, version);
+
+ if (candidateData == null || candidateData.getContentData() == null ||
+ candidateData.getFilesDataStructure() != null) {
+ return Optional.of(new FilesDataStructure());
}
- Optional<FilesDataStructure> candidateFileDataStructure =
- candidateService.getOrchestrationTemplateCandidateFileDataStructure(vspId, version);
+ Optional<FilesDataStructure> filesDataStructure =
+ healFilesDataStructure(vspId, version, candidateData);
- if (!candidateFileDataStructure.isPresent()) {
- healingResult = healFilesDataStructure(vspId, version, user, uploadData);
- }
+ filesDataStructure
+ .ifPresent(structure -> candidateDao.updateStructure(vspId, version, structure));
mdcDataDebugMessage.debugExitMessage(null);
- return healingResult;
+ return filesDataStructure;
}
- private Optional<FilesDataStructure> healFilesDataStructure(String vspId, Version version,
- String user,
- UploadDataEntity uploadData)
+ private Optional<FilesDataStructure> healFilesDataStructure(
+ String vspId, Version version, OrchestrationTemplateCandidateData candidateData)
throws Exception {
-
-
mdcDataDebugMessage.debugEntryMessage(null);
Optional<FilesDataStructure> healingResult;
- byte[] byteContentData = uploadData.getContentData().array();
+ byte[] byteContentData = candidateData.getContentData().array();
FileContentHandler fileContentHandler;
- try{
- fileContentHandler = CommonUtil.validateAndUploadFileContent(OnboardingTypesEnum.ZIP, byteContentData);
- Map<String, List<ErrorMessage>> errors = new HashMap<>();
- OrchestrationTemplateCandidateData candidateDataEntity =
- new CandidateEntityBuilder(candidateService)
- .buildCandidateEntityFromZip(new VspDetails(vspId, version), byteContentData,
- fileContentHandler, errors, user);
+ try {
+ fileContentHandler =
+ CommonUtil.validateAndUploadFileContent(OnboardingTypesEnum.ZIP, byteContentData);
- healingResult = getFileDataStructureFromJson(candidateDataEntity.getFilesDataStructure());
- }catch (Exception e){
+ String filesDataStructure =
+ new CandidateEntityBuilder(CandidateServiceFactory.getInstance().createInterface())
+ .buildCandidateEntityFromZip(new VspDetails(vspId, version), byteContentData,
+ fileContentHandler, new HashMap<>()).getFilesDataStructure();
+
+ healingResult =
+ Optional.of(JsonUtil.json2Object(filesDataStructure, FilesDataStructure.class));
+ } catch (Exception e) {
log.debug("", e);
- return Optional.empty();
+ healingResult = Optional.empty();
}
mdcDataDebugMessage.debugExitMessage(null);
return healingResult;
}
-
- private Optional<FilesDataStructure> getFileDataStructureFromJson(String fileDataStructureJson) {
- return Optional.of(JsonUtil.json2Object(fileDataStructureJson, FilesDataStructure.class));
- }
}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ForwarderCapabilityHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ForwarderCapabilityHealer.java
index c2d7c2c..7991c59 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ForwarderCapabilityHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ForwarderCapabilityHealer.java
@@ -5,7 +5,6 @@
import org.openecomp.core.model.dao.ServiceModelDaoFactory;
import org.openecomp.core.model.types.ServiceElement;
import org.openecomp.sdc.common.togglz.ToggleableFeature;
-import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.healing.interfaces.Healer;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
@@ -46,10 +45,7 @@
}
@Override
- public Object heal(Map<String, Object> healingParams) throws Exception {
- String vspId = (String) healingParams.get(SdcCommon.VSP_ID);
- Version version = (Version) healingParams.get(SdcCommon.VERSION);
-
+ public Object heal(String vspId, Version version) throws Exception {
if(!ToggleableFeature.FORWARDER_CAPABILITY.isActive()) {
return Optional.empty();
}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/HeatToToscaTranslationHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/HeatToToscaTranslationHealer.java
index 32cd8cb..ddae09f 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/HeatToToscaTranslationHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/HeatToToscaTranslationHealer.java
@@ -3,14 +3,11 @@
import org.openecomp.core.model.dao.ServiceModelDao;
import org.openecomp.core.model.dao.ServiceModelDaoFactory;
-import org.openecomp.core.model.dao.ServiceTemplateDaoFactory;
-import org.openecomp.core.model.dao.ServiceTemplateDaoInter;
import org.openecomp.core.model.types.ServiceElement;
import org.openecomp.core.translator.datatypes.TranslatorOutput;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.sdc.common.utils.CommonUtil;
-import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.healing.interfaces.Healer;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
@@ -19,37 +16,32 @@
import org.openecomp.sdc.translator.services.heattotosca.HeatToToscaUtil;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadDataEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.Map;
import java.util.Objects;
import java.util.Optional;
-public class HeatToToscaTranslationHealer implements Healer {
+public class HeatToToscaTranslationHealer implements Healer {
private static final OrchestrationTemplateDao orchestrationTemplateDao =
OrchestrationTemplateDaoFactory.getInstance().createInterface();
private static final ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao =
ServiceModelDaoFactory.getInstance().createInterface();
- public static final ServiceTemplateDaoInter
- templateDao = ServiceTemplateDaoFactory.getInstance().createInterface();
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
- public HeatToToscaTranslationHealer(){
+ public HeatToToscaTranslationHealer() {
}
@Override
- public Object heal(Map<String, Object> healingParams) throws Exception {
- mdcDataDebugMessage.debugEntryMessage(null, null);
- String vspId = (String) healingParams.get(SdcCommon.VSP_ID);
- Version version = (Version) healingParams.get(SdcCommon.VERSION);
- String user = (String) healingParams.get(SdcCommon.USER);
- UploadDataEntity uploadData =
- orchestrationTemplateDao.getOrchestrationTemplate(vspId, version);
+ public Object heal(String vspId, Version version) throws Exception {
+ mdcDataDebugMessage.debugEntryMessage(null);;
+
+ OrchestrationTemplateEntity uploadData =
+ orchestrationTemplateDao.get(vspId, version);
if (Objects.isNull(uploadData) || Objects.isNull(uploadData.getContentData())) {
return Optional.empty();
@@ -58,8 +50,9 @@
FileContentHandler fileContentHandler;
TranslatorOutput translatorOutput;
try {
- fileContentHandler = CommonUtil.validateAndUploadFileContent(OnboardingTypesEnum.ZIP, uploadData
- .getContentData().array());
+ fileContentHandler =
+ CommonUtil.validateAndUploadFileContent(OnboardingTypesEnum.ZIP, uploadData
+ .getContentData().array());
translatorOutput =
HeatToToscaUtil.loadAndTranslateTemplateData(fileContentHandler);
} catch (Exception e) {
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/NicDataHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/NicDataHealer.java
index 123a943..b2ef965 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/NicDataHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/NicDataHealer.java
@@ -1,20 +1,16 @@
package org.openecomp.sdc.healing.healers;
-import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.healing.interfaces.Healer;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.NetworkType;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic;
import org.openecomp.sdc.versioning.dao.types.Version;
import java.util.Collection;
-import java.util.Map;
public class NicDataHealer implements Healer {
/*private static final VendorSoftwareProductDao vendorSoftwareProductDao =
@@ -28,11 +24,9 @@
}
@Override
- public Object heal(Map<String, Object> healingParams) throws Exception {
+ public Object heal(String vspId, Version version) throws Exception {
mdcDataDebugMessage.debugEntryMessage(null, null);
- String vspId = (String) healingParams.get(SdcCommon.VSP_ID);
- Version version = (Version) healingParams.get(SdcCommon.VERSION);
- String user = (String) healingParams.get(SdcCommon.USER);
+
Collection<NicEntity> nics = nicDao.listByVsp(vspId, version);
for (NicEntity nicEntity : nics) {
Nic nic = nicEntity.getNicCompositionData();
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/OwnerHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/OwnerHealer.java
new file mode 100644
index 0000000..acc20c9
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/OwnerHealer.java
@@ -0,0 +1,47 @@
+package org.openecomp.sdc.healing.healers;
+
+import org.openecomp.sdc.common.session.SessionContextProviderFactory;
+import org.openecomp.sdc.healing.interfaces.Healer;
+import org.openecomp.sdc.itempermissions.dao.ItemPermissionsDao;
+import org.openecomp.sdc.itempermissions.dao.ItemPermissionsDaoFactory;
+import org.openecomp.sdc.itempermissions.impl.types.PermissionTypes;
+import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+
+/**
+ * Created by ayalaben on 8/28/2017
+ */
+public class OwnerHealer implements Healer {
+ private static final String HEALING_USER_SUFFIX = "_healer";
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+
+ private static final ItemPermissionsDao permissionsDao =
+ ItemPermissionsDaoFactory.getInstance().createInterface();
+
+ public Object heal(String itemId, Version version) {
+ mdcDataDebugMessage.debugEntryMessage(null);
+
+ Collection<ItemPermissionsEntity> itemPermissions = permissionsDao.listItemPermissions(itemId);
+
+ if (itemPermissions.stream().noneMatch(this::isOwnerPermission)) {
+ String currentUserId =
+ SessionContextProviderFactory.getInstance().createInterface().get().getUser().getUserId()
+ .replace(HEALING_USER_SUFFIX, "");
+
+ permissionsDao.updateItemPermissions(itemId, PermissionTypes.Owner.name(),
+ Collections.singleton(currentUserId), new HashSet<>());
+
+ return currentUserId;
+ }
+ return itemPermissions.stream().filter(this::isOwnerPermission).findFirst().get().getUserId();
+ }
+
+ private boolean isOwnerPermission(ItemPermissionsEntity permissionsEntity) {
+ return permissionsEntity.getPermission().equals(PermissionTypes.Owner.name());
+ }
+}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/SubEntitiesQuestionnaireHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/SubEntitiesQuestionnaireHealer.java
index 9355eb0..a1dd80c 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/SubEntitiesQuestionnaireHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/SubEntitiesQuestionnaireHealer.java
@@ -21,7 +21,6 @@
package org.openecomp.sdc.healing.healers;
import org.openecomp.core.utilities.json.JsonSchemaDataGenerator;
-import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.healing.interfaces.Healer;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
@@ -30,8 +29,6 @@
import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.CompositionEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity;
@@ -42,15 +39,12 @@
import org.openecomp.sdc.versioning.dao.types.Version;
import java.util.Collection;
-import java.util.Map;
import java.util.Objects;
public class SubEntitiesQuestionnaireHealer implements Healer {
private static Version version00 = new Version(0, 0);
private MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
- private static final VendorSoftwareProductDao vendorSoftwareProductDao =
- VendorSoftwareProductDaoFactory.getInstance().createInterface();
private static ComponentDao componentDao = ComponentDaoFactory.getInstance().createInterface();
private static NicDao nicDao = NicDaoFactory.getInstance().createInterface();
private static NetworkDao networkDao = NetworkDaoFactory.getInstance().createInterface();
@@ -59,22 +53,17 @@
private static String emptyJson = "{}";
@Override
- public Object heal(Map<String, Object> healingParams) throws Exception {
+ public Object heal(String vspId, Version version) throws Exception {
mdcDataDebugMessage.debugEntryMessage(null);
- String vspId = (String) healingParams.get(SdcCommon.VSP_ID);
- Version version = version00.equals(healingParams.get(SdcCommon.VERSION)) ? new Version
- (0, 1)
- : (Version) healingParams.get(SdcCommon.VERSION);
-
Collection<ComponentEntity> componentEntities =
componentDao.listCompositionAndQuestionnaire(vspId, version);
networkDao.list(new NetworkEntity(vspId, version, null));
- Collection<NicEntity> nicEntities = vendorSoftwareProductDao.listNicsByVsp(vspId, version);
+ Collection<NicEntity> nicEntities = nicDao.listByVsp(vspId, version);
healCompositionEntityQuestionnaire(componentEntities, version, CompositionEntityType.component);
healCompositionEntityQuestionnaire(nicEntities, version, CompositionEntityType.nic);
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ValidationStructureHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ValidationStructureHealer.java
index 4bf7e18..d172432 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ValidationStructureHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ValidationStructureHealer.java
@@ -2,7 +2,6 @@
import org.apache.commons.collections4.CollectionUtils;
import org.openecomp.core.utilities.json.JsonUtil;
-import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.healing.interfaces.Healer;
import org.openecomp.sdc.heat.datatypes.manifest.FileData;
@@ -13,16 +12,11 @@
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadData;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadDataEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
import org.openecomp.sdc.versioning.dao.types.Version;
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
@@ -32,78 +26,55 @@
*/
public class ValidationStructureHealer implements Healer {
- private static final VendorSoftwareProductInfoDao vspInfoDao =
- VendorSoftwareProductInfoDaoFactory.getInstance().createInterface();
+ private static final Logger logger = LoggerFactory.getLogger(JsonUtil.class);
private static final OrchestrationTemplateDao orchestrationTemplateDao =
OrchestrationTemplateDaoFactory.getInstance().createInterface();
- private static final Logger logger = LoggerFactory.getLogger(JsonUtil.class);
@Override
- public Object heal(Map<String, Object> healingParams) throws Exception {
+ public Object heal(String vspId, Version version) throws Exception {
- String vspId = (String) healingParams.get(SdcCommon.VSP_ID);
- Version version = (Version) healingParams.get(SdcCommon.VERSION);
+ OrchestrationTemplateEntity orchestrationTemplate =
+ orchestrationTemplateDao.get(vspId, version);
- VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));
- UploadDataEntity orchestrationTemplate =
- orchestrationTemplateDao.getOrchestrationTemplate(vspId, version);
-
- if(Objects.isNull(orchestrationTemplate.getValidationData())
- || !JsonUtil.isValidJson(orchestrationTemplate.getValidationData())){
+ if (Objects.isNull(orchestrationTemplate.getValidationData())
+ || !JsonUtil.isValidJson(orchestrationTemplate.getValidationData())) {
return Optional.empty();
}
OldValidationStructureTree oldValidationStructureTree;
- try{
- oldValidationStructureTree =
- JsonUtil.json2Object(orchestrationTemplate.getValidationData(), OldValidationStructureTree
- .class);
- } catch (Exception e){
- logger.debug("",e);
+ try {
+ oldValidationStructureTree = JsonUtil
+ .json2Object(orchestrationTemplate.getValidationData(), OldValidationStructureTree.class);
+ } catch (Exception e) {
+ logger.debug("", e);
return Optional.empty();
}
Optional<HeatStructureTree> newHeatStructureTreeFromOldStructureTree =
- createNewHeatStructureTreeFromOldStructureTree(oldValidationStructureTree.getImportStructure());
+ createNewHeatStructureTreeFromOldStructureTree(
+ oldValidationStructureTree.getImportStructure());
- if(newHeatStructureTreeFromOldStructureTree.isPresent()){
- ValidationStructureList validationData = new ValidationStructureList
- (newHeatStructureTreeFromOldStructureTree.get());
- vspDetails.setValidationDataStructure(validationData);
+ newHeatStructureTreeFromOldStructureTree.ifPresent(newStructure ->
+ updateValuesInDb(vspId, version, orchestrationTemplate,
+ new ValidationStructureList(newStructure)));
- updateValuesInDb(vspId, vspDetails, orchestrationTemplate, validationData);
- }
return newHeatStructureTreeFromOldStructureTree;
}
- private void updateValuesInDb(String vspId, VspDetails vspDetails,
- UploadDataEntity orchestrationTemplate,
+ private void updateValuesInDb(String vspId, Version version,
+ OrchestrationTemplateEntity orchestrationTemplate,
ValidationStructureList validationData) {
- vspInfoDao.update(vspDetails);
- UploadData uploadData = getUpdatedUploadData(orchestrationTemplate, validationData);
- orchestrationTemplateDao.updateOrchestrationTemplateData(vspId, uploadData);
+ orchestrationTemplate.setValidationDataStructure(validationData);
+ orchestrationTemplateDao.update(vspId, version, orchestrationTemplate);
}
- private UploadData getUpdatedUploadData(UploadDataEntity orchestrationTemplate,
- ValidationStructureList validationData) {
- UploadData uploadData = new UploadData();
- uploadData.setValidationDataStructure(validationData);
- uploadData.setValidationData(JsonUtil.object2Json(validationData));
- uploadData.setContentData(orchestrationTemplate.getContentData());
- uploadData.setId(orchestrationTemplate.getId());
- uploadData.setPackageName(orchestrationTemplate.getPackageName());
- uploadData.setPackageVersion(orchestrationTemplate.getPackageVersion());
- return uploadData;
- }
-
-
- private Optional<HeatStructureTree> createNewHeatStructureTreeFromOldStructureTree(OldHeatStructureTree
- oldHeatStructureTree){
+ private Optional<HeatStructureTree> createNewHeatStructureTreeFromOldStructureTree(
+ OldHeatStructureTree oldHeatStructureTree) {
HeatStructureTree heatStructureTree = new HeatStructureTree();
- if(Objects.isNull(oldHeatStructureTree)){
+ if (Objects.isNull(oldHeatStructureTree)) {
return Optional.empty();
}
@@ -112,11 +83,14 @@
Set<OldHeatStructureTree> heat =
oldHeatStructureTree.getHeat() == null ? new HashSet<>() : oldHeatStructureTree.getHeat();
Set<OldHeatStructureTree> volume =
- oldHeatStructureTree.getVolume() == null ? new HashSet<>() : oldHeatStructureTree.getVolume();
+ oldHeatStructureTree.getVolume() == null ? new HashSet<>()
+ : oldHeatStructureTree.getVolume();
Set<OldHeatStructureTree> nested =
- oldHeatStructureTree.getNested() == null ? new HashSet<>() : oldHeatStructureTree.getNested();
+ oldHeatStructureTree.getNested() == null ? new HashSet<>()
+ : oldHeatStructureTree.getNested();
Set<OldHeatStructureTree> network =
- oldHeatStructureTree.getNetwork() == null ? new HashSet<>() : oldHeatStructureTree.getNetwork();
+ oldHeatStructureTree.getNetwork() == null ? new HashSet<>()
+ : oldHeatStructureTree.getNetwork();
heatStructureTree.setHeat(createHeatStructureTreeSetFromOld(heat));
@@ -124,57 +98,47 @@
heatStructureTree.setNested(createHeatStructureTreeSetFromOld(nested));
heatStructureTree.setNetwork(createHeatStructureTreeSetFromOld(network));
-
return Optional.of(heatStructureTree);
-
}
- private void mapOldHeatStructureTreeValues(
- OldHeatStructureTree oldHeatStructureTree,
- HeatStructureTree heatStructureTree) {
+ private void mapOldHeatStructureTreeValues(OldHeatStructureTree oldHeatStructureTree,
+ HeatStructureTree heatStructureTree) {
heatStructureTree.setFileName(oldHeatStructureTree.getFileName());
heatStructureTree.setBase(oldHeatStructureTree.getBase());
heatStructureTree.setType(oldHeatStructureTree.getType());
heatStructureTree.setArtifacts(oldHeatStructureTree.getArtifacts());
heatStructureTree.setErrors(oldHeatStructureTree.getErrors());
- if(Objects.nonNull(oldHeatStructureTree.getEnv())) {
+ if (Objects.nonNull(oldHeatStructureTree.getEnv())) {
heatStructureTree.setEnv(new HeatStructureTree(oldHeatStructureTree.getEnv(), false));
}
}
private Set<HeatStructureTree> createHeatStructureTreeSetFromOld(Set<OldHeatStructureTree>
- oldHeatStructureTreeSet){
- if(CollectionUtils.isEmpty(oldHeatStructureTreeSet)){
+ oldHeatStructureTreeSet) {
+ if (CollectionUtils.isEmpty(oldHeatStructureTreeSet)) {
return null;
}
Set<HeatStructureTree> newHeatStructureSet = new HashSet<>();
- for(OldHeatStructureTree old : oldHeatStructureTreeSet){
+ for (OldHeatStructureTree old : oldHeatStructureTreeSet) {
Optional<HeatStructureTree> newHeatStructureTree =
createNewHeatStructureTreeFromOldStructureTree(old);
- if(newHeatStructureTree.isPresent()){
- newHeatStructureSet.add(newHeatStructureTree.get());
- }
+ newHeatStructureTree.ifPresent(newHeatStructureSet::add);
}
return newHeatStructureSet;
}
- private class OldValidationStructureTree{
+ private class OldValidationStructureTree {
private OldHeatStructureTree importStructure;
- public OldHeatStructureTree getImportStructure() {
+ OldHeatStructureTree getImportStructure() {
return importStructure;
}
-
- public void setImportStructure(
- OldHeatStructureTree importStructure) {
- this.importStructure = importStructure;
- }
}
- private class OldHeatStructureTree{
+ private class OldHeatStructureTree {
private String fileName;
private FileData.Type type;
private Boolean isBase;
@@ -190,93 +154,93 @@
public OldHeatStructureTree() {
}
- public String getFileName() {
- return fileName;
- }
+ public String getFileName() {
+ return fileName;
+ }
- public void setFileName(String fileName) {
- this.fileName = fileName;
- }
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
- public FileData.Type getType() {
- return type;
- }
+ public FileData.Type getType() {
+ return type;
+ }
- public void setType(FileData.Type type) {
- this.type = type;
- }
+ public void setType(FileData.Type type) {
+ this.type = type;
+ }
- public Boolean getBase() {
- return isBase;
- }
+ public Boolean getBase() {
+ return isBase;
+ }
- public void setBase(Boolean base) {
- isBase = base;
- }
+ public void setBase(Boolean base) {
+ isBase = base;
+ }
- public String getEnv() {
- return env;
- }
+ public String getEnv() {
+ return env;
+ }
- public void setEnv(String env) {
- this.env = env;
- }
+ public void setEnv(String env) {
+ this.env = env;
+ }
- public List<ErrorMessage> getErrors() {
- return errors;
- }
+ public List<ErrorMessage> getErrors() {
+ return errors;
+ }
- public void setErrors(List<ErrorMessage> errors) {
- this.errors = errors;
- }
+ public void setErrors(List<ErrorMessage> errors) {
+ this.errors = errors;
+ }
- public Set<OldHeatStructureTree> getHeat() {
- return heat;
- }
+ public Set<OldHeatStructureTree> getHeat() {
+ return heat;
+ }
- public void setHeat(Set<OldHeatStructureTree> heat) {
- this.heat = heat;
- }
+ public void setHeat(Set<OldHeatStructureTree> heat) {
+ this.heat = heat;
+ }
- public Set<OldHeatStructureTree> getVolume() {
- return volume;
- }
+ public Set<OldHeatStructureTree> getVolume() {
+ return volume;
+ }
- public void setVolume(Set<OldHeatStructureTree> volume) {
- this.volume = volume;
- }
+ public void setVolume(Set<OldHeatStructureTree> volume) {
+ this.volume = volume;
+ }
- public Set<OldHeatStructureTree> getNetwork() {
- return network;
- }
+ public Set<OldHeatStructureTree> getNetwork() {
+ return network;
+ }
- public void setNetwork(
- Set<OldHeatStructureTree> network) {
- this.network = network;
- }
+ public void setNetwork(
+ Set<OldHeatStructureTree> network) {
+ this.network = network;
+ }
- public Set<OldHeatStructureTree> getNested() {
- return nested;
- }
+ public Set<OldHeatStructureTree> getNested() {
+ return nested;
+ }
- public void setNested(Set<OldHeatStructureTree> nested) {
- this.nested = nested;
- }
+ public void setNested(Set<OldHeatStructureTree> nested) {
+ this.nested = nested;
+ }
- public Set<OldHeatStructureTree> getOther() {
- return other;
- }
+ public Set<OldHeatStructureTree> getOther() {
+ return other;
+ }
- public void setOther(Set<OldHeatStructureTree> other) {
- this.other = other;
- }
+ public void setOther(Set<OldHeatStructureTree> other) {
+ this.other = other;
+ }
- public Set<Artifact> getArtifacts() {
- return artifacts;
- }
+ public Set<Artifact> getArtifacts() {
+ return artifacts;
+ }
- public void setArtifacts(Set<Artifact> artifacts) {
- this.artifacts = artifacts;
+ public void setArtifacts(Set<Artifact> artifacts) {
+ this.artifacts = artifacts;
+ }
}
}
-}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VlmVersionHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VlmVersionHealer.java
index 085923b..a57ac74 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VlmVersionHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VlmVersionHealer.java
@@ -1,26 +1,21 @@
package org.openecomp.sdc.healing.healers;
-import org.apache.commons.collections4.CollectionUtils;
-import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.healing.interfaces.Healer;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDao;
import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDaoFactory;
import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
-import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
-import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory;
-import org.openecomp.sdc.vendorlicense.types.VersionedVendorLicenseModel;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.versioning.VersioningManager;
+import org.openecomp.sdc.versioning.VersioningManagerFactory;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.VersionInfo;
+import org.openecomp.sdc.versioning.dao.types.VersionStatus;
import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
+import java.util.Collection;
import java.util.Objects;
import java.util.Optional;
@@ -28,8 +23,8 @@
* Created by TALIO on 7/3/2017.
*/
public class VlmVersionHealer implements Healer {
- private static final VendorLicenseFacade vendorLicenseFacade =
- VendorLicenseFacadeFactory.getInstance().createInterface();
+ private VersioningManager versioningManager =
+ VersioningManagerFactory.getInstance().createInterface();
private static final VendorSoftwareProductInfoDao vspInfoDao =
VendorSoftwareProductInfoDaoFactory.getInstance().createInterface();
private static final LicenseAgreementDao licenseAgreementDao =
@@ -38,51 +33,35 @@
LoggerFactory.getLogger(VlmVersionHealer.class);
@Override
- public Object heal(Map<String, Object> healingParams) throws Exception {
- String vspId = (String) healingParams.get(SdcCommon.VSP_ID);
- Version version = (Version) healingParams.get(SdcCommon.VERSION);
- String user = (String) healingParams.get(SdcCommon.USER);
-
+ public Object heal(String vspId, Version version) throws Exception {
VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));
- VersionedVendorLicenseModel vendorLicenseModel;
-
- if(!Objects.isNull(vspDetails.getVlmVersion())) {
+
+ if (!Objects.isNull(vspDetails.getVlmVersion())) {
return Optional.empty();
}
-
- try{
- vendorLicenseModel =
- vendorLicenseFacade.getVendorLicenseModel(vspDetails.getVendorId(), null, user);
- } catch (Exception e){
- logger.debug("" + e);
+ // get the certified vlm version with the highest number in its name
+ Optional<Version> certifiedVlmVersion =
+ versioningManager.list(vspDetails.getVendorId()).stream()
+ .filter(ver -> VersionStatus.Certified == ver.getStatus())
+ .max((o1, o2) -> ((Double) Double.parseDouble(o1.getName()))
+ .compareTo(Double.parseDouble(o2.getName())));
+ if (!certifiedVlmVersion.isPresent()) {
logger.debug("No Vlm was found for Vsp " + vspDetails.getName());
return Optional.empty();
}
+ vspDetails.setVlmVersion(certifiedVlmVersion.get());
- VendorLicenseModelEntity vlm = vendorLicenseModel.getVendorLicenseModel();
- String vlmId = vlm.getId();
- Version vlmVersion = getLatestFinalVlmVersion(vendorLicenseModel.getVersionInfo());
-
- List<LicenseAgreementEntity> laList =
- new ArrayList<>(
- licenseAgreementDao.list(new LicenseAgreementEntity(vlmId, vlmVersion, null)));
-
-
- vspDetails.setVlmVersion(vlmVersion);
-
- if(CollectionUtils.isNotEmpty(laList)) {
- vspDetails.setLicenseAgreement(laList.get(0).getId());
- vspDetails.setFeatureGroups(new ArrayList<>(laList.get(0).getFeatureGroupIds()));
+ Collection<LicenseAgreementEntity> licenseAgreements = licenseAgreementDao.list(
+ new LicenseAgreementEntity(vspDetails.getVendorId(), certifiedVlmVersion.get(), null));
+ if (!licenseAgreements.isEmpty()) {
+ LicenseAgreementEntity licenseAgreement = licenseAgreements.iterator().next();
+ vspDetails.setLicenseAgreement(licenseAgreement.getId());
+ vspDetails.setFeatureGroups(new ArrayList<>(licenseAgreement.getFeatureGroupIds()));
}
vspInfoDao.update(vspDetails);
+
return vspDetails;
-
- }
-
- private Version getLatestFinalVlmVersion(VersionInfo versionInfo){
- return versionInfo.getActiveVersion().isFinal() ? versionInfo.getActiveVersion()
- : versionInfo.getLatestFinalVersion();
}
}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealer.java
index ddcd314..d5c082b 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealer.java
@@ -2,55 +2,91 @@
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
-import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.healing.interfaces.Healer;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OnboardingMethod;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.Map;
import java.util.Objects;
public class VspOnboardingMethodHealer implements Healer {
- private static VendorSoftwareProductInfoDao vendorSoftwareProductInfoDao;
+
+ private static final String DEFAULT_FILE_NAME = "Upload File";
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private VendorSoftwareProductInfoDao vendorSoftwareProductInfoDao;
+ private OrchestrationTemplateDao orchestrationTemplateDao;
+ private OrchestrationTemplateCandidateDao candidateDao;
public VspOnboardingMethodHealer(){
- this(VendorSoftwareProductInfoDaoFactory.getInstance().createInterface());
+ this(VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(),
+ OrchestrationTemplateDaoFactory.getInstance().createInterface(),
+ OrchestrationTemplateCandidateDaoFactory.getInstance().createInterface());
}
- public VspOnboardingMethodHealer( VendorSoftwareProductInfoDao inVendorSoftwareProductInfoDao){
- vendorSoftwareProductInfoDao = inVendorSoftwareProductInfoDao;
+ public VspOnboardingMethodHealer(VendorSoftwareProductInfoDao vspInfoDao,
+ OrchestrationTemplateDao orchestrationTemplateDao,
+ OrchestrationTemplateCandidateDao candidateDao) {
+ this.vendorSoftwareProductInfoDao = vspInfoDao;
+ this.orchestrationTemplateDao = orchestrationTemplateDao;
+ this.candidateDao = candidateDao;
}
-
@Override
- public Object heal(Map<String, Object> healingParams) throws Exception {
- mdcDataDebugMessage.debugEntryMessage(null, null);
+ public Object heal(String vspId, Version version) throws Exception {
+ mdcDataDebugMessage.debugEntryMessage(null);
- String onboardingMethod=null;
- String vspId = (String) healingParams.get(SdcCommon.VSP_ID);
- Version version = (Version) healingParams.get(SdcCommon.VERSION);
- VspDetails vendorSoftwareProductInfo =
- vendorSoftwareProductInfoDao.get(new VspDetails(vspId, version));
- String onboardingValue = vendorSoftwareProductInfo.getOnboardingMethod();
+ VspDetails vsp = vendorSoftwareProductInfoDao.get(new VspDetails(vspId, version));
+ healOnboardingMethod(vsp);
- if(Objects.isNull(onboardingValue)) {
- onboardingMethod="NetworkPackage";
-
- updateVSPInfo(OnboardingTypesEnum.ZIP.toString(), onboardingMethod, vendorSoftwareProductInfo);
- } else if (onboardingValue.equals("HEAT")){
- onboardingMethod="NetworkPackage";
- updateVSPInfo(OnboardingTypesEnum.ZIP.toString(),onboardingMethod, vendorSoftwareProductInfo);
+ if (!OnboardingMethod.Manual.name().equals(vsp.getOnboardingMethod())) {
+ healOrchestrationTemplateFileName(vspId, version);
+ healOrchestrationTemplateCandidateFileName(vspId, version);
}
- return onboardingMethod;
+
+ mdcDataDebugMessage.debugExitMessage(null);
+ return null;
}
- private void updateVSPInfo(String onboardingOrigin, String onboardingMethod, VspDetails vendorSoftwareProductInfo) {
- vendorSoftwareProductInfo.setOnboardingMethod(onboardingMethod);
- vendorSoftwareProductInfo.setOnboardingOrigin(onboardingOrigin);
- vendorSoftwareProductInfoDao.update(vendorSoftwareProductInfo);
+ private void healOnboardingMethod(VspDetails vsp) {
+ if (Objects.isNull(vsp.getOnboardingMethod()) || "HEAT".equals(vsp.getOnboardingMethod())) {
+ vsp.setOnboardingMethod(OnboardingMethod.NetworkPackage.name());
+ vendorSoftwareProductInfoDao.update(vsp);
+ }
+ }
+
+ private void healOrchestrationTemplateFileName(String vspId, Version version) {
+ OrchestrationTemplateEntity orchestrationTemplate =
+ orchestrationTemplateDao.get(vspId, version);
+
+ if (orchestrationTemplate == null || orchestrationTemplate.getContentData() == null ||
+ orchestrationTemplate.getFileSuffix() != null) {
+ return;
+ }
+ orchestrationTemplate.setFileSuffix(OnboardingTypesEnum.ZIP.toString());
+ orchestrationTemplate.setFileName(DEFAULT_FILE_NAME);
+
+ orchestrationTemplateDao.update(vspId, version, orchestrationTemplate);
+ }
+
+ private void healOrchestrationTemplateCandidateFileName(String vspId, Version version) {
+ OrchestrationTemplateCandidateData candidate = candidateDao.get(vspId, version);
+
+ if (candidate == null || candidate.getContentData() == null ||
+ candidate.getFileSuffix() != null) {
+ return;
+ }
+ candidate.setFileSuffix(OnboardingTypesEnum.ZIP.toString());
+ candidate.setFileName(DEFAULT_FILE_NAME);
+
+ candidateDao.update(vspId, version, candidate);
}
}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VspQuestionnaireHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VspQuestionnaireHealer.java
index 0952a4c..b45ce30 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VspQuestionnaireHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VspQuestionnaireHealer.java
@@ -21,7 +21,6 @@
package org.openecomp.sdc.healing.healers;
import org.openecomp.core.utilities.json.JsonSchemaDataGenerator;
-import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.healing.interfaces.Healer;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
@@ -35,7 +34,6 @@
import org.openecomp.sdc.versioning.dao.types.Version;
import java.io.IOException;
-import java.util.Map;
import java.util.Objects;
import java.util.Optional;
@@ -50,15 +48,12 @@
}
@Override
- public Object heal(Map<String, Object> healingParams) throws IOException {
+ public Object heal(String vspId, Version version) throws IOException {
mdcDataDebugMessage.debugEntryMessage(null, null);
Optional<String> questionnaireData = null;
- String vspId = (String) healingParams.get(SdcCommon.VSP_ID);
- Version version = (Version) healingParams.get(SdcCommon.VERSION);
-
VspQuestionnaireEntity vspQuestionnaireEntity =
vspInfoDao.getQuestionnaire(vspId, version);
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/ComponentQuestionnaireHealerTest.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/ComponentQuestionnaireHealerTest.java
index 69f4287..688d1d4 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/ComponentQuestionnaireHealerTest.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/ComponentQuestionnaireHealerTest.java
@@ -8,7 +8,6 @@
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDao;
@@ -20,10 +19,7 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.doNothing;
@@ -47,7 +43,6 @@
private static final String DUMMY_COMPONENT_ID = "2495ef442f964cbfb00d82bd54292f89";
private static final String DUMMY_COMPUTE_ID = "3495ef442f964cbfb00d82bd54292f89";
private static final String DUMMY_IMAGE_ID = "4495ef442f964cbfb00d82bd54292f89";
- private static Map<String, Object> healingParams = new HashMap<>();
private static final String componentQuestionnaireData = "{\"compute\": {" +
"\"guestOS\": {\"bitSize\": 64},\"vmSizing\": {\"IOOperationsPerSec\": \"0\"}," +
"\"numOfVMs\": {\"CpuOverSubscriptionRatio\": \"1:1\",\"MemoryRAM\": \"2 GB\"}}," +
@@ -131,16 +126,13 @@
@Before
public void init() throws Exception {
MockitoAnnotations.initMocks(ComponentQuestionnaireHealerTest.this);
-
- healingParams.put(SdcCommon.VSP_ID, DUMMY_VSP_ID);
- healingParams.put(SdcCommon.VERSION, VERSION);
}
@Test
public void healQuestionnaireNullTest() throws Exception {
prepareHealingData();
componentEntity.setQuestionnaireData(null);
- Object returnObject = componentQuestionnaireHealer.heal(healingParams);
+ Object returnObject = componentQuestionnaireHealer.heal(DUMMY_VSP_ID, VERSION);
Assert.assertTrue(returnObject instanceof Collection);
Collection<ComponentEntity> componentEntities = (Collection<ComponentEntity>) returnObject;
componentEntities.forEach(componentEntity -> {
@@ -152,7 +144,7 @@
public void healAllCasesTest() throws Exception {
prepareHealingData();
- Object returnObject = componentQuestionnaireHealer.heal(healingParams);
+ Object returnObject = componentQuestionnaireHealer.heal(DUMMY_VSP_ID, VERSION);
Assert.assertTrue(returnObject instanceof Collection);
Collection<ComponentEntity> componentEntities = (Collection<ComponentEntity>) returnObject;
componentEntities.forEach(componentEntity -> {
@@ -177,7 +169,7 @@
public void healDiskAttrMissingTest() throws Exception {
prepareHealingData();
componentEntity.setQuestionnaireData(componentQuestionnaireMissingDiskAttrData);
- Object returnObject = componentQuestionnaireHealer.heal(healingParams);
+ Object returnObject = componentQuestionnaireHealer.heal(DUMMY_VSP_ID, VERSION);
Assert.assertTrue(returnObject instanceof Collection);
Collection<ComponentEntity> componentEntities = (Collection<ComponentEntity>) returnObject;
componentEntities.forEach(componentEntity -> {
@@ -238,7 +230,7 @@
.getDeclaredMethod(methodName, JsonObject.class, JsonObject.class);
method.setAccessible(true);
- method.invoke(componentQuestionnaireHealer,jsonObject.getAsJsonObject(COMPUTE), null);
+ method.invoke(componentQuestionnaireHealer, jsonObject.getAsJsonObject(COMPUTE), null);
}
private void prepareHealingData() {
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/ForwarderCapabilityHealerTest.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/ForwarderCapabilityHealerTest.java
index 406d039..a07ace6 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/ForwarderCapabilityHealerTest.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/ForwarderCapabilityHealerTest.java
@@ -13,7 +13,6 @@
import org.openecomp.core.model.dao.ServiceModelDao;
import org.openecomp.core.model.types.ServiceElement;
import org.openecomp.sdc.common.togglz.ToggleableFeature;
-import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.healing.healers.util.TestUtil;
import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
@@ -32,13 +31,14 @@
import static org.mockito.Matchers.eq;
public class ForwarderCapabilityHealerTest {
+ private static final String vspId = "1";
+ private static final Version version = new Version(1, 1);
private static final String IN_SUFFIX = "/in";
private static final String OUT_SUFFIX = "/out";
private static final String BASE_DIRECTORY = "/mock/healers/forwarder";
private static final String ENTRY_DEFINITION_SERVICE_TEMPLATE = "MainServiceTemplate.yaml";
private static TestFeatureManager manager;
- private Map<String,Object> params = new HashMap<>();
@Mock
private ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao;
@@ -65,8 +65,6 @@
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(ForwarderCapabilityHealerTest.this);
- params.put(SdcCommon.VSP_ID,"1");
- params.put(SdcCommon.VERSION, new Version(1,1));
}
@@ -127,7 +125,7 @@
private void validateServiceModelAfterHealing(String testDirectory) throws Exception {
Optional<ToscaServiceModel> serviceModelObject =
- (Optional<ToscaServiceModel>) forwarderCapabilityHealer.heal(params);
+ (Optional<ToscaServiceModel>) forwarderCapabilityHealer.heal(vspId, version);
Assert.assertTrue(serviceModelObject.isPresent());
TestUtil
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealerTest.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealerTest.java
index b732cb0..5584a5f 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealerTest.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealerTest.java
@@ -2,69 +2,77 @@
import org.junit.Before;
import org.junit.Test;
+import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
-import org.openecomp.sdc.common.utils.SdcCommon;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.HashMap;
-import java.util.Map;
-
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
-public class VspOnboardingMethodHealerTest{
+public class VspOnboardingMethodHealerTest {
+ private static final String vspId = "1";
+ private static final Version version = new Version(1, 1);
- @Mock
- private VendorSoftwareProductInfoDao vendorSoftwareProductInfoDao;
+ @Mock
+ private VendorSoftwareProductInfoDao vendorSoftwareProductInfoDao;
+ @Mock
+ private OrchestrationTemplateDao orchestrationTemplateDao;
+ @Mock
+ private OrchestrationTemplateCandidateDao candidateDao;
+ @InjectMocks
+ private VspOnboardingMethodHealer vspOnboardingMethodHealer;
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(VspOnboardingMethodHealerTest.this);
- }
+ private OrchestrationTemplateEntity orchestrationTemplateEntity = new OrchestrationTemplateEntity();
+ private OrchestrationTemplateCandidateData candidateData = new OrchestrationTemplateCandidateData();
+ private static final String NETWORK_PACKAGE = "NetworkPackage";
+ private static final String HEAT = "HEAT";
+ private static final String MANUAL = "Manual";
- @Test
- public void checkHealingWithNullOnboarding() throws Exception{
- VspOnboardingMethodHealer vspOnboardingMethodHealer = new VspOnboardingMethodHealer(vendorSoftwareProductInfoDao);
- Map<String,Object> params = new HashMap<>();
- params.put(SdcCommon.VSP_ID,"1");
- params.put(SdcCommon.VERSION, new Version(1,1));
- VspDetails vspDetails = new VspDetails();
- vspDetails.setOnboardingMethod(null);
- Mockito.when(vendorSoftwareProductInfoDao.get(any())).thenReturn(vspDetails);
- vspOnboardingMethodHealer.heal(params);
- assertEquals(vspDetails.getOnboardingMethod(),"NetworkPackage");
- assertEquals(vspDetails.getOnboardingOrigin(),"zip");
- }
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(VspOnboardingMethodHealerTest.this);
+ }
- @Test
- public void checkHealingWithHEATOnboarding() throws Exception{
- VspOnboardingMethodHealer vspOnboardingMethodHealer = new VspOnboardingMethodHealer(vendorSoftwareProductInfoDao);
- Map<String,Object> params = new HashMap<>();
- params.put(SdcCommon.VSP_ID,"1");
- params.put(SdcCommon.VERSION, new Version(1,1));
- VspDetails vspDetails = new VspDetails();
- vspDetails.setOnboardingMethod("HEAT");
- Mockito.when(vendorSoftwareProductInfoDao.get(any())).thenReturn(vspDetails);
- vspOnboardingMethodHealer.heal(params);
- assertEquals(vspDetails.getOnboardingMethod(),"NetworkPackage");
- assertEquals(vspDetails.getOnboardingOrigin(),"zip");
- }
+ @Test
+ public void checkHealingWithNullOnboarding() throws Exception {
+ VspDetails vspDetails = initAndExecuteHealer(null);
+ assertEquals(vspDetails.getOnboardingMethod(), NETWORK_PACKAGE);
+ }
- @Test
- public void checkHealingWithManualOnboarding() throws Exception{
- VspOnboardingMethodHealer vspOnboardingMethodHealer = new VspOnboardingMethodHealer(vendorSoftwareProductInfoDao);
- Map<String,Object> params = new HashMap<>();
- params.put(SdcCommon.VSP_ID,"1");
- params.put(SdcCommon.VERSION, new Version(1,1));
- VspDetails vspDetails = new VspDetails();
- vspDetails.setOnboardingMethod("Manual");
- Mockito.when(vendorSoftwareProductInfoDao.get(any())).thenReturn(vspDetails);
- vspOnboardingMethodHealer.heal(params);
- assertEquals(vspDetails.getOnboardingMethod(),"Manual");
- assertEquals(vspDetails.getOnboardingOrigin(),null);
- }
+ @Test
+ public void checkHealingWithHEATOnboarding() throws Exception {
+ VspDetails vspDetails = initAndExecuteHealer(HEAT);
+ assertEquals(vspDetails.getOnboardingMethod(), NETWORK_PACKAGE);
+ }
+
+ @Test
+ public void checkHealingWithManualOnboarding() throws Exception {
+ VspDetails vspDetails = initAndExecuteHealer(MANUAL);
+ assertEquals(vspDetails.getOnboardingMethod(), MANUAL);
+ }
+
+ private VspDetails initAndExecuteHealer(String onboardingMethod) throws Exception {
+ VspDetails vspDetails = new VspDetails();
+ vspDetails.setOnboardingMethod(onboardingMethod);
+
+ setMockActions(vspDetails);
+ vspOnboardingMethodHealer.heal(vspId, version);
+ return vspDetails;
+ }
+
+ private void setMockActions(VspDetails vspDetails) {
+ Mockito.doReturn(vspDetails).when(vendorSoftwareProductInfoDao).get(any());
+ Mockito.doReturn(orchestrationTemplateEntity).when(orchestrationTemplateDao).get(any(), any());
+ Mockito.doNothing().when(orchestrationTemplateDao).update(any(), any(), any());
+ Mockito.doReturn(candidateData).when(candidateDao).get(any(), any());
+ Mockito.doNothing().when(candidateDao).update(any(), any(), any());
+ }
}
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/testHealers/data/TestDescriptionHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/testHealers/data/TestDescriptionHealer.java
new file mode 100644
index 0000000..aac1a50
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/testHealers/data/TestDescriptionHealer.java
@@ -0,0 +1,16 @@
+package org.openecomp.sdc.healing.healers.testHealers.data;
+
+import org.openecomp.sdc.healing.interfaces.Healer;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+public class TestDescriptionHealer implements Healer {
+
+ @Override
+ public Object heal(String vspId, Version version) throws Exception {
+ VspDetails vspDetails = new VspDetails(vspId, version);
+ vspDetails.setDescription("This is a data healer");
+
+ return vspDetails;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/testHealers/structure/TestNewEntityInVspHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/testHealers/structure/TestNewEntityInVspHealer.java
new file mode 100644
index 0000000..7d71c03
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/testHealers/structure/TestNewEntityInVspHealer.java
@@ -0,0 +1,16 @@
+package org.openecomp.sdc.healing.healers.testHealers.structure;
+
+import org.openecomp.sdc.healing.interfaces.Healer;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+public class TestNewEntityInVspHealer implements Healer {
+
+ @Override
+ public Object heal(String vspId, Version version) throws Exception {
+ VspDetails vspDetails = new VspDetails(vspId, version);
+ vspDetails.setDescription("This is a structure healer");
+
+ return vspDetails;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/pom.xml b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/pom.xml
new file mode 100644
index 0000000..f69f304
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/pom.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
+ <modelVersion>4.0.0</modelVersion>
+
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-item-permissions-lib</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <artifactId>openecomp-item-permissions-api</artifactId>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-nosqldb-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-facade-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+
+ </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsRules.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsRules.java
new file mode 100644
index 0000000..b5a119e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsRules.java
@@ -0,0 +1,17 @@
+package org.openecomp.sdc.itempermissions;
+
+import java.util.Set;
+
+/**
+ * Created by ayalaben on 6/22/2017.
+ */
+public interface PermissionsRules {
+
+ boolean isAllowed(String userId,String action);
+
+ void executeAction(String itemId, String userId, String action);
+
+ void updatePermission(String itemId,String currentUserId, String permission,Set<String>
+ addedUsersIds, Set<String> removedUsersIds);
+
+}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsRulesFactory.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsRulesFactory.java
new file mode 100644
index 0000000..c3e0672
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsRulesFactory.java
@@ -0,0 +1,16 @@
+package org.openecomp.sdc.itempermissions;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+/**
+ * Created by ayalaben on 6/26/2017
+ */
+public abstract class PermissionsRulesFactory extends
+ AbstractComponentFactory<PermissionsRules> {
+
+ public static PermissionsRulesFactory getInstance() {
+ return AbstractFactory.getInstance(PermissionsRulesFactory.class);
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsServices.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsServices.java
new file mode 100644
index 0000000..09c8102
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsServices.java
@@ -0,0 +1,26 @@
+package org.openecomp.sdc.itempermissions;
+
+import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity;
+
+import java.util.Collection;
+import java.util.Set;
+
+/**
+ * Created by ayalaben on 6/22/2017
+ */
+public interface PermissionsServices {
+
+ Collection<ItemPermissionsEntity> listItemPermissions(String itemId);
+
+ void updateItemPermissions(String itemId, String permission, Set<String> addedUsersIds,
+ Set<String> removedUsersIds);
+
+ boolean isAllowed(String itemId,String userId,String action);
+
+ void execute(String itemId,String userId,String action);
+
+ String getUserItemPermiission(String itemId, String userId);
+
+
+
+}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsServicesFactory.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsServicesFactory.java
new file mode 100644
index 0000000..97769bc
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsServicesFactory.java
@@ -0,0 +1,16 @@
+package org.openecomp.sdc.itempermissions;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+/**
+ * Created by ayalaben on 6/22/2017.
+ */
+public abstract class PermissionsServicesFactory extends
+ AbstractComponentFactory<PermissionsServices> {
+
+ public static PermissionsServicesFactory getInstance() {
+ return AbstractFactory.getInstance(PermissionsServicesFactory.class);
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/dao/ItemPermissionsDao.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/dao/ItemPermissionsDao.java
new file mode 100644
index 0000000..a0f51f9
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/dao/ItemPermissionsDao.java
@@ -0,0 +1,21 @@
+package org.openecomp.sdc.itempermissions.dao;
+
+import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity;
+
+import java.util.Collection;
+import java.util.Set;
+
+/**
+ * Created by ayalaben on 6/18/2017.
+ */
+public interface ItemPermissionsDao {
+
+ Collection<ItemPermissionsEntity> listItemPermissions(String itemId);
+
+ void updateItemPermissions(String itemId, String permission, Set<String> addedUsersIds,
+ Set<String> removedUsersIds);
+
+ void addUserPermission(String itemId, String userId, String permission);
+
+ String getUserItemPermiission(String itemId, String userId);
+}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/dao/ItemPermissionsDaoFactory.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/dao/ItemPermissionsDaoFactory.java
new file mode 100644
index 0000000..95d541e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/dao/ItemPermissionsDaoFactory.java
@@ -0,0 +1,15 @@
+package org.openecomp.sdc.itempermissions.dao;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+/**
+ * Created by ayalaben on 6/18/2017.
+ */
+public abstract class ItemPermissionsDaoFactory extends AbstractComponentFactory<ItemPermissionsDao> {
+
+ public static ItemPermissionsDaoFactory getInstance() {
+ return AbstractFactory.getInstance(ItemPermissionsDaoFactory.class);
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/errors/PermissionsErrorMessages.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/errors/PermissionsErrorMessages.java
new file mode 100644
index 0000000..a3fb9a1
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/errors/PermissionsErrorMessages.java
@@ -0,0 +1,23 @@
+package org.openecomp.sdc.itempermissions.errors;
+
+/**
+ * Created by ayalaben on 6/28/2017
+ */
+public enum PermissionsErrorMessages {
+
+ NO_PERMISSION_FOR_USER("The user is not permitted to edit this item"),
+ USER_NOT_OWNER_SUBMIT("The user must be the owner to submit the item"),
+ INVALID_PERMISSION_TYPE("Invalid permission type"),
+ INVALID_ACTION_TYPE("Invalid action type");
+
+ private String errorMessage;
+
+ PermissionsErrorMessages(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/errors/PermissionsErrorMessagesBuilder.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/errors/PermissionsErrorMessagesBuilder.java
new file mode 100644
index 0000000..f0c13d9
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/errors/PermissionsErrorMessagesBuilder.java
@@ -0,0 +1,29 @@
+package org.openecomp.sdc.itempermissions.errors;
+
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
+/**
+ * Created by ayalaben on 6/28/2017
+ */
+public class PermissionsErrorMessagesBuilder {
+ public static final String PERMISSIONS_ERROR= "PERMISSIONS_ERROR";
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+
+ /**
+ * Instantiates a new Submit uncompleted license model error builder.
+ *
+ * @param error
+ */
+ public PermissionsErrorMessagesBuilder(PermissionsErrorMessages error) {
+ builder.withId(PERMISSIONS_ERROR);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(error.getErrorMessage());
+ }
+
+ public ErrorCode build() {
+ return builder.build();
+ }
+
+
+}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/notifications/NotificationConstants.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/notifications/NotificationConstants.java
new file mode 100644
index 0000000..d4235cd
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/notifications/NotificationConstants.java
@@ -0,0 +1,14 @@
+package org.openecomp.sdc.itempermissions.notifications;
+
+/**
+ * @author avrahamg
+ * @since July 10, 2017
+ */
+public class NotificationConstants {
+ public static final String PERMISSION_CHANGED= "PermissionChanged";
+ public static final String PERMISSION_ITEM = "permission";
+ public static final String ITEM_ID_PROP = "itemId";
+ public static final String ITEM_NAME_PROP = "itemName";
+ public static final String PERMISSION_GRANTED = "granted";
+ public static final String PERMISSION_USER = "userId";
+}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/type/ItemPermissionsEntity.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/type/ItemPermissionsEntity.java
new file mode 100644
index 0000000..22ff437
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/type/ItemPermissionsEntity.java
@@ -0,0 +1,50 @@
+package org.openecomp.sdc.itempermissions.type;
+
+import com.datastax.driver.mapping.annotations.ClusteringColumn;
+import com.datastax.driver.mapping.annotations.Column;
+import com.datastax.driver.mapping.annotations.PartitionKey;
+import com.datastax.driver.mapping.annotations.Table;
+
+/**
+ * Created by ayalaben on 6/18/2017.
+ */
+
+@Table(keyspace = "dox", name = "item_permissions")
+public class ItemPermissionsEntity {
+
+ @PartitionKey
+ @Column(name = "item_id")
+ private String itemId;
+
+ @ClusteringColumn
+ @Column(name = "user_id")
+ private String userId;
+
+ @Column(name = "permission")
+ private String permission;
+
+
+ public String getItemId() {
+ return itemId;
+ }
+
+ public void setItemId(String itemId) {
+ this.itemId = itemId;
+ }
+
+ public String getUserId() {
+ return userId;
+ }
+
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ public String getPermission() {
+ return permission;
+ }
+
+ public void setPermission(String permission) {
+ this.permission = permission;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/pom.xml b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/pom.xml
new file mode 100644
index 0000000..a420b23
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/pom.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-item-permissions-lib</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <artifactId>openecomp-item-permissions-core</artifactId>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-session-lib</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-item-permissions-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-facade-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-nosqldb-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-notification-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>RELEASE</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsDaoFactoryImpl.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsDaoFactoryImpl.java
new file mode 100644
index 0000000..87c0338
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsDaoFactoryImpl.java
@@ -0,0 +1,19 @@
+package org.openecomp.sdc.itempermissions.dao.impl;
+
+
+import org.openecomp.sdc.itempermissions.dao.ItemPermissionsDao;
+import org.openecomp.sdc.itempermissions.dao.ItemPermissionsDaoFactory;
+
+
+/**
+ * Created by ayalaben on 6/18/2017.
+ */
+public class ItemPermissionsDaoFactoryImpl extends ItemPermissionsDaoFactory {
+
+ private static ItemPermissionsDao INSTANCE =new ItemPermissionsDaoImpl();
+
+ @Override
+ public ItemPermissionsDao createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsDaoImpl.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsDaoImpl.java
new file mode 100644
index 0000000..e1a9d1c
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsDaoImpl.java
@@ -0,0 +1,66 @@
+package org.openecomp.sdc.itempermissions.dao.impl;
+
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.mapping.Result;
+import com.datastax.driver.mapping.annotations.Accessor;
+import com.datastax.driver.mapping.annotations.Query;
+import org.openecomp.core.nosqldb.api.NoSqlDb;
+import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
+import org.openecomp.sdc.itempermissions.dao.ItemPermissionsDao;
+import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity;
+
+import java.util.Collection;
+import java.util.Set;
+
+/**
+ * Created by ayalaben on 6/20/2017.
+ */
+public class ItemPermissionsDaoImpl implements ItemPermissionsDao {
+ private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
+ private static ItemPermissionsAccessor accessor =
+ noSqlDb.getMappingManager().createAccessor(ItemPermissionsAccessor.class);
+
+ @Override
+ public Collection<ItemPermissionsEntity> listItemPermissions(String itemId) {
+ return accessor.getItemPermissions(itemId).all();
+ }
+
+ @Override
+ public void updateItemPermissions(String itemId, String permission, Set<String> addedUsersIds,
+ Set<String> removedUsersIds) {
+ addedUsersIds.forEach(userId -> accessor.addPermission(itemId,userId,permission));
+ removedUsersIds.forEach(userId -> accessor.deletePermission(itemId,userId));
+ }
+
+ @Override
+ public void addUserPermission(String itemId, String userId, String permission){
+ accessor.addPermission(itemId,userId,permission);
+ }
+
+ @Override
+ public String getUserItemPermiission(String itemId, String userId) {
+
+ ResultSet result = accessor.getUserItemPermission(itemId,userId);
+ if (result.getAvailableWithoutFetching() < 1) {
+ return null;
+ }
+ return result.one().getString(0);
+ }
+
+
+ @Accessor
+ interface ItemPermissionsAccessor {
+ @Query("select * from dox.item_permissions WHERE item_id = ?")
+ Result<ItemPermissionsEntity> getItemPermissions(String itemId);
+
+ @Query("select permission from dox.item_permissions WHERE item_id = ? AND user_id=?")
+ ResultSet getUserItemPermission(String itemId,String userId);
+
+ @Query("delete from dox.item_permissions where item_id = ? and user_id = ?")
+ void deletePermission(String itemId, String userId);
+
+ @Query("insert into dox.item_permissions (item_id,user_id,permission) values (?,?,?)")
+ void addPermission(String itemId,String userId, String permission);
+
+ }
+}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsServicesImpl.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsServicesImpl.java
new file mode 100644
index 0000000..ae40ea8
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsServicesImpl.java
@@ -0,0 +1,70 @@
+package org.openecomp.sdc.itempermissions.dao.impl;
+
+import org.openecomp.sdc.common.session.SessionContextProviderFactory;
+import org.openecomp.sdc.itempermissions.PermissionsRules;
+import org.openecomp.sdc.itempermissions.PermissionsServices;
+import org.openecomp.sdc.itempermissions.dao.ItemPermissionsDao;
+import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity;
+
+import java.util.Collection;
+import java.util.Set;
+
+
+/**
+ * Created by ayalaben on 6/22/2017.
+ */
+public class PermissionsServicesImpl implements PermissionsServices {
+
+ private ItemPermissionsDao permissionsDao;
+
+ private PermissionsRules permissionsRules;
+
+ private static final String CHANGE_PERMISSIONS = "Change_Item_Permissions";
+
+ public PermissionsServicesImpl(PermissionsRules permissionsRules,
+ ItemPermissionsDao permissionsDao) {
+ this.permissionsDao = permissionsDao;
+ this.permissionsRules = permissionsRules;
+ }
+
+
+ @Override
+ public Collection<ItemPermissionsEntity> listItemPermissions(String itemId) {
+ return permissionsDao.listItemPermissions(itemId);
+ }
+
+ @Override
+ public void updateItemPermissions(String itemId, String permission, Set<String> addedUsersIds,
+ Set<String> removedUsersIds) {
+
+ String currentUserId = SessionContextProviderFactory.getInstance()
+ .createInterface().get().getUser().getUserId();
+
+ permissionsRules.executeAction(itemId,currentUserId,CHANGE_PERMISSIONS);
+
+ permissionsRules.updatePermission(itemId,currentUserId,permission,addedUsersIds,
+ removedUsersIds);
+
+ permissionsDao.updateItemPermissions(itemId, permission,
+ addedUsersIds, removedUsersIds);
+
+ }
+
+ @Override
+ public boolean isAllowed(String itemId,String userId,String action) {
+
+ String userPermission = permissionsDao.getUserItemPermiission(itemId,userId);
+ return permissionsRules.isAllowed(userPermission,action);
+ }
+
+ @Override
+ public void execute(String itemId,String userId,String action) {
+ permissionsRules.executeAction(itemId, userId, action);
+ }
+
+ @Override
+ public String getUserItemPermiission(String itemId, String userId) {
+ return permissionsDao.getUserItemPermiission(itemId,userId);
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PrmissionsServicesFactoryImpl.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PrmissionsServicesFactoryImpl.java
new file mode 100644
index 0000000..34532cb
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PrmissionsServicesFactoryImpl.java
@@ -0,0 +1,21 @@
+package org.openecomp.sdc.itempermissions.dao.impl;
+
+import org.openecomp.sdc.itempermissions.PermissionsRulesFactory;
+import org.openecomp.sdc.itempermissions.PermissionsServices;
+import org.openecomp.sdc.itempermissions.PermissionsServicesFactory;
+import org.openecomp.sdc.itempermissions.dao.ItemPermissionsDaoFactory;
+
+/**
+ * Created by ayalaben on 6/22/2017
+ */
+public class PrmissionsServicesFactoryImpl extends PermissionsServicesFactory {
+
+ private static final PermissionsServices INSTANCE =
+ new org.openecomp.sdc.itempermissions.dao.impl.PermissionsServicesImpl(PermissionsRulesFactory.getInstance().createInterface(),
+ ItemPermissionsDaoFactory.getInstance().createInterface());
+
+ @Override
+ public PermissionsServices createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/servlet/PermissionsFilter.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/servlet/PermissionsFilter.java
new file mode 100644
index 0000000..21acc07
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/servlet/PermissionsFilter.java
@@ -0,0 +1,72 @@
+package org.openecomp.sdc.itempermissions.servlet;
+
+import org.openecomp.sdc.itempermissions.PermissionsServices;
+import org.openecomp.sdc.itempermissions.PermissionsServicesFactory;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * Created by ayalaben on 6/27/2017.
+ */
+public class PermissionsFilter implements Filter {
+
+ private final PermissionsServices permissionsServices;
+ public static final String IRRELEVANT_REQUEST = "Irrelevant_Request";
+ public static final String EDIT_ITEM = "Edit_Item";
+
+ public PermissionsFilter() {
+ this.permissionsServices = PermissionsServicesFactory.getInstance().createInterface();
+ }
+
+ @Override
+ public void init(FilterConfig filterConfig) throws ServletException {
+
+ }
+
+ @Override
+ public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,
+ FilterChain filterChain) throws IOException, ServletException {
+
+ if (servletRequest instanceof HttpServletRequest) {
+ if (((HttpServletRequest) servletRequest).getMethod().equals("POST")
+ || ((HttpServletRequest) servletRequest).getMethod().equals("PUT")) {
+
+ String userId = ((HttpServletRequest) servletRequest).getHeader("USER_ID");
+ String itemId = parseItemIdFromPath(((HttpServletRequest) servletRequest).getPathInfo());
+ if ( ! itemId.equals(IRRELEVANT_REQUEST)) {
+ if ( ! permissionsServices.isAllowed(itemId,userId,EDIT_ITEM)) {
+ ((HttpServletResponse) servletResponse).setStatus(HttpServletResponse.SC_FORBIDDEN);
+ servletResponse.getWriter().print("Permissions Error. The user does not have " +
+ "permission to perform" +
+ " this action.");
+ return;
+ }
+ }
+ }
+ }
+
+ filterChain.doFilter(servletRequest, servletResponse);
+ }
+
+ private String parseItemIdFromPath(String pathInfo) {
+ String[] tokens = pathInfo.split("/");
+ if (tokens.length < 4) {
+ return IRRELEVANT_REQUEST;
+ } else {
+ return tokens[3];
+ }
+ }
+
+ @Override
+ public void destroy() {
+
+ }
+}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/resources/factoryConfiguration.json b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/resources/factoryConfiguration.json
new file mode 100644
index 0000000..d239484
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/resources/factoryConfiguration.json
@@ -0,0 +1,4 @@
+{
+ "org.openecomp.sdc.itempermissions.dao.ItemPermissionsDaoFactory": "org.openecomp.sdc.itempermissions.dao.impl.ItemPermissionsDaoFactoryImpl",
+"org.openecomp.sdc.itempermissions.PermissionsServicesFactory" : "org.openecomp.sdc.itempermissions.dao.impl.PrmissionsServicesFactoryImpl"
+}
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/test/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsServicesImplTest.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/test/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsServicesImplTest.java
new file mode 100644
index 0000000..0a87c29
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/test/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsServicesImplTest.java
@@ -0,0 +1,111 @@
+package org.openecomp.sdc.itempermissions.dao.impl;
+
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.mockito.Spy;
+import org.openecomp.sdc.common.session.SessionContextProviderFactory;
+import org.openecomp.sdc.itempermissions.PermissionsRules;
+import org.openecomp.sdc.itempermissions.dao.ItemPermissionsDao;
+import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity;
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+/**
+ * Created by ayalaben on 7/9/2017
+ */
+public class PermissionsServicesImplTest {
+
+ private static final String ITEM1_ID = "1";
+ private static final String PERMISSION = "Owner";
+ private static final String USER2_ID = "testUser2";
+ private static final String USER1_ID = "testUser1";
+ private static final String ACTION_SUBMIT = "Submit_Item";
+ private static final String CHANGE_PERMISSIONS = "Change_Item_Permissions";
+
+ static {
+ SessionContextProviderFactory.getInstance().createInterface().create("testUser1");
+ }
+
+ @Mock
+ private ItemPermissionsDao permissionsDaoMock;
+ @Mock
+ private PermissionsRules permissionsRules;
+ @InjectMocks
+ @Spy
+ private PermissionsServicesImpl permissionsServices;
+
+
+ @BeforeMethod
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testListItemPermissionsWhenNone() {
+ Collection<ItemPermissionsEntity> permissions =
+ permissionsServices.listItemPermissions(ITEM1_ID);
+ Assert.assertEquals(permissions.size(), 0);
+ }
+
+
+ @Test
+ public void testListItemPermissions(){
+ doReturn(Arrays.asList(
+ createPermissionEntity(ITEM1_ID, USER1_ID, PERMISSION),
+ createPermissionEntity(ITEM1_ID, USER2_ID, PERMISSION)))
+ .when(permissionsDaoMock).listItemPermissions(anyObject());
+
+ Collection<ItemPermissionsEntity> actual =
+ permissionsServices.listItemPermissions(ITEM1_ID);
+ Assert.assertEquals(actual.size(), 2);
+ }
+
+
+ @Test
+ public void testIsAllowed(){
+ when(permissionsDaoMock.getUserItemPermiission(ITEM1_ID,USER1_ID)).thenReturn(PERMISSION);
+ when(permissionsRules.isAllowed(PERMISSION,ACTION_SUBMIT)).thenReturn(true);
+
+ Boolean result = permissionsServices.isAllowed(ITEM1_ID,USER1_ID,ACTION_SUBMIT);
+
+ Assert.assertTrue(result);
+
+ }
+ @Test
+ public void testUpdatePermissions(){
+
+ Set<String> addedUsers = new HashSet<String>();
+ addedUsers.add(USER2_ID);
+
+ permissionsServices.updateItemPermissions(ITEM1_ID,PERMISSION,addedUsers,
+ new HashSet<String>());
+
+ verify(permissionsRules).executeAction(ITEM1_ID,USER1_ID,CHANGE_PERMISSIONS);
+ verify(permissionsRules).updatePermission(ITEM1_ID,USER1_ID,PERMISSION,addedUsers,new HashSet<String>());
+ verify(permissionsDaoMock).updateItemPermissions(ITEM1_ID,PERMISSION,addedUsers,new
+ HashSet<String>());
+ }
+
+
+ public static ItemPermissionsEntity createPermissionEntity(String itemId, String
+ userId, String permission) {
+ ItemPermissionsEntity permissionsEntity = new ItemPermissionsEntity();
+ permissionsEntity.setItemId(itemId);
+ permissionsEntity.setUserId(userId);
+ permissionsEntity.setPermission(permission);
+ return permissionsEntity;
+ }
+
+}
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/pom.xml b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/pom.xml
new file mode 100644
index 0000000..0a3bf6e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/pom.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-item-permissions-lib</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+ <artifactId>openecomp-item-permissions-impl</artifactId>
+ <dependencies>
+
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-item-permissions-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-item-permissions-core</artifactId>
+ <version>${project.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/main/java/org/openecomp/sdc/itempermissions/impl/PermissionsRulesFactoryImpl.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/main/java/org/openecomp/sdc/itempermissions/impl/PermissionsRulesFactoryImpl.java
new file mode 100644
index 0000000..c74907c
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/main/java/org/openecomp/sdc/itempermissions/impl/PermissionsRulesFactoryImpl.java
@@ -0,0 +1,16 @@
+package org.openecomp.sdc.itempermissions.impl;
+
+import org.openecomp.sdc.itempermissions.PermissionsRules;
+import org.openecomp.sdc.itempermissions.PermissionsRulesFactory;
+
+/**
+ * Created by ayalaben on 6/26/2017.
+ */
+public class PermissionsRulesFactoryImpl extends PermissionsRulesFactory {
+
+ @Override
+ public PermissionsRules createInterface() {
+ return new PermissionsRulesImpl();
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/main/java/org/openecomp/sdc/itempermissions/impl/PermissionsRulesImpl.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/main/java/org/openecomp/sdc/itempermissions/impl/PermissionsRulesImpl.java
new file mode 100644
index 0000000..22d81a7
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/main/java/org/openecomp/sdc/itempermissions/impl/PermissionsRulesImpl.java
@@ -0,0 +1,126 @@
+package org.openecomp.sdc.itempermissions.impl;
+
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.itempermissions.PermissionsRules;
+import org.openecomp.sdc.itempermissions.PermissionsServicesFactory;
+import org.openecomp.sdc.itempermissions.errors.PermissionsErrorMessagesBuilder;
+import org.openecomp.sdc.itempermissions.impl.types.PermissionActionTypes;
+import org.openecomp.sdc.itempermissions.impl.types.PermissionTypes;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.openecomp.sdc.itempermissions.errors.PermissionsErrorMessages.INVALID_ACTION_TYPE;
+import static org.openecomp.sdc.itempermissions.errors.PermissionsErrorMessages.INVALID_PERMISSION_TYPE;
+
+/**
+ * Created by ayalaben on 6/26/2017.
+ */
+public class PermissionsRulesImpl implements PermissionsRules {
+
+
+ @Override
+ public boolean isAllowed(String permission, String action) {
+
+ if (permission == null) {
+ return false;
+ }
+ try {
+ PermissionTypes.valueOf(permission);
+ } catch (IllegalArgumentException ex) {
+ throw new CoreException(new PermissionsErrorMessagesBuilder(INVALID_PERMISSION_TYPE).build());
+ }
+
+ try {
+ switch (PermissionActionTypes.valueOf(action)) {
+ case Create_Item:
+ return true;
+
+ case Edit_Item:
+ if (permission.equals(PermissionTypes.Contributor.name()) || permission.equals
+ (PermissionTypes.Owner.name())) {
+ return true;
+ }
+ break;
+ case Commit_Item:
+ if (permission.equals(PermissionTypes.Contributor.name()) || permission.equals
+ (PermissionTypes.Owner.name())) {
+ return true;
+ }
+ break;
+
+ case Change_Item_Permissions:
+ if (permission.equals(PermissionTypes.Owner.name())) {
+ return true;
+ }
+ break;
+
+ case Submit_Item:
+ if (permission.equals(PermissionTypes.Owner.name())) {
+ return true;
+ }
+ break;
+
+ default:
+ return false;
+ }
+ } catch (IllegalArgumentException ex) {
+ throw new CoreException(new PermissionsErrorMessagesBuilder(INVALID_ACTION_TYPE).build());
+ }
+
+ return false;
+ }
+
+ @Override
+ public void executeAction(String itemId, String userId, String action) {
+ try {
+ switch (PermissionActionTypes.valueOf(action)) {
+ case Create_Item:
+ caseCreateItem(userId,itemId);
+ break;
+
+ case Change_Item_Permissions:
+ break;
+
+ case Edit_Item:
+ break;
+
+ case Submit_Item:
+ break;
+
+ default:
+ }
+ } catch (IllegalArgumentException ex) {
+ throw new CoreException(new PermissionsErrorMessagesBuilder(INVALID_ACTION_TYPE).build());
+ }
+ }
+
+ @Override
+ public void updatePermission(String itemId,String currentUserId, String permission, Set<String>
+ addedUsersIds,Set<String> removedUsersIds) {
+ try {
+ PermissionTypes.valueOf(permission);
+ } catch (IllegalArgumentException ex) {
+ throw new CoreException(new PermissionsErrorMessagesBuilder(INVALID_PERMISSION_TYPE).build());
+ }
+
+ if (permission.equals(PermissionTypes.Owner.name())) {
+
+ HashSet<String> currentOwner = new HashSet<String>();
+ currentOwner.add(currentUserId);
+
+ PermissionsServicesFactory.getInstance().createInterface()
+ .updateItemPermissions(itemId,PermissionTypes.Contributor.name(),
+ currentOwner,new HashSet<String>());
+ }
+ }
+
+ protected void caseCreateItem(String userId,String itemId) {
+ HashSet<String> ownerId = new HashSet<String>();
+ ownerId.add(userId);
+ PermissionsServicesFactory.getInstance().createInterface()
+ .updateItemPermissions(itemId, PermissionTypes.Owner.name(), ownerId,
+ new HashSet<String>());
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/main/java/org/openecomp/sdc/itempermissions/impl/types/PermissionActionTypes.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/main/java/org/openecomp/sdc/itempermissions/impl/types/PermissionActionTypes.java
new file mode 100644
index 0000000..3d1b8a8
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/main/java/org/openecomp/sdc/itempermissions/impl/types/PermissionActionTypes.java
@@ -0,0 +1,14 @@
+package org.openecomp.sdc.itempermissions.impl.types;
+
+/**
+ * Created by ayalaben on 6/26/2017
+ */
+public enum PermissionActionTypes {
+
+ Create_Item,
+ Change_Item_Permissions,
+ Edit_Item,
+ Commit_Item,
+ Submit_Item;
+
+}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/main/java/org/openecomp/sdc/itempermissions/impl/types/PermissionTypes.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/main/java/org/openecomp/sdc/itempermissions/impl/types/PermissionTypes.java
new file mode 100644
index 0000000..e3c93c5
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/main/java/org/openecomp/sdc/itempermissions/impl/types/PermissionTypes.java
@@ -0,0 +1,9 @@
+package org.openecomp.sdc.itempermissions.impl.types;
+
+/**
+ * Created by ayalaben on 6/26/2017.
+ */
+public enum PermissionTypes {
+ Owner,
+ Contributor
+}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/main/resources/factoryConfiguration.json b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/main/resources/factoryConfiguration.json
new file mode 100644
index 0000000..a3d3dae
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/main/resources/factoryConfiguration.json
@@ -0,0 +1,3 @@
+{
+ "org.openecomp.sdc.itempermissions.PermissionsRulesFactory": "org.openecomp.sdc.itempermissions.impl.PermissionsRulesFactoryImpl"
+}
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/test/java/org/openecomp/sdc/itempermissions/impl/PermissionsRulesImplTest.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/test/java/org/openecomp/sdc/itempermissions/impl/PermissionsRulesImplTest.java
new file mode 100644
index 0000000..635a0b2
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/test/java/org/openecomp/sdc/itempermissions/impl/PermissionsRulesImplTest.java
@@ -0,0 +1,101 @@
+package org.openecomp.sdc.itempermissions.impl;
+
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.mockito.Spy;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.itempermissions.dao.impl.PermissionsServicesImpl;
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.HashSet;
+
+
+/**
+ * Created by ayalaben on 7/10/2017
+ */
+public class PermissionsRulesImplTest {
+
+ private static final String ITEM1_ID = "1";
+ private static final String USER1_ID = "testUser1";
+ private static final String PERMISSION_OWNER = "Owner";
+ private static final String PERMISSION_CONTRIBUTOR = "Contributor";
+ private static final String INVALID_PERMISSION = "Invalid_Permission";
+ private static final String SUBMIT_ACTION = "Submit_Item";
+ private static final String EDIT_ACTION = "Edit_Item";
+ private static final String CHANGE_PERMISSIONS_ACTION = "Change_Item_Permissions";
+ private static final String INVALID_ACTION = "Invalid_Action";
+
+ @Mock
+ private PermissionsServicesImpl permissionsServices;
+
+ @InjectMocks
+ @Spy
+ private PermissionsRulesImpl permissionsRules;
+
+
+ @BeforeMethod
+ public void setUp() throws Exception {
+
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test(expectedExceptions = CoreException.class,expectedExceptionsMessageRegExp =
+ "Invalid permission type")
+ public void testIsAllowedWhenInvalidPermission() {
+ permissionsRules.isAllowed(INVALID_PERMISSION, EDIT_ACTION);
+ }
+
+ @Test(expectedExceptions = CoreException.class,expectedExceptionsMessageRegExp =
+ "Invalid action type")
+ public void testIsAllowedWhenInvalidAction() {
+ permissionsRules.isAllowed(PERMISSION_CONTRIBUTOR, INVALID_ACTION);
+ }
+
+ @Test
+ public void testIsAllowedCaseSubmitOwner(){
+ Assert.assertTrue(permissionsRules.isAllowed(PERMISSION_OWNER,SUBMIT_ACTION));
+ }
+
+ @Test
+ public void testIsAllowedCaseSubmitNotOwner(){
+ Assert.assertFalse(permissionsRules.isAllowed(PERMISSION_CONTRIBUTOR,SUBMIT_ACTION));
+ }
+
+ @Test
+ public void testIsAllowedCaseEditOwner(){
+ Assert.assertTrue(permissionsRules.isAllowed(PERMISSION_OWNER,EDIT_ACTION));
+ }
+
+ @Test
+ public void testIsAllowedCaseEditContributer(){
+ Assert.assertTrue(permissionsRules.isAllowed(PERMISSION_CONTRIBUTOR,EDIT_ACTION));
+ }
+
+ @Test
+ public void testIsAllowedCaseChangePermissionsContributer(){
+ Assert.assertFalse(permissionsRules.isAllowed(PERMISSION_CONTRIBUTOR,CHANGE_PERMISSIONS_ACTION));
+ }
+
+ @Test
+ public void testIsAllowedCaseChangePermissionsOwner(){
+ Assert.assertTrue(permissionsRules.isAllowed(PERMISSION_OWNER,CHANGE_PERMISSIONS_ACTION));
+ }
+
+ @Test(expectedExceptions = CoreException.class,expectedExceptionsMessageRegExp =
+ "Invalid permission type")
+ public void testUpdatePermissionWhenInvalidPermission() {
+ permissionsRules.updatePermission(ITEM1_ID,USER1_ID,INVALID_PERMISSION,new HashSet<String>(),
+ new HashSet<String>());
+ }
+
+ @Test(expectedExceptions = CoreException.class,expectedExceptionsMessageRegExp =
+ "Invalid action type")
+ public void testExecuteActionInvalidAction(){
+ permissionsRules.executeAction(ITEM1_ID,USER1_ID,INVALID_ACTION);
+ }
+
+
+}
\ No newline at end of file
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/resources/logback.xml b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/test/resources/logback.xml
similarity index 91%
copy from openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/resources/logback.xml
copy to openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/test/resources/logback.xml
index 9c9c06c..c1932e3 100644
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/resources/logback.xml
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/test/resources/logback.xml
@@ -9,7 +9,7 @@
</appender>
<root level="warn">
- <appender-ref ref="STDOUT"/>
+ <appender-ref ref="STDOUT" />
</root>
</configuration>
\ No newline at end of file
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/pom.xml b/openecomp-be/lib/openecomp-item-permissions-lib/pom.xml
similarity index 60%
copy from openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/pom.xml
copy to openecomp-be/lib/openecomp-item-permissions-lib/pom.xml
index 0b3c83c..fbf8ca5 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/pom.xml
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/pom.xml
@@ -4,19 +4,21 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>activity-log-rest</artifactId>
- <packaging>pom</packaging>
-
<parent>
+ <artifactId>openecomp-sdc-lib</artifactId>
<groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-rest-webapp</artifactId>
<version>1.2.0-SNAPSHOT</version>
+ <relativePath>..</relativePath>
</parent>
+ <artifactId>openecomp-item-permissions-lib</artifactId>
+ <packaging>pom</packaging>
+
+
<modules>
- <module>activity-log-rest-services</module>
- <module>activity-log-rest-types</module>
+ <module>openecomp-item-permissions-api</module>
+ <module>openecomp-item-permissions-impl</module>
+ <module>openecomp-item-permissions-core</module>
</modules>
-
-</project>
+
+</project>
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionExceptionMapper.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionExceptionMapper.java
index 98e1c69..9ca574a 100644
--- a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionExceptionMapper.java
+++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionExceptionMapper.java
@@ -20,6 +20,10 @@
package org.openecomp.sdc.action.errors;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+
import static org.openecomp.sdc.action.ActionConstants.WWW_AUTHENTICATE_HEADER_PARAM;
import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_ALREADY_EXISTS_CODE;
import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_CHECKSUM_ERROR_CODE;
@@ -60,10 +64,6 @@
import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_UPDATE_NOT_ALLOWED_FOR_NAME;
import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_UPDATE_ON_UNLOCKED_ENTITY;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.ext.ExceptionMapper;
-
/**
* Mapper class to map Action Library exceptions to corresponding HTTP Response objects.
*/
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/util/ActionUtil.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/util/ActionUtil.java
index 0315a31..820fb86 100644
--- a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/util/ActionUtil.java
+++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/util/ActionUtil.java
@@ -20,6 +20,18 @@
package org.openecomp.sdc.action.util;
+import org.openecomp.sdc.action.logging.CategoryLogLevel;
+import org.openecomp.sdc.action.logging.StatusCode;
+import org.openecomp.sdc.action.types.ActionLogResponseCode;
+import org.openecomp.sdc.action.types.ActionSubOperation;
+import org.slf4j.MDC;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.time.ZoneOffset;
+import java.util.Date;
+import java.util.TimeZone;
+
import static org.openecomp.sdc.action.ActionConstants.BEGIN_TIMESTAMP;
import static org.openecomp.sdc.action.ActionConstants.ELAPSED_TIME;
import static org.openecomp.sdc.action.ActionConstants.END_TIMESTAMP;
@@ -104,18 +116,6 @@
import static org.openecomp.sdc.action.types.ActionLogResponseCode.UPDATE_ON_LOCKED_ENTITY;
import static org.openecomp.sdc.action.types.ActionLogResponseCode.UPDATE_ON_UNLOCKED_ENTITY;
-import org.openecomp.sdc.action.logging.CategoryLogLevel;
-import org.openecomp.sdc.action.logging.StatusCode;
-import org.openecomp.sdc.action.types.ActionLogResponseCode;
-import org.openecomp.sdc.action.types.ActionSubOperation;
-import org.slf4j.MDC;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.time.ZoneOffset;
-import java.util.Date;
-import java.util.TimeZone;
-
public class ActionUtil {
private static final String UTC_DATE_FORMAT = "dd MMM yyyy kk:mm:ss z";
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionArtifactDaoImpl.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionArtifactDaoImpl.java
index bfa5830..27f0438 100644
--- a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionArtifactDaoImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionArtifactDaoImpl.java
@@ -20,20 +20,12 @@
package org.openecomp.sdc.action.dao.impl;
-import static org.openecomp.sdc.action.ActionConstants.TARGET_ENTITY_DB;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INTERNAL_SERVER_ERR_CODE;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_QUERY_FAILURE_CODE;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_QUERY_FAILURE_MSG;
-
import com.datastax.driver.core.exceptions.NoHostAvailableException;
import com.datastax.driver.mapping.Mapper;
import com.datastax.driver.mapping.Result;
import com.datastax.driver.mapping.annotations.Accessor;
import com.datastax.driver.mapping.annotations.Query;
import org.openecomp.core.dao.impl.CassandraBaseDao;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.core.nosqldb.api.NoSqlDb;
import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
import org.openecomp.sdc.action.dao.ActionArtifactDao;
@@ -44,10 +36,18 @@
import org.openecomp.sdc.action.types.ActionArtifact;
import org.openecomp.sdc.action.types.ActionSubOperation;
import org.openecomp.sdc.action.util.ActionUtil;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
import java.util.Collection;
import java.util.List;
+import static org.openecomp.sdc.action.ActionConstants.TARGET_ENTITY_DB;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INTERNAL_SERVER_ERR_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_QUERY_FAILURE_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_QUERY_FAILURE_MSG;
+
public class ActionArtifactDaoImpl extends CassandraBaseDao<ActionArtifactEntity>
implements ActionArtifactDao {
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionDaoImpl.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionDaoImpl.java
index b7f4b5c..a79687f 100644
--- a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionDaoImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionDaoImpl.java
@@ -20,30 +20,6 @@
package org.openecomp.sdc.action.dao.impl;
-import static com.datastax.driver.core.querybuilder.QueryBuilder.eq;
-import static com.datastax.driver.core.querybuilder.QueryBuilder.in;
-import static com.datastax.driver.core.querybuilder.QueryBuilder.set;
-import static org.openecomp.core.nosqldb.impl.cassandra.CassandraSessionFactory.getSession;
-import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_CATEGORY;
-import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_OPEN_ECOMP_COMPONENT;
-import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_MODEL;
-import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_NAME;
-import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_NONE;
-import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_VENDOR;
-import static org.openecomp.sdc.action.ActionConstants.STATUS;
-import static org.openecomp.sdc.action.ActionConstants.TARGET_ENTITY;
-import static org.openecomp.sdc.action.ActionConstants.TARGET_ENTITY_DB;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_DEL_LOCKED_OTHER_USER;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_DEL_LOCKED_OTHER_USER_CODE;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_NOT_EXIST;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_NOT_EXIST_CODE;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INTERNAL_SERVER_ERR_CODE;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_NOT_LOCKED_CODE;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_NOT_LOCKED_MSG;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_QUERY_FAILURE_CODE;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_QUERY_FAILURE_MSG;
-
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.Row;
import com.datastax.driver.core.Statement;
@@ -56,8 +32,6 @@
import com.datastax.driver.mapping.annotations.Accessor;
import com.datastax.driver.mapping.annotations.Query;
import org.openecomp.core.dao.impl.CassandraBaseDao;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.core.nosqldb.api.NoSqlDb;
import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
import org.openecomp.core.utilities.json.JsonUtil;
@@ -73,6 +47,8 @@
import org.openecomp.sdc.action.types.ActionSubOperation;
import org.openecomp.sdc.action.types.OpenEcompComponent;
import org.openecomp.sdc.action.util.ActionUtil;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.versioning.VersioningManagerFactory;
import org.openecomp.sdc.versioning.dao.VersionInfoDao;
import org.openecomp.sdc.versioning.dao.VersionInfoDaoFactory;
@@ -93,6 +69,30 @@
import java.util.Set;
import java.util.stream.Collectors;
+import static com.datastax.driver.core.querybuilder.QueryBuilder.eq;
+import static com.datastax.driver.core.querybuilder.QueryBuilder.in;
+import static com.datastax.driver.core.querybuilder.QueryBuilder.set;
+import static org.openecomp.core.nosqldb.impl.cassandra.CassandraSessionFactory.getSession;
+import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_CATEGORY;
+import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_MODEL;
+import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_NAME;
+import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_NONE;
+import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_OPEN_ECOMP_COMPONENT;
+import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_VENDOR;
+import static org.openecomp.sdc.action.ActionConstants.STATUS;
+import static org.openecomp.sdc.action.ActionConstants.TARGET_ENTITY;
+import static org.openecomp.sdc.action.ActionConstants.TARGET_ENTITY_DB;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_DEL_LOCKED_OTHER_USER;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_DEL_LOCKED_OTHER_USER_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_NOT_EXIST;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_NOT_EXIST_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INTERNAL_SERVER_ERR_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_NOT_LOCKED_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_NOT_LOCKED_MSG;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_QUERY_FAILURE_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_QUERY_FAILURE_MSG;
+
public class ActionDaoImpl extends CassandraBaseDao<ActionEntity> implements ActionDao {
private static NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
diff --git a/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-api/src/main/java/org/openecomp/sdc/activitylog/dao/ActivityLogDao.java b/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-api/src/main/java/org/openecomp/sdc/activitylog/dao/ActivityLogDao.java
index 9804bfc..6ca1010 100644
--- a/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-api/src/main/java/org/openecomp/sdc/activitylog/dao/ActivityLogDao.java
+++ b/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-api/src/main/java/org/openecomp/sdc/activitylog/dao/ActivityLogDao.java
@@ -18,10 +18,6 @@
import org.openecomp.core.dao.BaseDao;
import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
-import org.openecomp.sdc.versioning.dao.types.Version;
-
-import java.util.Collection;
public interface ActivityLogDao extends BaseDao<ActivityLogEntity> {
- Collection<ActivityLogEntity> getActivityLogListForItem(String itemId, String versionId);
}
diff --git a/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-api/src/main/java/org/openecomp/sdc/activitylog/dao/ActivityLogDaoFactory.java b/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-api/src/main/java/org/openecomp/sdc/activitylog/dao/ActivityLogDaoFactory.java
index d3ac277..1fc7de7 100644
--- a/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-api/src/main/java/org/openecomp/sdc/activitylog/dao/ActivityLogDaoFactory.java
+++ b/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-api/src/main/java/org/openecomp/sdc/activitylog/dao/ActivityLogDaoFactory.java
@@ -15,8 +15,8 @@
*/
package org.openecomp.sdc.activitylog.dao;
-import org.openecomp.core.factory.api.AbstractFactory;
import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
public abstract class ActivityLogDaoFactory extends AbstractComponentFactory<ActivityLogDao> {
diff --git a/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-api/src/main/java/org/openecomp/sdc/activitylog/dao/type/ActivityLogEntity.java b/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-api/src/main/java/org/openecomp/sdc/activitylog/dao/type/ActivityLogEntity.java
index e84a2be..36a4bbc 100644
--- a/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-api/src/main/java/org/openecomp/sdc/activitylog/dao/type/ActivityLogEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-api/src/main/java/org/openecomp/sdc/activitylog/dao/type/ActivityLogEntity.java
@@ -16,107 +16,130 @@
package org.openecomp.sdc.activitylog.dao.type;
-import com.datastax.driver.mapping.annotations.*;
+import com.datastax.driver.mapping.annotations.ClusteringColumn;
+import com.datastax.driver.mapping.annotations.Column;
+import com.datastax.driver.mapping.annotations.Enumerated;
+import com.datastax.driver.mapping.annotations.PartitionKey;
+import com.datastax.driver.mapping.annotations.Table;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.Calendar;
import java.util.Date;
@Table(keyspace = "dox", name = "activity_log")
public class ActivityLogEntity {
- @PartitionKey
- @Column(name = "item_id")
- private String itemId;
- @ClusteringColumn(value = 1)
- @Column(name = "version_id")
- private String versionId;
- @ClusteringColumn
- @Column(name = "activity_id")
- private String id;
- private String type;
- private String user;
- private Date timestamp;
- private boolean success;
- private String message;
- private String comment;
+ @PartitionKey
+ @Column(name = "item_id")
+ private String itemId;
+ @ClusteringColumn(value = 1)
+ @Column(name = "version_id")
+ private String versionId;
+ @ClusteringColumn
+ @Column(name = "activity_id")
+ private String id;
+ @Enumerated
+ private ActivityType type;
+ private String user;
+ private Date timestamp;
+ private boolean success;
+ private String message;
+ private String comment;
- public ActivityLogEntity() {}
+ public ActivityLogEntity() {
+ }
- public ActivityLogEntity(String itemId, String versionId, String type, String user, boolean success, String message, String comment) {
- this.itemId = itemId;
- this.versionId = versionId;
- this.type = type;
- this.user = user;
- this.success = success;
- this.message = message;
- this.comment = comment;
- Calendar now = Calendar.getInstance();
- this.timestamp = now.getTime();
- }
+ public ActivityLogEntity(String itemId, Version version) {
+ this.itemId = itemId;
+ setVersion(version);
+ }
- public String getItemId() { return itemId; }
+ public ActivityLogEntity(String itemId, Version version, ActivityType type, String user,
+ boolean success, String message, String comment) {
+ this(itemId, version);
+ this.type = type;
+ this.user = user;
+ this.success = success;
+ this.message = message;
+ this.comment = comment;
+ this.timestamp = new Date();
+ }
- public void setItemId(String itemId) {
- this.itemId = itemId;
- }
+ public String getItemId() {
+ return itemId;
+ }
- public String getVersionId() {
- return versionId;
- }
+ public void setItemId(String itemId) {
+ this.itemId = itemId;
+ }
- public void setVersionId(String versionId) {
- this.versionId = versionId;
- }
+ public Version getVersion() {
+ return versionId == null ? null : new Version(versionId);
+ }
- public String getId() { return id; }
+ public void setVersion(Version version) {
+ this.versionId = version == null ? null : version.getId();
+ }
- public void setId(String id) { this.id = id; }
+ public String getVersionId() {
+ return versionId;
+ }
- public String getType() {
- return type;
- }
+ public void setVersionId(String versionId) {
+ this.versionId = versionId;
+ }
- public void setType(String type) {
- this.type = type;
- }
+ public String getId() {
+ return id;
+ }
- public String getUser() {
- return user;
- }
+ public void setId(String id) {
+ this.id = id;
+ }
- public void setUser(String user) {
- this.user = user;
- }
+ public ActivityType getType() {
+ return type;
+ }
- public Date getTimestamp() {
- return timestamp;
- }
+ public void setType(ActivityType type) {
+ this.type = type;
+ }
- public void setTimestamp(Date timestamp) {
- this.timestamp = timestamp;
- }
+ public String getUser() {
+ return user;
+ }
- public boolean isSuccess() {
- return success;
- }
+ public void setUser(String user) {
+ this.user = user;
+ }
- public void setSuccess(boolean success) {
- this.success = success;
- }
+ public Date getTimestamp() {
+ return timestamp;
+ }
- public String getMessage() {
- return message;
- }
+ public void setTimestamp(Date timestamp) {
+ this.timestamp = timestamp;
+ }
- public void setMessage(String message) {
- this.message = message;
- }
+ public boolean isSuccess() {
+ return success;
+ }
- public String getComment() {
- return comment;
- }
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
- public void setComment(String comment) {
- this.comment = comment;
- }
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+ public void setComment(String comment) {
+ this.comment = comment;
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-api/src/main/java/org/openecomp/sdc/activitylog/dao/type/ActivityType.java b/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-api/src/main/java/org/openecomp/sdc/activitylog/dao/type/ActivityType.java
new file mode 100644
index 0000000..620113e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-api/src/main/java/org/openecomp/sdc/activitylog/dao/type/ActivityType.java
@@ -0,0 +1,13 @@
+package org.openecomp.sdc.activitylog.dao.type;
+
+public enum ActivityType {
+ Create,
+ Create_Version,
+ Commit,
+ Submit,
+ Upload_Artifact,
+ Upload_Network_Package,
+ Revert,
+ Reset
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-core/src/main/java/org/openecomp/sdc/activitylog/dao/impl/ActivityLogDaoCassandraImpl.java b/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-core/src/main/java/org/openecomp/sdc/activitylog/dao/impl/ActivityLogDaoCassandraImpl.java
index 5772cc1..85e0afa 100644
--- a/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-core/src/main/java/org/openecomp/sdc/activitylog/dao/impl/ActivityLogDaoCassandraImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-core/src/main/java/org/openecomp/sdc/activitylog/dao/impl/ActivityLogDaoCassandraImpl.java
@@ -26,58 +26,34 @@
import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
import java.util.Collection;
-import java.util.Date;
-public class ActivityLogDaoCassandraImpl extends CassandraBaseDao<ActivityLogEntity> implements ActivityLogDao{
- private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
- private static final Mapper<ActivityLogEntity> mapper =
- noSqlDb.getMappingManager().mapper(ActivityLogEntity.class);
- private static final ActivityLogAccessor accessor =
- noSqlDb.getMappingManager().createAccessor(ActivityLogAccessor.class);
+public class ActivityLogDaoCassandraImpl extends CassandraBaseDao<ActivityLogEntity>
+ implements ActivityLogDao {
+ private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
+ private static final Mapper<ActivityLogEntity> mapper =
+ noSqlDb.getMappingManager().mapper(ActivityLogEntity.class);
+ private static final ActivityLogAccessor accessor =
+ noSqlDb.getMappingManager().createAccessor(ActivityLogAccessor.class);
- @Override
- protected Mapper<ActivityLogEntity> getMapper() {
- return mapper;
- }
+ @Override
+ protected Mapper<ActivityLogEntity> getMapper() {
+ return mapper;
+ }
- @Override
- protected Object[] getKeys(ActivityLogEntity entity) {
- return new Object[0];
- }
+ @Override
+ protected Object[] getKeys(ActivityLogEntity entity) {
+ return new Object[]{entity.getItemId(), entity.getVersionId(), entity.getId()};
+ }
- @Override
- public Collection<ActivityLogEntity> list(ActivityLogEntity entity) {
- return accessor.list().all();
- }
+ @Override
+ public Collection<ActivityLogEntity> list(ActivityLogEntity entity) {
+ return accessor.listByItemVersion(entity.getItemId(), entity.getVersionId()).all();
+ }
- @Override
- public void create(ActivityLogEntity activityLogEntity) {
- accessor.create(activityLogEntity.getItemId(), activityLogEntity.getVersionId(),activityLogEntity.getId(),
- activityLogEntity.getType(),activityLogEntity.getUser(), activityLogEntity.getTimestamp(), activityLogEntity.isSuccess(),
- activityLogEntity.getMessage(), activityLogEntity.getComment());
- }
+ @Accessor
+ interface ActivityLogAccessor {
- @Override
- public Collection<ActivityLogEntity> getActivityLogListForItem(String itemId, String versionId) {
- return accessor.getForItem(itemId, versionId).all();
- }
-
-
- @Accessor
- interface ActivityLogAccessor {
- @Query("select item_id, version_id, activity_id, type, user, timestamp, success, message, comment"
- + " from activity_log")
- Result<ActivityLogEntity> list();
-
- @Query("select item_id, version_id, activity_id, type, user, timestamp, success, message, comment"
- + " from activity_log where item_id=? and version_id=?")
- Result<ActivityLogEntity> getForItem(String itemId, String versionId);
-
- @Query("insert into activity_log " +
- " (item_id, version_id, activity_id, type, user, timestamp, success, message, comment)" +
- " values (?,?,?,?,?,?,?,?,?)")
- Result<ActivityLogEntity> create(String itemId, String versionId, String id, String type,
- String user, Date timestamp, boolean success,
- String message, String comment);
- }
+ @Query("select * from activity_log where item_id=? and version_id=?")
+ Result<ActivityLogEntity> listByItemVersion(String itemId, String versionId);
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-core/src/main/java/org/openecomp/sdc/activitylog/dao/impl/ActivityLogDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-core/src/main/java/org/openecomp/sdc/activitylog/dao/impl/ActivityLogDaoFactoryImpl.java
index 98e4cc2..02c8a71 100644
--- a/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-core/src/main/java/org/openecomp/sdc/activitylog/dao/impl/ActivityLogDaoFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-core/src/main/java/org/openecomp/sdc/activitylog/dao/impl/ActivityLogDaoFactoryImpl.java
@@ -19,10 +19,10 @@
import org.openecomp.sdc.activitylog.dao.ActivityLogDaoFactory;
public class ActivityLogDaoFactoryImpl extends ActivityLogDaoFactory {
- private static final ActivityLogDao INSTANCE = new ActivityLogDaoCassandraImpl();
+ private static final ActivityLogDao INSTANCE = new ActivityLogDaoCassandraImpl();
- @Override
- public ActivityLogDao createInterface() {
- return INSTANCE;
- }
+ @Override
+ public ActivityLogDao createInterface() {
+ return INSTANCE;
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-datatypes-lib/src/main/java/org/openecomp/sdc/datatypes/model/ElementType.java b/openecomp-be/lib/openecomp-sdc-datatypes-lib/src/main/java/org/openecomp/sdc/datatypes/model/ElementType.java
new file mode 100644
index 0000000..19d5656
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-datatypes-lib/src/main/java/org/openecomp/sdc/datatypes/model/ElementType.java
@@ -0,0 +1,31 @@
+package org.openecomp.sdc.datatypes.model;
+
+public enum ElementType {
+ itemVersion,
+
+ VendorLicenseModel,
+ LicenseAgreements, LicenseAgreement,
+ FeatureGroups, FeatureGroup,
+ LicenseKeyGroups, LicenseKeyGroup,
+ EntitlementPools, EntitlementPool,
+ Limits, Limit,
+
+ VendorSoftwareProduct,
+ VSPQuestionnaire,
+
+ VspModel, NetworkPackage,
+ OrchestrationTemplateCandidate, OrchestrationTemplateCandidateContent,
+ // todo - remove OrchestrationTemplateContent
+ OrchestrationTemplate, OrchestrationTemplateValidationData, OrchestrationTemplateContent,
+ Networks, Network,
+ Components, Component, ComponentQuestionnaire, ComponentDependencies, ComponentDependency,
+ Nics, Nic, NicQuestionnaire,
+ Mibs, SNMP_POLL, SNMP_TRAP, VES_EVENTS,
+ Processes, Process,
+ DeploymentFlavors, DeploymentFlavor,
+ Computes, Compute, ComputeQuestionnaire,
+ Images, Image, ImageQuestionnaire,
+ ServiceModel, EnrichedServiceModel, ServiceTemplate, Templates, Artifact, Artifacts,
+
+ test
+}
diff --git a/openecomp-be/lib/openecomp-sdc-datatypes-lib/src/main/java/org/openecomp/sdc/datatypes/model/ItemType.java b/openecomp-be/lib/openecomp-sdc-datatypes-lib/src/main/java/org/openecomp/sdc/datatypes/model/ItemType.java
new file mode 100644
index 0000000..892351a
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-datatypes-lib/src/main/java/org/openecomp/sdc/datatypes/model/ItemType.java
@@ -0,0 +1,6 @@
+package org.openecomp.sdc.datatypes.model;
+
+public enum ItemType {
+ vlm,
+ vsp
+}
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-core/src/main/java/org/openecomp/sdc/enrichment/impl/EnrichmentManagerImpl.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-core/src/main/java/org/openecomp/sdc/enrichment/impl/EnrichmentManagerImpl.java
index 06b157b..6610ec5 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-core/src/main/java/org/openecomp/sdc/enrichment/impl/EnrichmentManagerImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-core/src/main/java/org/openecomp/sdc/enrichment/impl/EnrichmentManagerImpl.java
@@ -22,12 +22,12 @@
import org.openecomp.core.enrichment.api.EnrichmentManager;
import org.openecomp.core.enrichment.types.EntityInfo;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.enrichment.EnrichmentInfo;
import org.openecomp.sdc.enrichment.factory.EnricherHandlerFactory;
import org.openecomp.sdc.enrichment.inter.Enricher;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.versioning.dao.types.Version;
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-core/src/test/java/org/openecomp/sdc/enrichment/impl/EnrichmentManagerImplTest.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-core/src/test/java/org/openecomp/sdc/enrichment/impl/EnrichmentManagerImplTest.java
index 1b9e119..acd25dd 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-core/src/test/java/org/openecomp/sdc/enrichment/impl/EnrichmentManagerImplTest.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-core/src/test/java/org/openecomp/sdc/enrichment/impl/EnrichmentManagerImplTest.java
@@ -20,8 +20,6 @@
package org.openecomp.sdc.enrichment.impl;
-import static org.junit.Assert.assertEquals;
-
import org.openecomp.core.enrichment.factory.EnrichmentManagerFactory;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.sdc.logging.api.Logger;
@@ -50,6 +48,8 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
+import static org.junit.Assert.assertEquals;
+
public class EnrichmentManagerImplTest {
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/EnricherHandlerImpl.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/EnricherHandlerImpl.java
index a5eeece..c9d89ee 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/EnricherHandlerImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/EnricherHandlerImpl.java
@@ -20,12 +20,12 @@
package org.openecomp.sdc.enrichment.impl;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.enrichment.impl.external.artifact.ExternalArtifactEnricher;
import org.openecomp.sdc.enrichment.impl.tosca.ToscaEnricher;
import org.openecomp.sdc.enrichment.inter.Enricher;
import org.openecomp.sdc.enrichment.inter.EnricherHandler;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ProcessArtifactEnricher.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ProcessArtifactEnricher.java
index a5f6529..828de72 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ProcessArtifactEnricher.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ProcessArtifactEnricher.java
@@ -10,10 +10,10 @@
import org.openecomp.sdc.enrichment.EnrichmentInfo;
import org.openecomp.sdc.enrichment.inter.ExternalArtifactEnricherInterface;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessType;
@@ -28,7 +28,7 @@
public class ProcessArtifactEnricher implements ExternalArtifactEnricherInterface {
- private VendorSoftwareProductDao vendorSoftwareProductDao;
+ private ComponentDao componentDao;
//private ProcessArtifactDao processArtifactDao;
private ProcessDao processDao;
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
@@ -41,10 +41,9 @@
Version version = enrichmentInfo.getVersion();
Collection<ComponentEntity> components =
- getVendorSoftwareProductDao().listComponents(vspId, version);
- components.stream()
- .forEach(componentEntry -> errors.putAll(enrichComponent(componentEntry,
- vspId, version)));
+ getComponentDao().list(new ComponentEntity(vspId, version, null));
+ components.forEach(componentEntry -> errors.putAll(enrichComponent(componentEntry,
+ vspId, version)));
return errors;
}
@@ -79,10 +78,9 @@
ProcessArtifactEntity artifactEntity = new ProcessArtifactEntity(vspId, version,
componentId, entity.getId());*/
- processes.stream()
- .forEach(entity -> {
- ProcessEntity artifactEntity = new ProcessEntity(vspId, version,
- componentId, entity.getId());
+ processes.forEach(entity -> {
+ ProcessEntity artifactEntity = new ProcessEntity(vspId, version,
+ componentId, entity.getId());
ProcessEntity artifactProcessEntity = getProcessDao().get(artifactEntity);
//ProcessArtifactEntity artifact = getProcessArtifactDao().get(artifactEntity);
@@ -105,7 +103,7 @@
}
});
- mdcDataDebugMessage.debugExitMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null);
}
void enrichServiceArtifact(ComponentProcessInfo componentProcessInfo,
@@ -113,19 +111,19 @@
Map<String, List<ErrorMessage>> errors) {
- mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugEntryMessage(null);
processServiceArtifact.setName(componentProcessInfo.getName());
processServiceArtifact.setContentData(FileUtils.toByteArray(componentProcessInfo.getContent()));
getEnrichedServiceModelDao().storeExternalArtifact(processServiceArtifact);
- mdcDataDebugMessage.debugExitMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null);
}
- private VendorSoftwareProductDao getVendorSoftwareProductDao() {
- if (vendorSoftwareProductDao == null) {
- vendorSoftwareProductDao = VendorSoftwareProductDaoFactory.getInstance().createInterface();
+ private ComponentDao getComponentDao() {
+ if (componentDao == null) {
+ componentDao = ComponentDaoFactory.getInstance().createInterface();
}
- return vendorSoftwareProductDao;
+ return componentDao;
}
private ProcessDao getProcessDao() {
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/VspInformationArtifactEnricher.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/VspInformationArtifactEnricher.java
index b7da22b..9e46a5c 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/VspInformationArtifactEnricher.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/VspInformationArtifactEnricher.java
@@ -32,8 +32,6 @@
import org.openecomp.sdc.enrichment.inter.ExternalArtifactEnricherInterface;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
@@ -61,8 +59,6 @@
EnrichedServiceModelDaoFactory.getInstance().createInterface();
private VendorSoftwareProductInfoDao vspInfoDao = VendorSoftwareProductInfoDaoFactory
.getInstance().createInterface();
- private OrchestrationTemplateDao orchestrationTemplateDataDao =
- OrchestrationTemplateDaoFactory.getInstance().createInterface();
public VspInformationArtifactEnricher() {
}
@@ -81,7 +77,7 @@
throws IOException {
- mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugEntryMessage(null);
Map<String, List<ErrorMessage>> errors = new HashMap<>();
ByteBuffer infoArtifactByteBuffer = ByteBuffer.wrap(informationArtifactGenerator.generate(
@@ -94,13 +90,13 @@
vspId, version.toString())));
//TODO: add error to map (what is the key?)
- mdcDataDebugMessage.debugExitMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null);
return errors;
}
enrichInformationArtifact(vspId, version, infoArtifactByteBuffer);
- mdcDataDebugMessage.debugExitMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null);
return errors;
}
@@ -108,10 +104,7 @@
ByteBuffer infoArtifactByteBuffer) {
ServiceArtifact infoArtifactServiceArtifact = new ServiceArtifact();
- VspDetails vspDetails = getVspDetails(vspId, version);
-
- String vspName = vspDetails.getName();
-
+ String vspName = vspInfoDao.get(new VspDetails(vspId, version)).getName();
infoArtifactServiceArtifact.setVspId(vspId);
infoArtifactServiceArtifact.setVersion(version);
@@ -126,9 +119,5 @@
enrichedServiceModelDao.storeExternalArtifact(infoArtifactServiceArtifact);
}
- public VspDetails getVspDetails(String vspId,Version version){
- VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId,version));
- vspDetails.setValidationData(orchestrationTemplateDataDao.getValidationData(vspId,version));
- return vspDetails;
- }
+
}
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireData.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireData.java
index f49c53d..9ebe9e5 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireData.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireData.java
@@ -26,36 +26,35 @@
import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VFC_NAMING_CODE;
-
public class ComponentQuestionnaireData {
ComponentDao componentDao = ComponentDaoFactory.getInstance().createInterface();
- ComponentDependencyModelDao componentDependencyModelDao = ComponentDependencyModelDaoFactory.getInstance()
- .createInterface();
+ ComponentDependencyModelDao componentDependencyModelDao =
+ ComponentDependencyModelDaoFactory.getInstance().createInterface();
- private Map<String,String> sourceToTargetComponent;
+ private Map<String, String> sourceToTargetComponent;
- public Map<String,String> getSourceToTargetComponent() {
+ public Map<String, String> getSourceToTargetComponent() {
return sourceToTargetComponent;
}
- public void setSourceToTargetComponent(Map<String,String> sourceToTargetComponent) {
+ public void setSourceToTargetComponent(Map<String, String> sourceToTargetComponent) {
this.sourceToTargetComponent = sourceToTargetComponent;
}
public Map<String, Map<String, Object>> getPropertiesfromCompQuestionnaire(String key,
Version version) {
- Map<String, Map<String,Object>> componentProperties =
- new HashMap<String, Map<String,Object>>();
+ Map<String, Map<String, Object>> componentProperties =
+ new HashMap<String, Map<String, Object>>();
ComponentEntity entity = new ComponentEntity(key, version, null);
final Collection<ComponentEntity> componentEntities =
componentDao.listCompositionAndQuestionnaire(key, version);
- Map<String,String> sourceToTarget = new HashMap<String, String>();
+ Map<String, String> sourceToTarget = new HashMap<>();
for (ComponentEntity component : componentEntities) {
- Map<String, Object> questionnaireParams = new HashMap<String, Object>();
+ Map<String, Object> questionnaireParams = new HashMap<>();
final ComponentQuestionnaire componentQuestionnaire =
JsonUtil.json2Object(component.getQuestionnaireData(), ComponentQuestionnaire.class);
@@ -77,7 +76,7 @@
questionnaireParams.put(EnrichmentConstants.VFC_FUNCTION, vfcDescription);
- if (componentQuestionnaire.getHighAvailabilityAndLoadBalancing() != null ) {
+ if (componentQuestionnaire.getHighAvailabilityAndLoadBalancing() != null) {
String mandatory = componentQuestionnaire.getHighAvailabilityAndLoadBalancing()
.getIsComponentMandatory();
questionnaireParams.put(MANDATORY, mandatory);
@@ -91,19 +90,20 @@
final Integer maxVms =
componentQuestionnaire.getCompute() != null ? (componentQuestionnaire.getCompute()
.getNumOfVMs() != null ? componentQuestionnaire.getCompute().getNumOfVMs()
- .getMaximum(): null) : null;
+ .getMaximum() : null) : null;
final Integer minVms =
componentQuestionnaire.getCompute() != null ? (componentQuestionnaire.getCompute()
.getNumOfVMs() != null ? componentQuestionnaire.getCompute().getNumOfVMs()
- .getMinimum(): null) : null;
+ .getMinimum() : null) : null;
- questionnaireParams.put(MIN_INSTANCES,minVms != null && minVms == 0 ? null : minVms);
- questionnaireParams.put(MAX_INSTANCES,maxVms != null && maxVms == 0 ? null : maxVms);
+ questionnaireParams.put(MIN_INSTANCES, minVms != null && minVms == 0 ? null : minVms);
+ questionnaireParams.put(MAX_INSTANCES, maxVms != null && maxVms == 0 ? null : maxVms);
- if (! questionnaireParams.isEmpty())
+ if (!questionnaireParams.isEmpty()) {
componentProperties.put(JsonUtil.json2Object(component.getCompositionData(),
ComponentData.class).getDisplayName(), questionnaireParams);
+ }
}
setSourceToTargetComponent(sourceToTarget);
@@ -111,12 +111,12 @@
return componentProperties;
}
- public Map<String,List<String>> populateDependencies(String vspId, Version version, Map<String,
- String> componentNameData) {
+ public Map<String, List<String>> populateDependencies(String vspId, Version version, Map<String,
+ String> componentNameData) {
Collection<ComponentDependencyModelEntity> componentDependencies =
componentDependencyModelDao.list(new ComponentDependencyModelEntity(vspId, version, null));
- Map<String,List<String>> sourceToTargetComponent = new HashMap<String, List<String>>();
+ Map<String, List<String>> sourceToTargetComponent = new HashMap<String, List<String>>();
List<String> targetComponents = null;
for (ComponentDependencyModelEntity dependency : componentDependencies) {
String sourceComponentName = componentNameData.get(dependency.getSourceComponentId());
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/PortMirroringEnricher.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/PortMirroringEnricher.java
index 705773d..a855a74 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/PortMirroringEnricher.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/PortMirroringEnricher.java
@@ -1,9 +1,5 @@
package org.openecomp.sdc.enrichment.impl.tosca;
-import static org.openecomp.sdc.tosca.services.DataModelUtil.getClonedObject;
-import static org.openecomp.sdc.tosca.services.ToscaConstants.PORT_MIRRORING_CAPABILITY_CP_PROPERTY_NAME;
-import static org.openecomp.sdc.tosca.services.ToscaConstants.PORT_MIRRORING_CAPABILITY_ID;
-
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
@@ -39,6 +35,10 @@
import java.util.Set;
import java.util.stream.Collectors;
+import static org.openecomp.sdc.tosca.services.DataModelUtil.getClonedObject;
+import static org.openecomp.sdc.tosca.services.ToscaConstants.PORT_MIRRORING_CAPABILITY_CP_PROPERTY_NAME;
+import static org.openecomp.sdc.tosca.services.ToscaConstants.PORT_MIRRORING_CAPABILITY_ID;
+
public class PortMirroringEnricher {
//Map of service template file name and map of all port node template ids, node template
private Map<String, Map<String, NodeTemplate>> portNodeTemplates = new HashMap<>();
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ToscaEnricher.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ToscaEnricher.java
index 090c3ae..5ea1176 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ToscaEnricher.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ToscaEnricher.java
@@ -20,11 +20,13 @@
package org.openecomp.sdc.enrichment.impl.tosca;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.enrichment.inter.Enricher;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -45,13 +47,19 @@
private Map<String, List<ErrorMessage>> enrichAbstractSubstitute() {
mdcDataDebugMessage.debugEntryMessage(null, null);
- Map<String, List<ErrorMessage>> enrichErrors;
+ Map<String, List<ErrorMessage>> enrichErrors = new HashMap<>();
ToscaServiceModel toscaModel = (ToscaServiceModel) model;
AbstractSubstituteToscaEnricher abstractSubstituteToscaEnricher =
new AbstractSubstituteToscaEnricher();
- enrichErrors = abstractSubstituteToscaEnricher.enrich(toscaModel, data.getKey(),
- data.getVersion());
+
+ try {
+ enrichErrors = abstractSubstituteToscaEnricher.enrich(toscaModel, data.getKey(),
+ data.getVersion());
+ }catch (Exception e){
+ enrichErrors.put("Tosca Enrich", Arrays.asList(new ErrorMessage(ErrorLevel.ERROR, e
+ .getMessage())));
+ }
mdcDataDebugMessage.debugExitMessage(null, null);
return enrichErrors;
@@ -59,10 +67,16 @@
private Map<String, List<ErrorMessage>> enrichPortMirroring() {
mdcDataDebugMessage.debugEntryMessage(null, null);
- Map<String, List<ErrorMessage>> enrichErrors;
+ Map<String, List<ErrorMessage>> enrichErrors = new HashMap<>();
ToscaServiceModel toscaModel = (ToscaServiceModel) model;
PortMirroringEnricher portMirroringEnricher = new PortMirroringEnricher();
- enrichErrors = portMirroringEnricher.enrich(toscaModel);
+
+ try {
+ enrichErrors = portMirroringEnricher.enrich(toscaModel);
+ }catch (Exception e){
+ enrichErrors.put("Tosca Enrich", Arrays.asList(new ErrorMessage(ErrorLevel.ERROR, e
+ .getMessage())));
+ }
mdcDataDebugMessage.debugExitMessage(null, null);
return enrichErrors;
}
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/ExternalArtifactEnricherInterface.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/ExternalArtifactEnricherInterface.java
index 49b424e..bd250bb 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/ExternalArtifactEnricherInterface.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/ExternalArtifactEnricherInterface.java
@@ -32,5 +32,5 @@
* Created by Talio on 11/24/2016.
*/
public interface ExternalArtifactEnricherInterface {
- public Map<String, List<ErrorMessage>> enrich(EnrichmentInfo enrichmentInfo) throws IOException;
+ Map<String, List<ErrorMessage>> enrich(EnrichmentInfo enrichmentInfo) throws IOException;
}
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricherTest.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricherTest.java
index 3730a15..c01f986 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricherTest.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricherTest.java
@@ -35,7 +35,6 @@
import org.openecomp.sdc.tosca.services.DataModelUtil;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentArtifactDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity;
import org.openecomp.sdc.versioning.dao.types.Version;
@@ -60,8 +59,6 @@
@Mock
private EnrichedServiceModelDao enrichedServiceModelDaoMock;
@Mock
- private VendorSoftwareProductDao vendorSoftwareProductDaoMock;
- @Mock
private ComponentDao componentDaoMock;
@InjectMocks
@@ -157,7 +154,7 @@
private ByteBuffer getMibByteBuffer(String fileName) {
byte[] mibBytes = FileUtils.readViaInputStream(this.getClass().getResource(fileName),
- stream -> FileUtils.toByteArray(stream));
+ stream -> FileUtils.toByteArray(stream));
return ByteBuffer.wrap(mibBytes);
}
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/ProcessArtifactEnricherTest.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/ProcessArtifactEnricherTest.java
index 0bd84a4..59931a1 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/ProcessArtifactEnricherTest.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/ProcessArtifactEnricherTest.java
@@ -1,46 +1,15 @@
package org.openecomp.sdc.enrichment.impl.external.artifact;
-import org.mockito.ArgumentCaptor;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.openecomp.core.enrichment.types.ArtifactCategory;
-import org.openecomp.core.model.dao.EnrichedServiceModelDao;
-import org.openecomp.core.model.types.ServiceArtifact;
-import org.openecomp.core.utilities.file.FileUtils;
-import org.openecomp.sdc.enrichment.EnrichmentInfo;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessType;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.testng.Assert;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.io.File;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Collection;
-
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.atLeastOnce;
-import static org.mockito.Mockito.when;
-
public class ProcessArtifactEnricherTest {
/*@Mock
ProcessDao processDaoMock;
@Mock
EnrichedServiceModelDao enrichedServiceModelDaoMock;
@Mock
- VendorSoftwareProductDao vendorSoftwareProductDaoMock;
-
+ ComponentDao componentDaoMock;
@InjectMocks
ProcessArtifactEnricher processArtifactEnricher;
-
@BeforeMethod(alwaysRun = true)
public void injectDoubles() {
MockitoAnnotations.initMocks(this);
@@ -65,11 +34,11 @@
processEntity.setArtifactName("artifact_1kb.txt");
processEntity.setArtifact(getMibByteBuffer("/mock/enrichProcess/artifact_1kb.txt"));
- Collection<ComponentEntity> componentList = new ArrayList<ComponentEntity>();
+ Collection<ComponentEntity> componentList = new ArrayList<>();
componentList.add(componentEntity);
- when(vendorSoftwareProductDaoMock.listComponents(vspId, version)).thenReturn(componentList);
+ when(componentDaoMock.list(anyObject())).thenReturn(componentList);
- Collection<ProcessEntity> list = new ArrayList<ProcessEntity>();
+ Collection<ProcessEntity> list = new ArrayList<>();
list.add(processEntity);
when(processDaoMock.list(entity)).thenReturn(list);
@@ -111,7 +80,7 @@
private ByteBuffer getMibByteBuffer(String fileName) {
byte[] mibBytes = FileUtils.readViaInputStream(this.getClass().getResource(fileName),
- stream -> FileUtils.toByteArray(stream));
+ stream -> FileUtils.toByteArray(stream));
return ByteBuffer.wrap(mibBytes);
}*/
}
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/BaseToscaEnrichmentTest.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/BaseToscaEnrichmentTest.java
index 0001cdf..363e171 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/BaseToscaEnrichmentTest.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/BaseToscaEnrichmentTest.java
@@ -25,12 +25,18 @@
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.sdc.tosca.services.ToscaExtensionYamlUtil;
import org.openecomp.sdc.tosca.services.ToscaFileOutputService;
import org.openecomp.sdc.tosca.services.ToscaUtil;
import org.openecomp.sdc.tosca.services.impl.ToscaFileOutputServiceCsarImpl;
-import org.openecomp.sdc.tosca.services.ToscaExtensionYamlUtil;
-import java.io.*;
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
import java.net.URL;
import java.nio.file.NotDirectoryException;
import java.util.Collection;
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireDataTest.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireDataTest.java
index 7373257..d6810d9 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireDataTest.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireDataTest.java
@@ -1,31 +1,5 @@
package org.openecomp.sdc.enrichment.impl.tosca;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.testng.Assert;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.mockito.Mockito.doReturn;
-import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.HIGH_AVAIL_MODE;
-import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MANDATORY;
-import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MAX_INSTANCES;
-import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MIN_INSTANCES;
-import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VFC_CODE;
-import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VFC_FUNCTION;
-import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VFC_NAMING_CODE;
-
public class ComponentQuestionnaireDataTest {
/*private static String VSP_ID = "vspId";
public static final Version VERSION01 = new Version(0, 1);
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/PortMirroringEnricherTest.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/PortMirroringEnricherTest.java
index 0a8fe43..b48fd8d 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/PortMirroringEnricherTest.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/PortMirroringEnricherTest.java
@@ -2,8 +2,6 @@
import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/types/LoggerServiceName.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/types/LoggerServiceName.java
index 08c957a..1a9d327 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/types/LoggerServiceName.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/types/LoggerServiceName.java
@@ -161,8 +161,14 @@
CREATE_COMPONENT_DEPENDENCY_MODEL,
GET_COMPONENT_DEPENDENCY_MODEL,
+ GET_LIST_COMPONENT_DEPENDENCY,
+ CREATE_COMPONENT_DEPENDENCY,
+ UPDATE_COMPONENT_DEPENDENCY,
+ DELETE_COMPONENT_DEPENDENCY,
+ GET_COMPONENT_DEPENDENCY,
- Health_check
+ Health_check,
+ notifications
;
public static String getServiceName(LoggerServiceName serviceName) {
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/types/LoggerTragetServiceName.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/types/LoggerTragetServiceName.java
index 33573a5..ab7292a 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/types/LoggerTragetServiceName.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/types/LoggerTragetServiceName.java
@@ -128,6 +128,8 @@
public static final String CREATE_TRANSLATED_FILE = "Create Translated File";
public static final String CREATE_PACKAGE = "Create Package";
+ public static final String CREATE_VERSION = "Create Version";
+
public static final String SELF_HEALING = "Self Healing";
public static final String WRITE_ARTIFACT_XML = "Write Artifact To XML File";
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/test/java/org/openecomp/sdc/logging/api/LoggerFactoryTest.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/test/java/org/openecomp/sdc/logging/api/LoggerFactoryTest.java
index aa04c50..4b3a1ba 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/test/java/org/openecomp/sdc/logging/api/LoggerFactoryTest.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/test/java/org/openecomp/sdc/logging/api/LoggerFactoryTest.java
@@ -21,7 +21,9 @@
import java.lang.reflect.Field;
import java.util.ServiceLoader;
-import static org.testng.Assert.*;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
/**
* @author evitaliy
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/test/java/org/openecomp/sdc/logging/api/context/TaskFactoryTest.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/test/java/org/openecomp/sdc/logging/api/context/TaskFactoryTest.java
index 61e1819..f5c2187 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/test/java/org/openecomp/sdc/logging/api/context/TaskFactoryTest.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/test/java/org/openecomp/sdc/logging/api/context/TaskFactoryTest.java
@@ -4,7 +4,9 @@
import java.util.ServiceLoader;
-import static org.testng.Assert.*;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
/**
* @author evitaliy
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/servlet/LoggingFilter.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/servlet/LoggingFilter.java
index f34d09e..0ca550a 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/servlet/LoggingFilter.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/servlet/LoggingFilter.java
@@ -20,7 +20,12 @@
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.slf4j.MDC;
-import javax.servlet.*;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.net.InetAddress;
@@ -58,7 +63,7 @@
private static final HostAddressCache HOST_ADDRESS = new HostAddressCache();
private static final String UNKNOWN = "UNKNOWN";
- private final static Logger LOGGER = LoggerFactory.getLogger(LoggingFilter.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(LoggingFilter.class);
public void destroy() {
}
@@ -80,7 +85,8 @@
InetAddress host = HOST_ADDRESS.get();
- String ipAddress, hostName;
+ String ipAddress;
+ String hostName;
if (host == null) {
ipAddress = UNKNOWN;
hostName = UNKNOWN;
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/context/MDCPropagationFactoryTest.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/context/MDCPropagationFactoryTest.java
index 8502d95..1fda9e8 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/context/MDCPropagationFactoryTest.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/context/MDCPropagationFactoryTest.java
@@ -22,7 +22,9 @@
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
-import static org.testng.Assert.*;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
/**
* @author evitaliy
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/servlet/LoggingFilterTest.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/servlet/LoggingFilterTest.java
index 57911a3..95a5421 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/servlet/LoggingFilterTest.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/servlet/LoggingFilterTest.java
@@ -20,7 +20,13 @@
import org.testng.Assert;
import org.testng.annotations.Test;
-import javax.servlet.*;
+import javax.servlet.FilterChain;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.ServletInputStream;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceModelDao.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceModelDao.java
index aa8cbee..3e5975d 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceModelDao.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceModelDao.java
@@ -22,9 +22,6 @@
import org.openecomp.core.model.types.ServiceArtifact;
import org.openecomp.sdc.versioning.dao.VersionableDao;
-import org.openecomp.sdc.versioning.dao.types.Version;
-
-import java.util.List;
public interface EnrichedServiceModelDao<M, E> extends VersionableDao,ServiceModelDao<M, E>{
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/EnrichedServiceArtifactEntity.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/EnrichedServiceArtifactEntity.java
index d3d125b..8736f36 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/EnrichedServiceArtifactEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/EnrichedServiceArtifactEntity.java
@@ -16,14 +16,12 @@
package org.openecomp.core.model.types;
-import com.google.common.io.ByteStreams;
-
import com.datastax.driver.mapping.annotations.ClusteringColumn;
import com.datastax.driver.mapping.annotations.Column;
import com.datastax.driver.mapping.annotations.Frozen;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
-
+import com.google.common.io.ByteStreams;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
import org.openecomp.sdc.logging.types.LoggerConstants;
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/EnrichedServiceTemplateEntity.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/EnrichedServiceTemplateEntity.java
index c837a70..f60c892 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/EnrichedServiceTemplateEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/EnrichedServiceTemplateEntity.java
@@ -16,14 +16,12 @@
package org.openecomp.core.model.types;
-import com.google.common.io.ByteStreams;
-
import com.datastax.driver.mapping.annotations.ClusteringColumn;
import com.datastax.driver.mapping.annotations.Column;
import com.datastax.driver.mapping.annotations.Frozen;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
-
+import com.google.common.io.ByteStreams;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
import org.openecomp.sdc.logging.types.LoggerConstants;
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceArtifactEntity.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceArtifactEntity.java
index 8385a5d..ddff54b 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceArtifactEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceArtifactEntity.java
@@ -16,13 +16,12 @@
package org.openecomp.core.model.types;
-import com.google.common.io.ByteStreams;
-
import com.datastax.driver.mapping.annotations.ClusteringColumn;
import com.datastax.driver.mapping.annotations.Column;
import com.datastax.driver.mapping.annotations.Frozen;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
+import com.google.common.io.ByteStreams;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
import org.openecomp.sdc.logging.types.LoggerConstants;
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceTemplateEntity.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceTemplateEntity.java
index 4897c2f..8f886c2 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceTemplateEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ServiceTemplateEntity.java
@@ -20,14 +20,12 @@
package org.openecomp.core.model.types;
-import com.google.common.io.ByteStreams;
-
import com.datastax.driver.mapping.annotations.ClusteringColumn;
import com.datastax.driver.mapping.annotations.Column;
import com.datastax.driver.mapping.annotations.Frozen;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
-
+import com.google.common.io.ByteStreams;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
import org.openecomp.sdc.logging.types.LoggerConstants;
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceModelDaoImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceModelDaoImpl.java
index 14eda9e..348a8ad 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceModelDaoImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/EnrichedServiceModelDaoImpl.java
@@ -23,13 +23,10 @@
import org.openecomp.core.model.dao.EnrichedServiceArtifactDaoFactory;
import org.openecomp.core.model.dao.EnrichedServiceModelDao;
import org.openecomp.core.model.dao.EnrichedServiceTemplateDaoFactory;
-import org.openecomp.core.model.types.ServiceArtifact;
import org.openecomp.core.model.types.ServiceElement;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.List;
-
public class EnrichedServiceModelDaoImpl extends AbstractServiceModelDao
implements EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> {
public EnrichedServiceModelDaoImpl() {
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/EnrichedServiceModelDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/EnrichedServiceModelDaoZusammenImpl.java
index d018c9a..3bd2881 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/EnrichedServiceModelDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/EnrichedServiceModelDaoZusammenImpl.java
@@ -1,7 +1,6 @@
package org.openecomp.sdc.model.impl.zusammen;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
-import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.SessionContext;
import com.amdocs.zusammen.datatypes.item.Action;
import com.amdocs.zusammen.datatypes.item.ElementContext;
@@ -11,10 +10,13 @@
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+
public class EnrichedServiceModelDaoZusammenImpl extends ServiceModelDaoZusammenImpl implements
EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> {
@@ -23,28 +25,31 @@
public EnrichedServiceModelDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
super(zusammenAdaptor);
- this.name = StructureElement.EnrichedServiceModel.name();
+ this.elementType = ElementType.EnrichedServiceModel;
}
@Override
public void storeExternalArtifact(ServiceArtifact serviceArtifact) {
- ZusammenElement artifactElement = buildArtifactElement(serviceArtifact.getName(),
+ ZusammenElement artifact = buildArtifactElement(serviceArtifact.getName(),
FileUtils.toByteArray(serviceArtifact.getContent()), Action.CREATE);
- ZusammenElement artifactsElement =
- buildStructuralElement(StructureElement.Artifacts.name(), null);
- artifactsElement.addSubElement(artifactElement);
+ ZusammenElement artifacts = buildStructuralElement(ElementType.Artifacts, Action.IGNORE);
+ artifacts.addSubElement(artifact);
- ZusammenElement enrichedServiceModelElement = buildStructuralElement(name, null);
- enrichedServiceModelElement.addSubElement(artifactsElement);
+ ZusammenElement enrichedServiceModel = buildStructuralElement(elementType, Action.IGNORE);
+ enrichedServiceModel.addSubElement(artifacts);
+
+ ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.IGNORE);
+ vspModel.addSubElement(enrichedServiceModel);
SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(serviceArtifact.getVspId());
- ElementContext elementContext = new ElementContext(itemId, getFirstVersionId(context, itemId));
+ ElementContext elementContext =
+ new ElementContext(serviceArtifact.getVspId(), serviceArtifact.getVersion().getId());
zusammenAdaptor
- .saveElement(context, elementContext, enrichedServiceModelElement, "add service artifact.");
+ .saveElement(context, elementContext, vspModel, "add service external artifact.");
- logger.info("Finished adding artifact to service model for vsp id -> " +
+ logger.info(
+ "Finished adding artifact to enriched service model for VendorSoftwareProduct id -> {}",
elementContext.getItemId().getValue());
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java
index b5e3627..4ae9353 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java
@@ -8,7 +8,6 @@
import com.amdocs.zusammen.datatypes.item.Action;
import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.datatypes.item.Info;
-import com.amdocs.zusammen.datatypes.item.ItemVersion;
import org.apache.commons.io.IOUtils;
import org.openecomp.core.model.dao.ServiceModelDao;
import org.openecomp.core.model.errors.RetrieveServiceTemplateFromDbErrorBuilder;
@@ -17,14 +16,14 @@
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
import org.openecomp.core.zusammen.api.ZusammenUtil;
import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
import org.openecomp.sdc.tosca.services.ToscaExtensionYamlUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.dao.types.VersionStatus;
-import org.openecomp.core.converter.datatypes.Constants;
+import org.openecomp.types.ElementPropertyName;
import java.io.ByteArrayInputStream;
import java.util.Collection;
@@ -33,16 +32,20 @@
import java.util.Optional;
import java.util.stream.Collectors;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+
public class ServiceModelDaoZusammenImpl
implements ServiceModelDao<ToscaServiceModel, ServiceElement> {
+ private static final String BASE_PROPERTY = "base";
private static final Logger logger = LoggerFactory.getLogger(ServiceModelDaoZusammenImpl.class);
protected ZusammenAdaptor zusammenAdaptor;
- protected String name;
+ protected ElementType elementType;
public ServiceModelDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
this.zusammenAdaptor = zusammenAdaptor;
- this.name = StructureElement.ServiceModel.name();
+ this.elementType = ElementType.ServiceModel;
}
@Override
@@ -53,37 +56,128 @@
@Override
public ToscaServiceModel getServiceModel(String vspId, Version version) {
SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId, getFirstVersionId(context, itemId),
- version.getStatus() == VersionStatus.Locked ? null : version.toString());
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
- Optional<ElementInfo> serviceModelElement = zusammenAdaptor
- .getElementInfoByName(context, elementContext, null, name);
-
- if (serviceModelElement.isPresent()) {
- String entryDefinitionServiceTemplate =
- serviceModelElement.get().getInfo().getProperty("base");
- Id serviceModelElementId = serviceModelElement.get().getId();
- Map<String, ServiceTemplate> serviceTemplates =
- getTemplates(context, elementContext, serviceModelElementId);
- if (serviceTemplates == null) {
- return null;
- }
- FileContentHandler artifacts = getArtifacts(context, elementContext, serviceModelElementId);
-
-
- return new ToscaServiceModel(
- artifacts, serviceTemplates, entryDefinitionServiceTemplate);
- } else {
+ Optional<ElementInfo> serviceModel = getServiceModelElementInfo(context, elementContext);
+ if (!serviceModel.isPresent()) {
return null;
}
+
+ Id serviceModelElementId = serviceModel.get().getId();
+ Map<String, ServiceTemplate> serviceTemplates =
+ getTemplates(context, elementContext, serviceModelElementId);
+ if (serviceTemplates == null) {
+ return null;
+ }
+
+ FileContentHandler artifacts = getArtifacts(context, elementContext, serviceModelElementId);
+ String entryDefinitionServiceTemplate =
+ serviceModel.get().getInfo().getProperty(BASE_PROPERTY);
+
+ return new ToscaServiceModel(artifacts, serviceTemplates, entryDefinitionServiceTemplate);
}
- protected Map<String, ServiceTemplate> getTemplates(SessionContext context,
- ElementContext elementContext,
- Id serviceModelElementId) {
+ @Override
+ public void storeServiceModel(String vspId, Version version, ToscaServiceModel serviceModel) {
+ logger.info("Storing service model for VendorSoftwareProduct id -> {}", vspId);
+
+ ZusammenElement templatesElement = buildStructuralElement(ElementType.Templates, Action.UPDATE);
+ serviceModel.getServiceTemplates().entrySet().forEach(entry -> templatesElement.addSubElement(
+ buildServiceTemplateElement(entry.getKey(), entry.getValue(),
+ serviceModel.getEntryDefinitionServiceTemplate(), Action.CREATE)));
+
+ ZusammenElement artifactsElement = buildStructuralElement(ElementType.Artifacts, Action.UPDATE);
+ if (Objects.nonNull(serviceModel.getArtifactFiles())) {
+ serviceModel.getArtifactFiles().getFiles().entrySet()
+ .forEach(entry -> artifactsElement.addSubElement(
+ buildArtifactElement(entry.getKey(), entry.getValue(), Action.CREATE)));
+ }
+
+ ZusammenElement serviceModelElement = buildStructuralElement(elementType, Action.UPDATE);
+ serviceModelElement.getInfo()
+ .addProperty(BASE_PROPERTY, serviceModel.getEntryDefinitionServiceTemplate());
+
+ serviceModelElement.addSubElement(templatesElement);
+ serviceModelElement.addSubElement(artifactsElement);
+
+ ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.IGNORE);
+ vspModel.addSubElement(serviceModelElement);
+
+ SessionContext context = ZusammenUtil.createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+ zusammenAdaptor.saveElement(context, elementContext, vspModel, "Store service model");
+
+ logger
+ .info("Finished storing {} for VendorSoftwareProduct id -> {}", elementType.name(), vspId);
+ }
+
+ @Override
+ public ServiceElement getServiceModelInfo(String vspId, Version version, String name) {
+ return null;
+ }
+
+ @Override
+ public void deleteAll(String vspId, Version version) {
+ logger.info("Started deleting content of Templates and Artifacts of {} of vsp {} version {}",
+ elementType.name(), vspId, version.getId());
+
+ SessionContext context = ZusammenUtil.createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+
+ Optional<ElementInfo> serviceModel = getServiceModelElementInfo(context, elementContext);
+ if (!serviceModel.isPresent()) {
+ logger.info("{} of vsp {} version {} does not exist - nothing to delete", elementType.name(),
+ vspId, version.getId());
+ return;
+ }
+
+ ZusammenElement serviceModelElement = buildElement(serviceModel.get().getId(), Action.IGNORE);
+ for (Id serviceModelSubElementId :
+ serviceModel.get().getSubElements().stream()
+ .map(ElementInfo::getId)
+ .collect(Collectors.toSet())) {
+ ElementInfo serviceModelSubElementInfo =
+ zusammenAdaptor.getElementInfo(context, elementContext, serviceModelSubElementId)
+ .orElseThrow(() -> new IllegalStateException(String.format(
+ "Element %s declared as sub element of element %s (%s) does not exist",
+ serviceModelSubElementId.getValue(),
+ serviceModel.get().getId().getValue(),
+ elementType.name())));
+
+ if (ElementType.Templates.name().equals(serviceModelSubElementInfo.getInfo().getName())
+ || ElementType.Artifacts.name().equals(serviceModelSubElementInfo.getInfo().getName())) {
+ ZusammenElement serviceModelSubElement =
+ buildElement(serviceModelSubElementId, Action.IGNORE);
+ serviceModelSubElement.setSubElements(serviceModelSubElementInfo.getSubElements().stream()
+ .map(elementInfo -> buildElement(elementInfo.getId(), Action.DELETE))
+ .collect(Collectors.toSet()));
+ serviceModelElement.addSubElement(serviceModelSubElement);
+ }
+ }
+
+ zusammenAdaptor.saveElement(context, elementContext, serviceModelElement,
+ String.format("Delete content of Templates and Artifacts of %s", elementType.name()));
+
+ logger.info("Finished deleting content of Templates and Artifacts of {} of vsp {} version {}",
+ elementType.name(), vspId, version.getId());
+ }
+
+ private Optional<ElementInfo> getServiceModelElementInfo(SessionContext context,
+ ElementContext elementContext) {
+ Collection<ElementInfo> vspModelSubs = zusammenAdaptor
+ .listElementsByName(context, elementContext, null, ElementType.VspModel.name());
+
+ return vspModelSubs.stream()
+ .filter(elementInfo -> elementInfo.getInfo() != null
+ && elementType.name().equals(elementInfo.getInfo().getName()))
+ .findFirst();
+ }
+
+ private Map<String, ServiceTemplate> getTemplates(SessionContext context,
+ ElementContext elementContext,
+ Id serviceModelElementId) {
Optional<ElementInfo> templatesElementInfo = zusammenAdaptor.getElementInfoByName(
- context, elementContext, serviceModelElementId, StructureElement.Templates.name());
+ context, elementContext, serviceModelElementId, ElementType.Templates.name());
if (templatesElementInfo.isPresent()) {
Collection<Element> elements = zusammenAdaptor.listElementData(context, elementContext,
@@ -96,10 +190,10 @@
return null;
}
- protected FileContentHandler getArtifacts(SessionContext context, ElementContext elementContext,
- Id serviceModelElementId) {
+ private FileContentHandler getArtifacts(SessionContext context, ElementContext elementContext,
+ Id serviceModelElementId) {
Optional<ElementInfo> artifactsElement = zusammenAdaptor.getElementInfoByName(
- context, elementContext, serviceModelElementId, StructureElement.Artifacts.name());
+ context, elementContext, serviceModelElementId, ElementType.Artifacts.name());
if (artifactsElement.isPresent()) {
@@ -114,70 +208,34 @@
return null;
}
- @Override
- public void storeServiceModel(String vspId, Version version, ToscaServiceModel serviceModel) {
- logger.info("Storing service model for vsp id -> " + vspId);
-
- ZusammenElement templatesElement =
- buildStructuralElement(StructureElement.Templates.name(), null);
- serviceModel.getServiceTemplates().entrySet().forEach(entry -> templatesElement.addSubElement(
- buildServiceTemplateElement(entry.getKey(), entry.getValue(),
- serviceModel.getEntryDefinitionServiceTemplate(), Action.CREATE)));
-
- ZusammenElement artifactsElement =
- buildStructuralElement(StructureElement.Artifacts.name(), Action.UPDATE);
- if (Objects.nonNull(serviceModel.getArtifactFiles())) {
- serviceModel.getArtifactFiles().getFiles().entrySet().forEach(entry -> artifactsElement
- .addSubElement(buildArtifactElement(entry.getKey(), entry.getValue(), Action.CREATE)));
- }
-
- ZusammenElement serviceModelElement = buildStructuralElement(name, Action.UPDATE);
- serviceModelElement.getInfo()
- .addProperty("base", serviceModel.getEntryDefinitionServiceTemplate());
-
- serviceModelElement.addSubElement(templatesElement);
- serviceModelElement.addSubElement(artifactsElement);
-
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId, getFirstVersionId(context, itemId));
- zusammenAdaptor
- .saveElement(context, elementContext, serviceModelElement, "Store service model");
-
- logger.info("Finished storing service model for vsp id -> " + vspId);
- }
-
- @Override
- public ServiceElement getServiceModelInfo(String vspId, Version version, String name) {
- return null;
- }
-
- @Override
- public void deleteAll(String vspId, Version version) {
- logger.info("started deleting service model for vsp id -> " + vspId);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId, getFirstVersionId(context, itemId));
-
- ZusammenElement zusammenElement = ZusammenUtil.buildStructuralElement(name, Action.DELETE);
- zusammenAdaptor.saveElement(context, elementContext, zusammenElement, "delete:" + name + ".");
- logger.info("Finished deleting service model for vsp id -> " + vspId);
+ private Element buildServiceTemplateElement(String name, ServiceTemplate serviceTemplate,
+ String entryDefinitionServiceTemplate,
+ Action action) {
+ ZusammenElement zusammenElement = buildElement(null, action);
+ Info info = new Info();
+ info.setName(name);
+ info.setDescription(serviceTemplate.getDescription());
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.ServiceTemplate.name());
+ info.addProperty(BASE_PROPERTY, entryDefinitionServiceTemplate);
+ String yaml = new ToscaExtensionYamlUtil().objectToYaml(serviceTemplate);
+ zusammenElement.setData(new ByteArrayInputStream(yaml.getBytes()));
+ zusammenElement.setInfo(info);
+ return zusammenElement;
}
protected ZusammenElement buildArtifactElement(String name, byte[] artifact, Action action) {
- ZusammenElement artifactElement = new ZusammenElement();
- artifactElement.setAction(action);
+ ZusammenElement artifactElement = buildElement(null, action);
Info info = new Info();
info.setName(name);
- info.addProperty("type", ElementType.Artifact.name());
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.Artifact.name());
artifactElement.setInfo(info);
artifactElement.setData(new ByteArrayInputStream(artifact));
return artifactElement;
}
- private ServiceTemplate elementToServiceTemplate(Element element){
+ private ServiceTemplate elementToServiceTemplate(Element element) {
try {
String yamlContent = IOUtils.toString(element.getData());
return new ToscaExtensionYamlUtil().
@@ -188,31 +246,4 @@
element.getInfo().getName(), e.getMessage()).build());
}
}
-
- private Element buildServiceTemplateElement(String name, ServiceTemplate serviceTemplate,
- String entryDefinitionServiceTemplate,
- Action action) {
- ZusammenElement zusammenElement = new ZusammenElement();
- zusammenElement.setAction(action);
- Info info = new Info();
- info.setName(name);
- info.setDescription(serviceTemplate.getDescription());
- info.addProperty("type", ElementType.Servicetemplate.name());
- info.addProperty("base", entryDefinitionServiceTemplate);
- String yaml = new ToscaExtensionYamlUtil().objectToYaml(serviceTemplate);
- zusammenElement.setData(new ByteArrayInputStream(yaml.getBytes()));
- zusammenElement.setInfo(info);
- return zusammenElement;
- }
-
- protected Id getFirstVersionId(SessionContext context, Id vspId) {
- Optional<ItemVersion> itemVersionOptional = zusammenAdaptor.getFirstVersion(context, vspId);
- ItemVersion itemVersion = itemVersionOptional.orElseThrow(() ->
- new RuntimeException(String.format("Vsp %s does not contain any version.", vspId))); //todo
- return itemVersion.getId();
- }
-
- protected ZusammenElement buildStructuralElement(String structureElement, Action action) {
- return ZusammenUtil.buildStructuralElement(structureElement, action);
- }
}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/pom.xml b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/pom.xml
new file mode 100644
index 0000000..8e1c293
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/pom.xml
@@ -0,0 +1,20 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <name>openecomp-sdc-notification-api</name>
+ <artifactId>openecomp-sdc-notification-api</artifactId>
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-lib</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <relativePath>../..</relativePath>
+ </parent>
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-nosqldb-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/destinationprovider/DestinationProvider.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/destinationprovider/DestinationProvider.java
new file mode 100644
index 0000000..0c6dfc8
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/destinationprovider/DestinationProvider.java
@@ -0,0 +1,11 @@
+package org.openecomp.sdc.destinationprovider;
+
+import java.util.List;
+
+/**
+ * @author avrahamg
+ * @since July 09, 2017
+ */
+public interface DestinationProvider {
+ List<String> getSubscribers();
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspCreationDto.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/LastNotificationDao.java
similarity index 71%
copy from openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspCreationDto.java
copy to openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/LastNotificationDao.java
index f77005f..f0bf7e8 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspCreationDto.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/LastNotificationDao.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,19 +18,17 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdcrests.vendorsoftwareproducts.types;
+package org.openecomp.sdc.notification.dao;
-/**
- * Created by TALIO on 4/26/2016.
- */
-public class VspCreationDto {
- private String vspId;
+import org.openecomp.core.dao.BaseDao;
+import org.openecomp.sdc.notification.dao.types.LastSeenNotificationEntity;
- public String getVspId() {
- return vspId;
- }
+import java.util.UUID;
- public void setVspId(String vspId) {
- this.vspId = vspId;
- }
+public interface LastNotificationDao extends BaseDao<LastSeenNotificationEntity> {
+
+ UUID getOwnerLastEventId(String ownerId);
+
+ void persistOwnerLastEventId(String ownerId, UUID eventId);
+
}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/NotificationsDao.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/NotificationsDao.java
new file mode 100644
index 0000000..6542d70
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/NotificationsDao.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.notification.dao;
+
+import org.openecomp.core.dao.BaseDao;
+import org.openecomp.sdc.notification.dao.types.NotificationEntity;
+import org.openecomp.sdc.notification.dtos.NotificationsStatus;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+
+
+public interface NotificationsDao extends BaseDao<NotificationEntity> {
+
+ int DEFAULT_LIMIT_OF_RESULTS_FOR_OWNER_NOTIFICATIONS = 1000;
+
+ List<NotificationEntity> getNotificationsByOwnerId(String ownerId, int limit);
+
+ List<NotificationEntity> getNewNotificationsByOwnerId(String ownerId, UUID eventId);
+
+ List<NotificationEntity> getNewNotificationsByOwnerId(String ownerId, UUID eventId, int limit);
+
+ NotificationsStatus getNotificationsStatus(String ownerId, UUID lastSeenNotification, int numOfRecordsToReturn);
+
+ NotificationsStatus getNotificationsStatus(String ownerId, UUID lastSeenNotification, int numOfRecordsToReturn, UUID prevLastNotification);
+
+ void markNotificationAsRead(String ownerId, Collection<UUID> eventIds);
+
+ void createBatch(List<NotificationEntity> notificationEntities);
+}
diff --git a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activityLog/ActivityLogManager.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/SubscribersDao.java
similarity index 70%
copy from openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activityLog/ActivityLogManager.java
copy to openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/SubscribersDao.java
index a40e101..3daf165 100644
--- a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activityLog/ActivityLogManager.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/SubscribersDao.java
@@ -18,14 +18,20 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.activityLog;
+package org.openecomp.sdc.notification.dao;
-import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
-import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.core.dao.BaseDao;
+import org.openecomp.sdc.notification.dao.types.SubscribersEntity;
-import java.util.Collection;
+import java.util.Set;
-public interface ActivityLogManager {
- void addActionLog(ActivityLogEntity activityLogEntity, String user);
- Collection<ActivityLogEntity> listActivityLogs(String itemId, Version versionId, String user);
+
+public interface SubscribersDao extends BaseDao<SubscribersEntity> {
+
+ void subscribe(String ownerId, String entityId);
+
+ void unsubscribe(String ownerId, String entityId);
+
+ Set<String> getSubscribers(String entityId);
+
}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/LastSeenNotificationEntity.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/LastSeenNotificationEntity.java
new file mode 100644
index 0000000..d6e717d
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/LastSeenNotificationEntity.java
@@ -0,0 +1,103 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.notification.dao.types;
+
+import com.datastax.driver.mapping.annotations.Column;
+import com.datastax.driver.mapping.annotations.PartitionKey;
+import com.datastax.driver.mapping.annotations.Table;
+
+import java.util.Objects;
+import java.util.UUID;
+
+@Table(keyspace = "dox", name = "last_notification")
+public class LastSeenNotificationEntity {
+ public static final String ENTITY_TYPE = "Event Notification";
+
+ @PartitionKey
+ @Column(name = "owner_id")
+ private String ownerId;
+
+ @Column(name = "event_id")
+ private UUID lastEventId;
+
+ public LastSeenNotificationEntity() {
+ }
+
+ /**
+ * Instantiates a new Notification entity.
+ *
+ * @param ownerId the owner id
+ * @param lastEventId the last event id
+ */
+ public LastSeenNotificationEntity(String ownerId, UUID lastEventId) {
+ this.ownerId = ownerId;
+ this.lastEventId = lastEventId;
+ }
+
+ public String getOwnerId() {
+ return ownerId;
+ }
+
+ public void setOwnerId(String ownerId) {
+ this.ownerId = ownerId;
+ }
+
+ public UUID getLastEventId() {
+ return lastEventId;
+ }
+
+ public void setLastEventId(UUID lastEventId) {
+ this.lastEventId = lastEventId;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (Objects.equals(this, other)) {
+ return true;
+ }
+
+ if (Objects.equals(getClass(), other.getClass())) {
+ return false;
+ }
+
+ LastSeenNotificationEntity that = (LastSeenNotificationEntity) other;
+
+ if (Objects.equals(ownerId, that.ownerId)) {
+ return false;
+ }
+
+ return !Objects.equals(lastEventId, that.lastEventId);
+ }
+
+ @Override
+ public int hashCode() {
+ int result = ownerId != null ? ownerId.hashCode() : 0;
+ result = 31 * result + (lastEventId != null ? lastEventId.hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "LastSeenNotificationEntity {"
+ + "ownerId='" + ownerId + '\''
+ + '}';
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/NotificationEntity.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/NotificationEntity.java
new file mode 100644
index 0000000..5237707
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/NotificationEntity.java
@@ -0,0 +1,188 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.notification.dao.types;
+
+import com.datastax.driver.mapping.annotations.ClusteringColumn;
+import com.datastax.driver.mapping.annotations.Column;
+import com.datastax.driver.mapping.annotations.PartitionKey;
+import com.datastax.driver.mapping.annotations.Table;
+
+import java.util.Objects;
+import java.util.UUID;
+
+@Table(keyspace = "dox", name = "notifications")
+public class NotificationEntity {
+
+ public static final String ENTITY_TYPE = "Event Notification";
+
+ @PartitionKey
+ @Column(name = "owner_id")
+ private String ownerId;
+
+ @Column(name = "read")
+ private boolean read;
+
+ @ClusteringColumn
+ @Column(name = "event_id")
+ private UUID eventId;
+
+ @Column(name = "event_type")
+ private String eventType;
+
+ @Column(name = "event_attributes")
+ private String eventAttributes;
+
+ @Column(name = "originator_id")
+ private String originatorId;
+
+ public NotificationEntity() {
+ }
+
+ public NotificationEntity(String ownerId) {
+ this.ownerId = ownerId;
+ }
+
+ /**
+ * Instantiates a new Notification entity.
+ *
+ * @param ownerId the owner id
+ * @param eventId the event id
+ * @param eventType the event type
+ * @param originatorId the originator id
+ */
+ public NotificationEntity(String ownerId, UUID eventId, String eventType, String originatorId, boolean read, String eventAttributes) {
+ this.ownerId = ownerId;
+ this.read = read;
+ this.eventId = eventId;
+ this.eventType = eventType;
+ this.originatorId = originatorId;
+ this.eventAttributes = eventAttributes;
+ }
+
+ public NotificationEntity(String ownerId, UUID eventId, String eventType, String originatorId) {
+ this(ownerId, eventId, eventType, originatorId, false, null);
+ }
+
+ public NotificationEntity(String ownerId, UUID eventId) {
+ this(ownerId, eventId, null, null);
+ }
+
+ public String getOwnerId() {
+ return ownerId;
+ }
+
+ public void setOwnerId(String ownerId) {
+ this.ownerId = ownerId;
+ }
+
+ public boolean isRead() {
+ return read;
+ }
+
+ public void setRead(boolean read) {
+ this.read = read;
+ }
+
+ public UUID getEventId() {
+ return eventId;
+ }
+
+ public void setEventId(UUID eventId) {
+ this.eventId = eventId;
+ }
+
+ public String getEventType() {
+ return eventType;
+ }
+
+ public void setEventType(String eventType) {
+ this.eventType = eventType;
+ }
+
+ public String getEventAttributes() {
+ return eventAttributes;
+ }
+
+ public void setEventAttributes(String eventAttributes) {
+ this.eventAttributes = eventAttributes;
+ }
+
+ public String getOriginatorId() {
+ return originatorId;
+ }
+
+ public void setOriginatorId(String originatorId) {
+ this.originatorId = originatorId;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (Objects.equals(this, other)) {
+ return true;
+ }
+
+ if (Objects.equals(getClass(), other.getClass())) {
+ return false;
+ }
+
+ NotificationEntity that = (NotificationEntity) other;
+
+ if (Objects.equals(ownerId, that.ownerId)) {
+ return false;
+ }
+ if (read != that.read) {
+ return false;
+ }
+ if (Objects.equals(eventId, that.eventId)) {
+ return false;
+ }
+ if (Objects.equals(eventType, that.eventType)) {
+ return false;
+ }
+ if (Objects.equals(eventAttributes, that.eventAttributes)) {
+ return false;
+ }
+ if (Objects.equals(originatorId, that.originatorId)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = ownerId != null ? ownerId.hashCode() : 0;
+ result = 31 * result + (eventId != null ? eventId.hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "NotificationEntity {"
+ + "ownerId='" + ownerId + '\''
+ + ", state='" + (read ? "Read" : "Noread") + '\''
+ + ", originatorId='" + originatorId + '\''
+ + ", eventId='" + eventId + '\''
+ + ", eventType='" + eventType + '\''
+ + ", eventAttributes='" + eventAttributes + '\''
+ + '}';
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/SubscribersEntity.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/SubscribersEntity.java
new file mode 100644
index 0000000..d858cbd
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dao/types/SubscribersEntity.java
@@ -0,0 +1,68 @@
+package org.openecomp.sdc.notification.dao.types;
+
+import com.datastax.driver.mapping.annotations.Column;
+import com.datastax.driver.mapping.annotations.PartitionKey;
+import com.datastax.driver.mapping.annotations.Table;
+
+import java.util.Objects;
+import java.util.Set;
+
+import static java.util.Objects.hash;
+
+@Table(keyspace = "dox", name = "notification_subscribers")
+public class SubscribersEntity {
+
+ @PartitionKey
+ @Column(name = "entity_id")
+ private String entityId;
+
+ @Column(name = "subscribers")
+ private Set<String> subscribers;
+
+
+ public SubscribersEntity() {
+ }
+
+ public SubscribersEntity(String entityId, Set<String> subscribers) {
+ this.entityId = entityId;
+ this.subscribers = subscribers;
+ }
+
+ public String getEntityId() {
+ return entityId;
+ }
+
+ public void setEntityId(String entityId) {
+ this.entityId = entityId;
+ }
+
+ public Set<String> getSubscribers() {
+ return subscribers;
+ }
+
+ public void setSubscribers(Set<String> subscribers) {
+ this.subscribers = subscribers;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ SubscribersEntity that = (SubscribersEntity) o;
+ return Objects.equals(entityId, that.entityId) &&
+ Objects.equals(subscribers, that.subscribers);
+ }
+
+ @Override
+ public int hashCode() {
+ return hash(entityId, subscribers);
+ }
+
+ @Override
+ public String toString() {
+ return "SubscribersEntity{" +
+ "entityId='" + entityId + '\'' +
+ ", subscribers=" + subscribers +
+ '}';
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dtos/Event.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dtos/Event.java
new file mode 100644
index 0000000..f7a181e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dtos/Event.java
@@ -0,0 +1,14 @@
+package org.openecomp.sdc.notification.dtos;
+
+import java.util.Map;
+
+public interface Event {
+
+ String getEventType();
+
+ String getOriginatorId();
+
+ Map<String, Object> getAttributes();
+
+ String getEntityId();
+}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dtos/NotificationsStatus.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dtos/NotificationsStatus.java
new file mode 100644
index 0000000..1620569
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/dtos/NotificationsStatus.java
@@ -0,0 +1,24 @@
+package org.openecomp.sdc.notification.dtos;
+
+import org.openecomp.sdc.notification.dao.types.NotificationEntity;
+
+import java.util.List;
+import java.util.UUID;
+
+/**
+ * @author Avrahamg
+ * @since June 26, 2017
+ */
+public interface NotificationsStatus {
+
+ List<NotificationEntity> getNotifications();
+
+ List<UUID> getNewEntries();
+
+ UUID getLastScanned();
+
+ UUID getEndOfPage();
+
+ long getNumOfNotSeenNotifications();
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/exceptons/NotificationNotExistException.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/exceptons/NotificationNotExistException.java
new file mode 100644
index 0000000..90e53ea
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/exceptons/NotificationNotExistException.java
@@ -0,0 +1,18 @@
+package org.openecomp.sdc.notification.exceptons;
+
+/**
+ * @author avrahamg
+ * @since July 02, 2017
+ */
+public class NotificationNotExistException extends Exception {
+ private String message;
+
+
+ public NotificationNotExistException(String Message){
+ this(Message, null);
+ }
+ public NotificationNotExistException(String message, Throwable cause) {
+ super(cause);
+ this.message = message;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductDaoFactory.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/LastNotificationDaoFactory.java
similarity index 75%
rename from openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductDaoFactory.java
rename to openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/LastNotificationDaoFactory.java
index 32070fe..6e6f9f0 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductDaoFactory.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/LastNotificationDaoFactory.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,18 +18,17 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.vendorsoftwareproduct.dao;
+package org.openecomp.sdc.notification.factories;
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
+import org.openecomp.sdc.notification.dao.LastNotificationDao;
-public abstract class VendorSoftwareProductDaoFactory extends
- AbstractComponentFactory<VendorSoftwareProductDao> {
+public abstract class LastNotificationDaoFactory extends AbstractComponentFactory<LastNotificationDao> {
-
- public static VendorSoftwareProductDaoFactory getInstance() {
- return AbstractFactory.getInstance(VendorSoftwareProductDaoFactory.class);
+ public static LastNotificationDaoFactory getInstance() {
+ return AbstractFactory.getInstance(LastNotificationDaoFactory.class);
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/NotificationPropagationManagerFactory.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/NotificationPropagationManagerFactory.java
new file mode 100644
index 0000000..356055e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/NotificationPropagationManagerFactory.java
@@ -0,0 +1,15 @@
+package org.openecomp.sdc.notification.factories;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+import org.openecomp.sdc.notification.services.NotificationPropagationManager;
+
+public abstract class NotificationPropagationManagerFactory extends AbstractComponentFactory<NotificationPropagationManager> {
+
+
+ public static NotificationPropagationManagerFactory getInstance() {
+ return AbstractFactory.getInstance(NotificationPropagationManagerFactory.class);
+ }
+
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDaoFactory.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/NotificationsDaoFactory.java
similarity index 75%
copy from openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDaoFactory.java
copy to openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/NotificationsDaoFactory.java
index 9654551..341af7e 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDaoFactory.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/NotificationsDaoFactory.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,14 +18,17 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.vendorsoftwareproduct.dao;
+package org.openecomp.sdc.notification.factories;
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
+import org.openecomp.sdc.notification.dao.NotificationsDao;
-public abstract class UploadDataDaoFactory extends AbstractComponentFactory<UploadDataDao> {
- public static UploadDataDaoFactory getInstance() {
- return AbstractFactory.getInstance(UploadDataDaoFactory.class);
+public abstract class NotificationsDaoFactory extends AbstractComponentFactory<NotificationsDao> {
+
+ public static NotificationsDaoFactory getInstance() {
+ return AbstractFactory.getInstance(NotificationsDaoFactory.class);
}
+
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDaoFactory.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/NotificationsServiceFactory.java
similarity index 74%
copy from openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDaoFactory.java
copy to openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/NotificationsServiceFactory.java
index 9654551..eab2618 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDaoFactory.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/NotificationsServiceFactory.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,14 +18,17 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.vendorsoftwareproduct.dao;
+package org.openecomp.sdc.notification.factories;
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
+import org.openecomp.sdc.notification.services.NotificationsService;
-public abstract class UploadDataDaoFactory extends AbstractComponentFactory<UploadDataDao> {
- public static UploadDataDaoFactory getInstance() {
- return AbstractFactory.getInstance(UploadDataDaoFactory.class);
+public abstract class NotificationsServiceFactory extends AbstractComponentFactory<NotificationsService> {
+
+ public static NotificationsServiceFactory getInstance() {
+ return AbstractFactory.getInstance(NotificationsServiceFactory.class);
}
+
}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/PropagationServiceFactory.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/PropagationServiceFactory.java
new file mode 100644
index 0000000..e82783c
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/PropagationServiceFactory.java
@@ -0,0 +1,15 @@
+package org.openecomp.sdc.notification.factories;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+import org.openecomp.sdc.notification.services.PropagationService;
+
+public abstract class PropagationServiceFactory extends AbstractComponentFactory<PropagationService> {
+
+
+ public static PropagationServiceFactory getInstance() {
+ return AbstractFactory.getInstance(PropagationServiceFactory.class);
+ }
+
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activityLog/ActivityLogManagerFactory.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/SubscribersDaoFactory.java
similarity index 76%
copy from openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activityLog/ActivityLogManagerFactory.java
copy to openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/SubscribersDaoFactory.java
index 9816b76..33b62e2 100644
--- a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activityLog/ActivityLogManagerFactory.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/SubscribersDaoFactory.java
@@ -17,15 +17,18 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.activityLog;
+
+package org.openecomp.sdc.notification.factories;
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
-import org.openecomp.sdc.activityLog.ActivityLogManager;
+import org.openecomp.sdc.notification.dao.SubscribersDao;
-public abstract class ActivityLogManagerFactory extends AbstractComponentFactory<ActivityLogManager> {
- public static ActivityLogManagerFactory getInstance() {
- return AbstractFactory.getInstance(ActivityLogManagerFactory.class);
+public abstract class SubscribersDaoFactory extends AbstractComponentFactory<SubscribersDao> {
+
+ public static SubscribersDaoFactory getInstance() {
+ return AbstractFactory.getInstance(SubscribersDaoFactory.class);
}
+
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductDaoFactory.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/SubscriptionServiceFactory.java
similarity index 74%
copy from openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductDaoFactory.java
copy to openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/SubscriptionServiceFactory.java
index 32070fe..3e789c2 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductDaoFactory.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/factories/SubscriptionServiceFactory.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,18 +18,17 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.vendorsoftwareproduct.dao;
+package org.openecomp.sdc.notification.factories;
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
+import org.openecomp.sdc.notification.services.SubscriptionService;
-public abstract class VendorSoftwareProductDaoFactory extends
- AbstractComponentFactory<VendorSoftwareProductDao> {
+public abstract class SubscriptionServiceFactory extends AbstractComponentFactory<SubscriptionService> {
-
- public static VendorSoftwareProductDaoFactory getInstance() {
- return AbstractFactory.getInstance(VendorSoftwareProductDaoFactory.class);
- }
+ public static SubscriptionServiceFactory getInstance() {
+ return AbstractFactory.getInstance(SubscriptionServiceFactory.class);
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/NotificationPropagationManager.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/NotificationPropagationManager.java
new file mode 100644
index 0000000..7a1596e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/NotificationPropagationManager.java
@@ -0,0 +1,12 @@
+package org.openecomp.sdc.notification.services;
+
+import org.openecomp.sdc.notification.dtos.Event;
+
+/**
+ * @author avrahamg
+ * @since July 09, 2017
+ */
+public interface NotificationPropagationManager {
+ void notifySubscribers(Event event, String ... excludedSubscribers);
+ void directNotification(Event event, String destinationId);
+}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/NotificationsService.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/NotificationsService.java
new file mode 100644
index 0000000..17cfac1
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/NotificationsService.java
@@ -0,0 +1,31 @@
+package org.openecomp.sdc.notification.services;
+
+import org.openecomp.sdc.notification.dao.types.LastSeenNotificationEntity;
+import org.openecomp.sdc.notification.dao.types.NotificationEntity;
+import org.openecomp.sdc.notification.dtos.NotificationsStatus;
+import org.openecomp.sdc.notification.exceptons.NotificationNotExistException;
+
+import java.util.List;
+import java.util.UUID;
+
+/**
+ * @author Avrahamg
+ * @since June 22, 2017
+ */
+public interface NotificationsService {
+
+ LastSeenNotificationEntity getLastNotification(String ownerId);
+
+ NotificationsStatus getNotificationsStatus(String ownerId, UUID lastDelivered, int numOfRecordsToReturn, UUID endOfPage);
+
+ void updateLastSeenNotification(String ownerId, UUID eventId);
+
+ void markAsRead(String ownerId, String notificationId) throws NotificationNotExistException;
+
+ List<NotificationEntity> getNotificationsByOwnerId(String ownerId, int limit);
+
+ List<NotificationEntity> getNewNotificationsByOwnerId(String ownerId, UUID eventId);
+
+ List<NotificationEntity> getNewNotificationsByOwnerId(String ownerId, UUID eventId, int limit);
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/PropagationService.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/PropagationService.java
new file mode 100644
index 0000000..c084aa8
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/PropagationService.java
@@ -0,0 +1,9 @@
+package org.openecomp.sdc.notification.services;
+
+import org.openecomp.sdc.destinationprovider.DestinationProvider;
+import org.openecomp.sdc.notification.dtos.Event;
+
+public interface PropagationService {
+
+ void notify(Event event, DestinationProvider destinationProvider);
+}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/SubscriptionService.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/SubscriptionService.java
new file mode 100644
index 0000000..98cd458
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-api/src/main/java/org/openecomp/sdc/notification/services/SubscriptionService.java
@@ -0,0 +1,15 @@
+package org.openecomp.sdc.notification.services;
+
+import java.util.Set;
+
+/**
+ * @author avrahamg
+ * @since July 09, 2017
+ */
+public interface SubscriptionService {
+ void subscribe(String ownerId, String entityId);
+
+ void unsubscribe(String ownerId, String entityId);
+
+ Set<String> getSubscribers(String entityId);
+}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/pom.xml b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/pom.xml
new file mode 100644
index 0000000..4fe33ea
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/pom.xml
@@ -0,0 +1,42 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <name>openecomp-sdc-notification-core</name>
+ <artifactId>openecomp-sdc-notification-core</artifactId>
+
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-lib</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <relativePath>../..</relativePath>
+ </parent>
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-notification-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <scope>test</scope>
+ <version>1.10.19</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ <version>${junit.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ <version>1.6.5</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/destinationprovider/impl/MulticastDestination.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/destinationprovider/impl/MulticastDestination.java
new file mode 100644
index 0000000..431f9c1
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/destinationprovider/impl/MulticastDestination.java
@@ -0,0 +1,44 @@
+package org.openecomp.sdc.destinationprovider.impl;
+
+import org.apache.commons.lang3.ArrayUtils;
+import org.openecomp.sdc.destinationprovider.DestinationProvider;
+import org.openecomp.sdc.notification.services.SubscriptionService;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author avrahamg
+ * @since July 09, 2017
+ */
+public class MulticastDestination implements DestinationProvider {
+
+ private String entityId;
+ private SubscriptionService subscriptionService;
+ private String[] excludedSubscribers;
+
+ public MulticastDestination(String entityId, SubscriptionService subscriptionService,
+ String... excludedSubscribers) {
+ this.entityId = entityId;
+ this.excludedSubscribers = excludedSubscribers;
+ this.subscriptionService = subscriptionService;
+ }
+
+ public List<String> getSubscribers() {
+ ArrayList<String> subscribers = new ArrayList<>(subscriptionService.getSubscribers(entityId));
+ if (ArrayUtils.isNotEmpty(excludedSubscribers)) {
+ subscribers.removeAll(Arrays.asList(excludedSubscribers));
+ }
+ return Collections.unmodifiableList(subscribers);
+ }
+
+ public String getEntityId() {
+ return entityId;
+ }
+
+ public void setEntityId(String entityId) {
+ this.entityId = entityId;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/destinationprovider/impl/UnicastDestination.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/destinationprovider/impl/UnicastDestination.java
new file mode 100644
index 0000000..693c816
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/destinationprovider/impl/UnicastDestination.java
@@ -0,0 +1,23 @@
+package org.openecomp.sdc.destinationprovider.impl;
+
+import org.openecomp.sdc.destinationprovider.DestinationProvider;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author avrahamg
+ * @since July 09, 2017
+ */
+public class UnicastDestination implements DestinationProvider {
+
+ private String originatorId;
+
+ public UnicastDestination(String originatorId) {
+ this.originatorId = originatorId;
+ }
+
+ public List<String> getSubscribers() {
+ return Collections.unmodifiableList(Collections.singletonList(originatorId));
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/dao/impl/LastNotificationDaoCassandraImpl.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/dao/impl/LastNotificationDaoCassandraImpl.java
new file mode 100644
index 0000000..0bfd6a3
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/dao/impl/LastNotificationDaoCassandraImpl.java
@@ -0,0 +1,87 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.notification.dao.impl;
+
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+import com.datastax.driver.mapping.Mapper;
+import com.datastax.driver.mapping.Result;
+import com.datastax.driver.mapping.annotations.Accessor;
+import com.datastax.driver.mapping.annotations.Query;
+import org.openecomp.core.dao.impl.CassandraBaseDao;
+import org.openecomp.core.nosqldb.api.NoSqlDb;
+import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
+import org.openecomp.sdc.notification.dao.LastNotificationDao;
+import org.openecomp.sdc.notification.dao.types.LastSeenNotificationEntity;
+
+import java.util.Collection;
+import java.util.UUID;
+
+
+public class LastNotificationDaoCassandraImpl extends CassandraBaseDao<LastSeenNotificationEntity> implements LastNotificationDao {
+
+ private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
+ private static final Mapper<LastSeenNotificationEntity> mapper =
+ noSqlDb.getMappingManager().mapper(LastSeenNotificationEntity.class);
+ private static final LastNotificationAccessor accessor =
+ noSqlDb.getMappingManager().createAccessor(LastNotificationAccessor.class);
+
+ @Override
+ protected Mapper<LastSeenNotificationEntity> getMapper() {
+ return mapper;
+ }
+
+ @Override
+ protected Object[] getKeys(LastSeenNotificationEntity entity) {
+ return new Object[]{entity.getOwnerId()};
+ }
+
+ @Override
+ public Collection<LastSeenNotificationEntity> list(LastSeenNotificationEntity entity) {
+ return accessor.list(entity.getOwnerId()).all();
+ }
+
+ @Override
+ public UUID getOwnerLastEventId(String ownerId) {
+ ResultSet ownerLastEventId = accessor.getOwnerLastEventId(ownerId);
+ Row one = ownerLastEventId.one();
+ return one != null ? one.getUUID("event_id") : null;
+ }
+
+ @Override
+ public void persistOwnerLastEventId(String ownerId, UUID eventId) {
+ accessor.updateOwnerLastEventId(eventId, ownerId);
+ }
+
+ @Accessor
+ interface LastNotificationAccessor {
+
+ @Query("select * from last_notification where owner_id=?")
+ Result<LastSeenNotificationEntity> list(String ownerId);
+
+ @Query("select event_id from last_notification where owner_id=?")
+ ResultSet getOwnerLastEventId(String ownerId);
+
+ @Query("update last_notification set event_id=? where owner_id=?")
+ ResultSet updateOwnerLastEventId(UUID eventId, String ownerId);
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/dao/impl/NotificationsDaoCassandraImpl.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/dao/impl/NotificationsDaoCassandraImpl.java
new file mode 100644
index 0000000..151c2c8
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/dao/impl/NotificationsDaoCassandraImpl.java
@@ -0,0 +1,287 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.notification.dao.impl;
+
+import com.datastax.driver.core.BatchStatement;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Statement;
+import com.datastax.driver.core.utils.UUIDs;
+import com.datastax.driver.mapping.Mapper;
+import com.datastax.driver.mapping.Result;
+import com.datastax.driver.mapping.annotations.Accessor;
+import com.datastax.driver.mapping.annotations.Query;
+import org.apache.commons.collections.CollectionUtils;
+import org.openecomp.core.dao.impl.CassandraBaseDao;
+import org.openecomp.core.nosqldb.api.NoSqlDb;
+import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
+import org.openecomp.sdc.notification.dao.NotificationsDao;
+import org.openecomp.sdc.notification.dao.types.NotificationEntity;
+import org.openecomp.sdc.notification.dtos.NotificationsStatus;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.UUID;
+import java.util.stream.Collectors;
+
+import static org.openecomp.core.nosqldb.impl.cassandra.CassandraSessionFactory.getSession;
+
+//import org.openecomp.sdc.notification.dao.types.LastSeenNotificationEntity;
+//import java.util.Optional;
+
+public class NotificationsDaoCassandraImpl extends CassandraBaseDao<NotificationEntity>
+ implements NotificationsDao {
+
+ private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
+ private static final Mapper<NotificationEntity> mapper =
+ noSqlDb.getMappingManager().mapper(NotificationEntity.class);
+ private static final NotificationsAccessor accessor =
+ noSqlDb.getMappingManager().createAccessor(NotificationsAccessor.class);
+
+ @Override
+ protected Mapper<NotificationEntity> getMapper() {
+ return mapper;
+ }
+
+ @Override
+ protected Object[] getKeys(NotificationEntity entity) {
+ return new Object[]{entity.getOwnerId(), entity.getEventId()};
+ }
+
+ @Override
+ public List<NotificationEntity> list(NotificationEntity entity) {
+ return accessor.list(entity.getOwnerId()).all();
+ }
+
+ @Override
+ public List<NotificationEntity> getNotificationsByOwnerId(String ownerId, int limit) {
+ return accessor.getNotifications(ownerId, limit).all();
+ }
+
+ @Override
+ public List<NotificationEntity> getNewNotificationsByOwnerId(String ownerId, UUID eventId) {
+ return getNewNotificationsByOwnerId(ownerId, eventId,
+ DEFAULT_LIMIT_OF_RESULTS_FOR_OWNER_NOTIFICATIONS);
+ }
+
+ @Override
+ public List<NotificationEntity> getNewNotificationsByOwnerId(String ownerId, UUID eventId, int limit) {
+ if (Objects.isNull(eventId)) {
+ return getNotificationsByOwnerId(ownerId, limit);
+ }
+ return accessor.getNewNotifications(ownerId, eventId, limit).all();
+ }
+
+ @Override
+ public void markNotificationAsRead(String ownerId, Collection<UUID> eventIds) {
+ eventIds.forEach(eventId -> accessor.markAsRead(ownerId, eventId));
+ }
+
+ @Override
+ public NotificationsStatus getNotificationsStatus(String ownerId, UUID lastScannedEventId, int numOfRecordsToReturn) {
+ NotificationsStatusImpl notificationsStatus = new NotificationsStatusImpl();
+ List<NotificationEntity> entities = accessor.getNotifications(ownerId, numOfRecordsToReturn).all();
+ if (CollectionUtils.isNotEmpty(entities)) {
+ long lastSeen = UUIDs.unixTimestamp(lastScannedEventId);
+ populateNewNotifications(notificationsStatus, entities, lastSeen);
+ UUID firstScannedEventId = entities.get(0).getEventId();
+ notificationsStatus.setLastScanned(firstScannedEventId);
+ notificationsStatus.setNumOfNotSeenNotifications(accessor.getNewNotificationsCount(ownerId, lastScannedEventId, firstScannedEventId).one().getLong(0));
+ }
+ return notificationsStatus;
+ }
+
+ private void populateNewNotifications(NotificationsStatusImpl notificationsStatus, List<NotificationEntity> entities, long lastSeen) {
+ for (NotificationEntity entity : entities) {
+ UUID eventId = entity.getEventId();
+ notificationsStatus.addNotification(entity);
+ if (UUIDs.unixTimestamp(eventId) > lastSeen) {
+ notificationsStatus.addNewNotificationUUID(eventId);
+ }
+ }
+ }
+
+ @Override
+ public NotificationsStatus getNotificationsStatus(String ownerId, UUID lastSeenNotification, int numOfRecordsToReturn, UUID prevLastScannedEventId) {
+ NotificationsStatusImpl notificationsStatus = new NotificationsStatusImpl();
+ List<NotificationEntity> entities = accessor.getPrevNotifications(ownerId, prevLastScannedEventId, numOfRecordsToReturn).all();
+ if (CollectionUtils.isNotEmpty(entities)) {
+ long lastSeen = UUIDs.unixTimestamp(lastSeenNotification);
+ populateNewNotifications(notificationsStatus, entities, lastSeen);
+ }
+ return notificationsStatus;
+ }
+
+/*
+ @Override
+ public NotificationsStatus getNotificationsStatus(String ownerId,
+ LastSeenNotificationEntity lastSeenNotification,
+ int numOfRecordsToReturn) {
+
+ List<NotificationEntity> notificationEntities =
+ fetchNewNotifications(lastSeenNotification, numOfRecordsToReturn);
+ NotificationsStatusImpl notificationsStatus = new NotificationsStatusImpl();
+ if (CollectionUtils.isEmpty(notificationEntities)) {
+ return notificationsStatus;
+ }
+
+ notificationEntities.forEach(notification -> {
+ if (isNewNotification(lastSeenNotification, notification)) {
+ notificationsStatus.addNewNotificationUUID(notification.getEventId());
+ }
+ notificationsStatus.addNotification(notification);
+ });
+
+ Optional<NotificationEntity> latestNotification = notificationEntities.stream().findFirst();
+ latestNotification.ifPresent(e -> notificationsStatus.setLastScanned(e.getEventId()));
+ return notificationsStatus;
+ }
+
+ private List<NotificationEntity> fetchNewNotifications(
+ LastSeenNotificationEntity lastSeenNotification, int numOfRecordsToReturn) {
+ String ownerId = lastSeenNotification.getOwnerId();
+ UUID lastEventId = lastSeenNotification.getLastEventId();
+ List<NotificationEntity> newNotificationsByOwnerId =
+ getNewNotificationsByOwnerId(ownerId, lastEventId);
+ newNotificationsByOwnerId = fetchMoreIfNeeded(ownerId, newNotificationsByOwnerId,
+ numOfRecordsToReturn, lastEventId);
+ return newNotificationsByOwnerId;
+ }
+
+ private boolean isNewNotification(LastSeenNotificationEntity lastSeenNotification,
+ NotificationEntity notification) {
+ return Objects.isNull(lastSeenNotification.getLastEventId()) ||
+ UUIDs.unixTimestamp(notification.getEventId()) >
+ UUIDs.unixTimestamp(lastSeenNotification.getLastEventId());
+ }
+*/
+
+ @Override
+ public void createBatch(List<NotificationEntity> notificationEntities) {
+ BatchStatement batch = new BatchStatement();
+ List<Statement> statements = notificationEntities.stream()
+ .map(mapper::saveQuery)
+ .collect(Collectors.toList());
+ batch.addAll(statements);
+ getSession().execute(batch);
+ }
+
+ @Accessor
+ interface NotificationsAccessor {
+
+ @Query("select * from notifications where owner_id=?")
+ Result<NotificationEntity> list(String ownerId);
+
+ @Query("select * from notifications where owner_id=? limit ?")
+ Result<NotificationEntity> getNotifications(String ownerId, int limit);
+
+ @Query("select * from notifications where owner_id=? and event_id > ? limit ?")
+ Result<NotificationEntity> getNewNotifications(String ownerId, UUID lastScannedEventId, int limit);
+
+ @Query("select * from notifications where owner_id=? and event_id < ? limit ?")
+ Result<NotificationEntity> getPrevNotifications(String ownerId, UUID prevLastScannedEventId, int limit);
+
+ @Query("select count(*) from notifications where owner_id=? and event_id > ? and event_id <= ?")
+ ResultSet getNewNotificationsCount(String ownerId, UUID lastScannedEventId, UUID firstScannedEventId);
+
+ @Query("update notifications set read=true where owner_id=? and event_id=?")
+ ResultSet markAsRead(String ownerId, UUID eventId);
+ }
+
+ private class NotificationsStatusImpl implements NotificationsStatus {
+
+ private List<NotificationEntity> notifications = new ArrayList<>();
+ private List<UUID> newEntries = new ArrayList<>();
+ private UUID lastScanned;
+ private UUID endOfPage;
+ private long numOfNotSeenNotifications = 0;
+
+ void addNotification(NotificationEntity notification) {
+ notifications.add(notification);
+ endOfPage = notification.getEventId();
+ }
+
+ void addNewNotificationUUID(UUID notificationUuid) {
+ newEntries.add(notificationUuid);
+ }
+
+ @Override
+ public List<NotificationEntity> getNotifications() {
+ return Collections.unmodifiableList(notifications);
+ }
+
+ @Override
+ public List<UUID> getNewEntries() {
+ return Collections.unmodifiableList(newEntries);
+ }
+
+ @Override
+ public UUID getLastScanned() {
+ return lastScanned;
+ }
+
+ void setLastScanned(UUID lastScanned) {
+ this.lastScanned = lastScanned;
+ }
+
+ @Override
+ public UUID getEndOfPage() {
+ return endOfPage;
+ }
+
+ @Override
+ public long getNumOfNotSeenNotifications() {
+ return numOfNotSeenNotifications;
+ }
+
+ void setNumOfNotSeenNotifications(long numOfNotSeenNotifications) {
+ this.numOfNotSeenNotifications = numOfNotSeenNotifications;
+ }
+ }
+
+/*
+ private List<NotificationEntity> fetchMoreIfNeeded(String ownerId,
+ List<NotificationEntity> notificationEntities,
+ int numOfRecordsToReturn, UUID lastEventId) {
+
+ if (numOfRecordsToReturn <= notificationEntities.size() || Objects.isNull(lastEventId)) {
+ return notificationEntities;
+ }
+
+ int multiplier = 2;
+ while (numOfRecordsToReturn > notificationEntities.size()) {
+
+ int bring = notificationEntities.size() +
+ (numOfRecordsToReturn - notificationEntities.size()) * multiplier;
+ notificationEntities = getNotificationsByOwnerId(ownerId, bring);
+
+ if (notificationEntities.size() < bring) {
+ return notificationEntities;
+ }
+ multiplier++;
+ }
+ return notificationEntities;
+ }
+*/
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/dao/impl/SubscribersDaoCassandraImpl.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/dao/impl/SubscribersDaoCassandraImpl.java
new file mode 100644
index 0000000..8e8cf9b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/dao/impl/SubscribersDaoCassandraImpl.java
@@ -0,0 +1,104 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.notification.dao.impl;
+
+import com.datastax.driver.mapping.Mapper;
+import com.datastax.driver.mapping.Result;
+import com.datastax.driver.mapping.annotations.Accessor;
+import com.datastax.driver.mapping.annotations.Query;
+import com.google.common.collect.Sets;
+import org.openecomp.core.dao.impl.CassandraBaseDao;
+import org.openecomp.core.nosqldb.api.NoSqlDb;
+import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
+import org.openecomp.sdc.notification.dao.SubscribersDao;
+import org.openecomp.sdc.notification.dao.types.SubscribersEntity;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Objects;
+import java.util.Set;
+
+import static java.util.Objects.isNull;
+
+public class SubscribersDaoCassandraImpl extends CassandraBaseDao<SubscribersEntity> implements
+ SubscribersDao {
+
+ private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
+ private static final Mapper<SubscribersEntity> mapper =
+ noSqlDb.getMappingManager().mapper(SubscribersEntity.class);
+ private static final SubscribersAccessor accessor =
+ noSqlDb.getMappingManager().createAccessor(SubscribersAccessor.class);
+
+
+ @Override
+ protected Object[] getKeys(SubscribersEntity entity) {
+ return new Object[]{entity.getEntityId()};
+ }
+
+ @Override
+ protected Mapper<SubscribersEntity> getMapper() {
+ return mapper;
+ }
+
+ @Override
+ public void subscribe(String ownerId, String entityId) {
+ Objects.requireNonNull(ownerId);
+ Objects.requireNonNull(entityId);
+ accessor.subscribe(Sets.newHashSet(ownerId), entityId);
+ }
+
+ @Override
+ @Deprecated
+ public Collection<SubscribersEntity> list(SubscribersEntity entity) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void unsubscribe(String ownerId, String entityId) {
+ Objects.requireNonNull(ownerId);
+ Objects.requireNonNull(entityId);
+ accessor.unsubscribe(Sets.newHashSet(ownerId), entityId);
+ }
+
+ @Override
+ public Set<String> getSubscribers(String entityId) {
+ Objects.requireNonNull(entityId);
+ SubscribersEntity subscribersEntity = accessor.getSubscribers(entityId).one();
+ if (isNull(subscribersEntity)) {
+ return Collections.emptySet();
+ }
+ return subscribersEntity.getSubscribers();
+ }
+
+ @Accessor
+ interface SubscribersAccessor {
+
+ @Query("select * from notification_subscribers where entity_id=?")
+ Result<SubscribersEntity> getSubscribers(String entityId);
+
+ @Query("update notification_subscribers set subscribers=subscribers+? WHERE entity_id=?")
+ void subscribe(Set<String> ownerId, String entityId);
+
+ @Query("update notification_subscribers set subscribers=subscribers-? WHERE entity_id=?")
+ void unsubscribe(Set<String> ownerId, String entityId);
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/LastNotificationDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/LastNotificationDaoFactoryImpl.java
new file mode 100644
index 0000000..7ac9e00
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/LastNotificationDaoFactoryImpl.java
@@ -0,0 +1,19 @@
+package org.openecomp.sdc.notification.factories.impl;
+
+import org.openecomp.sdc.notification.dao.LastNotificationDao;
+import org.openecomp.sdc.notification.dao.impl.LastNotificationDaoCassandraImpl;
+import org.openecomp.sdc.notification.factories.LastNotificationDaoFactory;
+
+/**
+ * @author itzikpa
+ * @since June 23, 2017
+ */
+
+public class LastNotificationDaoFactoryImpl extends LastNotificationDaoFactory {
+ private static final LastNotificationDao INSTANCE = new LastNotificationDaoCassandraImpl();
+
+ @Override
+ public LastNotificationDao createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/NotificationPropagationManagerFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/NotificationPropagationManagerFactoryImpl.java
new file mode 100644
index 0000000..7b9e51e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/NotificationPropagationManagerFactoryImpl.java
@@ -0,0 +1,19 @@
+package org.openecomp.sdc.notification.factories.impl;
+
+import org.openecomp.sdc.notification.factories.NotificationPropagationManagerFactory;
+import org.openecomp.sdc.notification.factories.PropagationServiceFactory;
+import org.openecomp.sdc.notification.factories.SubscriptionServiceFactory;
+import org.openecomp.sdc.notification.services.NotificationPropagationManager;
+import org.openecomp.sdc.notification.services.impl.NotificationPropagationManagerImpl;
+
+public class NotificationPropagationManagerFactoryImpl extends
+ NotificationPropagationManagerFactory {
+ private static final NotificationPropagationManager INSTANCE = new NotificationPropagationManagerImpl(
+ PropagationServiceFactory.getInstance().createInterface(), SubscriptionServiceFactory
+ .getInstance().createInterface());
+
+ @Override
+ public NotificationPropagationManager createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/NotificationsDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/NotificationsDaoFactoryImpl.java
new file mode 100644
index 0000000..edb0206
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/NotificationsDaoFactoryImpl.java
@@ -0,0 +1,18 @@
+package org.openecomp.sdc.notification.factories.impl;
+
+import org.openecomp.sdc.notification.dao.NotificationsDao;
+import org.openecomp.sdc.notification.dao.impl.NotificationsDaoCassandraImpl;
+import org.openecomp.sdc.notification.factories.NotificationsDaoFactory;
+
+/**
+ * @author Avrahamg
+ * @since June 20, 2017
+ */
+public class NotificationsDaoFactoryImpl extends NotificationsDaoFactory {
+ private static final NotificationsDao INSTANCE = new NotificationsDaoCassandraImpl();
+
+ @Override
+ public NotificationsDao createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/NotificationsServiceFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/NotificationsServiceFactoryImpl.java
new file mode 100644
index 0000000..ac265e3
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/NotificationsServiceFactoryImpl.java
@@ -0,0 +1,22 @@
+package org.openecomp.sdc.notification.factories.impl;
+
+import org.openecomp.sdc.notification.factories.LastNotificationDaoFactory;
+import org.openecomp.sdc.notification.factories.NotificationsDaoFactory;
+import org.openecomp.sdc.notification.factories.NotificationsServiceFactory;
+import org.openecomp.sdc.notification.services.NotificationsService;
+import org.openecomp.sdc.notification.services.impl.NotificationsServiceImpl;
+
+/**
+ * @author Avrahamg
+ * @since June 20, 2017
+ */
+public class NotificationsServiceFactoryImpl extends NotificationsServiceFactory {
+ private static final NotificationsService INSTANCE = new NotificationsServiceImpl(
+ LastNotificationDaoFactory.getInstance().createInterface(), NotificationsDaoFactory
+ .getInstance().createInterface());
+
+ @Override
+ public NotificationsService createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/PropagationServiceFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/PropagationServiceFactoryImpl.java
new file mode 100644
index 0000000..e5987fe
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/PropagationServiceFactoryImpl.java
@@ -0,0 +1,16 @@
+package org.openecomp.sdc.notification.factories.impl;
+
+import org.openecomp.sdc.notification.factories.NotificationsDaoFactory;
+import org.openecomp.sdc.notification.factories.PropagationServiceFactory;
+import org.openecomp.sdc.notification.services.PropagationService;
+import org.openecomp.sdc.notification.services.impl.PropagationServiceImpl;
+
+public class PropagationServiceFactoryImpl extends PropagationServiceFactory {
+ private static final PropagationService INSTANCE = new PropagationServiceImpl(
+ NotificationsDaoFactory.getInstance().createInterface());
+
+ @Override
+ public PropagationService createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/SubscribersDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/SubscribersDaoFactoryImpl.java
new file mode 100644
index 0000000..fb87b94
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/SubscribersDaoFactoryImpl.java
@@ -0,0 +1,15 @@
+package org.openecomp.sdc.notification.factories.impl;
+
+import org.openecomp.sdc.notification.dao.SubscribersDao;
+import org.openecomp.sdc.notification.dao.impl.SubscribersDaoCassandraImpl;
+import org.openecomp.sdc.notification.factories.SubscribersDaoFactory;
+
+
+public class SubscribersDaoFactoryImpl extends SubscribersDaoFactory {
+ private static final SubscribersDao INSTANCE = new SubscribersDaoCassandraImpl();
+
+ @Override
+ public SubscribersDao createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/SubscriptionServiceFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/SubscriptionServiceFactoryImpl.java
new file mode 100644
index 0000000..604cff0
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/factories/impl/SubscriptionServiceFactoryImpl.java
@@ -0,0 +1,17 @@
+package org.openecomp.sdc.notification.factories.impl;
+
+import org.openecomp.sdc.notification.factories.SubscribersDaoFactory;
+import org.openecomp.sdc.notification.factories.SubscriptionServiceFactory;
+import org.openecomp.sdc.notification.services.SubscriptionService;
+import org.openecomp.sdc.notification.services.impl.SubscriptionServiceImpl;
+
+
+public class SubscriptionServiceFactoryImpl extends SubscriptionServiceFactory {
+ private static final SubscriptionService INSTANCE = new SubscriptionServiceImpl
+ (SubscribersDaoFactory.getInstance().createInterface());
+
+ @Override
+ public SubscriptionService createInterface() {
+ return INSTANCE;
+ }
+}
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/NotificationPropagationManagerImpl.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/NotificationPropagationManagerImpl.java
new file mode 100644
index 0000000..d381268
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/NotificationPropagationManagerImpl.java
@@ -0,0 +1,35 @@
+package org.openecomp.sdc.notification.services.impl;
+
+import org.openecomp.sdc.destinationprovider.impl.MulticastDestination;
+import org.openecomp.sdc.destinationprovider.impl.UnicastDestination;
+import org.openecomp.sdc.notification.dtos.Event;
+import org.openecomp.sdc.notification.services.NotificationPropagationManager;
+import org.openecomp.sdc.notification.services.PropagationService;
+import org.openecomp.sdc.notification.services.SubscriptionService;
+
+/**
+ * @author avrahamg
+ * @since July 10, 2017
+ */
+public class NotificationPropagationManagerImpl implements NotificationPropagationManager {
+
+ private PropagationService propagationService;
+ private SubscriptionService subscriptionService;
+
+ public NotificationPropagationManagerImpl(PropagationService propagationService,
+ SubscriptionService subscriptionService) {
+ this.propagationService = propagationService;
+ this.subscriptionService = subscriptionService;
+ }
+
+ @Override
+ public void notifySubscribers(Event event, String ... excludedSubscribers) {
+ propagationService.notify(event, new MulticastDestination(event.getEntityId(),
+ subscriptionService, excludedSubscribers));
+ }
+
+ @Override
+ public void directNotification(Event event, String destinationId) {
+ propagationService.notify(event, new UnicastDestination(destinationId));
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/NotificationsServiceImpl.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/NotificationsServiceImpl.java
new file mode 100644
index 0000000..8a7ab8b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/NotificationsServiceImpl.java
@@ -0,0 +1,92 @@
+package org.openecomp.sdc.notification.services.impl;
+
+import org.openecomp.sdc.notification.dao.LastNotificationDao;
+import org.openecomp.sdc.notification.dao.NotificationsDao;
+import org.openecomp.sdc.notification.dao.types.LastSeenNotificationEntity;
+import org.openecomp.sdc.notification.dao.types.NotificationEntity;
+import org.openecomp.sdc.notification.dtos.NotificationsStatus;
+import org.openecomp.sdc.notification.exceptons.NotificationNotExistException;
+import org.openecomp.sdc.notification.services.NotificationsService;
+
+import java.util.List;
+import java.util.Objects;
+import java.util.UUID;
+
+/**
+ * @author Avrahamg
+ * @since June 26, 2017
+ */
+public class NotificationsServiceImpl implements NotificationsService {
+
+ private LastNotificationDao lastNotificationDao;
+ private NotificationsDao notificationsDao;
+
+ public NotificationsServiceImpl(LastNotificationDao lastNotificationDao,
+ NotificationsDao notificationsDao) {
+ this.lastNotificationDao = lastNotificationDao;
+ this.notificationsDao = notificationsDao;
+ }
+
+ @Override
+ public LastSeenNotificationEntity getLastNotification(String ownerId) {
+ return new LastSeenNotificationEntity(ownerId,
+ lastNotificationDao.getOwnerLastEventId(ownerId));
+ }
+
+ @Override
+ public void updateLastSeenNotification(String ownerId, UUID eventId)
+ {
+ lastNotificationDao.persistOwnerLastEventId(ownerId, eventId);
+ }
+
+ @Override
+ public NotificationsStatus getNotificationsStatus(String ownerId, UUID lastDelivered, int numOfRecordsToReturn, UUID endOfPage) {
+ if (Objects.isNull(lastDelivered)) {
+ LastSeenNotificationEntity entity = getLastNotification(ownerId);
+ if (Objects.nonNull(entity)) {
+ lastDelivered = entity.getLastEventId();
+ }
+ if (Objects.isNull(lastDelivered)) {
+ lastDelivered = UUID.fromString("00000000-0000-1000-8080-808080808080"); // Lowest time UUID value
+ }
+ }
+ if (Objects.isNull(endOfPage)) {
+ // First page
+ return notificationsDao.getNotificationsStatus(ownerId, lastDelivered, numOfRecordsToReturn);
+ }
+ else {
+ // Next page
+ return notificationsDao.getNotificationsStatus(ownerId, lastDelivered, numOfRecordsToReturn, endOfPage);
+ }
+ }
+
+ @Override
+ public void markAsRead(String ownerId, String notificationId) throws
+ NotificationNotExistException {
+ NotificationEntity notificationEntity =
+ notificationsDao.get(new NotificationEntity(ownerId, UUID.fromString(notificationId)));
+ if (Objects.isNull(notificationEntity)) {
+ throw new NotificationNotExistException(
+ "Notification '" + notificationId + "' is not related to ownerId" +
+ " '" + ownerId + "'");
+ }
+ notificationEntity.setRead(true);
+ notificationsDao.update(notificationEntity);
+ }
+
+ @Override
+ public List<NotificationEntity> getNotificationsByOwnerId(String ownerId, int limit) {
+ return notificationsDao.getNotificationsByOwnerId(ownerId, limit);
+ }
+
+ @Override
+ public List<NotificationEntity> getNewNotificationsByOwnerId(String ownerId, UUID eventId) {
+ return notificationsDao.getNewNotificationsByOwnerId(ownerId, eventId);
+ }
+
+ @Override
+ public List<NotificationEntity> getNewNotificationsByOwnerId(String ownerId, UUID eventId, int limit) {
+ return notificationsDao.getNewNotificationsByOwnerId(ownerId, eventId, limit);
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/PropagationServiceImpl.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/PropagationServiceImpl.java
new file mode 100644
index 0000000..99d35b3
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/PropagationServiceImpl.java
@@ -0,0 +1,78 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.notification.services.impl;
+
+import com.datastax.driver.core.utils.UUIDs;
+import org.apache.commons.collections4.CollectionUtils;
+import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.sdc.destinationprovider.DestinationProvider;
+import org.openecomp.sdc.notification.dao.NotificationsDao;
+import org.openecomp.sdc.notification.dao.types.NotificationEntity;
+import org.openecomp.sdc.notification.dtos.Event;
+import org.openecomp.sdc.notification.services.PropagationService;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.stream.Collectors;
+
+import static java.util.Objects.requireNonNull;
+
+public class PropagationServiceImpl implements PropagationService {
+
+ private NotificationsDao notificationsDao;
+
+ public PropagationServiceImpl(NotificationsDao notificationsDao) {
+ this.notificationsDao = notificationsDao;
+ }
+
+
+ @Override
+ public void notify(Event event, DestinationProvider destinationProvider) {
+ requireNonNull(event.getEventType());
+ requireNonNull(event.getOriginatorId());
+ List<String> subscribers = destinationProvider.getSubscribers();
+ if (CollectionUtils.isEmpty(subscribers)) {
+ return;
+ }
+ List<NotificationEntity> notificationEntities = subscribers.stream().map(
+ subscriber -> {
+ UUID eventId = UUIDs.timeBased();
+ return createNotificationEntity(event.getEventType(), subscriber,
+ event.getOriginatorId(), event.getAttributes(), eventId);
+ }).collect(Collectors.toList());
+ if(CollectionUtils.isNotEmpty(notificationEntities)) {
+ notificationsDao.createBatch(notificationEntities);
+ }
+ }
+
+ private NotificationEntity createNotificationEntity(String eventType, String subscriber,
+ String originatorId,
+ Map<String, Object> attributes,
+ UUID eventId) {
+ NotificationEntity notificationEntity =
+ new NotificationEntity(subscriber, eventId, eventType, originatorId);
+ if (attributes != null && !attributes.isEmpty()) {
+ notificationEntity.setEventAttributes(JsonUtil.object2Json(attributes));
+ }
+ return notificationEntity;
+ }
+}
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/SubscriptionServiceImpl.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/SubscriptionServiceImpl.java
new file mode 100644
index 0000000..2a12463
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/java/org/openecomp/sdc/notification/services/impl/SubscriptionServiceImpl.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.notification.services.impl;
+
+import org.openecomp.sdc.notification.dao.SubscribersDao;
+import org.openecomp.sdc.notification.services.SubscriptionService;
+
+import java.util.Set;
+
+public class SubscriptionServiceImpl implements SubscriptionService {
+
+ private SubscribersDao subscribersDao;
+
+ public SubscriptionServiceImpl(SubscribersDao subscribersDao) {
+ this.subscribersDao = subscribersDao;
+ }
+
+ @Override
+ public void subscribe(String ownerId, String entityId) {
+ subscribersDao.subscribe(ownerId, entityId);
+ }
+
+ @Override
+ public void unsubscribe(String ownerId, String entityId) {
+ subscribersDao.unsubscribe(ownerId, entityId);
+ }
+
+ @Override
+ public Set<String> getSubscribers(String entityId) {
+ return subscribersDao.getSubscribers(entityId);
+ }
+}
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/resources/factoryConfiguration.json b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/resources/factoryConfiguration.json
new file mode 100644
index 0000000..3f1bdf3
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/main/resources/factoryConfiguration.json
@@ -0,0 +1,9 @@
+{
+ "org.openecomp.sdc.notification.factories.LastNotificationDaoFactory": "org.openecomp.sdc.notification.factories.impl.LastNotificationDaoFactoryImpl",
+ "org.openecomp.sdc.notification.factories.NotificationsDaoFactory": "org.openecomp.sdc.notification.factories.impl.NotificationsDaoFactoryImpl",
+ "org.openecomp.sdc.notification.factories.NotificationsServiceFactory": "org.openecomp.sdc.notification.factories.impl.NotificationsServiceFactoryImpl",
+ "org.openecomp.sdc.notification.factories.SubscribersDaoFactory": "org.openecomp.sdc.notification.factories.impl.SubscribersDaoFactoryImpl",
+ "org.openecomp.sdc.notification.factories.PropagationServiceFactory": "org.openecomp.sdc.notification.factories.impl.PropagationServiceFactoryImpl",
+ "org.openecomp.sdc.notification.factories.SubscriptionServiceFactory": "org.openecomp.sdc.notification.factories.impl.SubscriptionServiceFactoryImpl",
+ "org.openecomp.sdc.notification.factories.NotificationPropagationManagerFactory": "org.openecomp.sdc.notification.factories.impl.NotificationPropagationManagerFactoryImpl"
+}
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/test/java/org/openecomp/sdc/destinationprovider/impl/MulticastDestinationTest.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/test/java/org/openecomp/sdc/destinationprovider/impl/MulticastDestinationTest.java
new file mode 100644
index 0000000..a0dd006
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/test/java/org/openecomp/sdc/destinationprovider/impl/MulticastDestinationTest.java
@@ -0,0 +1,67 @@
+package org.openecomp.sdc.destinationprovider.impl;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.notification.services.SubscriptionService;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doReturn;
+
+/**
+ * @author avrahamg
+ * @since July 13, 2017
+ */
+public class MulticastDestinationTest {
+ @Mock
+ private SubscriptionService subscriptionServiceMock;
+
+ private final String excludedSubscriber = "excluded";
+ private Set<String> subscribers = new HashSet<>(Arrays.asList("a", "b", excludedSubscriber));
+ private MulticastDestination multicastDestination;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void shouldReturnAllSubscribersIfNoExcludedProvided() throws Exception {
+ doReturn(subscribers).when(subscriptionServiceMock).getSubscribers(any());
+ multicastDestination = new MulticastDestination("aa", subscriptionServiceMock);
+ assertEquals(subscribers.size(), multicastDestination.getSubscribers().size());
+ List<String> actualSubscribers = multicastDestination.getSubscribers();
+ assertTrue(actualSubscribers.containsAll(subscribers));
+ }
+
+ @Test
+ public void shouldReturnAllSubscribersExceptExcluded() throws Exception {
+ doReturn(subscribers).when(subscriptionServiceMock).getSubscribers(any());
+ multicastDestination =
+ new MulticastDestination("aa", subscriptionServiceMock, excludedSubscriber);
+ List<String> actualSubscribers = multicastDestination.getSubscribers();
+ assertNotEquals(this.subscribers.size(), actualSubscribers.size());
+ assertFalse(actualSubscribers.containsAll(subscribers));
+ assertFalse(actualSubscribers.contains(excludedSubscriber));
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void shouldThrowUnsupportedOperationExceptionWhenTryingToChangeSubscribersList() throws
+ Exception {
+ doReturn(subscribers).when(subscriptionServiceMock).getSubscribers(any());
+ multicastDestination =
+ new MulticastDestination("aa", subscriptionServiceMock, excludedSubscriber);
+ List<String> actualSubscribers = multicastDestination.getSubscribers();
+ actualSubscribers.add("sss");
+ }
+}
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/test/java/org/openecomp/sdc/notification/services/impl/NotificationPropagationManagerImplTest.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/test/java/org/openecomp/sdc/notification/services/impl/NotificationPropagationManagerImplTest.java
new file mode 100644
index 0000000..0eb2b62
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/test/java/org/openecomp/sdc/notification/services/impl/NotificationPropagationManagerImplTest.java
@@ -0,0 +1,64 @@
+package org.openecomp.sdc.notification.services.impl;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.InjectMocks;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.mockito.Spy;
+import org.openecomp.sdc.destinationprovider.DestinationProvider;
+import org.openecomp.sdc.destinationprovider.impl.MulticastDestination;
+import org.openecomp.sdc.destinationprovider.impl.UnicastDestination;
+import org.openecomp.sdc.notification.dtos.Event;
+import org.openecomp.sdc.notification.services.PropagationService;
+import org.openecomp.sdc.notification.services.SubscriptionService;
+
+import static org.mockito.Mockito.verify;
+
+
+/**
+ * @author avrahamg
+ * @since July 13, 2017
+ */
+public class NotificationPropagationManagerImplTest {
+ @Mock
+ private PropagationService propagationServiceMock;
+ @Mock
+ private SubscriptionService subscriptionServiceMock;
+ @Mock
+ private Event eventMock;
+ @Captor
+ private ArgumentCaptor<DestinationProvider> destinationProviderCaptor;
+
+ @Spy
+ @InjectMocks
+ private NotificationPropagationManagerImpl notificationPropagationManager;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void shouldCallPropagationServiceNotifyWithMulticastDestinationWhenNotifySubscribers()
+ throws Exception {
+ notificationPropagationManager.notifySubscribers(eventMock);
+ verify(propagationServiceMock).notify(Matchers.eq(eventMock), destinationProviderCaptor
+ .capture());
+ Assert.assertTrue(destinationProviderCaptor.getValue() instanceof MulticastDestination);
+
+ }
+
+ @Test
+ public void shouldCallPropagationServiceNotifyWithUnicastDestinationWhenDirectNotification()
+ throws Exception {
+ notificationPropagationManager.directNotification(eventMock, "aaa");
+ verify(propagationServiceMock).notify(Matchers.eq(eventMock), destinationProviderCaptor
+ .capture());
+ Assert.assertTrue(destinationProviderCaptor.getValue() instanceof UnicastDestination);
+ }
+}
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/test/java/org/openecomp/sdc/notification/services/impl/NotificationsServiceImplTest.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/test/java/org/openecomp/sdc/notification/services/impl/NotificationsServiceImplTest.java
new file mode 100644
index 0000000..a20d0cc
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/test/java/org/openecomp/sdc/notification/services/impl/NotificationsServiceImplTest.java
@@ -0,0 +1,50 @@
+package org.openecomp.sdc.notification.services.impl;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.mockito.Spy;
+import org.openecomp.sdc.notification.dao.LastNotificationDao;
+import org.openecomp.sdc.notification.dao.NotificationsDao;
+import org.openecomp.sdc.notification.dao.types.NotificationEntity;
+import org.openecomp.sdc.notification.exceptons.NotificationNotExistException;
+
+import java.util.UUID;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+/**
+ * @author avrahamg
+ * @since July 13, 2017
+ */
+public class NotificationsServiceImplTest {
+ @Mock
+ private LastNotificationDao lastNotificationDao;
+ @Mock
+ private NotificationsDao notificationsDao;
+ @Spy
+ @InjectMocks
+ private NotificationsServiceImpl notificationsService;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ public void shouldCallNotificationsDaoIfNotificationEntityExist() throws Exception {
+ doReturn(new NotificationEntity()).when(notificationsDao).get(any());
+ notificationsService.markAsRead("ownerId", UUID.randomUUID().toString());
+ verify(notificationsDao, times(1)).update(any());
+ }
+
+ @Test(expected = NotificationNotExistException.class)
+ public void shouldThrowExceptionIfOwnerIdAndNotificationIdDontRelate() throws Exception {
+ doReturn(null).when(notificationsDao).get(any());
+ notificationsService.markAsRead("ownerId", UUID.randomUUID().toString());
+ }
+}
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/test/java/org/openecomp/sdc/notification/services/impl/PropagationServiceImplTest.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/test/java/org/openecomp/sdc/notification/services/impl/PropagationServiceImplTest.java
new file mode 100644
index 0000000..866dec0
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/src/test/java/org/openecomp/sdc/notification/services/impl/PropagationServiceImplTest.java
@@ -0,0 +1,96 @@
+package org.openecomp.sdc.notification.services.impl;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.mockito.Spy;
+import org.openecomp.sdc.destinationprovider.DestinationProvider;
+import org.openecomp.sdc.notification.dao.NotificationsDao;
+import org.openecomp.sdc.notification.dtos.Event;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+
+import static org.mockito.Matchers.anyList;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+
+/**
+ * @author avrahamg
+ * @since July 13, 2017
+ */
+public class PropagationServiceImplTest {
+ @Mock
+ private NotificationsDao notificationsDaoMock;
+ @Mock
+ private Event eventMock;
+ @Mock
+ private DestinationProvider destinationProviderMock;
+ @Captor
+ private ArgumentCaptor<List> createBatchCaptor;
+
+ @Rule
+ public ExpectedException thrown= ExpectedException.none();
+
+ @InjectMocks
+ @Spy
+ private PropagationServiceImpl propagationService;
+ private List<String> subscribersList = Arrays.asList("A1, A2, A3");;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ initEventMock();
+ }
+
+ @Test
+ public void shouldCallToNotificationsDaoWithCreateBatchWithNotificationEntitiesAsNumberOfSubscribers()
+ throws Exception {
+ doReturn(subscribersList).when(destinationProviderMock).getSubscribers();
+ propagationService.notify(eventMock, destinationProviderMock);
+ verify(notificationsDaoMock).createBatch(createBatchCaptor.capture());
+ Assert.assertEquals(createBatchCaptor.getValue().size(), subscribersList.size());
+ }
+
+ @Test
+ public void shouldNotCallNotificationDaoIfSubscriberIsNull() throws Exception {
+ doReturn(Collections.EMPTY_LIST).when(destinationProviderMock).getSubscribers();
+ verify(notificationsDaoMock,never()).createBatch(anyList());
+ }
+
+ @Test
+ public void shouldThrowExceptionIfEventTypeIsNull() throws Exception {
+ doReturn(null).when(eventMock).getEventType();
+ callToNotify();
+ }
+
+ @Test
+ public void shouldThrowExceptionIfOriginatorIdIsNull() throws Exception {
+ doReturn(null).when(eventMock).getOriginatorId();
+ callToNotify();
+ }
+
+ private void callToNotify() {
+ thrown.expect(NullPointerException.class);
+ propagationService.notify(eventMock, destinationProviderMock);
+ }
+
+ private void initEventMock() {
+ doReturn("eventType").when(eventMock).getEventType();
+ doReturn("originator").when(eventMock).getOriginatorId();
+ doReturn("entity").when(eventMock).getEntityId();
+ doReturn(new HashMap<>()).when(eventMock).getAttributes();
+ }
+
+
+}
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-websocket/pom.xml b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-websocket/pom.xml
new file mode 100644
index 0000000..abff87f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-websocket/pom.xml
@@ -0,0 +1,34 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <name>openecomp-sdc-notification-websocket</name>
+ <artifactId>openecomp-sdc-notification-websocket</artifactId>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-lib</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <relativePath>../..</relativePath>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-notification-worker</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-websocket</artifactId>
+ <version>4.3.4.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.3.1</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-websocket/src/main/java/org/openecomp/sdc/notification/websocket/NotificationWebsocketHandler.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-websocket/src/main/java/org/openecomp/sdc/notification/websocket/NotificationWebsocketHandler.java
new file mode 100644
index 0000000..1e42463
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-websocket/src/main/java/org/openecomp/sdc/notification/websocket/NotificationWebsocketHandler.java
@@ -0,0 +1,130 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.notification.websocket;
+
+import com.google.gson.Gson;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+import org.openecomp.sdc.notification.types.NotificationsStatusDto;
+import org.openecomp.sdc.notification.workers.NotificationWorker;
+import org.springframework.http.HttpHeaders;
+import org.springframework.web.socket.CloseStatus;
+import org.springframework.web.socket.TextMessage;
+import org.springframework.web.socket.WebSocketSession;
+import org.springframework.web.socket.handler.TextWebSocketHandler;
+
+import java.io.IOException;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.function.Consumer;
+
+public class NotificationWebsocketHandler extends TextWebSocketHandler {
+
+ private static final String USER_ID_HEADER_PARAM = "USER_ID";
+ private static final String LAST_DELIVERED_QUERY_PARAM = "LAST_DELIVERED_EVENT_ID";
+ private static final String COOKIE = "Cookie";
+ private static Logger LOGGER = LoggerFactory.getLogger(NotificationWebsocketHandler.class);
+ private NotificationWorker worker;
+
+ public NotificationWebsocketHandler(NotificationWorker worker) {
+ super();
+ this.worker = Objects.requireNonNull(worker, "NotificationWorker object is not initialized.");
+ }
+
+ @Override
+ public void afterConnectionEstablished(WebSocketSession session) throws Exception {
+ super.afterConnectionEstablished(session);
+
+ String ownerId = getOwnerId(session);
+ if (ownerId == null) {
+ return;
+ }
+ UUID lastDelivered = getLastEventId(session);
+
+ Consumer<NotificationsStatusDto> notesProcessor = (notes) -> notifyReceiver(session, notes);
+
+ worker.register(ownerId, lastDelivered, notesProcessor);
+ }
+
+ @Override
+ public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception {
+ String ownerId = getOwnerId(session);
+ if (ownerId != null) {
+ worker.unregister(ownerId);
+ }
+ super.afterConnectionClosed(session, status);
+ }
+
+ private void notifyReceiver(WebSocketSession session, NotificationsStatusDto notificationsStatusDto) {
+
+ try {
+ session.sendMessage(new TextMessage(new Gson().toJson(notificationsStatusDto)));
+ } catch (IOException e) {
+ LOGGER.error("IO Exception during Receiver notification.", e);
+ }
+ }
+
+ private String getOwnerId(WebSocketSession session) {
+
+ HttpHeaders handshakeHeaders = session.getHandshakeHeaders();
+ if (handshakeHeaders.containsKey(COOKIE)) {
+ String[] cookies = handshakeHeaders.get(COOKIE).get(0).split("; ");
+ Optional<String> cookie = extractValue(cookies, USER_ID_HEADER_PARAM);
+ if (cookie.isPresent()) {
+ return cookie.get();
+ }
+ }
+
+ LOGGER.error("No " + USER_ID_HEADER_PARAM + " specified in the session cookies.");
+ return null;
+ }
+
+ private UUID getLastEventId(WebSocketSession session) {
+
+ String uriQuery = session.getUri().getQuery();
+ if (uriQuery != null) {
+
+ String[] queries = uriQuery.split("; ");
+ Optional<String> paramValue = extractValue(queries, LAST_DELIVERED_QUERY_PARAM);
+ if (paramValue.isPresent()) {
+ return UUID.fromString(paramValue.get());
+ }
+ }
+
+ LOGGER.warn("No " + LAST_DELIVERED_QUERY_PARAM + " specified in the request URI.");
+ return null;
+ }
+
+ private Optional<String> extractValue(String[] pairs, String name) {
+
+ for (String nameValuePair : pairs) {
+
+ String[] value = nameValuePair.split("=");
+ if (value[0].equals(name)) {
+ return Optional.of(value[1]);
+ }
+ }
+
+ return Optional.empty();
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/pom.xml b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/pom.xml
new file mode 100644
index 0000000..fb55d28
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/pom.xml
@@ -0,0 +1,73 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <name>openecomp-sdc-notification-worker</name>
+ <artifactId>openecomp-sdc-notification-worker</artifactId>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-lib</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <relativePath>../..</relativePath>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-utilities-lib</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-jaxrs</artifactId>
+ <version>${org.codehaus.jackson.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-core-asl</artifactId>
+ <version>${org.codehaus.jackson.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-websocket</artifactId>
+ <version>4.3.4.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>com.googlecode.json-simple</groupId>
+ <artifactId>json-simple</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.4.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore</artifactId>
+ <version>4.4.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.datastax.cassandra</groupId>
+ <artifactId>cassandra-driver-core</artifactId>
+ <version>2.0.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ <version>${junit.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/config/ConfigurationManager.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/config/ConfigurationManager.java
new file mode 100644
index 0000000..d960b8b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/config/ConfigurationManager.java
@@ -0,0 +1,113 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.notification.config;
+
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+import org.openecomp.sdc.tosca.services.YamlUtil;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.function.BiConsumer;
+
+public class ConfigurationManager {
+
+ private static final String CONFIGURATION_YAML_FILE = "onboarding_configuration.yaml";
+ private static final String NOTIFICATIONS_CONFIG = "notifications";
+
+ private LinkedHashMap<String, Object> notificationsConfiguration;
+ private static final Logger LOGGER = LoggerFactory.getLogger(ConfigurationManager.class);
+ private static final ConfigurationManager SINGLETON = new ConfigurationManager();
+
+ public static ConfigurationManager getInstance() {
+ return SINGLETON;
+ }
+
+ private ConfigurationManager() {
+ initConfiguration();
+ }
+
+ private void initConfiguration() {
+
+ YamlUtil yamlUtil = new YamlUtil();
+ readConfigurationFromStream(yamlUtil, (filename, stream) -> {
+
+ if (stream == null) {
+ LOGGER.warn("Configuration not found: " + filename + ". Using defaults");
+ return;
+ }
+
+ Map<String, LinkedHashMap<String, Object>> configurationMap = yamlUtil.yamlToMap(stream);
+ if (configurationMap == null) {
+ LOGGER.warn("Configuration cannot be parsed: " + filename + ". Using defaults");
+ return;
+ }
+
+ notificationsConfiguration = configurationMap.get(NOTIFICATIONS_CONFIG);
+ if (notificationsConfiguration == null) {
+ LOGGER.error(NOTIFICATIONS_CONFIG +
+ " is missing in configuration file '" + filename + "'. Using defaults");
+ }
+ });
+ }
+
+ private void readConfigurationFromStream(YamlUtil yamlUtil,
+ BiConsumer<String, InputStream> reader) {
+
+ String configurationYamlFile = System.getProperty(CONFIGURATION_YAML_FILE);
+
+ try {
+
+ if (configurationYamlFile == null) {
+
+ try (InputStream inputStream =
+ yamlUtil.loadYamlFileIs("/" + CONFIGURATION_YAML_FILE)) {
+ reader.accept(CONFIGURATION_YAML_FILE, inputStream);
+ }
+
+ } else {
+
+ try (InputStream inputStream = new FileInputStream(configurationYamlFile)) {
+ reader.accept(configurationYamlFile, inputStream);
+ }
+ }
+
+ } catch (IOException e) {
+ LOGGER.error("Failed to read configuration", e);
+ }
+ }
+
+ public <T> T getConfigValue(String name, T defaultValue) {
+
+ Object value = notificationsConfiguration.get(name);
+
+ try {
+ return value == null ? defaultValue : (T) value;
+ } catch (ClassCastException e) {
+ LOGGER.warn(String.format("Failed to read configuration property '%s' as requested type. Using default '%s'",
+ name, defaultValue), e);
+ return defaultValue;
+ }
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/types/NotificationEntityDto.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/types/NotificationEntityDto.java
new file mode 100644
index 0000000..a415d9e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/types/NotificationEntityDto.java
@@ -0,0 +1,103 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.notification.types;
+
+import java.util.Map;
+import java.util.UUID;
+
+public class NotificationEntityDto {
+ private boolean read;
+ private UUID eventId;
+ private String dateTime;
+ private String eventType;
+ private Map<String, Object> eventAttributes;
+
+ public NotificationEntityDto() {
+ }
+ public NotificationEntityDto(boolean read, UUID eventId, String eventType,
+ Map<String, Object> eventAttributes) {
+ this.read = read;
+ this.eventId = eventId;
+ this.eventType = eventType;
+ this.eventAttributes = eventAttributes;
+ }
+
+ public NotificationEntityDto(boolean read, UUID eventId,String eventType,
+ Map<String, Object> eventAttributes, String dateTime) {
+ this.read = read;
+ this.eventId = eventId;
+ this.dateTime = dateTime;
+ this.eventType = eventType;
+ this.eventAttributes = eventAttributes;
+ }
+
+ public boolean isRead() {
+ return read;
+ }
+
+ public void setRead(boolean read) {
+ this.read = read;
+ }
+
+ public UUID getEventId() {
+ return eventId;
+ }
+
+ public void setEventId(UUID eventId) {
+ this.eventId = eventId;
+ }
+
+ public String getEventType() {
+ return eventType;
+ }
+
+ public void setEventType(String eventType) {
+ this.eventType = eventType;
+ }
+
+ public Map<String, Object> getEventAttributes() {
+ return eventAttributes;
+ }
+
+ public void setEventAttributes(Map<String, Object> eventAttributes) {
+ this.eventAttributes = eventAttributes;
+ }
+
+ public String getDateTime() {
+ return dateTime;
+ }
+
+ public void setDateTime(String dateTime) {
+ this.dateTime = dateTime;
+ }
+
+ @Override
+ public String toString() {
+ return "NotificationEntityDto {"
+ + ", state='" + (read ? "Read" : "Noread") + '\''
+ + ", dateTime='" + dateTime + '\''
+ + ", eventId='" + eventId + '\''
+ + ", eventType='" + eventType + '\''
+ + ", eventAttributes='" + eventAttributes + '\''
+ + '}';
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/types/NotificationsStatusDto.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/types/NotificationsStatusDto.java
new file mode 100644
index 0000000..fd8d320
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/types/NotificationsStatusDto.java
@@ -0,0 +1,72 @@
+package org.openecomp.sdc.notification.types;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+/**
+ * @author avrahamg
+ * @since June 29, 2017
+ */
+public class NotificationsStatusDto {
+ private List<NotificationEntityDto> notifications;
+ private List<UUID> newEntries = new ArrayList<>();
+ private UUID lastScanned;
+ private UUID endOfPage;
+ private long numOfNotSeenNotifications;
+
+ public NotificationsStatusDto() {
+ }
+
+ public List<NotificationEntityDto> getNotifications() {
+ return notifications;
+ }
+
+ public void setNotifications(
+ List<NotificationEntityDto> notifications) {
+ this.notifications = notifications;
+ }
+
+ public List<UUID> getNewEntries() {
+ return newEntries;
+ }
+
+ public void setNewEntries(List<UUID> newEntries) {
+ this.newEntries = newEntries;
+ }
+
+ public UUID getLastScanned() {
+ return lastScanned;
+ }
+
+ public void setLastScanned(UUID lastScanned) {
+ this.lastScanned = lastScanned;
+ }
+
+ public UUID getEndOfPage() {
+ return endOfPage;
+ }
+
+ public void setEndOfPage(UUID endOfPage) {
+ this.endOfPage = endOfPage;
+ }
+
+ public long getNumOfNotSeenNotifications() {
+ return numOfNotSeenNotifications;
+ }
+
+ public void setNumOfNotSeenNotifications(long numOfNotSeenNotifications) {
+ this.numOfNotSeenNotifications = numOfNotSeenNotifications;
+ }
+
+ @Override
+ public String toString() {
+ return "NotificationsStatusDto{" +
+ "notifications=" + notifications +
+ ", newEntries=" + newEntries +
+ ", lastScanned=" + lastScanned +
+ ", endOfPage=" + endOfPage +
+ ", numOfNotSeenNotifications=" + numOfNotSeenNotifications +
+ '}';
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspCreationDto.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/NewNotificationsReader.java
similarity index 76%
rename from openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspCreationDto.java
rename to openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/NewNotificationsReader.java
index f77005f..75b9f5c 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspCreationDto.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/NewNotificationsReader.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,19 +18,12 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdcrests.vendorsoftwareproducts.types;
+package org.openecomp.sdc.notification.workers;
-/**
- * Created by TALIO on 4/26/2016.
- */
-public class VspCreationDto {
- private String vspId;
+import org.openecomp.sdc.notification.types.NotificationsStatusDto;
- public String getVspId() {
- return vspId;
- }
+import java.util.UUID;
- public void setVspId(String vspId) {
- this.vspId = vspId;
- }
+public interface NewNotificationsReader {
+ NotificationsStatusDto getNewNotifications(String ownerId, UUID eventId, int limit);
}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/NotificationReceiver.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/NotificationReceiver.java
new file mode 100644
index 0000000..ee80264
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/NotificationReceiver.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.notification.workers;
+
+import org.openecomp.sdc.notification.types.NotificationsStatusDto;
+
+import java.util.UUID;
+import java.util.function.Consumer;
+
+
+
+public class NotificationReceiver {
+
+ public String ownerId = null;
+ public Consumer<NotificationsStatusDto> notesProcessor = null;
+ public UUID lastEventId = null;
+
+ NotificationReceiver(String ownerId, UUID lastEventId, Consumer<NotificationsStatusDto> notesProcessor) {
+ this.ownerId = ownerId;
+ this.lastEventId = lastEventId;
+ this.notesProcessor = notesProcessor;
+ }
+
+ NotificationReceiver(String ownerId, Consumer<NotificationsStatusDto> notesProcessor) {
+ this(ownerId, null, notesProcessor);
+ }
+
+ public void setOwnerId(String ownerId) {
+ this.ownerId = ownerId;
+ }
+
+ public String getOwnerId() {
+ return this.ownerId;
+ }
+
+ public void setNotesProcessor(Consumer<NotificationsStatusDto> notesProcessor) {
+ this.notesProcessor = notesProcessor;
+ }
+
+ public Consumer<NotificationsStatusDto> getNotesProcessor() {
+ return this.notesProcessor;
+ }
+
+ public void setLastEventId(UUID lastEventId) {
+ this.lastEventId = lastEventId;
+ }
+
+ public UUID getlastEventId() {
+ return this.lastEventId;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/NotificationWorker.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/NotificationWorker.java
new file mode 100644
index 0000000..e8c2006
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/NotificationWorker.java
@@ -0,0 +1,117 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.notification.workers;
+
+import org.apache.commons.collections4.CollectionUtils;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+import org.openecomp.sdc.notification.config.ConfigurationManager;
+import org.openecomp.sdc.notification.types.NotificationsStatusDto;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.Consumer;
+
+public class NotificationWorker {
+
+ private static final int DEFAULT_POLLING_INTERVAL = 2000;
+ private static final String POLLING_INTERVAL = "pollingIntervalMsec";
+ private static final int DEFAULT_SELECTION_LIMIT = 10;
+ private static final String SELECTION_SIZE = "selectionSize";
+
+ private static boolean stopRunning = false;
+
+ private int selectionLimit = DEFAULT_SELECTION_LIMIT;
+ private int pollingSleepInterval = DEFAULT_POLLING_INTERVAL;
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(NotificationWorker.class);
+
+ private static Map<String, NotificationReceiver> activeUsers = new ConcurrentHashMap<>();
+ private NewNotificationsReader news = null;
+
+ public NotificationWorker(NewNotificationsReader news) {
+ ConfigurationManager cm = ConfigurationManager.getInstance();
+ pollingSleepInterval = cm.getConfigValue(POLLING_INTERVAL, DEFAULT_POLLING_INTERVAL);
+ selectionLimit = cm.getConfigValue(SELECTION_SIZE, DEFAULT_SELECTION_LIMIT);
+
+ Objects.requireNonNull(news, "NotificationNews object is not initialized.");
+ this.news = news;
+
+ NotificationWorker.Poller p = new Poller();
+ Thread thread = new Thread(p);
+ thread.start();
+ }
+
+ public Map<String, NotificationReceiver> getActiveUsers() {
+ return activeUsers;
+ }
+
+ public class Poller extends Thread {
+ public void run() {
+ try {
+ while (!stopRunning) {
+ pollNotifications();
+ Thread.sleep(pollingSleepInterval);
+ }
+ }
+ catch (InterruptedException e) {
+ LOGGER.error("Interrupted Exception during Notification poller launch.", e);
+ }
+ }
+
+ private void pollNotifications() {
+
+ Map<String, NotificationReceiver> currUsers = new HashMap<>();
+ currUsers.putAll(getActiveUsers());
+
+ for (NotificationReceiver receiver : currUsers.values()) {
+ String ownerId = receiver.getOwnerId();
+ UUID eventId = receiver.getlastEventId();
+ NotificationsStatusDto status = news.getNewNotifications(ownerId, eventId, selectionLimit);
+ if(Objects.nonNull(status) && CollectionUtils.isNotEmpty(status.getNotifications())) {
+ receiver.setLastEventId(status.getLastScanned());
+ receiver.getNotesProcessor().accept(status);
+ }
+ }
+ }
+
+ }
+
+ public void register(String ownerId, UUID lastDelivered, Consumer<NotificationsStatusDto> notesProcessor) {
+ NotificationReceiver receiver = new NotificationReceiver(ownerId, lastDelivered, notesProcessor);
+ activeUsers.put(ownerId, receiver);
+ LOGGER.debug("User {} is registered with eventId: {}", ownerId, receiver.getlastEventId());
+ }
+
+ public void unregister(String ownerId) {
+ activeUsers.remove(ownerId);
+ LOGGER.debug("User {} is unregistered.", ownerId);
+ }
+
+ public void stopPolling() {
+ LOGGER.debug("Stop notification polling.");
+ stopRunning = true;
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/impl/NewNotificationsReaderRestImpl.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/impl/NewNotificationsReaderRestImpl.java
new file mode 100644
index 0000000..a332efa
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/impl/NewNotificationsReaderRestImpl.java
@@ -0,0 +1,84 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.notification.workers.impl;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+import org.openecomp.sdc.notification.config.ConfigurationManager;
+import org.openecomp.sdc.notification.types.NotificationsStatusDto;
+import org.openecomp.sdc.notification.workers.NewNotificationsReader;
+
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import java.io.InputStreamReader;
+import java.util.UUID;
+
+public class NewNotificationsReaderRestImpl implements NewNotificationsReader {
+
+ private static final String USER_ID_HEADER_PARAM = "USER_ID";
+ private static final String LAST_DELIVERED_QUERY_PARAM = "LAST_DELIVERED_EVENT_ID";
+ private static final String LIMIT_QUERY_PARAM = "NOTIFICATION_ROWS_LIMIT";
+ private static final String BE_HOST = "beHost";
+ private static final String BE_PORT = "beHttpPort";
+ private static final String DEFAULT_BE_HOST = "localhost";
+ private static final int DEFAULT_BE_PORT = 8080;
+ private static final String URL = "http://%s:%d/onboarding-api/v1.0/notifications/worker?";
+ private static final ObjectMapper mapper = new ObjectMapper();
+
+ private static String beHost;
+ private static int bePort;
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(NewNotificationsReaderRestImpl.class);
+
+ public NewNotificationsReaderRestImpl() {
+ ConfigurationManager cm = ConfigurationManager.getInstance();
+ bePort = cm.getConfigValue(BE_PORT, DEFAULT_BE_PORT);
+ beHost = cm.getConfigValue(BE_HOST, DEFAULT_BE_HOST);
+ }
+
+ public NotificationsStatusDto getNewNotifications(String ownerId, UUID eventId, int limit) {
+ HttpClient client = HttpClientBuilder.create().build();
+ String url = String.format(URL, beHost, bePort);
+
+ url = url + LIMIT_QUERY_PARAM + "=" + limit;
+ if (eventId != null) {
+ url = url + "&" + LAST_DELIVERED_QUERY_PARAM + "=" + eventId;
+ }
+
+ HttpGet request = new HttpGet(url);
+ request.addHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
+ request.addHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
+ request.addHeader(USER_ID_HEADER_PARAM, ownerId);
+
+ try {
+ HttpResponse response = client.execute(request);
+ return mapper.readValue(new InputStreamReader(response.getEntity().getContent()), NotificationsStatusDto.class);
+ } catch (Exception e) {
+ LOGGER.error("Failed to execute the request {}", url, e);
+ return null;
+ }
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/resources/factoryConfiguration.json b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/resources/factoryConfiguration.json
new file mode 100644
index 0000000..5f5693f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/resources/factoryConfiguration.json
@@ -0,0 +1,3 @@
+{
+ "org.openecomp.config.api.ConfigurationManager": "org.openecomp.config.impl.ConfigurationImpl"
+}
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/resources/onboarding_configuration.yaml b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/resources/onboarding_configuration.yaml
new file mode 100644
index 0000000..a1b7ba5
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/resources/onboarding_configuration.yaml
@@ -0,0 +1,5 @@
+notifications:
+ pollingIntervalMsec: 2000
+ selectionSize: 10
+ beHost: localhost
+ beHttpPort: 8080
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/test/java/org/openecomp/sdc/notification/workers/NotificationWorkerTest.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/test/java/org/openecomp/sdc/notification/workers/NotificationWorkerTest.java
new file mode 100644
index 0000000..457ba07
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/test/java/org/openecomp/sdc/notification/workers/NotificationWorkerTest.java
@@ -0,0 +1,134 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.notification.workers;
+
+import com.datastax.driver.core.utils.UUIDs;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.sdc.notification.types.NotificationEntityDto;
+import org.openecomp.sdc.notification.types.NotificationsStatusDto;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.text.DateFormat;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.UUID;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+//import org.junit.Before;
+
+
+public class NotificationWorkerTest {
+
+ private static final String OWNER = "owner_1";
+
+ private String fileName = null;
+ private NewNotificationsReader news = this.new SimNewNotificationsReader();
+ private NotificationWorker worker = new NotificationWorker(news);
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ }
+
+ @Test
+ public void testBasicResourceCreation() throws IOException, InterruptedException {
+
+ Consumer<NotificationsStatusDto> notesProcessor = this::notifyReceiver;
+
+ fileName = "notification_1.csv";
+
+ worker.register(OWNER, null, notesProcessor);
+ worker.register("owner_2", null, notesProcessor);
+ worker.register("owner_3", null, notesProcessor);
+
+ int pollInterval = 2000;
+ Thread.sleep(pollInterval);
+
+ worker.unregister("owner_2");
+
+ fileName = "notification_2.csv";
+
+ Thread.sleep(pollInterval);
+
+ worker.stopPolling();
+
+ }
+
+ private void notifyReceiver(NotificationsStatusDto notes) {
+ if (Objects.nonNull(notes)) {
+ System.out.println("Received notes:");
+ System.out.println(notes);
+ }
+ }
+
+
+ private class SimNewNotificationsReader implements NewNotificationsReader {
+
+
+ private String resourcesDir = "src/test/resources/";
+
+ public NotificationsStatusDto getNewNotifications(String ownerId, UUID eventId, int limit) {
+ if (fileName == null) {
+ return null;
+ }
+ String fn = fileName;
+ fileName = null;
+
+ return getNotifications(fn);
+ }
+
+ private NotificationsStatusDto getNotifications(String fn) {
+ NotificationsStatusDto notificationsStatusDto = new NotificationsStatusDto();
+ List<NotificationEntityDto> inputList = new ArrayList<>();
+ try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(resourcesDir + fn))))) {
+ int limit = 10;
+ inputList = br.lines().skip(1).limit(limit).map(mapToEntity).collect(Collectors.toCollection(ArrayList::new));
+ } catch (IOException e) {
+ System.err.println("getNotifications(): file " + resourcesDir + fn + " open exception: " + e.getMessage());
+ }
+ notificationsStatusDto.setNotifications(inputList);
+ notificationsStatusDto.setLastScanned(inputList.get(0).getEventId());
+ return notificationsStatusDto;
+ }
+
+ private Function<String, NotificationEntityDto> mapToEntity = (line) -> {
+ String[] p = line.split("\\|");
+ NotificationEntityDto entity = new NotificationEntityDto();
+ DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT);
+ entity.setRead(Boolean.parseBoolean(p[1]));
+ entity.setEventId(UUID.fromString(p[2]));
+ entity.setEventType(p[4]);
+ entity.setDateTime(formatter.format(UUIDs.unixTimestamp(entity.getEventId())));
+ entity.setEventAttributes(JsonUtil.json2Object(p[5], Map.class));
+ return entity;
+ };
+ }
+
+}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/resources/logback.xml b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/test/resources/logback.xml
similarity index 91%
copy from openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/resources/logback.xml
copy to openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/test/resources/logback.xml
index 9c9c06c..c1932e3 100644
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/resources/logback.xml
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/test/resources/logback.xml
@@ -9,7 +9,7 @@
</appender>
<root level="warn">
- <appender-ref ref="STDOUT"/>
+ <appender-ref ref="STDOUT" />
</root>
</configuration>
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/test/resources/notification_1.csv b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/test/resources/notification_1.csv
new file mode 100644
index 0000000..8b7de38
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/test/resources/notification_1.csv
@@ -0,0 +1,11 @@
+# Owner|Read|EventId|EventType|OriginatorId|EventAttributes
+owner_1|false|1dc38a90-5e85-11e7-907b-a6006ad3dba0|type_1|orig_1|{attr_1: val_1, attr_2: val_2}
+owner_1|false|1dc387d4-5e85-11e7-907b-a6006ad3dba0|type_1|orig_1|{attr_1: val_1, attr_2: val_2}
+owner_1|false|1dc38702-5e85-11e7-907b-a6006ad3dba0|type_1|orig_1|{attr_1: val_1, attr_2: val_2}
+owner_1|false|1dc385fe-5e85-11e7-907b-a6006ad3dba0|type_1|orig_1|{attr_1: val_1, attr_2: val_2}
+owner_1|false|1dc384a0-5e85-11e7-907b-a6006ad3dba0|type_1|orig_1|{attr_1: val_1, attr_2: val_2}
+owner_1|false|1dc383c4-5e85-11e7-907b-a6006ad3dba0|type_1|orig_1|{attr_1: val_1, attr_2: val_2}
+owner_1|false|1dc3818a-5e85-11e7-907b-a6006ad3dba0|type_1|orig_1|{attr_1: val_1, attr_2: val_2}
+owner_1|false|1dc380b8-5e85-11e7-907b-a6006ad3dba0|type_1|orig_1|{attr_1: val_1, attr_2: val_2}
+owner_1|false|1dc37fdc-5e85-11e7-907b-a6006ad3dba0|type_1|orig_1|{attr_1: val_1, attr_2: val_2}
+owner_1|false|1dc37ee2-5e85-11e7-907b-a6006ad3dba0|type_1|orig_1|{attr_1: val_1, attr_2: val_2}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/test/resources/notification_2.csv b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/test/resources/notification_2.csv
new file mode 100644
index 0000000..565e80b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/test/resources/notification_2.csv
@@ -0,0 +1,11 @@
+# Owner|Read|EventId|EventType|OriginatorId|EventAttributes
+owner_1|false|1dc39346-5e85-11e7-907b-a6006ad3dba0|type_1|orig_1|{attr_1: val_1, attr_2: val_2}
+owner_1|false|1dc39288-5e85-11e7-907b-a6006ad3dba0|type_1|orig_1|{attr_1: val_1, attr_2: val_2}
+owner_1|false|1dc391c0-5e85-11e7-907b-a6006ad3dba0|type_1|orig_1|{attr_1: val_1, attr_2: val_2}
+owner_1|false|1dc38f2c-5e85-11e7-907b-a6006ad3dba0|type_1|orig_1|{attr_1: val_1, attr_2: val_2}
+owner_1|false|1dc38e64-5e85-11e7-907b-a6006ad3dba0|type_1|orig_1|{attr_1: val_1, attr_2: val_2}
+owner_1|false|1dc38da6-5e85-11e7-907b-a6006ad3dba0|type_1|orig_1|{attr_1: val_1, attr_2: val_2}
+owner_1|false|1dc38ce8-5e85-11e7-907b-a6006ad3dba0|type_1|orig_1|{attr_1: val_1, attr_2: val_2}
+owner_1|false|1dc38c2a-5e85-11e7-907b-a6006ad3dba0|type_1|orig_1|{attr_1: val_1, attr_2: val_2}
+owner_1|false|1dc38b62-5e85-11e7-907b-a6006ad3dba0|type_1|orig_1|{attr_1: val_1, attr_2: val_2}
+owner_1|false|1dc37c08-5e85-11e7-907b-a6006ad3dba0|type_1|orig_1|{attr_1: val_1, attr_2: val_2}
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/test/resources/onboarding_configuration.yaml b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/test/resources/onboarding_configuration.yaml
new file mode 100644
index 0000000..cc04531
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/test/resources/onboarding_configuration.yaml
@@ -0,0 +1,5 @@
+notifications:
+ pollingIntervalMsec: 3000
+ selectionSize: 5
+ beHost: localhost
+ beHttpPort: 8080
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/pom.xml b/openecomp-be/lib/openecomp-sdc-notification-lib/pom.xml
new file mode 100644
index 0000000..9dc0dcf
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/pom.xml
@@ -0,0 +1,23 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <name>openecomp-sdc-notification-lib</name>
+ <artifactId>openecomp-sdc-notification-lib</artifactId>
+
+ <packaging>pom</packaging>
+ <parent>
+ <artifactId>openecomp-sdc-lib</artifactId>
+ <groupId>org.openecomp.sdc</groupId>
+ <version>1.2.0-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <modules>
+ <module>openecomp-sdc-notification-api</module>
+ <module>openecomp-sdc-notification-core</module>
+ <module>openecomp-sdc-notification-worker</module>
+ <module>openecomp-sdc-notification-websocket</module>
+ </modules>
+
+</project>
diff --git a/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-core/src/main/java/org/openecomp/sdc/generator/core/services/ManualVspToscaGenerationService.java b/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-core/src/main/java/org/openecomp/sdc/generator/core/services/ManualVspToscaGenerationService.java
index 6ec7bfc..8234179 100644
--- a/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-core/src/main/java/org/openecomp/sdc/generator/core/services/ManualVspToscaGenerationService.java
+++ b/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-core/src/main/java/org/openecomp/sdc/generator/core/services/ManualVspToscaGenerationService.java
@@ -1,21 +1,5 @@
package org.openecomp.sdc.generator.core.services;
-import static org.openecomp.sdc.generator.util.GeneratorConstants.ALLOWED_FLAVORS_PROPERTY;
-import static org.openecomp.sdc.generator.util.GeneratorConstants.DISK_SIZE;
-import static org.openecomp.sdc.generator.util.GeneratorConstants.DISK_SIZE_PROP_DESC_PREFIX;
-import static org.openecomp.sdc.generator.util.GeneratorConstants.IMAGES_PROPERTY;
-import static org.openecomp.sdc.generator.util.GeneratorConstants.MEM_SIZE;
-import static org.openecomp.sdc.generator.util.GeneratorConstants.MEM_SIZE_PROP_DESC_PREFIX;
-import static org.openecomp.sdc.generator.util.GeneratorConstants.NUM_CPUS;
-import static org.openecomp.sdc.generator.util.GeneratorConstants.NUM_CPUS_PROP_DESC_PREFIX;
-import static org.openecomp.sdc.generator.util.GeneratorConstants.PORT_NODE_TEMPLATE_ID_SUFFIX;
-import static org.openecomp.sdc.generator.util.GeneratorConstants.PORT_TYPE_EXTERNAL_NODE_TEMPLATE_SUFFIX;
-import static org.openecomp.sdc.generator.util.GeneratorConstants.PORT_TYPE_INTERNAL_NODE_TEMPLATE_SUFFIX;
-import static org.openecomp.sdc.generator.util.GeneratorConstants.RELEASE_VENDOR;
-import static org.openecomp.sdc.generator.util.GeneratorConstants.TOSCA_SERVICE_TEMPLATE_FILE_NAME_SUFFIX;
-import static org.openecomp.sdc.generator.util.GeneratorConstants.VNF_CONFIG_NODE_TEMPLATE_ID_SUFFIX;
-import static org.openecomp.sdc.generator.util.GeneratorConstants.VNF_NODE_TEMPLATE_ID_SUFFIX;
-
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.openecomp.sdc.generator.core.utils.GeneratorUtils;
@@ -48,6 +32,22 @@
import java.util.Objects;
import java.util.Optional;
+import static org.openecomp.sdc.generator.util.GeneratorConstants.ALLOWED_FLAVORS_PROPERTY;
+import static org.openecomp.sdc.generator.util.GeneratorConstants.DISK_SIZE;
+import static org.openecomp.sdc.generator.util.GeneratorConstants.DISK_SIZE_PROP_DESC_PREFIX;
+import static org.openecomp.sdc.generator.util.GeneratorConstants.IMAGES_PROPERTY;
+import static org.openecomp.sdc.generator.util.GeneratorConstants.MEM_SIZE;
+import static org.openecomp.sdc.generator.util.GeneratorConstants.MEM_SIZE_PROP_DESC_PREFIX;
+import static org.openecomp.sdc.generator.util.GeneratorConstants.NUM_CPUS;
+import static org.openecomp.sdc.generator.util.GeneratorConstants.NUM_CPUS_PROP_DESC_PREFIX;
+import static org.openecomp.sdc.generator.util.GeneratorConstants.PORT_NODE_TEMPLATE_ID_SUFFIX;
+import static org.openecomp.sdc.generator.util.GeneratorConstants.PORT_TYPE_EXTERNAL_NODE_TEMPLATE_SUFFIX;
+import static org.openecomp.sdc.generator.util.GeneratorConstants.PORT_TYPE_INTERNAL_NODE_TEMPLATE_SUFFIX;
+import static org.openecomp.sdc.generator.util.GeneratorConstants.RELEASE_VENDOR;
+import static org.openecomp.sdc.generator.util.GeneratorConstants.TOSCA_SERVICE_TEMPLATE_FILE_NAME_SUFFIX;
+import static org.openecomp.sdc.generator.util.GeneratorConstants.VNF_CONFIG_NODE_TEMPLATE_ID_SUFFIX;
+import static org.openecomp.sdc.generator.util.GeneratorConstants.VNF_NODE_TEMPLATE_ID_SUFFIX;
+
/**
* The type Manual vsp tosca generator.
*/
@@ -329,7 +329,6 @@
ToscaServiceModel toscaServiceModel,
String substitutionNodeTypeId,
String componentName) {
- ToscaAnalyzerService toscaAnalyzerService = new ToscaAnalyzerServiceImpl();
ServiceTemplate globalSubstitutionServiceTemplate = fetchGlobalSubstitutionServiceTemplate();
NodeType substitutionNodeType =
createGlobalSubstitutionNodeType(substitutionServiceTemplate, componentName);
diff --git a/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-core/src/main/java/org/openecomp/sdc/generator/core/utils/GeneratorUtils.java b/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-core/src/main/java/org/openecomp/sdc/generator/core/utils/GeneratorUtils.java
index 7e493f2..129929a 100644
--- a/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-core/src/main/java/org/openecomp/sdc/generator/core/utils/GeneratorUtils.java
+++ b/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-core/src/main/java/org/openecomp/sdc/generator/core/utils/GeneratorUtils.java
@@ -1,7 +1,5 @@
package org.openecomp.sdc.generator.core.utils;
-import static org.openecomp.sdc.tosca.services.DataModelUtil.addSubstitutionNodeTypeRequirements;
-
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
@@ -29,6 +27,8 @@
import java.util.List;
import java.util.Map;
+import static org.openecomp.sdc.tosca.services.DataModelUtil.addSubstitutionNodeTypeRequirements;
+
/**
* The type Generator utils.
*/
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/TranslationContext.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/TranslationContext.java
index 3686a51..87c578c 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/TranslationContext.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/TranslationContext.java
@@ -20,7 +20,6 @@
package org.openecomp.sdc.translator.datatypes.heattotosca;
-import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.openecomp.config.api.Configuration;
import org.openecomp.config.api.ConfigurationManager;
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationService.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationService.java
index d3f2a72..628186e 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationService.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationService.java
@@ -3,7 +3,6 @@
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate;
import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java
index 895b3f9..9d875d2 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java
@@ -27,10 +27,9 @@
import org.openecomp.core.translator.factory.HeatToToscaTranslatorFactory;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.file.FileUtils;
-import org.openecomp.sdc.common.togglz.ToggleableFeature;
-import org.openecomp.sdc.tosca.services.YamlUtil;
import org.openecomp.core.validation.util.MessageContainerUtil;
import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.togglz.ToggleableFeature;
import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
@@ -73,9 +72,10 @@
import org.openecomp.sdc.tosca.services.DataModelUtil;
import org.openecomp.sdc.tosca.services.ToscaAnalyzerService;
import org.openecomp.sdc.tosca.services.ToscaConstants;
-import org.openecomp.sdc.tosca.services.ToscaUtil;
-import org.openecomp.sdc.tosca.services.impl.ToscaAnalyzerServiceImpl;
import org.openecomp.sdc.tosca.services.ToscaExtensionYamlUtil;
+import org.openecomp.sdc.tosca.services.ToscaUtil;
+import org.openecomp.sdc.tosca.services.YamlUtil;
+import org.openecomp.sdc.tosca.services.impl.ToscaAnalyzerServiceImpl;
import org.openecomp.sdc.translator.datatypes.heattotosca.AttachedPropertyVal;
import org.openecomp.sdc.translator.datatypes.heattotosca.AttachedResourceId;
import org.openecomp.sdc.translator.datatypes.heattotosca.ReferenceType;
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/UnifiedCompositionService.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/UnifiedCompositionService.java
index 244434c..bd0fbcb 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/UnifiedCompositionService.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/UnifiedCompositionService.java
@@ -20,12 +20,6 @@
package org.openecomp.sdc.translator.services.heattotosca;
-import static org.openecomp.sdc.tosca.services.DataModelUtil.getClonedObject;
-import static org.openecomp.sdc.translator.services.heattotosca.Constants.ABSTRACT_NODE_TEMPLATE_ID_PREFIX;
-import static org.openecomp.sdc.translator.services.heattotosca.Constants.COMPUTE_IDENTICAL_VALUE_PROPERTY_PREFIX;
-import static org.openecomp.sdc.translator.services.heattotosca.Constants.COMPUTE_IDENTICAL_VALUE_PROPERTY_SUFFIX;
-import static org.openecomp.sdc.translator.services.heattotosca.Constants.PORT_IDENTICAL_VALUE_PROPERTY_PREFIX;
-
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
@@ -94,6 +88,12 @@
import java.util.Set;
import java.util.regex.Pattern;
+import static org.openecomp.sdc.tosca.services.DataModelUtil.getClonedObject;
+import static org.openecomp.sdc.translator.services.heattotosca.Constants.ABSTRACT_NODE_TEMPLATE_ID_PREFIX;
+import static org.openecomp.sdc.translator.services.heattotosca.Constants.COMPUTE_IDENTICAL_VALUE_PROPERTY_PREFIX;
+import static org.openecomp.sdc.translator.services.heattotosca.Constants.COMPUTE_IDENTICAL_VALUE_PROPERTY_SUFFIX;
+import static org.openecomp.sdc.translator.services.heattotosca.Constants.PORT_IDENTICAL_VALUE_PROPERTY_PREFIX;
+
public class UnifiedCompositionService {
protected static Logger logger =
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/GlobalTypesServiceTemplates.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/GlobalTypesServiceTemplates.java
index 531de16..dff208f 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/GlobalTypesServiceTemplates.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/globaltypes/GlobalTypesServiceTemplates.java
@@ -5,8 +5,8 @@
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.logging.types.LoggerErrorDescription;
import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
-import org.openecomp.sdc.tosca.services.ToscaUtil;
import org.openecomp.sdc.tosca.services.ToscaExtensionYamlUtil;
+import org.openecomp.sdc.tosca.services.ToscaUtil;
import org.openecomp.sdc.translator.utils.ResourceWalker;
import java.util.HashMap;
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/helper/VolumeTranslationHelper.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/helper/VolumeTranslationHelper.java
index ef75f31..87bf36b 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/helper/VolumeTranslationHelper.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/helper/VolumeTranslationHelper.java
@@ -20,8 +20,6 @@
package org.openecomp.sdc.translator.services.heattotosca.helper;
-import static org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes.CINDER_VOLUME_RESOURCE_TYPE;
-
import org.apache.commons.collections4.CollectionUtils;
import org.openecomp.sdc.heat.datatypes.manifest.FileData;
import org.openecomp.sdc.heat.datatypes.model.HeatOrchestrationTemplate;
@@ -45,6 +43,8 @@
import java.util.function.Predicate;
import java.util.stream.Collectors;
+import static org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes.CINDER_VOLUME_RESOURCE_TYPE;
+
public class VolumeTranslationHelper {
private final Logger logger;
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetAttrImpl.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetAttrImpl.java
index 48d5642..1d35795 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetAttrImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetAttrImpl.java
@@ -21,7 +21,6 @@
package org.openecomp.sdc.translator.services.heattotosca.impl.functiontranslation;
import org.apache.commons.lang3.StringUtils;
-import org.openecomp.sdc.tosca.services.YamlUtil;
import org.openecomp.sdc.heat.datatypes.model.HeatOrchestrationTemplate;
import org.openecomp.sdc.heat.datatypes.model.Resource;
import org.openecomp.sdc.heat.services.HeatConstants;
@@ -29,6 +28,7 @@
import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate;
import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
import org.openecomp.sdc.tosca.datatypes.model.Template;
+import org.openecomp.sdc.tosca.services.YamlUtil;
import org.openecomp.sdc.translator.datatypes.heattotosca.TranslationContext;
import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.EntityConsolidationData;
import org.openecomp.sdc.translator.services.heattotosca.ConfigConstants;
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetFileImpl.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetFileImpl.java
index bc0926c..374f8a9 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetFileImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetFileImpl.java
@@ -30,8 +30,8 @@
import org.openecomp.sdc.tosca.services.ToscaConstants;
import org.openecomp.sdc.tosca.services.ToscaFileOutputService;
import org.openecomp.sdc.tosca.services.impl.ToscaFileOutputServiceCsarImpl;
-import org.openecomp.sdc.translator.services.heattotosca.FunctionTranslation;
import org.openecomp.sdc.translator.datatypes.heattotosca.TranslationContext;
+import org.openecomp.sdc.translator.services.heattotosca.FunctionTranslation;
import java.util.ArrayList;
import java.util.HashMap;
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetParamImpl.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetParamImpl.java
index 877659e..184aa52 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetParamImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetParamImpl.java
@@ -25,9 +25,9 @@
import org.openecomp.sdc.tosca.datatypes.ToscaFunctions;
import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
import org.openecomp.sdc.tosca.datatypes.model.Template;
+import org.openecomp.sdc.translator.datatypes.heattotosca.TranslationContext;
import org.openecomp.sdc.translator.services.heattotosca.FunctionTranslation;
import org.openecomp.sdc.translator.services.heattotosca.FunctionTranslationFactory;
-import org.openecomp.sdc.translator.datatypes.heattotosca.TranslationContext;
import java.util.ArrayList;
import java.util.HashMap;
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetResourceImpl.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetResourceImpl.java
index b2d11e3..ce160ce 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetResourceImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetResourceImpl.java
@@ -23,8 +23,8 @@
import org.openecomp.sdc.heat.datatypes.model.HeatOrchestrationTemplate;
import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
import org.openecomp.sdc.tosca.datatypes.model.Template;
-import org.openecomp.sdc.translator.services.heattotosca.FunctionTranslation;
import org.openecomp.sdc.translator.datatypes.heattotosca.TranslationContext;
+import org.openecomp.sdc.translator.services.heattotosca.FunctionTranslation;
import org.openecomp.sdc.translator.services.heattotosca.helper.FunctionTranslationHelper;
import org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation.ResourceTranslationBase;
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseResourceConnection.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseResourceConnection.java
index b0094b0..459c44e 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseResourceConnection.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseResourceConnection.java
@@ -21,7 +21,6 @@
package org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation;
import org.apache.commons.collections4.MapUtils;
-import org.openecomp.sdc.tosca.services.YamlUtil;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
@@ -44,6 +43,7 @@
import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
import org.openecomp.sdc.tosca.services.DataModelUtil;
import org.openecomp.sdc.tosca.services.ToscaAnalyzerService;
+import org.openecomp.sdc.tosca.services.YamlUtil;
import org.openecomp.sdc.tosca.services.impl.ToscaAnalyzerServiceImpl;
import org.openecomp.sdc.translator.datatypes.heattotosca.AttachedResourceId;
import org.openecomp.sdc.translator.datatypes.heattotosca.to.TranslateTo;
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceConnectionUsingCapabilityHelper.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceConnectionUsingCapabilityHelper.java
index 231190a..3a3a7c7 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceConnectionUsingCapabilityHelper.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceConnectionUsingCapabilityHelper.java
@@ -20,7 +20,6 @@
package org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation;
-import org.openecomp.sdc.common.utils.CommonUtil;
import org.openecomp.sdc.heat.datatypes.manifest.FileData;
import org.openecomp.sdc.heat.datatypes.model.Resource;
import org.openecomp.sdc.tosca.datatypes.model.CapabilityDefinition;
@@ -32,7 +31,6 @@
import org.openecomp.sdc.tosca.services.DataModelUtil;
import org.openecomp.sdc.translator.datatypes.heattotosca.to.TranslateTo;
import org.openecomp.sdc.translator.datatypes.heattotosca.to.TranslatedHeatResource;
-import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ConsolidationData;
import org.openecomp.sdc.translator.services.heattotosca.ConsolidationDataUtil;
import org.openecomp.sdc.translator.services.heattotosca.HeatToToscaUtil;
import org.openecomp.sdc.translator.services.heattotosca.ResourceTranslationFactory;
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationBase.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationBase.java
index 72739d3..e439935 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationBase.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationBase.java
@@ -22,7 +22,6 @@
import org.apache.commons.collections4.CollectionUtils;
import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.heat.datatypes.model.HeatOrchestrationTemplate;
import org.openecomp.sdc.heat.datatypes.model.Resource;
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationCinderVolumeAttachmentImpl.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationCinderVolumeAttachmentImpl.java
index 4cf817b..ea8f78a 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationCinderVolumeAttachmentImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationCinderVolumeAttachmentImpl.java
@@ -20,8 +20,6 @@
package org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation;
-import static org.openecomp.sdc.translator.services.heattotosca.HeatToToscaUtil.getResource;
-
import org.apache.commons.lang3.StringUtils;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
@@ -56,6 +54,8 @@
import java.util.List;
import java.util.Optional;
+import static org.openecomp.sdc.translator.services.heattotosca.HeatToToscaUtil.getResource;
+
public class ResourceTranslationCinderVolumeAttachmentImpl extends ResourceTranslationBase {
protected static Logger logger =
(Logger) LoggerFactory.getLogger(ResourceTranslationCinderVolumeAttachmentImpl.class);
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailAttachPolicyImpl.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailAttachPolicyImpl.java
index d729c04..90206cf 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailAttachPolicyImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailAttachPolicyImpl.java
@@ -20,11 +20,11 @@
package org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.heat.datatypes.model.Resource;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
import org.openecomp.sdc.logging.types.LoggerConstants;
import org.openecomp.sdc.logging.types.LoggerErrorCode;
@@ -32,9 +32,9 @@
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
import org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType;
import org.openecomp.sdc.tosca.datatypes.ToscaRelationshipType;
+import org.openecomp.sdc.tosca.datatypes.ToscaTopologyTemplateElements;
import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate;
import org.openecomp.sdc.tosca.datatypes.model.RequirementAssignment;
-import org.openecomp.sdc.tosca.datatypes.ToscaTopologyTemplateElements;
import org.openecomp.sdc.tosca.services.DataModelUtil;
import org.openecomp.sdc.tosca.services.ToscaConstants;
import org.openecomp.sdc.translator.datatypes.heattotosca.AttachedResourceId;
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailV2NetworkPolicyImpl.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailV2NetworkPolicyImpl.java
index 71efc18..d12075d 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailV2NetworkPolicyImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailV2NetworkPolicyImpl.java
@@ -20,7 +20,6 @@
package org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation;
-import org.openecomp.sdc.common.utils.CommonUtil;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerGroupsImpl.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerGroupsImpl.java
index 875903f..9ed59e0 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerGroupsImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerGroupsImpl.java
@@ -24,9 +24,9 @@
import org.openecomp.sdc.heat.datatypes.model.Resource;
import org.openecomp.sdc.tosca.datatypes.ToscaGroupType;
import org.openecomp.sdc.tosca.datatypes.ToscaPolicyType;
+import org.openecomp.sdc.tosca.datatypes.ToscaTopologyTemplateElements;
import org.openecomp.sdc.tosca.datatypes.model.GroupDefinition;
import org.openecomp.sdc.tosca.datatypes.model.PolicyDefinition;
-import org.openecomp.sdc.tosca.datatypes.ToscaTopologyTemplateElements;
import org.openecomp.sdc.tosca.services.DataModelUtil;
import org.openecomp.sdc.translator.datatypes.heattotosca.to.TranslateTo;
import org.openecomp.sdc.translator.services.heattotosca.mapping.TranslatorHeatToToscaPropertyConverter;
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerImpl.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerImpl.java
index 96c105c..2a2ecf9 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerImpl.java
@@ -44,14 +44,12 @@
import org.openecomp.sdc.translator.datatypes.heattotosca.TranslationContext;
import org.openecomp.sdc.translator.datatypes.heattotosca.to.TranslateTo;
import org.openecomp.sdc.translator.datatypes.heattotosca.to.TranslatedHeatResource;
-
import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ComputeTemplateConsolidationData;
import org.openecomp.sdc.translator.services.heattotosca.ConsolidationDataUtil;
import org.openecomp.sdc.translator.services.heattotosca.Constants;
import org.openecomp.sdc.translator.services.heattotosca.HeatToToscaUtil;
import org.openecomp.sdc.translator.services.heattotosca.NameExtractor;
import org.openecomp.sdc.translator.services.heattotosca.ResourceTranslationFactory;
-
import org.openecomp.sdc.translator.services.heattotosca.mapping.TranslatorHeatToToscaPropertyConverter;
import java.util.ArrayList;
@@ -398,28 +396,23 @@
private void manageNovaServerNetwork(TranslateTo translateTo,
NodeTemplate novaNodeTemplate) {
+ mdcDataDebugMessage.debugEntryMessage(null, null);
-
- String heatFileName = translateTo.getHeatFileName();
- ServiceTemplate serviceTemplate = translateTo.getServiceTemplate();
- HeatOrchestrationTemplate heatOrchestrationTemplate = translateTo
- .getHeatOrchestrationTemplate();
Resource resource = translateTo.getResource();
String translatedId = translateTo.getTranslatedId();
- TranslationContext context = translateTo.getContext();
-
- mdcDataDebugMessage.debugEntryMessage(null, null);
if (resource.getProperties() == null) {
return;
}
- List<Map<String, Object>> heatNetworkList =
- (List<Map<String, Object>>) resource.getProperties().get("networks");
-
- if (CollectionUtils.isEmpty(heatNetworkList)) {
+ Object networks = resource.getProperties().get("networks");
+ if(Objects.isNull(networks)
+ || !(networks instanceof List)){
return;
}
+ List<Map<String, Object>> heatNetworkList =
+ (List<Map<String, Object>>) networks;
+
for (Map<String, Object> heatNetwork : heatNetworkList) {
getOrTranslatePortTemplate(translateTo, heatNetwork.get(
Constants.PORT_PROPERTY_NAME), translatedId, novaNodeTemplate);
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/SecurityRulesToPortResourceConnection.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/SecurityRulesToPortResourceConnection.java
index 3d183b1..b32ea2d 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/SecurityRulesToPortResourceConnection.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/SecurityRulesToPortResourceConnection.java
@@ -21,7 +21,6 @@
package org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation;
import org.openecomp.sdc.heat.datatypes.manifest.FileData;
-
import org.openecomp.sdc.heat.datatypes.model.HeatOrchestrationTemplate;
import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes;
import org.openecomp.sdc.heat.datatypes.model.Resource;
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/TestUtils.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/TestUtils.java
index 27298ff..c7d3931 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/TestUtils.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/TestUtils.java
@@ -36,7 +36,19 @@
import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
import org.openecomp.sdc.tosca.services.DataModelUtil;
import org.openecomp.sdc.tosca.services.ToscaExtensionYamlUtil;
-import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.*;
+import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ComputeConsolidationData;
+import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ComputeTemplateConsolidationData;
+import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ConsolidationData;
+import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.EntityConsolidationData;
+import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.FileComputeConsolidationData;
+import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.FileNestedConsolidationData;
+import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.FilePortConsolidationData;
+import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.GetAttrFuncData;
+import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.NestedConsolidationData;
+import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.NestedTemplateConsolidationData;
+import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.PortTemplateConsolidationData;
+import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.RequirementAssignmentData;
+import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.TypeComputeConsolidationData;
import java.io.File;
import java.io.FileInputStream;
@@ -45,7 +57,13 @@
import java.io.InputStream;
import java.net.URL;
import java.nio.file.NotDirectoryException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
public class TestUtils {
private static final String MANIFEST_NAME = SdcCommon.MANIFEST_NAME;
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/resources/OSNovaServerTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/resources/OSNovaServerTest.java
index ebb3450..9743483 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/resources/OSNovaServerTest.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/impl/heattotosca/resources/OSNovaServerTest.java
@@ -20,9 +20,6 @@
package org.openecomp.sdc.translator.impl.heattotosca.resources;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_PORT_POSITIVE;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_VOLUME_POSITIVE;
-
import org.junit.Before;
import org.junit.Test;
import org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataValidationType;
@@ -30,6 +27,9 @@
import java.io.IOException;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_PORT_POSITIVE;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_VOLUME_POSITIVE;
+
public class OSNovaServerTest extends BaseResourceTranslationTest {
@Override
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtilTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtilTest.java
index 019d143..3f294eb 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtilTest.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtilTest.java
@@ -1,6 +1,7 @@
package org.openecomp.sdc.translator.services.heattotosca;
import org.testng.annotations.Test;
+
import static org.testng.Assert.assertEquals;
public class ConsolidationDataUtilTest {
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationServiceTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationServiceTest.java
index 085c329..4af2415 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationServiceTest.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationServiceTest.java
@@ -1,39 +1,5 @@
package org.openecomp.sdc.translator.services.heattotosca;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.apache.commons.lang3.tuple.Pair;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Captor;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.mockito.Spy;
-import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
-import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
-import org.openecomp.sdc.tosca.services.ToscaConstants;
-import org.openecomp.sdc.translator.TestUtils;
-import org.openecomp.sdc.translator.datatypes.heattotosca.TranslationContext;
-import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.composition.UnifiedCompositionData;
-import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.composition.UnifiedCompositionMode;
-import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ConsolidationData;
-import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.GetAttrFuncData;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
/**
* Created by TALIO on 3/7/2017.
*/
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/UnifiedCompositionServiceTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/UnifiedCompositionServiceTest.java
index 69db1b2..7de9ae5 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/UnifiedCompositionServiceTest.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/UnifiedCompositionServiceTest.java
@@ -1,9 +1,5 @@
package org.openecomp.sdc.translator.services.heattotosca;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.anyString;
-
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.junit.Before;
@@ -13,22 +9,40 @@
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
-import org.openecomp.sdc.tosca.services.YamlUtil;
import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate;
import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
import org.openecomp.sdc.tosca.services.DataModelUtil;
import org.openecomp.sdc.tosca.services.ToscaExtensionYamlUtil;
+import org.openecomp.sdc.tosca.services.YamlUtil;
import org.openecomp.sdc.translator.TestUtils;
import org.openecomp.sdc.translator.datatypes.heattotosca.TranslationContext;
import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.composition.UnifiedCompositionData;
import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.composition.UnifiedCompositionEntity;
import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.composition.UnifiedSubstitutionData;
-import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.*;
+import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ComputeTemplateConsolidationData;
+import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ConsolidationData;
+import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.EntityConsolidationData;
+import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.GetAttrFuncData;
+import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.NestedTemplateConsolidationData;
+import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.PortTemplateConsolidationData;
+import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.RequirementAssignmentData;
import org.openecomp.sdc.translator.services.heattotosca.impl.unifiedcomposition.UnifiedCompositionSingleSubstitution;
import java.io.IOException;
import java.net.URL;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.anyString;
public class UnifiedCompositionServiceTest {
private static final String BASE_DIRECTORY = "/mock/services/heattotosca/unifiedComposition/";
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/buildconsolidationdata/ConsolidationDataTestUtil.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/buildconsolidationdata/ConsolidationDataTestUtil.java
index dd48e61..bb1f898 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/buildconsolidationdata/ConsolidationDataTestUtil.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/buildconsolidationdata/ConsolidationDataTestUtil.java
@@ -1,19 +1,5 @@
package org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.MAIN_SERVICE_TEMPLATE;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_DEPENDS_ON_INVALID_DEPENDENCY_CANDIDATE;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_DEPENDS_ON_MULTIPLE_COMPUTE;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_DEPENDS_ON_NODES_CONNECTED_IN;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_DEPENDS_ON_NODES_CONNECTED_IN_AND_OUT;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_DEPENDS_ON_NODES_CONNECTED_OUT;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_DEPENDS_ON_NO_DEPENDENCY;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_MULTIPLE_MULTI_LEVEL_NESTED_RESOURCE;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_MULTIPLE_NESTED_RESOURCE;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_SECURITY_RULE_PORT_MULTI_LEVEL_NESTED_CONNECTION;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_SECURITY_RULE_PORT_MULTI_LEVEL_NESTED_SHARED_PORT;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_SECURITY_RULE_PORT_NESTED_CONNECTION;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_SINGLE_NESTED_RESOURCE;
-
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.junit.Assert;
@@ -51,6 +37,20 @@
import java.util.Optional;
import java.util.Set;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.MAIN_SERVICE_TEMPLATE;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_DEPENDS_ON_INVALID_DEPENDENCY_CANDIDATE;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_DEPENDS_ON_MULTIPLE_COMPUTE;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_DEPENDS_ON_NODES_CONNECTED_IN;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_DEPENDS_ON_NODES_CONNECTED_IN_AND_OUT;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_DEPENDS_ON_NODES_CONNECTED_OUT;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_DEPENDS_ON_NO_DEPENDENCY;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_MULTIPLE_MULTI_LEVEL_NESTED_RESOURCE;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_MULTIPLE_NESTED_RESOURCE;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_SECURITY_RULE_PORT_MULTI_LEVEL_NESTED_CONNECTION;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_SECURITY_RULE_PORT_MULTI_LEVEL_NESTED_SHARED_PORT;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_SECURITY_RULE_PORT_NESTED_CONNECTION;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_SINGLE_NESTED_RESOURCE;
+
public class ConsolidationDataTestUtil {
public static void validateVolumeInConsolidationData(String computeNodeTemplateId,
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/helper/ContrailTranslationHelperTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/helper/ContrailTranslationHelperTest.java
index 9b4a59b..1a108ce 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/helper/ContrailTranslationHelperTest.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/helper/ContrailTranslationHelperTest.java
@@ -31,7 +31,7 @@
import java.util.Map;
import java.util.Optional;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
/**
* @author SHIRIA
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetFileImplTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetFileImplTest.java
index b79671d..2a633da 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetFileImplTest.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetFileImplTest.java
@@ -28,8 +28,8 @@
import org.openecomp.sdc.tosca.services.ToscaConstants;
import org.openecomp.sdc.tosca.services.ToscaFileOutputService;
import org.openecomp.sdc.tosca.services.impl.ToscaFileOutputServiceCsarImpl;
-import org.openecomp.sdc.translator.services.heattotosca.FunctionTranslationFactory;
import org.openecomp.sdc.translator.datatypes.heattotosca.TranslationContext;
+import org.openecomp.sdc.translator.services.heattotosca.FunctionTranslationFactory;
import java.util.HashMap;
import java.util.List;
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetParamImplTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetParamImplTest.java
index 981c061..860074b 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetParamImplTest.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetParamImplTest.java
@@ -30,7 +30,8 @@
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
public class FunctionTranslationGetParamImplTest extends BaseResourceTranslationTest {
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/nameextractor/NameExtractorContrailComputeImplTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/nameextractor/NameExtractorContrailComputeImplTest.java
index 9fdd2db..9a249d7 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/nameextractor/NameExtractorContrailComputeImplTest.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/nameextractor/NameExtractorContrailComputeImplTest.java
@@ -23,7 +23,6 @@
import org.junit.Assert;
import org.junit.Test;
import org.openecomp.sdc.heat.datatypes.model.Resource;
-import org.openecomp.sdc.translator.services.heattotosca.impl.nameextractor.NameExtractorContrailComputeImpl;
import java.util.HashMap;
import java.util.Map;
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/nameextractor/NameExtractorNovaServerImplTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/nameextractor/NameExtractorNovaServerImplTest.java
index 5823797..3095b52 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/nameextractor/NameExtractorNovaServerImplTest.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/nameextractor/NameExtractorNovaServerImplTest.java
@@ -23,7 +23,6 @@
import org.junit.Test;
import org.openecomp.sdc.heat.datatypes.model.Resource;
import org.openecomp.sdc.translator.services.heattotosca.Constants;
-import org.openecomp.sdc.translator.services.heattotosca.impl.nameextractor.NameExtractorNovaServerImpl;
import org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation.ResourceTranslationNovaServerImpl;
import java.util.Arrays;
@@ -31,7 +30,7 @@
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertTrue;
/**
* @author SHIRIA
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseResourceTranslationTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseResourceTranslationTest.java
index 528db5e..dcfe127 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseResourceTranslationTest.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseResourceTranslationTest.java
@@ -20,19 +20,6 @@
package org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation;
-import static org.junit.Assert.assertEquals;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validateComputeConnectivityIn;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validateComputeConnectivityOut;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validateDependsOnInConsolidationData;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validateGetAttr;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validateGroupsInConsolidationData;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validateNestedConsolidationData;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validatePortConnectivityIn;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validatePortConnectivityOut;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validatePortsInConsolidationData;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validateNestedConsolidationDataNodeTemplateIds;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validateVolumeInConsolidationData;
-
import org.apache.commons.collections4.MapUtils;
import org.junit.AfterClass;
import org.junit.Assert;
@@ -86,6 +73,19 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
+import static org.junit.Assert.assertEquals;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validateComputeConnectivityIn;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validateComputeConnectivityOut;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validateDependsOnInConsolidationData;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validateGetAttr;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validateGroupsInConsolidationData;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validateNestedConsolidationData;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validateNestedConsolidationDataNodeTemplateIds;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validatePortConnectivityIn;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validatePortConnectivityOut;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validatePortsInConsolidationData;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validateVolumeInConsolidationData;
+
public class BaseResourceTranslationTest {
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/DependsOnResourceBaseTranslationlTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/DependsOnResourceBaseTranslationlTest.java
index 117dd0c..9c4c3a4 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/DependsOnResourceBaseTranslationlTest.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/DependsOnResourceBaseTranslationlTest.java
@@ -20,6 +20,12 @@
package org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation;
+import org.junit.Before;
+import org.junit.Test;
+import org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataValidationType;
+
+import java.io.IOException;
+
import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_DEPENDS_ON_INVALID_DEPENDENCY_CANDIDATE;
import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_DEPENDS_ON_MULTIPLE_COMPUTE;
import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_DEPENDS_ON_NODES_CONNECTED_IN;
@@ -28,12 +34,6 @@
import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_DEPENDS_ON_NODE_TEMPLATE_TRANSLATION_ORDER_INVARIANCE;
import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_DEPENDS_ON_NO_DEPENDENCY;
-import org.junit.Before;
-import org.junit.Test;
-import org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataValidationType;
-
-import java.io.IOException;
-
public class DependsOnResourceBaseTranslationlTest extends BaseResourceTranslationTest {
@Override
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationCinderVolumeAttachmentImplTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationCinderVolumeAttachmentImplTest.java
index 786b613..637b131 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationCinderVolumeAttachmentImplTest.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationCinderVolumeAttachmentImplTest.java
@@ -20,15 +20,15 @@
package org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_VOLUME_NEGATIVE;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_VOLUME_POSITIVE;
-
import org.junit.Before;
import org.junit.Test;
import org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataValidationType;
import java.io.IOException;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_VOLUME_NEGATIVE;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_VOLUME_POSITIVE;
+
public class ResourceTranslationCinderVolumeAttachmentImplTest extends BaseResourceTranslationTest {
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailV2VmInterfaceImplTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailV2VmInterfaceImplTest.java
index 3e69ed1..74a6ce5 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailV2VmInterfaceImplTest.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailV2VmInterfaceImplTest.java
@@ -20,14 +20,14 @@
package org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_CONNECTIVITY_POSITIVE;
-
import org.junit.Before;
import org.junit.Test;
import org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataValidationType;
import java.io.IOException;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_CONNECTIVITY_POSITIVE;
+
/**
* @author Avrahamg
* @since August 10, 2016
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNeutronPortImplTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNeutronPortImplTest.java
index 854a263..97a59c3 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNeutronPortImplTest.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNeutronPortImplTest.java
@@ -20,14 +20,14 @@
package org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_CONNECTIVITY_POSITIVE;
-
import org.junit.Before;
import org.junit.Test;
import org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataValidationType;
import java.io.IOException;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_CONNECTIVITY_POSITIVE;
+
public class ResourceTranslationNeutronPortImplTest extends BaseResourceTranslationTest {
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerGroupsImplTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerGroupsImplTest.java
index 03b9402..6767db4 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerGroupsImplTest.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerGroupsImplTest.java
@@ -20,14 +20,14 @@
package org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_GROUP_POSITIVE;
-
import org.junit.Before;
import org.junit.Test;
import org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataValidationType;
import java.io.IOException;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants.TEST_GROUP_POSITIVE;
+
public class ResourceTranslationNovaServerGroupsImplTest extends BaseResourceTranslationTest {
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/SecurityRulesToPortResourceConnectionTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/SecurityRulesToPortResourceConnectionTest.java
index 724f624..15bf0f2 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/SecurityRulesToPortResourceConnectionTest.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/SecurityRulesToPortResourceConnectionTest.java
@@ -20,14 +20,14 @@
package org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation;
-import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validateNestedNodesConnectedInSecurityRuleToPort;
-
import org.junit.Before;
import org.junit.Test;
import org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.TestConstants;
import java.io.IOException;
+import static org.openecomp.sdc.translator.services.heattotosca.buildconsolidationdata.ConsolidationDataTestUtil.validateNestedNodesConnectedInSecurityRuleToPort;
+
public class SecurityRulesToPortResourceConnectionTest extends BaseResourceTranslationTest {
@Override
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/GlobalValidationContext.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/GlobalValidationContext.java
index bc401d4..97da6ef 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/GlobalValidationContext.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/GlobalValidationContext.java
@@ -22,9 +22,9 @@
import org.apache.commons.collections4.CollectionUtils;
import org.openecomp.core.validation.ErrorMessageCode;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
-import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.logging.context.MdcUtil;
import org.openecomp.sdc.logging.types.LoggerConstants;
import org.openecomp.sdc.logging.types.LoggerErrorCode;
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/java/org/openecomp/sdc/validation/impl/ValidationManagerImpl.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/java/org/openecomp/sdc/validation/impl/ValidationManagerImpl.java
index acb4eed..2f5a8ce 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/java/org/openecomp/sdc/validation/impl/ValidationManagerImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/main/java/org/openecomp/sdc/validation/impl/ValidationManagerImpl.java
@@ -21,13 +21,13 @@
package org.openecomp.sdc.validation.impl;
import org.apache.commons.collections4.CollectionUtils;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.core.validation.api.ValidationManager;
-import org.openecomp.sdc.validation.Validator;
import org.openecomp.core.validation.types.GlobalValidationContext;
import org.openecomp.core.validation.types.MessageContainer;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+import org.openecomp.sdc.validation.Validator;
import org.openecomp.sdc.validation.services.ValidationFactory;
import java.util.HashMap;
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/test/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/test/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerTest.java
index e3464db..e5d1a88 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/test/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/test/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerTest.java
@@ -20,7 +20,6 @@
package org.openecomp.sdc.heat.services.tree;
-import org.openecomp.config.ConfigurationUtils;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.sdc.heat.datatypes.structure.HeatStructureTree;
@@ -33,9 +32,6 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Collectors;
public class HeatTreeManagerTest {
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/util/HeatValidationService.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/util/HeatValidationService.java
index 90750a4..e437892 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/util/HeatValidationService.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/util/HeatValidationService.java
@@ -17,13 +17,15 @@
package org.openecomp.sdc.validation.impl.util;
import org.apache.commons.collections4.CollectionUtils;
-import org.openecomp.sdc.heat.datatypes.model.*;
-import org.openecomp.sdc.tosca.services.YamlUtil;
import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
import org.openecomp.core.validation.types.GlobalValidationContext;
import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.heat.datatypes.DefinedHeatParameterTypes;
+import org.openecomp.sdc.heat.datatypes.model.Environment;
+import org.openecomp.sdc.heat.datatypes.model.HeatOrchestrationTemplate;
+import org.openecomp.sdc.heat.datatypes.model.Parameter;
+import org.openecomp.sdc.heat.datatypes.model.Resource;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
@@ -32,10 +34,18 @@
import org.openecomp.sdc.logging.types.LoggerErrorCode;
import org.openecomp.sdc.logging.types.LoggerErrorDescription;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+import org.openecomp.sdc.tosca.services.YamlUtil;
import org.openecomp.sdc.validation.impl.validators.HeatValidator;
import java.io.InputStream;
-import java.util.*;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
public class HeatValidationService {
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ContrailValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ContrailValidator.java
index 5045c80..eb23930 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ContrailValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ContrailValidator.java
@@ -22,9 +22,7 @@
import org.apache.commons.collections4.MapUtils;
import org.openecomp.core.validation.ErrorMessageCode;
-import org.openecomp.sdc.tosca.services.YamlUtil;
import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
-import org.openecomp.sdc.validation.Validator;
import org.openecomp.core.validation.types.GlobalValidationContext;
import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
@@ -39,6 +37,8 @@
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.logging.types.LoggerErrorDescription;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+import org.openecomp.sdc.tosca.services.YamlUtil;
+import org.openecomp.sdc.validation.Validator;
import org.openecomp.sdc.validation.tos.ContrailResourcesMappingTo;
import org.openecomp.sdc.validation.util.ValidationUtil;
@@ -62,7 +62,7 @@
ManifestContent manifestContent;
try {
- manifestContent = ValidationUtil.checkValidationPreCondition(globalContext);
+ manifestContent = ValidationUtil.validateManifest(globalContext);
} catch (Exception exception) {
logger.debug("",exception);
return;
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidator.java
index 2dad766..2107825 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ForbiddenResourceGuideLineValidator.java
@@ -63,7 +63,7 @@
public void validate(GlobalValidationContext globalContext) {
ManifestContent manifestContent;
try {
- manifestContent = ValidationUtil.checkValidationPreCondition(globalContext);
+ manifestContent = ValidationUtil.validateManifest(globalContext);
} catch (Exception exception) {
log.debug("",exception);
return;
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatResourceValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatResourceValidator.java
index 10cfe35..89e96ef 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatResourceValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatResourceValidator.java
@@ -14,7 +14,6 @@
import org.openecomp.sdc.heat.services.manifest.ManifestUtil;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
-import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.validation.ValidationContext;
import org.openecomp.sdc.validation.base.ResourceBaseValidator;
import org.openecomp.sdc.validation.type.ConfigConstants;
@@ -31,8 +30,7 @@
import java.util.Set;
public class HeatResourceValidator extends ResourceBaseValidator {
- public static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
- private static Logger logger = (Logger) LoggerFactory.getLogger(ResourceBaseValidator.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(ResourceBaseValidator.class);
private static final ErrorMessageCode ERROR_CODE_HTR_1 = new ErrorMessageCode("HTR1");
@Override
@@ -42,14 +40,14 @@
@Override
public ValidationContext createValidationContext(String fileName,
- String envFileName,
- HeatOrchestrationTemplate heatOrchestrationTemplate,
- GlobalValidationContext globalContext) {
+ String envFileName,
+ HeatOrchestrationTemplate heatOrchestrationTemplate,
+ GlobalValidationContext globalContext) {
ManifestContent manifestContent = new ManifestContent();
try {
- manifestContent = ValidationUtil.checkValidationPreCondition(globalContext);
+ manifestContent = ValidationUtil.validateManifest(globalContext);
} catch (Exception exception) {
- logger.debug("",exception);
+ LOGGER.debug("", exception);
}
Set<String> baseFiles = ManifestUtil.getBaseFiles(manifestContent);
String baseFileName = CollectionUtils.isEmpty(baseFiles) ? null : baseFiles.iterator().next();
@@ -58,7 +56,7 @@
ValidationUtil.checkHeatOrchestrationPreCondition(baseFileName, globalContext);
Set<String> securityGroupsNamesFromBaseFileOutputs = baseFileName == null ? new HashSet<>()
: checkForBaseFilePortsExistenceAndReturnSecurityGroupNamesFromOutputsIfNot
- (baseFileName, baseHot, globalContext);
+ (baseHot);
Map<String, Resource> resourcesMap =
heatOrchestrationTemplate.getResources() == null ? new HashMap<>()
@@ -86,7 +84,7 @@
GlobalValidationContext globalContext) {
initTypeRelationsMapFromResourcesMap
- (fileName, resourceMap, securityGroupsNamesFromBaseFileOutputs,
+ (fileName, resourceMap,
typeToPointingResourcesMap, globalContext);
initTypeRelationsMapFromOutputsMap
@@ -133,13 +131,13 @@
private void initTypeRelationsMapFromResourcesMap(String fileName,
Map<String, Resource> resourceMap,
- Set<String> securityGroupsNamesFromBaseFileOutputs,
Map<String, Map<String, Map<String, List<String>>>> typeToPointingResourcesMap,
GlobalValidationContext globalContext) {
for (Map.Entry<String, Resource> resourceEntry : resourceMap.entrySet()) {
Resource pointingResource = resourceEntry.getValue();
Map<String, Object> properties =
- pointingResource.getProperties() == null ? new HashMap<>() : pointingResource.getProperties();
+ pointingResource.getProperties() == null ? new HashMap<>()
+ : pointingResource.getProperties();
Set<String> referencedResourcesByGetResource =
getResourcesIdsPointedByCurrentResource(fileName, ResourceReferenceFunctions.GET_RESOURCE,
@@ -231,9 +229,9 @@
(pointingResourceType, new ArrayList<>());
}
- private Set<String> handleGetAttrBetweenResources(Map<String, Object> properties){
+ private Set<String> handleGetAttrBetweenResources(Map<String, Object> properties) {
Set<String> referencedResourcesByGetAttr = new HashSet<>();
- for(Map.Entry<String, Object> proprtyEntry : properties.entrySet()){
+ for (Map.Entry<String, Object> proprtyEntry : properties.entrySet()) {
referencedResourcesByGetAttr.addAll(getGetAttrReferencesInCaseOfContrail(proprtyEntry
.getValue()));
}
@@ -242,7 +240,7 @@
}
- private Set<String> getGetAttrReferencesInCaseOfContrail(Object propertyValue){
+ private Set<String> getGetAttrReferencesInCaseOfContrail(Object propertyValue) {
Object value;
Set<String> getAttrReferences = new HashSet<>();
@@ -255,11 +253,11 @@
getAttrReferences.add((String) ((List) value).get(0));
return getAttrReferences;
} else {
- logger.warn("invalid format of 'get_attr' function - " + propertyValue.toString());
+ LOGGER.warn("invalid format of 'get_attr' function - " + propertyValue.toString());
}
}
}
- }else {
+ } else {
Collection<Object> valCollection = ((Map) propertyValue).values();
for (Object entryValue : valCollection) {
getAttrReferences.addAll(getGetAttrReferencesInCaseOfContrail(entryValue));
@@ -294,8 +292,7 @@
}
private Set<String> checkForBaseFilePortsExistenceAndReturnSecurityGroupNamesFromOutputsIfNot(
- String baseFileName, HeatOrchestrationTemplate heatOrchestrationTemplate,
- GlobalValidationContext globalContext) {
+ HeatOrchestrationTemplate heatOrchestrationTemplate) {
Set<String> securityGroupsNamesFromOutputsMap = new HashSet<>();
if (heatOrchestrationTemplate != null) {
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatValidator.java
index da87a13..8064c6f 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/HeatValidator.java
@@ -23,11 +23,6 @@
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.openecomp.core.validation.ErrorMessageCode;
-import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
-import org.openecomp.sdc.logging.types.LoggerConstants;
-import org.openecomp.sdc.logging.types.LoggerErrorCode;
-import org.openecomp.sdc.tosca.services.YamlUtil;
-import org.openecomp.sdc.validation.Validator;
import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
import org.openecomp.core.validation.types.GlobalValidationContext;
import org.openecomp.sdc.common.errors.Messages;
@@ -48,13 +43,24 @@
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
+import org.openecomp.sdc.logging.types.LoggerConstants;
+import org.openecomp.sdc.logging.types.LoggerErrorCode;
import org.openecomp.sdc.logging.types.LoggerErrorDescription;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+import org.openecomp.sdc.tosca.services.YamlUtil;
+import org.openecomp.sdc.validation.Validator;
import org.openecomp.sdc.validation.impl.util.HeatValidationService;
import org.openecomp.sdc.validation.util.ValidationUtil;
import java.io.InputStream;
-import java.util.*;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
public class HeatValidator implements Validator {
public static final MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
@@ -126,91 +132,91 @@
: heatOrchestrationTemplate.getResources().values();
Collection<Output> outputsValues = heatOrchestrationTemplate.getOutputs() == null ? null
: heatOrchestrationTemplate.getOutputs().values();
- checkResourceExistenceFromResourcesMap(fileName, resourcesNames, resourcesValues,
- globalContext);
- checkResourceExistenceFromResourcesMap(fileName, resourcesNames, outputsValues,
- globalContext);
+ checkResourceExistenceFromResourcesMap(fileName, resourcesNames, resourcesValues,
+ globalContext);
+ checkResourceExistenceFromResourcesMap(fileName, resourcesNames, outputsValues,
+ globalContext);
mdcDataDebugMessage.debugExitMessage("file", fileName);
}
- private static void checkResourceExistenceFromResourcesMap(String fileName,
- Set<String> resourcesNames,
- Collection<?> valuesToSearchIn,
- GlobalValidationContext globalContext) {
+ private static void checkResourceExistenceFromResourcesMap(String fileName,
+ Set<String> resourcesNames,
+ Collection<?> valuesToSearchIn,
+ GlobalValidationContext globalContext) {
- mdcDataDebugMessage.debugEntryMessage("file", fileName);
+ mdcDataDebugMessage.debugEntryMessage("file", fileName);
- if (CollectionUtils.isNotEmpty(valuesToSearchIn)) {
- for (Object value : valuesToSearchIn) {
- if (value instanceof Resource) {
- extractResourceProperty(fileName, resourcesNames, globalContext, (Resource) value);
- } else if (value instanceof Output) {
- Output output = (Output) value;
- Object outputsValue = output.getValue();
- handleReferencedResources(fileName, outputsValue, resourcesNames,
- globalContext);
- }
- }
+ if (CollectionUtils.isNotEmpty(valuesToSearchIn)) {
+ for (Object value : valuesToSearchIn) {
+ if (value instanceof Resource) {
+ extractResourceProperty(fileName, resourcesNames, globalContext, (Resource) value);
+ } else if (value instanceof Output) {
+ Output output = (Output) value;
+ Object outputsValue = output.getValue();
+ handleReferencedResources(fileName, outputsValue, resourcesNames,
+ globalContext);
}
+ }
}
+ }
private static void extractResourceProperty(String fileName, Set<String> resourcesNames,
GlobalValidationContext globalContext,
Resource value) {
Resource resource = value;
Collection<Object> resourcePropertiesValues =
- resource.getProperties() == null ? null : resource.getProperties()
- .values();
+ resource.getProperties() == null ? null : resource.getProperties()
+ .values();
if (CollectionUtils.isNotEmpty(resourcePropertiesValues)) {
- for (Object propertyValue : resourcePropertiesValues) {
- handleReferencedResources(fileName, propertyValue, resourcesNames,
- globalContext);
- }
+ for (Object propertyValue : resourcePropertiesValues) {
+ handleReferencedResources(fileName, propertyValue, resourcesNames,
+ globalContext);
+ }
}
}
private static void handleReferencedResources(String fileName, Object valueToSearchReferencesIn,
- Set<String> resourcesNames,
- GlobalValidationContext globalContext) {
+ Set<String> resourcesNames,
+ GlobalValidationContext globalContext) {
- mdcDataDebugMessage.debugEntryMessage("file", fileName);
- globalContext.setMessageCode(ERROR_CODE_HOT_13);
- Set<String> referencedResourcesNames = HeatStructureUtil
- .getReferencedValuesByFunctionName(fileName,
- ResourceReferenceFunctions.GET_RESOURCE.getFunction(),
- valueToSearchReferencesIn, globalContext);
- if (CollectionUtils.isNotEmpty(referencedResourcesNames)) {
- checkIfResourceReferenceExist(fileName, resourcesNames, referencedResourcesNames,
- globalContext);
- }
-
- mdcDataDebugMessage.debugExitMessage("file", fileName);
+ mdcDataDebugMessage.debugEntryMessage("file", fileName);
+ globalContext.setMessageCode(ERROR_CODE_HOT_13);
+ Set<String> referencedResourcesNames = HeatStructureUtil
+ .getReferencedValuesByFunctionName(fileName,
+ ResourceReferenceFunctions.GET_RESOURCE.getFunction(),
+ valueToSearchReferencesIn, globalContext);
+ if (CollectionUtils.isNotEmpty(referencedResourcesNames)) {
+ checkIfResourceReferenceExist(fileName, resourcesNames, referencedResourcesNames,
+ globalContext);
}
- private static void checkIfResourceReferenceExist(String fileName,
- Set<String> referencedResourcesNames,
- Set<String> referencedResources,
- GlobalValidationContext globalContext) {
+ mdcDataDebugMessage.debugExitMessage("file", fileName);
+ }
+
+ private static void checkIfResourceReferenceExist(String fileName,
+ Set<String> referencedResourcesNames,
+ Set<String> referencedResources,
+ GlobalValidationContext globalContext) {
- mdcDataDebugMessage.debugEntryMessage("file", fileName);
+ mdcDataDebugMessage.debugEntryMessage("file", fileName);
- referencedResources.stream()
- .filter(referencedResource -> !referencedResourcesNames.contains(referencedResource))
- .forEach(referencedResource -> {
- globalContext.addMessage(fileName,
- ErrorLevel.ERROR, ErrorMessagesFormatBuilder
- .getErrorWithParameters(ERROR_CODE_HOT_16,Messages
- .REFERENCED_RESOURCE_NOT_FOUND.getErrorMessage(), referencedResource),
- LoggerTragetServiceName.VALIDATE_RESOURCE_REFERENCE_EXISTENCE,
- LoggerErrorDescription.RESOURCE_NOT_FOUND);
- });
+ referencedResources.stream()
+ .filter(referencedResource -> !referencedResourcesNames.contains(referencedResource))
+ .forEach(referencedResource -> {
+ globalContext.addMessage(fileName,
+ ErrorLevel.ERROR, ErrorMessagesFormatBuilder
+ .getErrorWithParameters(ERROR_CODE_HOT_16,Messages
+ .REFERENCED_RESOURCE_NOT_FOUND.getErrorMessage(), referencedResource),
+ LoggerTragetServiceName.VALIDATE_RESOURCE_REFERENCE_EXISTENCE,
+ LoggerErrorDescription.RESOURCE_NOT_FOUND);
+ });
- mdcDataDebugMessage.debugExitMessage("file", fileName);
- }
+ mdcDataDebugMessage.debugExitMessage("file", fileName);
+ }
/* validation 16 */
@@ -294,79 +300,79 @@
mdcDataDebugMessage.debugExitMessage("file", fileName);
}
- private static void loopOverOutputMapAndValidateGetAttrFromNested(String fileName,
- Map<String, Output> outputMap,
- HeatOrchestrationTemplate
- heatOrchestrationTemplate,
- GlobalValidationContext
- globalContext) {
- for (Output output : outputMap.values()) {
- Object outputValue = output.getValue();
- if (outputValue != null && outputValue instanceof Map) {
- Map<String, Object> outputValueMap = (Map<String, Object>) outputValue;
- List<String> getAttrValue =
- (List<String>) outputValueMap.get(
- ResourceReferenceFunctions.GET_ATTR.getFunction());
- if (!CollectionUtils.isEmpty(getAttrValue)) {
- String resourceName = getAttrValue.get(0);
- Object attNameObject = getAttrValue.get(1);
- if (!(attNameObject instanceof String)) {
- return;
- }
- String attName = getAttrValue.get(1);
- String resourceType =
- getResourceTypeFromResourcesMap(resourceName, heatOrchestrationTemplate);
-
- if (Objects.nonNull(resourceType)
- && HeatValidationService.isNestedResource(resourceType)) {
- handleGetAttrNestedResource(fileName, globalContext, resourceName, attName,
- resourceType);
- }
- }
- }
- }
- }
-
- private static void handleGetAttrNestedResource(String fileName,
- GlobalValidationContext globalContext,
- String resourceName, String attName,
- String resourceType) {
- Map<String, Output> nestedOutputMap;
- HeatOrchestrationTemplate nestedHeatOrchestrationTemplate;
- try {
- Optional<InputStream> fileContent = globalContext.getFileContent(resourceType);
- if (fileContent.isPresent()) {
- nestedHeatOrchestrationTemplate =
- new YamlUtil().yamlToObject(fileContent.get(), HeatOrchestrationTemplate.class);
- } else {
- MdcDataErrorMessage
- .createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
- LoggerTragetServiceName.VALIDATE_GET_ATTR_FROM_NESTED,
- ErrorLevel.ERROR.name(), LoggerErrorCode.DATA_ERROR.getErrorCode(),
- LoggerErrorDescription.EMPTY_FILE);
- throw new Exception("The file '" + resourceType + "' has no content");
- }
- } catch (Exception exception) {
- logger.debug("",exception);
+ private static void loopOverOutputMapAndValidateGetAttrFromNested(String fileName,
+ Map<String, Output> outputMap,
+ HeatOrchestrationTemplate
+ heatOrchestrationTemplate,
+ GlobalValidationContext
+ globalContext) {
+ for (Output output : outputMap.values()) {
+ Object outputValue = output.getValue();
+ if (outputValue != null && outputValue instanceof Map) {
+ Map<String, Object> outputValueMap = (Map<String, Object>) outputValue;
+ List<String> getAttrValue =
+ (List<String>) outputValueMap.get(
+ ResourceReferenceFunctions.GET_ATTR.getFunction());
+ if (!CollectionUtils.isEmpty(getAttrValue)) {
+ String resourceName = getAttrValue.get(0);
+ Object attNameObject = getAttrValue.get(1);
+ if (!(attNameObject instanceof String)) {
return;
- }
- nestedOutputMap = nestedHeatOrchestrationTemplate.getOutputs();
+ }
+ String attName = getAttrValue.get(1);
+ String resourceType =
+ getResourceTypeFromResourcesMap(resourceName, heatOrchestrationTemplate);
- if (MapUtils.isEmpty(nestedOutputMap) || !nestedOutputMap.containsKey(attName)) {
- globalContext.addMessage(fileName, ErrorLevel.ERROR, ErrorMessagesFormatBuilder
- .getErrorWithParameters(ERROR_CODE_HOT_17,Messages.
- GET_ATTR_NOT_FOUND.getErrorMessage(),
- attName, resourceName),
- LoggerTragetServiceName.VALIDATE_GET_ATTR_FROM_NESTED,
- LoggerErrorDescription.GET_ATTR_NOT_FOUND);
+ if (Objects.nonNull(resourceType)
+ && HeatValidationService.isNestedResource(resourceType)) {
+ handleGetAttrNestedResource(fileName, globalContext, resourceName, attName,
+ resourceType);
+ }
}
+ }
}
+ }
- private static String getResourceTypeFromResourcesMap(String resourceName,
- HeatOrchestrationTemplate
- heatOrchestrationTemplate) {
- return heatOrchestrationTemplate.getResources().get(resourceName).getType();
+ private static void handleGetAttrNestedResource(String fileName,
+ GlobalValidationContext globalContext,
+ String resourceName, String attName,
+ String resourceType) {
+ Map<String, Output> nestedOutputMap;
+ HeatOrchestrationTemplate nestedHeatOrchestrationTemplate;
+ try {
+ Optional<InputStream> fileContent = globalContext.getFileContent(resourceType);
+ if (fileContent.isPresent()) {
+ nestedHeatOrchestrationTemplate =
+ new YamlUtil().yamlToObject(fileContent.get(), HeatOrchestrationTemplate.class);
+ } else {
+ MdcDataErrorMessage
+ .createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
+ LoggerTragetServiceName.VALIDATE_GET_ATTR_FROM_NESTED,
+ ErrorLevel.ERROR.name(), LoggerErrorCode.DATA_ERROR.getErrorCode(),
+ LoggerErrorDescription.EMPTY_FILE);
+ throw new Exception("The file '" + resourceType + "' has no content");
+ }
+ } catch (Exception exception) {
+ logger.debug("",exception);
+ return;
}
+ nestedOutputMap = nestedHeatOrchestrationTemplate.getOutputs();
+
+ if (MapUtils.isEmpty(nestedOutputMap) || !nestedOutputMap.containsKey(attName)) {
+ globalContext.addMessage(fileName, ErrorLevel.ERROR, ErrorMessagesFormatBuilder
+ .getErrorWithParameters(ERROR_CODE_HOT_17,Messages.
+ GET_ATTR_NOT_FOUND.getErrorMessage(),
+ attName, resourceName),
+ LoggerTragetServiceName.VALIDATE_GET_ATTR_FROM_NESTED,
+ LoggerErrorDescription.GET_ATTR_NOT_FOUND);
+ }
+ }
+
+ private static String getResourceTypeFromResourcesMap(String resourceName,
+ HeatOrchestrationTemplate
+ heatOrchestrationTemplate) {
+ return heatOrchestrationTemplate.getResources().get(resourceName).getType();
+ }
/* validation 17 + */
private static void validateEnvFile(String fileName, String envFileName,
@@ -416,7 +422,7 @@
if (parametersNames != null && !parametersNames.contains(envParameter)) {
globalContext.addMessage(envFile, ErrorLevel.ERROR, ErrorMessagesFormatBuilder
.getErrorWithParameters(
- ERROR_CODE_HOT_3,Messages.
+ ERROR_CODE_HOT_3,Messages.
ENV_INCLUDES_PARAMETER_NOT_IN_HEAT.getErrorMessage(), envFile,
envParameter), LoggerTragetServiceName.VALIDATE_ENV_FILE,
LoggerErrorDescription.ENV_PARAMETER_NOT_IN_HEAT);
@@ -459,7 +465,7 @@
if (!isValueMatchDefault) {
globalContext.addMessage(fileName, ErrorLevel.ERROR, ErrorMessagesFormatBuilder
.getErrorWithParameters(
- ERROR_CODE_HOT_4,Messages.
+ ERROR_CODE_HOT_4,Messages.
PARAMETER_DEFAULT_VALUE_NOT_ALIGN_WITH_TYPE.getErrorMessage(),
parameterEntry.getKey(), parameterType),
LoggerTragetServiceName.VALIDATE_PARAMTER_DEFAULT_MATCH_TYPE,
@@ -495,7 +501,7 @@
.isValueIsFromGivenType(parameterEnvValue, parameterType)) {
globalContext.addMessage(envFile, ErrorLevel.ERROR, ErrorMessagesFormatBuilder
.getErrorWithParameters(
- ERROR_CODE_HOT_5,Messages.
+ ERROR_CODE_HOT_5,Messages.
PARAMETER_ENV_VALUE_NOT_ALIGN_WITH_TYPE.getErrorMessage(),
parameterName), LoggerTragetServiceName.VALIDATE_ENV_PARAMETER_MATCH_TYPE,
LoggerErrorDescription.PARAMETER_DEFAULT_VALUE_NOT_ALIGNED_WITH_TYPE);
@@ -513,7 +519,7 @@
mdcDataDebugMessage.debugEntryMessage(null, null);
ManifestContent manifestContent;
try {
- manifestContent = ValidationUtil.checkValidationPreCondition(globalContext);
+ manifestContent = ValidationUtil.validateManifest(globalContext);
} catch (Exception exception) {
logger.debug("",exception);
return;
@@ -546,9 +552,9 @@
.filter(fileName -> isManifestArtifact(manifestArtifacts, fileName) &&
isNotArtifact(artifacts, fileName))
.forEach(fileName -> globalContext.addMessage(fileName, ErrorLevel.WARNING,
- ErrorMessagesFormatBuilder
- .getErrorWithParameters(ERROR_CODE_HOT_11,
- Messages.ARTIFACT_FILE_NOT_REFERENCED.getErrorMessage()),
+ ErrorMessagesFormatBuilder
+ .getErrorWithParameters(ERROR_CODE_HOT_11,
+ Messages.ARTIFACT_FILE_NOT_REFERENCED.getErrorMessage()),
LoggerTragetServiceName.CHECK_FOR_ORPHAN_ARTIFACTS,
LoggerErrorDescription.ARTIFACT_NOT_REFERENCED));
@@ -567,10 +573,10 @@
private void validate(String fileName, String envFileName, String baseFileName,
Set<String> artifacts, Set<String> securityGroupsNamesFromBaseFileOutputs,
GlobalValidationContext globalContext) {
- globalContext.setMessageCode(ERROR_CODE_HOT_12);
+ globalContext.setMessageCode(ERROR_CODE_HOT_12);
HeatOrchestrationTemplate
heatOrchestrationTemplate = ValidationUtil.checkHeatOrchestrationPreCondition(
- fileName, globalContext);
+ fileName, globalContext);
if (heatOrchestrationTemplate != null) {
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ManifestValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ManifestValidator.java
index 2ad2f9a..e3a35af 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ManifestValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/ManifestValidator.java
@@ -22,7 +22,6 @@
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.core.validation.ErrorMessageCode;
-import org.openecomp.sdc.validation.Validator;
import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
import org.openecomp.core.validation.types.GlobalValidationContext;
import org.openecomp.sdc.common.errors.Messages;
@@ -38,6 +37,7 @@
import org.openecomp.sdc.logging.types.LoggerErrorCode;
import org.openecomp.sdc.logging.types.LoggerErrorDescription;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+import org.openecomp.sdc.validation.Validator;
import java.io.InputStream;
import java.util.ArrayList;
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/NamingConventionGuideLineValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/NamingConventionGuideLineValidator.java
index 724b7e4..43e8e94 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/NamingConventionGuideLineValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/NamingConventionGuideLineValidator.java
@@ -1,8 +1,8 @@
package org.openecomp.sdc.validation.impl.validators;
-import org.openecomp.sdc.validation.ValidationContext;
import org.openecomp.core.validation.types.GlobalValidationContext;
import org.openecomp.sdc.heat.datatypes.model.HeatOrchestrationTemplate;
+import org.openecomp.sdc.validation.ValidationContext;
import org.openecomp.sdc.validation.base.ResourceBaseValidator;
import org.openecomp.sdc.validation.type.ConfigConstants;
import org.openecomp.sdc.validation.type.NamingConventionValidationContext;
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidator.java
index 424f8d3..fb7d6a2 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidator.java
@@ -3,13 +3,10 @@
import org.apache.commons.collections4.CollectionUtils;
import org.openecomp.core.utilities.CommonMethods;
import org.openecomp.core.validation.ErrorMessageCode;
-import org.openecomp.sdc.common.utils.SdcCommon;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-import org.openecomp.sdc.validation.Validator;
import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
import org.openecomp.core.validation.types.GlobalValidationContext;
import org.openecomp.sdc.common.errors.Messages;
+import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.heat.datatypes.manifest.FileData;
import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
@@ -18,9 +15,12 @@
import org.openecomp.sdc.heat.datatypes.model.ResourceReferenceFunctions;
import org.openecomp.sdc.heat.services.HeatStructureUtil;
import org.openecomp.sdc.heat.services.manifest.ManifestUtil;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.logging.types.LoggerErrorDescription;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+import org.openecomp.sdc.validation.Validator;
import org.openecomp.sdc.validation.util.ValidationUtil;
import java.util.HashSet;
@@ -44,7 +44,7 @@
public void validate(GlobalValidationContext globalContext) {
ManifestContent manifestContent;
try {
- manifestContent = ValidationUtil.checkValidationPreCondition(globalContext);
+ manifestContent = ValidationUtil.validateManifest(globalContext);
} catch (Exception exception) {
log.debug("",exception);
return;
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java
index c0468f8..ab2e427 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java
@@ -21,8 +21,6 @@
package org.openecomp.sdc.validation.impl.validators;
import org.openecomp.core.validation.ErrorMessageCode;
-import org.openecomp.sdc.tosca.services.YamlUtil;
-import org.openecomp.sdc.validation.Validator;
import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
import org.openecomp.core.validation.types.GlobalValidationContext;
import org.openecomp.sdc.common.errors.Messages;
@@ -32,6 +30,8 @@
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.logging.types.LoggerErrorDescription;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+import org.openecomp.sdc.tosca.services.YamlUtil;
+import org.openecomp.sdc.validation.Validator;
import org.openecomp.sdc.validation.impl.util.YamlValidatorUtil;
import java.io.InputStream;
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerResourceValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerResourceValidator.java
index 9c9f4bc..33d20d5 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerResourceValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerResourceValidator.java
@@ -2,7 +2,6 @@
import org.apache.commons.collections4.MapUtils;
import org.openecomp.core.validation.ErrorMessageCode;
-import org.openecomp.sdc.validation.ResourceValidator;
import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
import org.openecomp.core.validation.types.GlobalValidationContext;
import org.openecomp.sdc.common.errors.Messages;
@@ -15,6 +14,7 @@
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.logging.types.LoggerErrorDescription;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+import org.openecomp.sdc.validation.ResourceValidator;
import org.openecomp.sdc.validation.ValidationContext;
import org.openecomp.sdc.validation.type.HeatResourceValidationContext;
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidator.java
index b98b6d6..795bdf0 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidator.java
@@ -1,7 +1,5 @@
package org.openecomp.sdc.validation.impl.validators.namingconvention;
-import static java.util.Objects.nonNull;
-
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
@@ -36,6 +34,8 @@
import java.util.Objects;
import java.util.TreeMap;
+import static java.util.Objects.nonNull;
+
public class NovaServerNamingConventionGuideLineValidator implements ResourceValidator {
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
private static final ErrorMessageCode ERROR_CODE_NNS1 = new ErrorMessageCode("NNS1");
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ContrailValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ContrailValidatorTest.java
index f921102..96db0fd 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ContrailValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ContrailValidatorTest.java
@@ -20,9 +20,9 @@
package org.openecomp.sdc.validation.impl.validators;
-import org.openecomp.sdc.validation.Validator;
import org.openecomp.core.validation.types.MessageContainer;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
+import org.openecomp.sdc.validation.Validator;
import org.openecomp.sdc.validation.util.ValidationTestUtil;
import org.testng.Assert;
import org.testng.annotations.Test;
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ErrorMessagesTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ErrorMessagesTest.java
index 64b3d2b..5c2c0c0 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ErrorMessagesTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/ErrorMessagesTest.java
@@ -21,10 +21,10 @@
package org.openecomp.sdc.validation.impl.validators;
import org.junit.Test;
+import org.openecomp.core.validation.ErrorMessageCode;
import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
import org.openecomp.sdc.common.errors.Messages;
import org.testng.Assert;
-import org.openecomp.core.validation.ErrorMessageCode;
public class ErrorMessagesTest {
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/HeatValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/HeatValidatorTest.java
index a523627..2ec119e 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/HeatValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/HeatValidatorTest.java
@@ -21,8 +21,8 @@
package org.openecomp.sdc.validation.impl.validators;
-import org.openecomp.sdc.validation.Validator;
import org.openecomp.core.validation.types.MessageContainer;
+import org.openecomp.sdc.validation.Validator;
import org.openecomp.sdc.validation.util.ValidationTestUtil;
import org.testng.Assert;
import org.testng.annotations.Test;
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidatorTest.java
index e7c2d37..58400b9 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/SharedResourceGuideLineValidatorTest.java
@@ -1,7 +1,7 @@
package org.openecomp.sdc.validation.impl.validators;
-import org.openecomp.sdc.validation.Validator;
import org.openecomp.core.validation.types.MessageContainer;
+import org.openecomp.sdc.validation.Validator;
import org.openecomp.sdc.validation.util.ValidationTestUtil;
import org.testng.Assert;
import org.testng.annotations.Test;
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceTemplateNamingConventionValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceTemplateNamingConventionValidatorTest.java
index 681c54b..0db8c22 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceTemplateNamingConventionValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/ContrailServiceTemplateNamingConventionValidatorTest.java
@@ -1,9 +1,8 @@
package org.openecomp.sdc.validation.impl.validators.namingconvention;
-import org.openecomp.sdc.validation.impl.validators.HeatResourceValidator;
-
import org.openecomp.core.validation.types.MessageContainer;
import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes;
+import org.openecomp.sdc.validation.impl.validators.HeatResourceValidator;
import org.openecomp.sdc.validation.util.ValidationTestUtil;
import org.testng.Assert;
import org.testng.annotations.Test;
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NeutronPortNamingConventionValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NeutronPortNamingConventionValidatorTest.java
index 1a7b608..3837f3b 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NeutronPortNamingConventionValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NeutronPortNamingConventionValidatorTest.java
@@ -1,9 +1,8 @@
package org.openecomp.sdc.validation.impl.validators.namingconvention;
-import org.openecomp.sdc.validation.impl.validators.NamingConventionGuideLineValidator;
-
import org.openecomp.core.validation.types.MessageContainer;
import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes;
+import org.openecomp.sdc.validation.impl.validators.NamingConventionGuideLineValidator;
import org.openecomp.sdc.validation.util.ValidationTestUtil;
import org.testng.Assert;
import org.testng.annotations.Test;
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/base/ResourceBaseValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/base/ResourceBaseValidator.java
index c4d6f88..68c1b74 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/base/ResourceBaseValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/base/ResourceBaseValidator.java
@@ -4,7 +4,9 @@
import org.openecomp.core.utilities.CommonMethods;
import org.openecomp.core.validation.ErrorMessageCode;
import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
+import org.openecomp.core.validation.types.GlobalValidationContext;
import org.openecomp.sdc.common.errors.Messages;
+import org.openecomp.sdc.datatypes.configuration.ImplementationConfiguration;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.heat.datatypes.manifest.FileData;
import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
@@ -12,15 +14,13 @@
import org.openecomp.sdc.heat.datatypes.model.Resource;
import org.openecomp.sdc.heat.services.HeatStructureUtil;
import org.openecomp.sdc.heat.services.manifest.ManifestUtil;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.types.LoggerErrorDescription;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
import org.openecomp.sdc.validation.ResourceValidator;
import org.openecomp.sdc.validation.ValidationContext;
import org.openecomp.sdc.validation.Validator;
-import org.openecomp.core.validation.types.GlobalValidationContext;
-import org.openecomp.sdc.datatypes.configuration.ImplementationConfiguration;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.validation.type.ConfigConstants;
import org.openecomp.sdc.validation.util.ValidationUtil;
@@ -54,7 +54,7 @@
public void validate(GlobalValidationContext globalContext) {
ManifestContent manifestContent;
try {
- manifestContent = ValidationUtil.checkValidationPreCondition(globalContext);
+ manifestContent = ValidationUtil.validateManifest(globalContext);
} catch (Exception exception) {
logger.debug("",exception);
return;
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationTestUtil.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationTestUtil.java
index 2b58a30..08a3548 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationTestUtil.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationTestUtil.java
@@ -25,7 +25,6 @@
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.StringWriter;
import java.net.URL;
@@ -97,7 +96,7 @@
String resourceTypeToValidate, String path) {
GlobalValidationContext globalContext = createGlobalContextFromPath(path);
- ManifestContent manifestContent = ValidationUtil.checkValidationPreCondition(globalContext);
+ ManifestContent manifestContent = ValidationUtil.validateManifest(globalContext);
Map<String, FileData.Type> fileTypeMap = ManifestUtil.getFileTypeMap(manifestContent);
Map<String, FileData> fileEnvMap = ManifestUtil.getFileAndItsEnv(manifestContent);
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationUtil.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationUtil.java
index d9e0351..76b4aff 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationUtil.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationUtil.java
@@ -6,6 +6,7 @@
import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
import org.openecomp.core.validation.types.GlobalValidationContext;
import org.openecomp.sdc.common.errors.Messages;
+import org.openecomp.sdc.common.errors.SdcRuntimeException;
import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
@@ -176,7 +177,7 @@
return false;
}
- public static ManifestContent checkValidationPreCondition(GlobalValidationContext globalContext) {
+ public static ManifestContent validateManifest(GlobalValidationContext globalContext) {
Optional<InputStream> manifest = globalContext.getFileContent(SdcCommon.MANIFEST_NAME);
if (!manifest.isPresent()) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
@@ -192,7 +193,7 @@
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
LoggerTragetServiceName.VALIDATE_MANIFEST_CONTENT, ErrorLevel.ERROR.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_MANIFEST);
- throw new RuntimeException("Can't load manifest file for Heat Validator");
+ throw new SdcRuntimeException("Can't load manifest file for Heat Validator");
}
return manifestContent;
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseUtil.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseUtil.java
new file mode 100644
index 0000000..3ee326a
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseUtil.java
@@ -0,0 +1,28 @@
+package org.openecomp.sdc.vendorlicense;
+
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+
+public class VendorLicenseUtil {
+
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+
+ public static String getIsoFormatDate(String inputDate) {
+ mdcDataDebugMessage.debugEntryMessage("inputDate date", inputDate);
+ String isoFormatDate = null;
+ SimpleDateFormat isoDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
+ SimpleDateFormat inputDateFormat = new SimpleDateFormat("MM/dd/yyyy'T'HH:mm:ss'Z'");
+
+ try {
+ isoFormatDate = isoDateFormat.format(inputDateFormat.parse(inputDate));
+ } catch (ParseException e) {
+ mdcDataDebugMessage.debugExitMessage("parsing error", isoFormatDate);
+ isoFormatDate = null;
+ }
+
+ mdcDataDebugMessage.debugExitMessage("formatted date", isoFormatDate);
+ return isoFormatDate;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/EntitlementPoolEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/EntitlementPoolEntity.java
index 2b7b3a6..6c4ba90 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/EntitlementPoolEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/EntitlementPoolEntity.java
@@ -26,6 +26,9 @@
import com.datastax.driver.mapping.annotations.Frozen;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
+import org.apache.commons.lang3.StringUtils;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.vendorlicense.VendorLicenseUtil;
import org.openecomp.sdc.vendorlicense.dao.types.xml.LimitForXml;
import org.openecomp.sdc.vendorlicense.dao.types.xml.LimitXml;
import org.openecomp.sdc.vendorlicense.dao.types.xml.OperationalScopeForXml;
@@ -40,6 +43,8 @@
@Table(keyspace = "dox", name = "entitlement_pool")
public class EntitlementPoolEntity implements VersionableEntity {
+
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
private static final String ENTITY_TYPE = "Entitlement Pool";
@PartitionKey
@@ -201,7 +206,7 @@
}
public void setOperationalScope(MultiChoiceOrOther<OperationalScope> operationalScope) {
- if(operationalScope != null) {
+ if (operationalScope != null) {
operationalScope.resolveEnum(OperationalScope.class);
}
this.operationalScope = operationalScope;
@@ -220,7 +225,8 @@
}
/**
- * Gets version for artifact.
+ * Gets version for artifact.
+ *
* @return version in format suitable for artifact
*/
public String getVersionForArtifact() {
@@ -251,17 +257,18 @@
this.limits = limits;
}
- public LimitForXml getSPLimits(){
- if(limits != null){
+ public LimitForXml getSPLimits() {
+ if (limits != null) {
Set<LimitXml> hs = new HashSet<>();
- for(LimitEntity obj : limits){
- if(obj.getType().equals(LimitType.ServiceProvider)){
+ for (LimitEntity obj : limits) {
+ if (obj.getType().equals(LimitType.ServiceProvider)) {
LimitXml xmlObj = new LimitXml();
xmlObj.setDescription(obj.getDescription());
xmlObj.setMetric(obj.getMetric());
xmlObj.setValues(obj.getValue());
xmlObj.setUnit(obj.getUnit());
- xmlObj.setAggregationFunction(obj.getAggregationFunction()!=null?obj.getAggregationFunction().name():null);
+ xmlObj.setAggregationFunction(
+ obj.getAggregationFunction() != null ? obj.getAggregationFunction().name() : null);
xmlObj.setTime(obj.getTime());
hs.add(xmlObj);
}
@@ -274,17 +281,18 @@
return null;
}
- public LimitForXml getVendorLimits(){
- if(limits != null){
+ public LimitForXml getVendorLimits() {
+ if (limits != null) {
Set<LimitXml> hs = new HashSet<>();
- for(LimitEntity obj : limits){
- if(obj.getType().equals(LimitType.Vendor)){
+ for (LimitEntity obj : limits) {
+ if (obj.getType().equals(LimitType.Vendor)) {
LimitXml xmlObj = new LimitXml();
xmlObj.setDescription(obj.getDescription());
xmlObj.setMetric(obj.getMetric());
xmlObj.setValues(obj.getValue());
xmlObj.setUnit(obj.getUnit());
- xmlObj.setAggregationFunction(obj.getAggregationFunction()!=null?obj.getAggregationFunction().name():null);
+ xmlObj.setAggregationFunction(
+ obj.getAggregationFunction() != null ? obj.getAggregationFunction().name() : null);
xmlObj.setTime(obj.getTime());
hs.add(xmlObj);
}
@@ -324,7 +332,9 @@
&& Objects.equals(operationalScope, that.operationalScope)
&& Objects.equals(referencingFeatureGroups, that.referencingFeatureGroups)
&& Objects.equals(startDate, that.startDate)
- && Objects.equals(expiryDate, that.expiryDate);
+ && Objects.equals(expiryDate, that.expiryDate)
+ && Objects.equals(manufacturerReferenceNumber, that.manufacturerReferenceNumber)
+ && Objects.equals(version, that.version);
}
@Override
@@ -354,7 +364,7 @@
public OperationalScopeForXml getOperationalScopeForArtifact() {
OperationalScopeForXml obj = new OperationalScopeForXml();
if (operationalScope != null) {
- if(operationalScope.getResults().size() > 0) {
+ if (operationalScope.getResults().size() > 0) {
obj.setValue(operationalScope.getResults());
}
}
@@ -369,4 +379,27 @@
public String getManufacturerReferenceNumber() {
return manufacturerReferenceNumber;
}
+
+ public String getIsoFormatStartDate() {
+ mdcDataDebugMessage.debugEntryMessage("start date", startDate);
+ String isoFormatStartDate = null;
+ if (!StringUtils.isEmpty(startDate)) {
+ isoFormatStartDate = VendorLicenseUtil.getIsoFormatDate(startDate);
+ mdcDataDebugMessage.debugExitMessage("start date", "iso format start date", startDate,
+ isoFormatStartDate);
+ }
+ return isoFormatStartDate;
+ }
+
+
+ public String getIsoFormatExpiryDate() {
+ mdcDataDebugMessage.debugEntryMessage("expiry date", expiryDate);
+ String isoFormatExpDate = null;
+ if (!StringUtils.isEmpty(expiryDate)) {
+ isoFormatExpDate = VendorLicenseUtil.getIsoFormatDate(expiryDate);
+ mdcDataDebugMessage.debugExitMessage("expiry date", "iso format expiry date", expiryDate,
+ isoFormatExpDate);
+ }
+ return isoFormatExpDate;
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseKeyGroupEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseKeyGroupEntity.java
index 364a240..7794aaf 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseKeyGroupEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseKeyGroupEntity.java
@@ -26,9 +26,12 @@
import com.datastax.driver.mapping.annotations.Frozen;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
+import org.apache.commons.lang3.StringUtils;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.vendorlicense.VendorLicenseUtil;
import org.openecomp.sdc.vendorlicense.dao.types.xml.LicenseKeyTypeForXml;
-import org.openecomp.sdc.vendorlicense.dao.types.xml.LimitXml;
import org.openecomp.sdc.vendorlicense.dao.types.xml.LimitForXml;
+import org.openecomp.sdc.vendorlicense.dao.types.xml.LimitXml;
import org.openecomp.sdc.vendorlicense.dao.types.xml.OperationalScopeForXml;
import org.openecomp.sdc.vendorlicense.dao.types.xml.ThresholdForXml;
import org.openecomp.sdc.versioning.dao.types.Version;
@@ -41,6 +44,8 @@
@Table(keyspace = "dox", name = "license_key_group")
public class LicenseKeyGroupEntity implements VersionableEntity {
+
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
private static final String ENTITY_TYPE = "License Key Group";
@PartitionKey
@@ -164,7 +169,7 @@
}
public void setOperationalScope(MultiChoiceOrOther<OperationalScope> operationalScope) {
- if(operationalScope != null) {
+ if (operationalScope != null) {
operationalScope.resolveEnum(OperationalScope.class);
}
this.operationalScope = operationalScope;
@@ -217,17 +222,18 @@
this.limits = limits;
}
- public LimitForXml getSPLimits(){
- if(limits != null){
+ public LimitForXml getSPLimits() {
+ if (limits != null) {
Set<LimitXml> hs = new HashSet<>();
- for(LimitEntity obj : limits){
- if(obj.getType().equals(LimitType.ServiceProvider)){
+ for (LimitEntity obj : limits) {
+ if (obj.getType().equals(LimitType.ServiceProvider)) {
LimitXml xmlObj = new LimitXml();
xmlObj.setDescription(obj.getDescription());
xmlObj.setMetric(obj.getMetric());
xmlObj.setValues(obj.getValue());
xmlObj.setUnit(obj.getUnit());
- xmlObj.setAggregationFunction(obj.getAggregationFunction()!=null?obj.getAggregationFunction().name():null);
+ xmlObj.setAggregationFunction(
+ obj.getAggregationFunction() != null ? obj.getAggregationFunction().name() : null);
xmlObj.setTime(obj.getTime());
hs.add(xmlObj);
}
@@ -240,17 +246,18 @@
return null;
}
- public LimitForXml getVendorLimits(){
- if(limits != null){
+ public LimitForXml getVendorLimits() {
+ if (limits != null) {
Set<LimitXml> hs = new HashSet<>();
- for(LimitEntity obj : limits){
- if(obj.getType().equals(LimitType.Vendor)){
+ for (LimitEntity obj : limits) {
+ if (obj.getType().equals(LimitType.Vendor)) {
LimitXml xmlObj = new LimitXml();
xmlObj.setDescription(obj.getDescription());
xmlObj.setMetric(obj.getMetric());
xmlObj.setValues(obj.getValue());
xmlObj.setUnit(obj.getUnit());
- xmlObj.setAggregationFunction(obj.getAggregationFunction()!=null?obj.getAggregationFunction().name():null);
+ xmlObj.setAggregationFunction(
+ obj.getAggregationFunction() != null ? obj.getAggregationFunction().name() : null);
xmlObj.setTime(obj.getTime());
hs.add(xmlObj);
}
@@ -297,6 +304,7 @@
}
LicenseKeyGroupEntity that = (LicenseKeyGroupEntity) obj;
return Objects.equals(vendorLicenseModelId, that.vendorLicenseModelId)
+ && Objects.equals(version, that.version)
&& Objects.equals(id, that.id)
&& Objects.equals(name, that.name)
&& Objects.equals(description, that.description)
@@ -307,7 +315,8 @@
&& Objects.equals(expiryDate, that.expiryDate)
&& Objects.equals(thresholdValue, that.thresholdValue)
&& Objects.equals(thresholdUnits, that.thresholdUnits)
- && Objects.equals(increments, that.increments);
+ && Objects.equals(increments, that.increments)
+ && Objects.equals(manufacturerReferenceNumber, that.manufacturerReferenceNumber);
}
@Override
@@ -337,7 +346,7 @@
public OperationalScopeForXml getOperationalScopeForArtifact() {
OperationalScopeForXml obj = new OperationalScopeForXml();
if (operationalScope != null) {
- if(operationalScope.getResults().size() > 0) {
+ if (operationalScope.getResults().size() > 0) {
obj.setValue(operationalScope.getResults());
}
}
@@ -346,6 +355,7 @@
/**
* Gets version for artifact.
+ *
* @return version in format suitable for artifact
*/
public String getVersionForArtifact() {
@@ -375,4 +385,29 @@
public void setManufacturerReferenceNumber(String manufacturerReferenceNumber) {
this.manufacturerReferenceNumber = manufacturerReferenceNumber;
}
+
+ public String getIsoFormatStartDate() {
+ mdcDataDebugMessage.debugEntryMessage("start date", startDate);
+ String isoFormatStartDate = null;
+ if (!StringUtils.isEmpty(startDate)) {
+ isoFormatStartDate = VendorLicenseUtil.getIsoFormatDate(startDate);
+ mdcDataDebugMessage.debugExitMessage("start date", "iso format start date", startDate,
+ isoFormatStartDate);
+ }
+ return isoFormatStartDate;
+ }
+
+
+ public String getIsoFormatExpiryDate() {
+ mdcDataDebugMessage.debugEntryMessage("expiry date", expiryDate);
+ String isoFormatExpDate = null;
+ if (!StringUtils.isEmpty(expiryDate)) {
+ isoFormatExpDate = VendorLicenseUtil.getIsoFormatDate(expiryDate);
+ mdcDataDebugMessage.debugExitMessage("expiry date", "iso format expiry date", expiryDate,
+ isoFormatExpDate);
+ }
+ return isoFormatExpDate;
+ }
+
+
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LimitEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LimitEntity.java
index 58ccd5e..0860c24 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LimitEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LimitEntity.java
@@ -47,7 +47,7 @@
}
public void setAggregationFunction(
- AggregationFunction aggregationFunction) {
+ AggregationFunction aggregationFunction) {
this.aggregationFunction = aggregationFunction;
}
@@ -159,7 +159,7 @@
@Override
public int hashCode() {
return Objects.hash(vendorLicenseModelId, version, epLkgId, id, name, description, type,
- metric, unit, time, aggregationFunction, value);
+ metric, unit, time, aggregationFunction, value);
}
@Override
@@ -172,35 +172,35 @@
}
LimitEntity that = (LimitEntity) obj;
return Objects.equals(that.unit, unit)
- && Objects.equals(that.value, value)
- && Objects.equals(vendorLicenseModelId, that.vendorLicenseModelId)
- && Objects.equals(epLkgId, that.epLkgId)
- && Objects.equals(id, that.id)
- && Objects.equals(name, that.name)
- && Objects.equals(description, that.description)
- && Objects.equals(type, that.type)
- && Objects.equals(metric, that.metric)
- && Objects.equals(aggregationFunction, that.aggregationFunction);
+ && Objects.equals(that.value, value)
+ && Objects.equals(vendorLicenseModelId, that.vendorLicenseModelId)
+ && Objects.equals(epLkgId, that.epLkgId)
+ && Objects.equals(id, that.id)
+ && Objects.equals(name, that.name)
+ && Objects.equals(description, that.description)
+ && Objects.equals(type, that.type)
+ && Objects.equals(metric, that.metric)
+ && Objects.equals(aggregationFunction, that.aggregationFunction);
}
@Override
public String toString() {
return "LimitEntity{"
- + "vendorLicenseModelId='" + vendorLicenseModelId + '\''
- + ", version=" + version
- + ", epLkgId=" + epLkgId
- + ", id='" + id + '\''
- + ", name='" + name + '\''
- + ", description='" + description + '\''
- + ", type=" + type
- + ", metric=" + metric
- + ", value='" + value + '\''
- + ", unit='" + unit + '\''
- + ", aggregationFunction=" + aggregationFunction
- + ", time=" + time
+ + "vendorLicenseModelId='" + vendorLicenseModelId + '\''
+ + ", version=" + version
+ + ", epLkgId=" + epLkgId
+ + ", id='" + id + '\''
+ + ", name='" + name + '\''
+ + ", description='" + description + '\''
+ + ", type=" + type
+ + ", metric=" + metric
+ + ", value='" + value + '\''
+ + ", unit='" + unit + '\''
+ + ", aggregationFunction=" + aggregationFunction
+ + ", time=" + time
- + '}';
+ + '}';
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/VendorLicenseModelEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/VendorLicenseModelEntity.java
index b57b850..05cc78f 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/VendorLicenseModelEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/VendorLicenseModelEntity.java
@@ -45,6 +45,7 @@
@Column(name = "vendor_name")
private String vendorName;
private String description;
+ private String oldVersion;
@Column(name = "icon")
private String iconRef;
@@ -111,6 +112,15 @@
this.iconRef = iconRef;
}
+ public void setOldVersion(String oldVersion) {
+ this.oldVersion = oldVersion;
+ }
+
+ public String getOldVersion() {
+ return oldVersion;
+ }
+
+
@Override
public int hashCode() {
return Objects.hash(id, version, vendorName, description, iconRef);
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/facade/VendorLicenseFacade.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/facade/VendorLicenseFacade.java
index 3d27de3..dda42ee 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/facade/VendorLicenseFacade.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/facade/VendorLicenseFacade.java
@@ -29,72 +29,52 @@
import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity;
import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
-import org.openecomp.sdc.vendorlicense.types.VersionedVendorLicenseModel;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.VersionInfo;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
import java.util.Collection;
public interface VendorLicenseFacade {
- Version checkin(String vendorLicenseModelId, String user);
-
- Version submit(String vendorLicenseModelId, String user);
-
- FeatureGroupEntity getFeatureGroup(FeatureGroupEntity featureGroup, String user);
-
- FeatureGroupModel getFeatureGroupModel(FeatureGroupEntity featureGroup, String user);
-
LicenseAgreementEntity getLicenseAgreement(String vlmId, Version version,
- String licenseAgreementId, String user);
+ String licenseAgreementId);
LicenseAgreementModel getLicenseAgreementModel(String vlmId, Version version,
- String licenseAgreementId, String user);
+ String licenseAgreementId);
- EntitlementPoolEntity createEntitlementPool(EntitlementPoolEntity entitlementPool, String user);
+ LicenseAgreementEntity createLicenseAgreement(LicenseAgreementEntity licenseAgreement);
- void updateEntitlementPool(EntitlementPoolEntity entitlementPool, String user);
+ Collection<FeatureGroupEntity> listFeatureGroups(String vlmId, Version version);
- Collection<LicenseKeyGroupEntity> listLicenseKeyGroups(String vlmId, Version version,
- String user);
+ FeatureGroupEntity getFeatureGroup(FeatureGroupEntity featureGroup);
- Collection<EntitlementPoolEntity> listEntitlementPools(String vlmId, Version version,
- String user);
+ FeatureGroupModel getFeatureGroupModel(FeatureGroupEntity featureGroup);
- void updateLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user);
+ FeatureGroupEntity createFeatureGroup(FeatureGroupEntity featureGroup);
- LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user);
+ Collection<EntitlementPoolEntity> listEntitlementPools(String vlmId, Version version);
+ EntitlementPoolEntity createEntitlementPool(EntitlementPoolEntity entitlementPool);
- VersionedVendorLicenseModel getVendorLicenseModel(String vlmId, Version version, String user);
+ void updateEntitlementPool(EntitlementPoolEntity entitlementPool);
- VendorLicenseModelEntity createVendorLicenseModel(
- VendorLicenseModelEntity vendorLicenseModelEntity, String user);
+ Collection<LicenseKeyGroupEntity> listLicenseKeyGroups(String vlmId, Version version);
+ LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup);
- LicenseAgreementEntity createLicenseAgreement(LicenseAgreementEntity licenseAgreement,
- String user);
+ void updateLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup);
- Collection<FeatureGroupEntity> listFeatureGroups(String vlmId, Version version,
- String user);
+ Collection<LimitEntity> listLimits(String vlmId, Version version, String epLkgId);
- FeatureGroupEntity createFeatureGroup(FeatureGroupEntity featureGroup, String user);
+ LimitEntity createLimit(LimitEntity limit);
+
+ void updateLimit(LimitEntity limit);
+
+ VendorLicenseModelEntity getVendorLicenseModel(String vlmId, Version version);
Collection<ErrorCode> validateLicensingData(String vlmId, Version vlmVersion,
String licenseAgreementId,
Collection<String> featureGroupIds);
- VersionInfo getVersionInfo(String vendorLicenseModelId, VersionableEntityAction action,
- String user);
-
- void updateVlmLastModificationTime(String vendorLicenseModelId, Version version);
-
- LimitEntity createLimit(LimitEntity limit, String user);
-
- Collection<LimitEntity> listLimits(String vlmId, Version version, String epLkgId
- ,String user);
-
- void updateLimit(LimitEntity limit, String user);
+ void validate(String vendorLicenseModelId, Version version);
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/healing/HealingService.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/healing/HealingService.java
index 6ae2de1..a3a5b72 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/healing/HealingService.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/healing/HealingService.java
@@ -24,7 +24,7 @@
public interface HealingService {
- VersionableEntity heal(VersionableEntity toHeal, String user);
+ VersionableEntity heal(VersionableEntity toHeal);
void persistNoHealing(VersionableEntity alreadyHealed);
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/VendorLicenseArtifactsService.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/VendorLicenseArtifactsService.java
index c0610a9..66ac7ab 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/VendorLicenseArtifactsService.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/VendorLicenseArtifactsService.java
@@ -28,5 +28,5 @@
public interface VendorLicenseArtifactsService {
FileContentHandler createLicenseArtifacts(String vspId, String vlmId, Version vlmVersion,
- List<String> featureGroups, String user);
+ List<String> featureGroups);
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/FeatureGroupCassandraDaoImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/FeatureGroupCassandraDaoImpl.java
index 2568d71..dd22397 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/FeatureGroupCassandraDaoImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/FeatureGroupCassandraDaoImpl.java
@@ -20,8 +20,6 @@
package org.openecomp.sdc.vendorlicense.dao.impl;
-import static org.openecomp.core.utilities.CommonMethods.toSingleElementSet;
-
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.UDTValue;
import com.datastax.driver.mapping.Mapper;
@@ -47,6 +45,8 @@
import java.util.HashSet;
import java.util.Set;
+import static org.openecomp.core.utilities.CommonMethods.toSingleElementSet;
+
public class FeatureGroupCassandraDaoImpl extends CassandraBaseDao<FeatureGroupEntity>
implements FeatureGroupDao {
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/EntitlementPoolZusammenDaoImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/EntitlementPoolZusammenDaoImpl.java
index b880c67..35182a3 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/EntitlementPoolZusammenDaoImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/EntitlementPoolZusammenDaoImpl.java
@@ -10,25 +10,20 @@
import com.amdocs.zusammen.datatypes.item.Info;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDao;
+import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor.ElementToEntitlementPoolConvertor;
import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther;
-import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope;
-import org.openecomp.sdc.vendorlicense.dao.types.ThresholdUnit;
-import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.types.ElementPropertyName;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
import java.util.Map;
import java.util.Optional;
-import java.util.Set;
import java.util.stream.Collectors;
-/**
- * Created by ayalaben on 3/28/2017.
- */
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement;
+
public class EntitlementPoolZusammenDaoImpl implements EntitlementPoolDao {
private ZusammenAdaptor zusammenAdaptor;
@@ -48,18 +43,22 @@
buildEntitlementPoolElement(entitlementPool, Action.CREATE);
ZusammenElement entitlementPoolsElement =
- VlmZusammenUtil.buildStructuralElement(StructureElement.EntitlementPools, null);
+ ZusammenUtil.buildStructuralElement(ElementType.EntitlementPools, Action.IGNORE);
+ ZusammenElement limitsElement =
+ ZusammenUtil.buildStructuralElement(ElementType.Limits, Action.CREATE);
+
+ entitlementPoolElement.addSubElement(limitsElement);
entitlementPoolsElement.addSubElement(entitlementPoolElement);
SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(entitlementPool.getVendorLicenseModelId());
- Optional<Element> savedElement = zusammenAdaptor.saveElement(context, new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
+ Element epsSavedElement = zusammenAdaptor.saveElement(context,
+ new ElementContext(entitlementPool.getVendorLicenseModelId(),
+ entitlementPool.getVersion().getId()),
entitlementPoolsElement, "Create entitlement pool");
- savedElement.ifPresent(element -> entitlementPool
- .setId(element.getSubElements().iterator().next().getElementId().getValue()));
+ entitlementPool
+ .setId(epsSavedElement.getSubElements().iterator().next().getElementId().getValue());
}
@Override
@@ -68,9 +67,8 @@
buildEntitlementPoolElement(entitlementPool, Action.UPDATE);
SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(entitlementPool.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ ElementContext elementContext = new ElementContext(entitlementPool.getVendorLicenseModelId(),
+ entitlementPool.getVersion().getId());
Optional<ElementInfo> epFromDb = zusammenAdaptor.getElementInfo(context, elementContext,
new Id(entitlementPool.getId()));
@@ -84,35 +82,33 @@
}
}
- zusammenAdaptor.saveElement(context,elementContext, entitlmentpoolElement,
+ zusammenAdaptor.saveElement(context, elementContext, entitlmentpoolElement,
String.format("Update entitlement pool with id %s", entitlementPool.getId()));
}
@Override
public EntitlementPoolEntity get(EntitlementPoolEntity entitlementPool) {
SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(entitlementPool.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VlmZusammenUtil.getVersionTag(entitlementPool.getVersion()));
-
+ ElementContext elementContext = new ElementContext(entitlementPool.getVendorLicenseModelId(),
+ entitlementPool.getVersion().getId());
+ ElementToEntitlementPoolConvertor convertor = new ElementToEntitlementPoolConvertor();
return zusammenAdaptor.getElementInfo(context, elementContext, new Id(entitlementPool.getId()))
- .map(elementInfo -> mapElementInfoToEntitlementPool(
- entitlementPool.getVendorLicenseModelId(), entitlementPool.getVersion(), elementInfo))
+ .map(elementInfo -> {
+ EntitlementPoolEntity entity = convertor.convert(elementInfo);
+ entity.setVendorLicenseModelId(entitlementPool.getVendorLicenseModelId());
+ entity.setVersion(entitlementPool.getVersion());
+ return entity;
+ })
.orElse(null);
}
@Override
public void delete(EntitlementPoolEntity entitlementPool) {
- SessionContext context = ZusammenUtil.createSessionContext();
- ZusammenElement zusammenElement = new ZusammenElement();
- zusammenElement.setAction(Action.DELETE);
- zusammenElement.setElementId(new Id(entitlementPool.getId()));
+ ZusammenElement zusammenElement = buildElement(new Id(entitlementPool.getId()), Action.DELETE);
- Id itemId = new Id(entitlementPool.getVendorLicenseModelId());
- ElementContext elementContext =
- new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = ZusammenUtil.createSessionContext();
+ ElementContext elementContext = new ElementContext(entitlementPool.getVendorLicenseModelId(),
+ entitlementPool.getVersion().getId());
zusammenAdaptor.saveElement(context, elementContext, zusammenElement,
"delete entitlement pool. id:" + entitlementPool.getId() + ".");
}
@@ -120,28 +116,27 @@
@Override
public Collection<EntitlementPoolEntity> list(EntitlementPoolEntity entitlementPool) {
SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(entitlementPool.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VlmZusammenUtil.getVersionTag(entitlementPool.getVersion()));
-
+ ElementContext elementContext = new ElementContext(entitlementPool.getVendorLicenseModelId(),
+ entitlementPool.getVersion().getId());
+ ElementToEntitlementPoolConvertor convertor = new ElementToEntitlementPoolConvertor();
return zusammenAdaptor
- .listElementsByName(context, elementContext, null, StructureElement.EntitlementPools.name())
- .stream().map(elementInfo -> mapElementInfoToEntitlementPool(
- entitlementPool.getVendorLicenseModelId(), entitlementPool.getVersion(), elementInfo))
- .collect(Collectors.toList());
+ .listElementsByName(context, elementContext, null, ElementType.EntitlementPools.name())
+ .stream().map(elementInfo -> {
+ EntitlementPoolEntity entity = convertor.convert(elementInfo);
+ entity.setVendorLicenseModelId(entitlementPool.getVendorLicenseModelId());
+ entity.setVersion(entitlementPool.getVersion());
+ return entity;
+ }).collect(Collectors.toList());
}
@Override
public long count(EntitlementPoolEntity entitlementPool) {
SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(entitlementPool.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VlmZusammenUtil.getVersionTag(entitlementPool.getVersion()));
+ ElementContext elementContext = new ElementContext(entitlementPool.getVendorLicenseModelId(),
+ entitlementPool.getVersion().getId());
return zusammenAdaptor
- .listElementsByName(context, elementContext, null, StructureElement.EntitlementPools.name())
+ .listElementsByName(context, elementContext, null, ElementType.EntitlementPools.name())
.size();
}
@@ -149,9 +144,8 @@
public void removeReferencingFeatureGroup(EntitlementPoolEntity entitlementPool,
String referencingFeatureGroupId) {
SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(entitlementPool.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ ElementContext elementContext = new ElementContext(entitlementPool.getVendorLicenseModelId(),
+ entitlementPool.getVersion().getId());
Optional<ElementInfo> elementInfo =
zusammenAdaptor.getElementInfo(context, elementContext, new Id(entitlementPool.getId()));
@@ -173,9 +167,8 @@
public void addReferencingFeatureGroup(EntitlementPoolEntity entitlementPool,
String referencingFeatureGroupId) {
SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(entitlementPool.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ ElementContext elementContext = new ElementContext(entitlementPool.getVendorLicenseModelId(),
+ entitlementPool.getVersion().getId());
Optional<ElementInfo> elementInfo =
zusammenAdaptor.getElementInfo(context, elementContext, new Id(entitlementPool.getId()));
@@ -199,17 +192,32 @@
//not supported
}
+ @Override
+ public String getManufacturerReferenceNumber(EntitlementPoolEntity entitlementPoolEntity) {
+ SessionContext context = ZusammenUtil.createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(entitlementPoolEntity.getVendorLicenseModelId(),
+ entitlementPoolEntity.getVersion().getId());
+
+ Optional<ElementInfo> elementInfo1 = zusammenAdaptor
+ .getElementInfo(context, elementContext, new Id(entitlementPoolEntity.getId()));
+ Map<String, Object> properties = elementInfo1.get().getInfo().getProperties();
+ String manufacturerReferenceNumber = null;
+ if (properties != null && properties.containsKey("manufacturerReferenceNumber")) {
+ manufacturerReferenceNumber = (String) properties.get("manufacturerReferenceNumber");
+ }
+ return manufacturerReferenceNumber;
+ }
+
private ZusammenElement buildEntitlementPoolElement(EntitlementPoolEntity entitlementPool,
Action action) {
-
- ZusammenElement entitlementPoolElement = new ZusammenElement();
- entitlementPoolElement.setAction(action);
- if (entitlementPool.getId() != null) {
- entitlementPoolElement.setElementId(new Id(entitlementPool.getId()));
- }
+ ZusammenElement entitlementPoolElement =
+ buildElement(entitlementPool.getId() == null ? null : new Id(entitlementPool.getId()),
+ action);
Info info = new Info();
info.setName(entitlementPool.getName());
info.setDescription(entitlementPool.getDescription());
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.EntitlementPool);
info.addProperty("version_uuid", entitlementPool.getVersionUuId());
info.addProperty("thresholdValue", entitlementPool.getThresholdValue());
info.addProperty("threshold_unit", entitlementPool.getThresholdUnit());
@@ -219,8 +227,8 @@
info.addProperty("expiryDate", entitlementPool.getExpiryDate());
entitlementPoolElement.setInfo(info);
- if (entitlementPool.getReferencingFeatureGroups() != null
- && entitlementPool.getReferencingFeatureGroups().size() > 0) {
+ if (entitlementPool.getReferencingFeatureGroups() != null
+ && entitlementPool.getReferencingFeatureGroups().size() > 0) {
entitlementPoolElement.setRelations(entitlementPool.getReferencingFeatureGroups().stream()
.map(rel -> VlmZusammenUtil
.createRelation(RelationType.EntitlmentPoolToReferencingFeatureGroup, rel))
@@ -229,62 +237,5 @@
return entitlementPoolElement;
}
- private EntitlementPoolEntity mapElementInfoToEntitlementPool(String vlmId, Version version,
- ElementInfo elementInfo) {
- EntitlementPoolEntity entitlmentPool =
- new EntitlementPoolEntity(vlmId, version, elementInfo.getId().getValue());
- entitlmentPool.setName(elementInfo.getInfo().getName());
- entitlmentPool.setDescription(elementInfo.getInfo().getDescription());
- entitlmentPool.setVersionUuId(elementInfo.getInfo().getProperty("version_uuid"));
- entitlmentPool
- .setThresholdValue(elementInfo.getInfo().getProperty("thresholdValue") != null
- ? VlmZusammenUtil.toInteger(elementInfo.getInfo().getProperty("thresholdValue")) : null);
-
- Object threshold_unit = elementInfo.getInfo().getProperty("threshold_unit");
- entitlmentPool.setThresholdUnit( threshold_unit != null ?
- ThresholdUnit.valueOf(elementInfo.getInfo().getProperty("threshold_unit")) : null);
- entitlmentPool.setIncrements(elementInfo.getInfo().getProperty("increments"));
- entitlmentPool.setOperationalScope(getOperationalScopeMultiChoiceOrOther(
- elementInfo.getInfo().getProperty("operational_scope")));
- entitlmentPool.setStartDate(elementInfo.getInfo().getProperty("startDate"));
- entitlmentPool.setExpiryDate(elementInfo.getInfo().getProperty("expiryDate"));
-
- if (elementInfo.getRelations() != null && elementInfo.getRelations().size() > 0) {
- entitlmentPool
- .setReferencingFeatureGroups(elementInfo.getRelations().stream().map(relation -> relation
- .getEdge2().getElementId().getValue()).collect(Collectors.toSet()));
- }
- return entitlmentPool;
- }
-
- private MultiChoiceOrOther<OperationalScope> getOperationalScopeMultiChoiceOrOther
- (Map<String, Object>
- operationalScope) {
- if(operationalScope != null && !operationalScope.isEmpty()) {
- Set<OperationalScope> choices = new HashSet<>();
- ((List<String>) operationalScope.get("choices")).
- forEach(choice -> choices.add(OperationalScope.valueOf(choice)));
-
- return new MultiChoiceOrOther<>(choices, operationalScope.get("other")==null?null:
- (String) operationalScope.get("other"));
- }
- return null;
- }
-
- @Override
- public String getManufacturerReferenceNumber(EntitlementPoolEntity entitlementPoolEntity){
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(entitlementPoolEntity.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VlmZusammenUtil.getVersionTag(entitlementPoolEntity.getVersion()));
- Optional<ElementInfo> elementInfo1 = zusammenAdaptor.getElementInfo(context, elementContext, new Id(entitlementPoolEntity.getId()));
- Map<String, Object> properties = elementInfo1.get().getInfo().getProperties();
- String manufacturerReferenceNumber = null;
- if(properties != null && properties.containsKey("manufacturerReferenceNumber") ) {
- manufacturerReferenceNumber = (String)properties.get("manufacturerReferenceNumber");
- }
- return manufacturerReferenceNumber;
- }
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/FeatureGroupDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/FeatureGroupDaoZusammenImpl.java
index aa9e6c7..8dcc964 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/FeatureGroupDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/FeatureGroupDaoZusammenImpl.java
@@ -10,21 +10,22 @@
import com.amdocs.zusammen.datatypes.item.Info;
import com.amdocs.zusammen.datatypes.item.Relation;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDao;
+import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor.ElementToFeatureGroupConvertor;
import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
-import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.types.ElementPropertyName;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
-/**
- * Created by ayalaben on 3/27/2017.
- */
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
public class FeatureGroupDaoZusammenImpl implements FeatureGroupDao {
private ZusammenAdaptor zusammenAdaptor;
@@ -40,88 +41,86 @@
@Override
public void create(FeatureGroupEntity featureGroup) {
- ZusammenElement featureGroupElement =
- buildFeatureGroupElement(featureGroup, Action.CREATE);
+ ZusammenElement featureGroupElement = buildFeatureGroupElement(featureGroup, Action.CREATE);
ZusammenElement featureGroupsElement =
- VlmZusammenUtil.buildStructuralElement(StructureElement.FeatureGroups, null);
+ buildStructuralElement(ElementType.FeatureGroups, Action.IGNORE);
featureGroupsElement.addSubElement(featureGroupElement);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(featureGroup.getVendorLicenseModelId());
- Optional<Element> savedElement = zusammenAdaptor.saveElement(context, new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
- featureGroupsElement, "Create feature group");
+ SessionContext context = createSessionContext();
+ Element featureGroupsSavedElement = zusammenAdaptor.saveElement(context,
+ new ElementContext(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion().getId()), featureGroupsElement, "Create feature group");
- savedElement.ifPresent(element -> featureGroup
- .setId(element.getSubElements().iterator().next().getElementId().getValue()));
+ featureGroup.setId(
+ featureGroupsSavedElement.getSubElements().iterator().next().getElementId().getValue());
}
@Override
public void update(FeatureGroupEntity featureGroup) {
ZusammenElement featureGroupElement = buildFeatureGroupElement(featureGroup, Action.UPDATE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(featureGroup.getVendorLicenseModelId());
- zusammenAdaptor.saveElement(context, new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)), featureGroupElement,
+ SessionContext context = createSessionContext();
+ zusammenAdaptor.saveElement(context, new ElementContext(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion().getId()), featureGroupElement,
String.format("Update feature group with id %s", featureGroup.getId()));
}
@Override
public FeatureGroupEntity get(FeatureGroupEntity featureGroup) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(featureGroup.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VlmZusammenUtil.getVersionTag(featureGroup.getVersion()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion().getId());
return zusammenAdaptor.getElementInfo(context, elementContext, new Id(featureGroup.getId()))
- .map(elementInfo -> mapElementInfoToFeatureGroup(
- featureGroup.getVendorLicenseModelId(), featureGroup.getVersion(), elementInfo))
+ .map(elementInfo -> {
+ FeatureGroupEntity entity = new ElementToFeatureGroupConvertor().convert(elementInfo);
+ entity.setVendorLicenseModelId(featureGroup.getVendorLicenseModelId());
+ entity.setVersion(featureGroup.getVersion());
+ return entity;
+ })
.orElse(null);
}
@Override
public void delete(FeatureGroupEntity featureGroup) {
- SessionContext context = ZusammenUtil.createSessionContext();
- ZusammenElement zusammenElement = new ZusammenElement();
- zusammenElement.setAction(Action.DELETE);
- zusammenElement.setElementId(new Id(featureGroup.getId()));
+ ZusammenElement zusammenElement = buildElement(new Id(featureGroup.getId()), Action.DELETE);
- Id itemId = new Id(featureGroup.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion().getId());
zusammenAdaptor.saveElement(context, elementContext, zusammenElement,
"delete feature group. id:" + featureGroup.getId() + ".");
}
@Override
public Collection<FeatureGroupEntity> list(FeatureGroupEntity featureGroup) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(featureGroup.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VlmZusammenUtil.getVersionTag(featureGroup.getVersion()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion().getId());
+ ElementToFeatureGroupConvertor convertor = new ElementToFeatureGroupConvertor();
return zusammenAdaptor
- .listElementsByName(context, elementContext, null, StructureElement.FeatureGroups.name())
- .stream().map(elementInfo -> mapElementInfoToFeatureGroup(
- featureGroup.getVendorLicenseModelId(), featureGroup.getVersion(), elementInfo))
+ .listElementsByName(context, elementContext, null, ElementType.FeatureGroups.name())
+ .stream().map(elementInfo -> {
+ FeatureGroupEntity entity = convertor.convert(
+ elementInfo);
+ entity.setVendorLicenseModelId(featureGroup.getVendorLicenseModelId());
+ entity.setVersion(featureGroup.getVersion());
+ return entity;
+ })
.collect(Collectors.toList());
}
@Override
public long count(FeatureGroupEntity featureGroup) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(featureGroup.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VlmZusammenUtil.getVersionTag(featureGroup.getVersion()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion().getId());
return zusammenAdaptor
- .listElementsByName(context, elementContext, null, StructureElement.FeatureGroups.name())
+ .listElementsByName(context, elementContext, null, ElementType.FeatureGroups.name())
.size();
}
@@ -138,10 +137,9 @@
private void removeRelationToContainedEntity(FeatureGroupEntity featureGroup,
String containedEntityId,
String containedEntityType) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(featureGroup.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion().getId());
Optional<ElementInfo> elementInfo = zusammenAdaptor.getElementInfo(context,
elementContext, new Id(featureGroup.getId()));
@@ -158,25 +156,23 @@
}
@Override
- public void updateFeatureGroup(FeatureGroupEntity
- featureGroup, Set<String> addedEntitlementPools,
+ public void updateFeatureGroup(FeatureGroupEntity featureGroup,
+ Set<String> addedEntitlementPools,
Set<String> removedEntitlementPools,
Set<String> addedLicenseKeyGroups,
Set<String> removedLicenseKeyGroups) {
ZusammenElement featureGroupElement = buildFeatureGroupElement(featureGroup, Action.UPDATE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(featureGroup.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
-
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion().getId());
+ ElementToFeatureGroupConvertor convertor = new ElementToFeatureGroupConvertor();
Optional<ElementInfo> elementInfo = zusammenAdaptor.getElementInfo(context,
elementContext, new Id(featureGroup.getId()));
if (elementInfo.isPresent()) {
- FeatureGroupEntity currentFeatureGroup =
- mapElementInfoToFeatureGroup(featureGroup.getId(), featureGroup.getVersion(),
- elementInfo.get());
-
- if (!(removedEntitlementPools == null )) {
+ FeatureGroupEntity currentFeatureGroup = convertor.convert(elementInfo.get());
+ currentFeatureGroup.setVendorLicenseModelId(featureGroup.getVendorLicenseModelId());
+ currentFeatureGroup.setVersion(featureGroup.getVersion());
+ if (!(removedEntitlementPools == null)) {
currentFeatureGroup.getEntitlementPoolIds().removeAll(removedEntitlementPools);
}
if (!(addedEntitlementPools == null)) {
@@ -192,22 +188,24 @@
.createRelation(RelationType.FeatureGroupToEntitlmentPool, relation))
.collect(Collectors.toList()));
- if (! ( removedLicenseKeyGroups == null)) {
+ if (!(removedLicenseKeyGroups == null)) {
currentFeatureGroup.getLicenseKeyGroupIds().removeAll(removedLicenseKeyGroups);
}
- if (! ( addedLicenseKeyGroups == null)) {
+ if (!(addedLicenseKeyGroups == null)) {
currentFeatureGroup.getLicenseKeyGroupIds().addAll(addedLicenseKeyGroups);
}
+
featureGroupElement.getRelations()
.addAll(currentFeatureGroup.getLicenseKeyGroupIds().stream()
.map(relation -> VlmZusammenUtil
.createRelation(RelationType.FeatureGroupToLicenseKeyGroup, relation))
.collect(Collectors.toList()));
- Collection<Relation> LaRelations = elementInfo.get().getRelations().stream().filter
- (rel->rel.getType().equals(RelationType.FeatureGroupToReferencingLicenseAgreement.name()))
- .map(rel ->VlmZusammenUtil.createRelation(RelationType
- .FeatureGroupToReferencingLicenseAgreement,rel.getEdge2().getElementId().toString()))
+ Collection<Relation> LaRelations = elementInfo.get().getRelations().stream().filter
+ (rel -> rel.getType()
+ .equals(RelationType.FeatureGroupToReferencingLicenseAgreement.name()))
+ .map(rel -> VlmZusammenUtil.createRelation(RelationType
+ .FeatureGroupToReferencingLicenseAgreement, rel.getEdge2().getElementId().toString()))
.collect(Collectors.toList());
featureGroupElement.getRelations().addAll(LaRelations);
@@ -226,10 +224,9 @@
@Override
public void addReferencingLicenseAgreement(FeatureGroupEntity featureGroup,
String licenseAgreementId) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(featureGroup.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion().getId());
Optional<ElementInfo> elementInfo =
zusammenAdaptor.getElementInfo(context, elementContext, new Id(featureGroup.getId()));
@@ -247,10 +244,9 @@
@Override
public void removeReferencingLicenseAgreement(FeatureGroupEntity featureGroup,
String licenseAgreementId) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(featureGroup.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion().getId());
Optional<ElementInfo> elementInfo =
zusammenAdaptor.getElementInfo(context, elementContext, new Id(featureGroup.getId()));
@@ -268,15 +264,12 @@
}
private ZusammenElement buildFeatureGroupElement(FeatureGroupEntity featureGroup, Action action) {
-
- ZusammenElement featureGroupElement = new ZusammenElement();
- featureGroupElement.setAction(action);
- if (featureGroup.getId() != null) {
- featureGroupElement.setElementId(new Id(featureGroup.getId()));
- }
+ ZusammenElement featureGroupElement =
+ buildElement(featureGroup.getId() == null ? null : new Id(featureGroup.getId()), action);
Info info = new Info();
info.setName(featureGroup.getName());
info.setDescription(featureGroup.getDescription());
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.FeatureGroup);
info.addProperty("partNumber", featureGroup.getPartNumber());
info.addProperty("manufacturerReferenceNumber", featureGroup.getManufacturerReferenceNumber());
featureGroupElement.setInfo(info);
@@ -310,39 +303,5 @@
.collect(Collectors.toList()));
}
return featureGroupElement;
-
- }
-
- private FeatureGroupEntity mapElementInfoToFeatureGroup(String vlmId, Version version,
- ElementInfo elementInfo) {
- FeatureGroupEntity featureGroup =
- new FeatureGroupEntity(vlmId, version, elementInfo.getId().getValue());
- featureGroup.setName(elementInfo.getInfo().getName());
- featureGroup.setDescription(elementInfo.getInfo().getDescription());
- featureGroup.setPartNumber(elementInfo.getInfo().getProperty("partNumber"));
- featureGroup.setManufacturerReferenceNumber(elementInfo.getInfo()
- .getProperty("manufacturerReferenceNumber"));
-
- Set<String> entitlementPoolIds = new HashSet<>();
- Set<String> licenseAgreements = new HashSet<>();
- Set<String> licenseKeyGroupIds = new HashSet<>();
-
- if (elementInfo.getRelations() != null) {
- for (Relation relation : elementInfo.getRelations()) {
- if (RelationType.FeatureGroupToEntitlmentPool.name().equals(relation.getType())) {
- entitlementPoolIds.add(relation.getEdge2().getElementId().getValue());
- } else if (RelationType.FeatureGroupToLicenseKeyGroup.name().equals(relation.getType())) {
- licenseKeyGroupIds.add(relation.getEdge2().getElementId().getValue());
- } else if (RelationType.FeatureGroupToReferencingLicenseAgreement.name()
- .equals(relation.getType())) {
- licenseAgreements.add(relation.getEdge2().getElementId().getValue());
- }
- }
- }
- featureGroup.setEntitlementPoolIds(entitlementPoolIds);
- featureGroup.setLicenseKeyGroupIds(licenseKeyGroupIds);
- featureGroup.setReferencingLicenseAgreements(licenseAgreements);
-
- return featureGroup;
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/LicenseAgreementDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/LicenseAgreementDaoZusammenImpl.java
index 45c831f..0fbac66 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/LicenseAgreementDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/LicenseAgreementDaoZusammenImpl.java
@@ -29,19 +29,21 @@
import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.datatypes.item.Info;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDao;
-import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther;
+import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor.ElementToLicenseAgreementConvertor;
import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseTerm;
-import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.types.ElementPropertyName;
import java.util.Collection;
-import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
public class LicenseAgreementDaoZusammenImpl implements LicenseAgreementDao {
@@ -61,16 +63,17 @@
ZusammenElement licenseAgreementElement =
buildLicenseAgreementElement(licenseAgreement, Action.CREATE);
ZusammenElement licenseAgreementsElement =
- VlmZusammenUtil.buildStructuralElement(StructureElement.LicenseAgreements, null);
+ buildStructuralElement(ElementType.LicenseAgreements, Action.IGNORE);
licenseAgreementsElement.addSubElement(licenseAgreementElement);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(licenseAgreement.getVendorLicenseModelId());
- Optional<Element> savedElement = zusammenAdaptor.saveElement(context, new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
- licenseAgreementsElement, "Create license agreement");
- savedElement.ifPresent(element -> licenseAgreement
- .setId(element.getSubElements().iterator().next().getElementId().getValue()));
+ SessionContext context = createSessionContext();
+ Element licenseAgreementsSavedElement = zusammenAdaptor.saveElement(context,
+ new ElementContext(licenseAgreement.getVendorLicenseModelId(),
+ licenseAgreement.getVersion().getId()), licenseAgreementsElement,
+ "Create license agreement");
+ licenseAgreement
+ .setId(licenseAgreementsSavedElement.getSubElements().iterator().next().getElementId()
+ .getValue());
}
@Override
@@ -78,38 +81,36 @@
ZusammenElement licenseAgreementElement =
buildLicenseAgreementElement(licenseAgreement, Action.UPDATE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(licenseAgreement.getVendorLicenseModelId());
- zusammenAdaptor.saveElement(context, new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
- licenseAgreementElement,
+ SessionContext context = createSessionContext();
+ zusammenAdaptor.saveElement(context,
+ new ElementContext(licenseAgreement.getVendorLicenseModelId(),
+ licenseAgreement.getVersion().getId()), licenseAgreementElement,
String.format("Update license agreement with id %s", licenseAgreement.getId()));
}
@Override
public LicenseAgreementEntity get(LicenseAgreementEntity licenseAgreement) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(licenseAgreement.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VlmZusammenUtil.getVersionTag(licenseAgreement.getVersion()));
-
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(licenseAgreement.getVendorLicenseModelId(),
+ licenseAgreement.getVersion().getId());
+ ElementToLicenseAgreementConvertor convertor = new ElementToLicenseAgreementConvertor();
return zusammenAdaptor.getElementInfo(context, elementContext, new Id(licenseAgreement.getId()))
- .map(elementInfo -> mapElementInfoToLicenseAgreement(
- licenseAgreement.getVendorLicenseModelId(), licenseAgreement.getVersion(), elementInfo))
+ .map(elementInfo -> {
+ LicenseAgreementEntity entity = convertor.convert(elementInfo);
+ entity.setVendorLicenseModelId(licenseAgreement.getVendorLicenseModelId());
+ entity.setVersion(licenseAgreement.getVersion());
+ return entity;
+ })
.orElse(null);
}
@Override
public void delete(LicenseAgreementEntity licenseAgreement) {
- SessionContext context = ZusammenUtil.createSessionContext();
- ZusammenElement zusammenElement = new ZusammenElement();
- zusammenElement.setAction(Action.DELETE);
- zusammenElement.setElementId(new Id(licenseAgreement.getId()));
+ ZusammenElement zusammenElement = buildElement(new Id(licenseAgreement.getId()), Action.DELETE);
- Id itemId = new Id(licenseAgreement.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(licenseAgreement.getVendorLicenseModelId(),
+ licenseAgreement.getVersion().getId());
zusammenAdaptor.saveElement(context, elementContext, zusammenElement,
"delete license agreement. id:" + licenseAgreement.getId() + ".");
}
@@ -117,30 +118,30 @@
@Override
public Collection<LicenseAgreementEntity> list(LicenseAgreementEntity licenseAgreement) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(licenseAgreement.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VlmZusammenUtil.getVersionTag(licenseAgreement.getVersion()));
-
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(licenseAgreement.getVendorLicenseModelId(),
+ licenseAgreement.getVersion().getId());
+ ElementToLicenseAgreementConvertor convertor = new ElementToLicenseAgreementConvertor();
return zusammenAdaptor
.listElementsByName(context, elementContext, null,
- StructureElement.LicenseAgreements.name())
- .stream().map(elementInfo -> mapElementInfoToLicenseAgreement(
- licenseAgreement.getVendorLicenseModelId(), licenseAgreement.getVersion(), elementInfo))
+ ElementType.LicenseAgreements.name())
+ .stream().map(elementInfo -> {
+ LicenseAgreementEntity entity = convertor.convert(elementInfo);
+ entity.setVendorLicenseModelId(licenseAgreement.getVendorLicenseModelId());
+ entity.setVersion(licenseAgreement.getVersion());
+ return entity;
+ })
.collect(Collectors.toList());
}
@Override
public long count(LicenseAgreementEntity licenseAgreement) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(licenseAgreement.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VlmZusammenUtil.getVersionTag(licenseAgreement.getVersion()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(licenseAgreement.getVendorLicenseModelId(),
+ licenseAgreement.getVersion().getId());
return zusammenAdaptor.listElementsByName(context, elementContext, null,
- StructureElement.LicenseAgreements.name())
+ ElementType.LicenseAgreements.name())
.size();
}
@@ -151,10 +152,9 @@
@Override
public void removeFeatureGroup(LicenseAgreementEntity licenseAgreement, String featureGroupId) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(licenseAgreement.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(licenseAgreement.getVendorLicenseModelId(),
+ licenseAgreement.getVersion().getId());
Optional<ElementInfo> elementInfo = zusammenAdaptor.getElementInfo(context,
elementContext, new Id(licenseAgreement.getId()));
@@ -175,23 +175,22 @@
ZusammenElement licenseAgreementElement =
buildLicenseAgreementElement(licenseAgreement, Action.UPDATE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(licenseAgreement.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
-
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(licenseAgreement.getVendorLicenseModelId(),
+ licenseAgreement.getVersion().getId());
+ ElementToLicenseAgreementConvertor convertor = new ElementToLicenseAgreementConvertor();
Optional<ElementInfo> elementInfo =
zusammenAdaptor.getElementInfo(context, elementContext, new Id(licenseAgreement.getId()));
if (elementInfo.isPresent()) {
LicenseAgreementEntity currentLicenseAgreement =
- mapElementInfoToLicenseAgreement(licenseAgreement.getId(), licenseAgreement.getVersion(),
- elementInfo.get());
-
- if (! (removedFeatureGroupIds == null) ) {
+ convertor.convert(elementInfo.get());
+ currentLicenseAgreement.setVendorLicenseModelId(licenseAgreement.getVendorLicenseModelId());
+ currentLicenseAgreement.setVersion(licenseAgreement.getVersion());
+ if (!(removedFeatureGroupIds == null)) {
currentLicenseAgreement.getFeatureGroupIds().removeAll(removedFeatureGroupIds);
}
- if (! (addedFeatureGroupIds == null)) {
+ if (!(addedFeatureGroupIds == null)) {
currentLicenseAgreement.getFeatureGroupIds().addAll(addedFeatureGroupIds);
}
licenseAgreementElement.setRelations(currentLicenseAgreement.getFeatureGroupIds().stream()
@@ -203,41 +202,15 @@
}
}
- private LicenseAgreementEntity mapElementInfoToLicenseAgreement(String vlmId, Version version,
- ElementInfo elementInfo) {
- LicenseAgreementEntity licenseAgreement =
- new LicenseAgreementEntity(vlmId, version, elementInfo.getId().getValue());
- licenseAgreement.setName(elementInfo.getInfo().getName());
- licenseAgreement.setDescription(elementInfo.getInfo().getDescription());
-
- licenseAgreement
- .setLicenseTerm(getCoiceOrOther(elementInfo.getInfo().getProperty("licenseTerm")));
- licenseAgreement.setRequirementsAndConstrains(
- elementInfo.getInfo().getProperty("requirementsAndConstrains"));
- if (elementInfo.getRelations() != null && elementInfo.getRelations().size() > 0) {
- licenseAgreement.setFeatureGroupIds(elementInfo.getRelations().stream()
- .map(relation -> relation.getEdge2().getElementId().getValue())
- .collect(Collectors.toSet()));
- }
- return licenseAgreement;
- }
-
- private ChoiceOrOther<LicenseTerm> getCoiceOrOther(Map licenseTerm) {
- return new ChoiceOrOther(LicenseTerm.valueOf((String) licenseTerm.get("choice")),
- (String) licenseTerm.get("other"));
- }
-
-
private ZusammenElement buildLicenseAgreementElement(LicenseAgreementEntity licenseAgreement,
Action action) {
- ZusammenElement licenseAgreementElement = new ZusammenElement();
- licenseAgreementElement.setAction(action);
- if (licenseAgreement.getId() != null) {
- licenseAgreementElement.setElementId(new Id(licenseAgreement.getId()));
- }
+ ZusammenElement licenseAgreementElement =
+ buildElement(licenseAgreement.getId() == null ? null : new Id(licenseAgreement.getId()),
+ action);
Info info = new Info();
info.setName(licenseAgreement.getName());
info.setDescription(licenseAgreement.getDescription());
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.LicenseAgreement);
info.addProperty("licenseTerm", licenseAgreement.getLicenseTerm());
info.addProperty("requirementsAndConstrains", licenseAgreement.getRequirementsAndConstrains());
licenseAgreementElement.setInfo(info);
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/LicenseKeyGroupZusammenDaoImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/LicenseKeyGroupZusammenDaoImpl.java
index 976db94..4e7aee3 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/LicenseKeyGroupZusammenDaoImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/LicenseKeyGroupZusammenDaoImpl.java
@@ -9,27 +9,22 @@
import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.datatypes.item.Info;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDao;
+import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor.ElementToLicenseKeyGroupConvertor;
import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyType;
-import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther;
-import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope;
-import org.openecomp.sdc.vendorlicense.dao.types.ThresholdUnit;
-import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.types.ElementPropertyName;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
import java.util.Optional;
-import java.util.Set;
import java.util.stream.Collectors;
-/**
- * Created by ayalaben on 3/30/2017.
- */
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
+
public class LicenseKeyGroupZusammenDaoImpl implements LicenseKeyGroupDao {
private ZusammenAdaptor zusammenAdaptor;
@@ -47,18 +42,20 @@
ZusammenElement licenseKeyGroupElement =
buildLicenseKeyGroupElement(licenseKeyGroup, Action.CREATE);
+ ZusammenElement limitsElement = buildStructuralElement(ElementType.Limits, Action.CREATE);
+ licenseKeyGroupElement.addSubElement(limitsElement);
+
ZusammenElement lkgsElement =
- VlmZusammenUtil.buildStructuralElement(StructureElement.LicenseKeyGroups, null);
+ buildStructuralElement(ElementType.LicenseKeyGroups, Action.IGNORE);
lkgsElement.addSubElement(licenseKeyGroupElement);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(licenseKeyGroup.getVendorLicenseModelId());
- Optional<Element> savedElement = zusammenAdaptor.saveElement(context, new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
- lkgsElement, "Create license Key Group");
+ SessionContext context = createSessionContext();
+ Element lkgsSavedElement = zusammenAdaptor.saveElement(context,
+ new ElementContext(licenseKeyGroup.getVendorLicenseModelId(),
+ licenseKeyGroup.getVersion().getId()), lkgsElement, "Create license Key Group");
- savedElement.ifPresent(element -> licenseKeyGroup
- .setId(element.getSubElements().iterator().next().getElementId().getValue()));
+ licenseKeyGroup
+ .setId(lkgsSavedElement.getSubElements().iterator().next().getElementId().getValue());
}
@Override
@@ -66,55 +63,50 @@
ZusammenElement licenseKeyGroupElement =
buildLicenseKeyGroupElement(licenseKeyGroup, Action.UPDATE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(licenseKeyGroup.getVendorLicenseModelId());
-
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(licenseKeyGroup.getVendorLicenseModelId(),
+ licenseKeyGroup.getVersion().getId());
Optional<ElementInfo> lkgFromDb = zusammenAdaptor.getElementInfo(context, elementContext,
new Id(licenseKeyGroup.getId()));
- if(lkgFromDb.isPresent()) {
+ if (lkgFromDb.isPresent()) {
- if( licenseKeyGroupElement.getRelations() == null) {
- licenseKeyGroupElement.setRelations(new ArrayList<>());
+ if (licenseKeyGroupElement.getRelations() == null) {
+ licenseKeyGroupElement.setRelations(new ArrayList<>());
}
if (lkgFromDb.get().getRelations() != null && lkgFromDb.get().getRelations().size() > 0) {
licenseKeyGroupElement.getRelations().addAll(lkgFromDb.get().getRelations());
}
}
-
- zusammenAdaptor.saveElement(context, elementContext,
- licenseKeyGroupElement,
+ zusammenAdaptor.saveElement(context, elementContext, licenseKeyGroupElement,
String.format("Update license key group with id %s", licenseKeyGroup.getId()));
}
@Override
public LicenseKeyGroupEntity get(LicenseKeyGroupEntity licenseKeyGroup) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(licenseKeyGroup.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VlmZusammenUtil.getVersionTag(licenseKeyGroup.getVersion()));
-
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(licenseKeyGroup.getVendorLicenseModelId(),
+ licenseKeyGroup.getVersion().getId());
+ ElementToLicenseKeyGroupConvertor convertor = new ElementToLicenseKeyGroupConvertor();
return zusammenAdaptor.getElementInfo(context, elementContext, new Id(licenseKeyGroup.getId()))
- .map(elementInfo -> mapElementInfoToLicenseKeyGroup(
- licenseKeyGroup.getVendorLicenseModelId(), licenseKeyGroup.getVersion(), elementInfo))
+ .map(elementInfo -> {
+ LicenseKeyGroupEntity entity = convertor.convert(elementInfo);
+ entity.setVendorLicenseModelId(licenseKeyGroup.getVendorLicenseModelId());
+ entity.setVersion(licenseKeyGroup.getVersion());
+ return entity;
+ })
.orElse(null);
}
@Override
public void delete(LicenseKeyGroupEntity licenseKeyGroup) {
- SessionContext context = ZusammenUtil.createSessionContext();
- ZusammenElement zusammenElement = new ZusammenElement();
- zusammenElement.setAction(Action.DELETE);
- zusammenElement.setElementId(new Id(licenseKeyGroup.getId()));
+ ZusammenElement zusammenElement = buildElement(new Id(licenseKeyGroup.getId()), Action.DELETE);
- Id itemId = new Id(licenseKeyGroup.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(licenseKeyGroup.getVendorLicenseModelId(),
+ licenseKeyGroup.getVersion().getId());
zusammenAdaptor.saveElement(context, elementContext, zusammenElement,
"delete license key group. id:" + licenseKeyGroup.getId() + ".");
@@ -122,29 +114,29 @@
@Override
public Collection<LicenseKeyGroupEntity> list(LicenseKeyGroupEntity licenseKeyGroup) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(licenseKeyGroup.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VlmZusammenUtil.getVersionTag(licenseKeyGroup.getVersion()));
-
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(licenseKeyGroup.getVendorLicenseModelId(),
+ licenseKeyGroup.getVersion().getId());
+ ElementToLicenseKeyGroupConvertor convertor = new ElementToLicenseKeyGroupConvertor();
return zusammenAdaptor
- .listElementsByName(context, elementContext, null, StructureElement.LicenseKeyGroups.name())
- .stream().map(elementInfo -> mapElementInfoToLicenseKeyGroup(
- licenseKeyGroup.getVendorLicenseModelId(), licenseKeyGroup.getVersion(), elementInfo))
+ .listElementsByName(context, elementContext, null, ElementType.LicenseKeyGroups.name())
+ .stream().map(elementInfo -> {
+ LicenseKeyGroupEntity entity = convertor.convert(elementInfo);
+ entity.setVendorLicenseModelId(licenseKeyGroup.getVendorLicenseModelId());
+ entity.setVersion(licenseKeyGroup.getVersion());
+ return entity;
+ })
.collect(Collectors.toList());
}
@Override
public long count(LicenseKeyGroupEntity licenseKeyGroup) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(licenseKeyGroup.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VlmZusammenUtil.getVersionTag(licenseKeyGroup.getVersion()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(licenseKeyGroup.getVendorLicenseModelId(),
+ licenseKeyGroup.getVersion().getId());
return zusammenAdaptor
- .listElementsByName(context, elementContext, null, StructureElement.LicenseKeyGroups.name())
+ .listElementsByName(context, elementContext, null, ElementType.LicenseKeyGroups.name())
.size();
}
@@ -156,10 +148,9 @@
@Override
public void removeReferencingFeatureGroup(LicenseKeyGroupEntity licenseKeyGroup,
String featureGroupId) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(licenseKeyGroup.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(licenseKeyGroup.getVendorLicenseModelId(),
+ licenseKeyGroup.getVersion().getId());
Optional<ElementInfo> elementInfo =
zusammenAdaptor.getElementInfo(context, elementContext, new Id(licenseKeyGroup.getId()));
@@ -180,10 +171,9 @@
@Override
public void addReferencingFeatureGroup(LicenseKeyGroupEntity licenseKeyGroup,
String featureGroupId) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(licenseKeyGroup.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(licenseKeyGroup.getVendorLicenseModelId(),
+ licenseKeyGroup.getVersion().getId());
Optional<ElementInfo> elementInfo =
zusammenAdaptor.getElementInfo(context, elementContext, new Id(licenseKeyGroup.getId()));
@@ -204,18 +194,15 @@
private ZusammenElement buildLicenseKeyGroupElement(LicenseKeyGroupEntity licenseKeyGroup,
Action action) {
-
- ZusammenElement lkgElement = new ZusammenElement();
- lkgElement.setAction(action);
- if (licenseKeyGroup.getId() != null) {
- lkgElement.setElementId(new Id(licenseKeyGroup.getId()));
- }
+ ZusammenElement lkgElement =
+ buildElement(licenseKeyGroup.getId() == null ? null : new Id(licenseKeyGroup.getId()),
+ action);
Info info = new Info();
info.setName(licenseKeyGroup.getName());
info.setDescription(licenseKeyGroup.getDescription());
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.LicenseKeyGroup);
info.addProperty("version_uuid", licenseKeyGroup.getVersionUuId());
info.addProperty("LicenseKeyType", licenseKeyGroup.getType());
- info.addProperty("version_uuid", licenseKeyGroup.getVersionUuId());
info.addProperty("operational_scope", licenseKeyGroup.getOperationalScope());
info.addProperty("startDate", licenseKeyGroup.getStartDate());
info.addProperty("expiryDate", licenseKeyGroup.getExpiryDate());
@@ -224,70 +211,15 @@
info.addProperty("increments", licenseKeyGroup.getIncrements());
lkgElement.setInfo(info);
- if (licenseKeyGroup.getReferencingFeatureGroups() != null
- && licenseKeyGroup.getReferencingFeatureGroups().size() > 0) {
+ if (licenseKeyGroup.getReferencingFeatureGroups() != null
+ && licenseKeyGroup.getReferencingFeatureGroups().size() > 0) {
lkgElement.setRelations(licenseKeyGroup.getReferencingFeatureGroups().stream()
.map(rel -> VlmZusammenUtil
.createRelation(RelationType.LicenseKeyGroupToReferencingFeatureGroup, rel))
.collect(Collectors.toList()));
}
-
return lkgElement;
}
- private LicenseKeyGroupEntity mapElementInfoToLicenseKeyGroup(String vlmId, Version version,
- ElementInfo elementInfo) {
- LicenseKeyGroupEntity licenseKeyGroup =
- new LicenseKeyGroupEntity(vlmId, version, elementInfo.getId().getValue());
- licenseKeyGroup.setName(elementInfo.getInfo().getName());
- licenseKeyGroup.setDescription(elementInfo.getInfo().getDescription());
- licenseKeyGroup.setVersionUuId(elementInfo.getInfo().getProperty("version_uuid"));
- licenseKeyGroup
- .setType(LicenseKeyType.valueOf(elementInfo.getInfo().getProperty("LicenseKeyType")));
- licenseKeyGroup.setVersionUuId(elementInfo.getInfo().getProperty("version_uuid"));
- licenseKeyGroup.setOperationalScope(getOperationalScopeMultiChoiceOrOther(
- elementInfo.getInfo().getProperty("operational_scope")));
- licenseKeyGroup.setStartDate(elementInfo.getInfo().getProperty("startDate"));
- licenseKeyGroup.setExpiryDate(elementInfo.getInfo().getProperty("expiryDate"));
- if (elementInfo.getInfo().getProperty("thresholdUnits") != null ){
- licenseKeyGroup.setThresholdUnits(ThresholdUnit.valueOf(elementInfo
- .getInfo().getProperty("thresholdUnits")));
- }
- if (elementInfo.getInfo().getProperty("thresholdValue") != null ){
- licenseKeyGroup.setThresholdValue(toInteger(elementInfo.getInfo().getProperty
- ("thresholdValue")));
- }
- licenseKeyGroup.setIncrements(elementInfo.getInfo().getProperty("increments"));
- if (elementInfo.getRelations() != null && elementInfo.getRelations().size() > 0) {
- licenseKeyGroup
- .setReferencingFeatureGroups(elementInfo.getRelations().stream().map(relation -> relation
- .getEdge2().getElementId().getValue()).collect(Collectors.toSet()));
- }
- return licenseKeyGroup;
- }
-
- private MultiChoiceOrOther<OperationalScope> getOperationalScopeMultiChoiceOrOther
- (Map<String, Object>
- operationalScope) {
- if(operationalScope != null && !operationalScope.isEmpty()) {
- Set<OperationalScope> choices = new HashSet<>();
- ((List<String>) operationalScope.get("choices"))
- .forEach(choice -> choices.add(OperationalScope.valueOf(choice)));
-
- return new MultiChoiceOrOther<>(choices, operationalScope.get("other")==null?null:(String) operationalScope.get("other"));
- }
- return null;
- }
-
- private Integer toInteger(Object val) {
- if (val instanceof Double) {
- return ((Double) val).intValue();
- } else if (val instanceof String) {
- return new Integer((String) val);
- } else if (val instanceof Integer) {
- return (Integer) val;
- }
- throw new RuntimeException("invalid value for integer:" + val.getClass());
- }
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/LimitZusammenDaoImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/LimitZusammenDaoImpl.java
index 78c26c8..7b19236 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/LimitZusammenDaoImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/LimitZusammenDaoImpl.java
@@ -9,26 +9,30 @@
import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.datatypes.item.Info;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorlicense.dao.LimitDao;
import org.openecomp.sdc.vendorlicense.dao.types.AggregationFunction;
import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity;
import org.openecomp.sdc.vendorlicense.dao.types.LimitType;
import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.types.ElementPropertyName;
import java.util.Collection;
import java.util.Collections;
-import java.util.Optional;
import java.util.stream.Collectors;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
public class LimitZusammenDaoImpl implements LimitDao {
- public static final String LIMT_TYPE = "type";
- public static final String METRIC = "metric";
- public static final String AGGREGATIONFUNCTION = "aggregationfunction";
- public static final String TIME = "time";
- public static final String UNIT = "unit";
- public static final String VALUE = "value";
+ private static final String LIMT_TYPE = "type";
+ private static final String METRIC = "metric";
+ private static final String AGGREGATIONFUNCTION = "aggregationfunction";
+ private static final String TIME = "time";
+ private static final String UNIT = "unit";
+ private static final String VALUE = "value";
private ZusammenAdaptor zusammenAdaptor;
public LimitZusammenDaoImpl(ZusammenAdaptor zusammenAdaptor) {
@@ -39,36 +43,30 @@
public void create(LimitEntity limitEntity) {
ZusammenElement limitElement = limitToZusammen(limitEntity, Action.CREATE);
- ZusammenElement limitsElement =
- VlmZusammenUtil.buildStructuralElement(StructureElement.Limits, null);
+ ZusammenElement limitsElement = buildStructuralElement(ElementType.Limits, null);
limitsElement.setSubElements(Collections.singletonList(limitElement));
- ZusammenElement epLkgElement =
- buildZusammenElement(new Id(limitEntity.getEpLkgId()), Action.IGNORE);
+ ZusammenElement epLkgElement = buildElement(new Id(limitEntity.getEpLkgId()), Action.IGNORE);
epLkgElement.setSubElements(Collections.singletonList(limitsElement));
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(limitEntity.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(limitEntity.getVendorLicenseModelId(), limitEntity.getVersion().getId());
- Optional<Element> savedElement =
+ Element savedElement =
zusammenAdaptor.saveElement(context, elementContext, epLkgElement, "Create limit");
- savedElement.ifPresent(element ->
- limitEntity.setId(element.getSubElements().iterator().next()
- .getSubElements().iterator().next().getElementId().getValue()));
+ limitEntity.setId(savedElement.getSubElements().iterator().next()
+ .getSubElements().iterator().next().getElementId().getValue());
}
@Override
public boolean isLimitPresent(LimitEntity limitEntity) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(limitEntity.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VlmZusammenUtil.getVersionTag(limitEntity.getVersion()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(limitEntity.getVendorLicenseModelId(), limitEntity.getVersion().getId());
Collection<ElementInfo> elementInfos = zusammenAdaptor.listElementsByName(context,
- elementContext, new Id(limitEntity.getEpLkgId()),StructureElement.Limits.name());
+ elementContext, new Id(limitEntity.getEpLkgId()), ElementType.Limits.name());
for (ElementInfo elementInfo : elementInfos) {
if (elementInfo.getId().getValue().equals(limitEntity.getId())) {
@@ -81,20 +79,18 @@
@Override
public Collection<LimitEntity> list(LimitEntity limitEntity) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(limitEntity.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VlmZusammenUtil.getVersionTag(limitEntity.getVersion()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(limitEntity.getVendorLicenseModelId(), limitEntity.getVersion().getId());
return listLimits(context, elementContext, limitEntity);
}
private Collection<LimitEntity> listLimits(SessionContext context, ElementContext elementContext,
- LimitEntity limitEntity) {
+ LimitEntity limitEntity) {
return zusammenAdaptor
.listElementsByName(context, elementContext, new Id(limitEntity.getEpLkgId()),
- StructureElement.Limits.name())
+ ElementType.Limits.name())
.stream().map(elementInfo -> mapElementInfoToLimit(
limitEntity.getVendorLicenseModelId(), limitEntity.getVersion(),
limitEntity.getEpLkgId(), elementInfo))
@@ -102,18 +98,18 @@
}
private LimitEntity mapElementInfoToLimit(String vlmId, Version version,
- String epLkgId, ElementInfo elementInfo) {
+ String epLkgId, ElementInfo elementInfo) {
LimitEntity limitEntity =
new LimitEntity(vlmId, version, epLkgId, elementInfo.getId().getValue());
limitEntity.setName(elementInfo.getInfo().getName());
limitEntity.setDescription(elementInfo.getInfo().getDescription());
- limitEntity.setType( elementInfo.getInfo().getProperties().get(LIMT_TYPE) != null ?
+ limitEntity.setType(elementInfo.getInfo().getProperties().get(LIMT_TYPE) != null ?
LimitType.valueOf((String) elementInfo.getInfo().getProperties().get(LIMT_TYPE)) :
null);
- limitEntity.setTime((String) elementInfo.getInfo().getProperties().get(TIME) );
- limitEntity.setMetric( (String) elementInfo.getInfo().getProperties().get(METRIC));
- limitEntity.setAggregationFunction( elementInfo.getInfo().getProperties().get
+ limitEntity.setTime((String) elementInfo.getInfo().getProperties().get(TIME));
+ limitEntity.setMetric((String) elementInfo.getInfo().getProperties().get(METRIC));
+ limitEntity.setAggregationFunction(elementInfo.getInfo().getProperties().get
(AGGREGATIONFUNCTION) != null ?
AggregationFunction.valueOf((String) elementInfo.getInfo().getProperties()
.get(AGGREGATIONFUNCTION)) : null);
@@ -126,25 +122,22 @@
}
@Override
- public void update(LimitEntity entity) {
- ZusammenElement limitElement = limitToZusammen(entity, Action.UPDATE);
+ public void update(LimitEntity limitEntity) {
+ ZusammenElement limitElement = limitToZusammen(limitEntity, Action.UPDATE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(entity.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(limitEntity.getVendorLicenseModelId(), limitEntity.getVersion().getId());
- zusammenAdaptor.saveElement(context,elementContext, limitElement,
- String.format("Update limit with id %s", entity.getId()));
+ zusammenAdaptor.saveElement(context, elementContext, limitElement,
+ String.format("Update limit with id %s", limitEntity.getId()));
}
@Override
public LimitEntity get(LimitEntity limitEntity) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(limitEntity.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VlmZusammenUtil.getVersionTag(limitEntity.getVersion()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(limitEntity.getVendorLicenseModelId(), limitEntity.getVersion().getId());
return zusammenAdaptor.getElementInfo(context, elementContext, new Id(limitEntity.getId()))
.map(elementInfo -> mapElementInfoToLimit(
@@ -154,18 +147,14 @@
}
@Override
- public void delete(LimitEntity entity) {
- SessionContext context = ZusammenUtil.createSessionContext();
- ZusammenElement zusammenElement = new ZusammenElement();
- zusammenElement.setAction(Action.DELETE);
- zusammenElement.setElementId(new Id(entity.getId()));
+ public void delete(LimitEntity limitEntity) {
+ ZusammenElement zusammenElement = buildElement(new Id(limitEntity.getId()), Action.DELETE);
- Id itemId = new Id(entity.getVendorLicenseModelId());
+ SessionContext context = createSessionContext();
ElementContext elementContext =
- new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ new ElementContext(limitEntity.getVendorLicenseModelId(), limitEntity.getVersion().getId());
zusammenAdaptor.saveElement(context, elementContext, zusammenElement,
- "delete limit Id:" + entity.getId() + ".");
+ "delete limit Id:" + limitEntity.getId() + ".");
}
@Override
@@ -173,23 +162,13 @@
}
- private ZusammenElement limitToZusammen(LimitEntity limit,
- Action action) {
- ZusammenElement limitElement = buildLimitElement(limit, action);
- return limitElement;
- }
-
- private ZusammenElement buildLimitElement(LimitEntity limit,
- Action action) {
- ZusammenElement limitElement = new ZusammenElement();
- limitElement.setAction(action);
- if (limit.getId() != null) {
- limitElement.setElementId(new Id(limit.getId()));
- }
-
+ private ZusammenElement limitToZusammen(LimitEntity limit, Action action) {
+ ZusammenElement limitElement =
+ buildElement(limit.getId() == null ? null : new Id(limit.getId()), action);
Info info = new Info();
info.setName(limit.getName());
info.setDescription(limit.getDescription());
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.Limit);
info.addProperty(LIMT_TYPE, limit.getType());
info.addProperty(METRIC, limit.getMetric());
info.addProperty(AGGREGATIONFUNCTION, limit.getAggregationFunction());
@@ -199,11 +178,4 @@
limitElement.setInfo(info);
return limitElement;
}
-
- private ZusammenElement buildZusammenElement(Id elementId, Action action) {
- ZusammenElement element = new ZusammenElement();
- element.setElementId(elementId);
- element.setAction(action);
- return element;
- }
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/VendorLicenseModelDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/VendorLicenseModelDaoZusammenImpl.java
index cd1ef0f..1306551 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/VendorLicenseModelDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/VendorLicenseModelDaoZusammenImpl.java
@@ -1,23 +1,21 @@
package org.openecomp.sdc.vendorlicense.dao.impl.zusammen;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
-import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.SessionContext;
import com.amdocs.zusammen.datatypes.item.Action;
import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.datatypes.item.Info;
-import com.amdocs.zusammen.datatypes.item.ItemVersion;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDao;
+import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor.ElementToVLMGeneralConvertor;
import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
import org.openecomp.sdc.versioning.VersioningManagerFactory;
-import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdc.versioning.types.VersionableEntityMetadata;
import org.openecomp.sdc.versioning.types.VersionableEntityStoreType;
import java.util.Collection;
-import java.util.Date;
import java.util.stream.Collectors;
public class VendorLicenseModelDaoZusammenImpl implements VendorLicenseModelDao {
@@ -31,63 +29,91 @@
@Override
public void registerVersioning(String versionableEntityType) {
VersionableEntityMetadata metadata =
- new VersionableEntityMetadata(VersionableEntityStoreType.Zusammen, "vlm", null, null);
+ new VersionableEntityMetadata(VersionableEntityStoreType.Zusammen, "VendorLicenseModel",
+ null, null);
VersioningManagerFactory.getInstance().createInterface()
.register(versionableEntityType, metadata);
}
@Override
- public Collection<VendorLicenseModelEntity> list(VendorLicenseModelEntity entity) {
+ public Collection<VendorLicenseModelEntity> list(
+ VendorLicenseModelEntity vendorLicenseModelEntity) {
+
+ ElementToVLMGeneralConvertor convertor = new ElementToVLMGeneralConvertor();
return zusammenAdaptor.listItems(ZusammenUtil.createSessionContext()).stream()
- .map(item -> mapInfoToVlm(
- item.getId().getValue(), null, item.getInfo(),
- item.getModificationTime(), item.getCreationTime()))
+ .filter(item -> "VendorLicenseModel".equals(item.getInfo().getProperty("item_type")))
+ .map(item -> {
+ VendorLicenseModelEntity entity = convertor.convert(item);
+ entity.setId(item.getId().getValue());
+ entity.setVersion(null);
+ return entity;
+ })
.collect(Collectors.toList());
}
@Override
public void create(VendorLicenseModelEntity vendorLicenseModel) {
+
SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = zusammenAdaptor.createItem(context, mapVlmToZusammenItemInfo(vendorLicenseModel));
- Id versionId =
- zusammenAdaptor.createVersion(context, itemId, null, ZusammenUtil.createFirstVersionData());
+ ElementContext elementContext = new ElementContext(vendorLicenseModel.getId(),
+ vendorLicenseModel.getVersion().getId());
ZusammenElement generalElement = mapVlmToZusammenElement(vendorLicenseModel, Action.CREATE);
- zusammenAdaptor.saveElement(context, new ElementContext(itemId, versionId),
- generalElement, "Create VSP General Info Element");
- vendorLicenseModel.setId(itemId.getValue());//set id for caller
+ zusammenAdaptor.saveElement(context, elementContext, generalElement,
+ "Create VLM General Info Element");
+
+ ZusammenElement licenseAgreementsElement =
+ ZusammenUtil.buildStructuralElement(ElementType.LicenseAgreements, Action.CREATE);
+
+ zusammenAdaptor.saveElement(context, elementContext, licenseAgreementsElement,
+ "Create VLM licenseAgreementsElement");
+
+ ZusammenElement featureGroupsElement =
+ ZusammenUtil.buildStructuralElement(ElementType.FeatureGroups, Action.CREATE);
+
+ zusammenAdaptor.saveElement(context, elementContext, featureGroupsElement,
+ "Create VLM featureGroupsElement");
+
+ ZusammenElement lkgsElement =
+ ZusammenUtil.buildStructuralElement(ElementType.LicenseKeyGroups, Action.CREATE);
+
+ zusammenAdaptor.saveElement(context, elementContext, lkgsElement,
+ "Create VLM lkgsElement");
+
+ ZusammenElement entitlementPoolsElement =
+ ZusammenUtil.buildStructuralElement(ElementType.EntitlementPools, Action.CREATE);
+
+ zusammenAdaptor.saveElement(context, elementContext, entitlementPoolsElement,
+ "Create VLM entitlementPoolsElement");
}
@Override
public void update(VendorLicenseModelEntity vendorLicenseModel) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vendorLicenseModel.getId());
- Id versionId = VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor);
-
- zusammenAdaptor.updateItem(context, itemId, mapVlmToZusammenItemInfo(vendorLicenseModel));
-
ZusammenElement generalElement = mapVlmToZusammenElement(vendorLicenseModel, Action.UPDATE);
- zusammenAdaptor.saveElement(context, new ElementContext(itemId, versionId),
+
+ SessionContext context = ZusammenUtil.createSessionContext();
+ zusammenAdaptor.saveElement(context,
+ new ElementContext(vendorLicenseModel.getId(), vendorLicenseModel.getVersion().getId()),
generalElement, "Update VSP General Info Element");
}
@Override
public VendorLicenseModelEntity get(VendorLicenseModelEntity vendorLicenseModel) {
SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vendorLicenseModel.getId());
- ItemVersion itemVersion = VlmZusammenUtil.getFirstVersion(context, itemId, zusammenAdaptor);
- ElementContext elementContext = new ElementContext(itemId, itemVersion.getId(),
- VlmZusammenUtil.getVersionTag(vendorLicenseModel.getVersion()));
-
+ ElementContext elementContext =
+ new ElementContext(vendorLicenseModel.getId(), vendorLicenseModel.getVersion().getId());
+ ElementToVLMGeneralConvertor convertor = new ElementToVLMGeneralConvertor();
return zusammenAdaptor
- .getElementInfoByName(context, elementContext, null, StructureElement.General.name())
- .map(generalElementInfo -> mapInfoToVlm(
- vendorLicenseModel.getId(), vendorLicenseModel.getVersion(),
- generalElementInfo.getInfo(),
- itemVersion.getModificationTime(), itemVersion.getCreationTime()))
+ .getElementInfoByName(context, elementContext, null, ElementType.VendorLicenseModel.name())
+ .map(generalElementInfo -> {
+ VendorLicenseModelEntity entity = convertor.convert(generalElementInfo);
+ entity.setId(vendorLicenseModel.getId());
+ entity.setVersion(vendorLicenseModel.getVersion());
+ return entity;
+ })
.orElse(null);
}
@@ -96,19 +122,19 @@
}
- private Info mapVlmToZusammenItemInfo(VendorLicenseModelEntity vendorLicenseModel) {
+ /* private Info mapVlmToZusammenItemInfo(VendorLicenseModelEntity vendorLicenseModel) {
Info info = new Info();
info.setName(vendorLicenseModel.getVendorName());
info.setDescription(vendorLicenseModel.getDescription());
- info.addProperty("type", "vlm");
+ info.addProperty("type", "VendorLicenseModel");
addVlmToInfo(info, vendorLicenseModel);
return info;
- }
+ }*/
private ZusammenElement mapVlmToZusammenElement(VendorLicenseModelEntity vendorLicenseModel,
Action action) {
ZusammenElement generalElement =
- VlmZusammenUtil.buildStructuralElement(StructureElement.General, action);
+ ZusammenUtil.buildStructuralElement(ElementType.VendorLicenseModel, action);
addVlmToInfo(generalElement.getInfo(), vendorLicenseModel);
return generalElement;
}
@@ -117,22 +143,21 @@
info.addProperty(InfoPropertyName.name.name(), vendorLicenseModel.getVendorName());
info.addProperty(InfoPropertyName.description.name(), vendorLicenseModel.getDescription());
info.addProperty(InfoPropertyName.iconRef.name(), vendorLicenseModel.getIconRef());
+ info.addProperty(InfoPropertyName.oldVersion.name(), vendorLicenseModel.getOldVersion());
}
- private VendorLicenseModelEntity mapInfoToVlm(String vlmId, Version version, Info info,
- Date modificationTime, Date creationTime) {
+ /*private VendorLicenseModelEntity mapInfoToVlm(String vlmId, Version version, Info info) {
VendorLicenseModelEntity vendorLicenseModel = new VendorLicenseModelEntity(vlmId, version);
vendorLicenseModel.setVendorName(info.getProperty(InfoPropertyName.name.name()));
vendorLicenseModel.setDescription(info.getProperty(InfoPropertyName.description.name()));
vendorLicenseModel.setIconRef(info.getProperty(InfoPropertyName.iconRef.name()));
- vendorLicenseModel.setWritetimeMicroSeconds(
- modificationTime == null ? creationTime.getTime() : modificationTime.getTime());
return vendorLicenseModel;
- }
+ }*/
- private enum InfoPropertyName {
+ public enum InfoPropertyName {
name,
description,
- iconRef
+ iconRef,
+ oldVersion
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/VlmZusammenUtil.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/VlmZusammenUtil.java
index f16d0fa..07a4f87 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/VlmZusammenUtil.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/VlmZusammenUtil.java
@@ -3,49 +3,13 @@
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
import com.amdocs.zusammen.datatypes.Id;
-import com.amdocs.zusammen.datatypes.SessionContext;
-import com.amdocs.zusammen.datatypes.item.Action;
-import com.amdocs.zusammen.datatypes.item.ItemVersion;
import com.amdocs.zusammen.datatypes.item.Relation;
import com.amdocs.zusammen.datatypes.item.RelationEdge;
-import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
-import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.vendorlicense.errors.VendorLicenseModelNotFoundErrorBuilder;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.dao.types.VersionStatus;
-import java.util.Optional;
import java.util.stream.Collectors;
public class VlmZusammenUtil {
- static ItemVersion getFirstVersion(SessionContext context, Id itemId,
- ZusammenAdaptor zusammenAdaptor) {
- Optional<ItemVersion> itemVersion = zusammenAdaptor.getFirstVersion(context, itemId);
-
- if (!itemVersion.isPresent()) {
- throw new CoreException(
- new VendorLicenseModelNotFoundErrorBuilder(itemId.getValue()).build());
- }
- return itemVersion.get();
- }
-
- static Id getFirstVersionId(SessionContext context, Id itemId, ZusammenAdaptor zusammenAdaptor) {
- return getFirstVersion(context, itemId, zusammenAdaptor).getId();
- }
-
- // TODO: 4/25/2017 remove upon working with more than one single version
- static String getVersionTag(Version version) {
- return version.getStatus() == VersionStatus.Locked
- ? null
- : version.toString();
- }
-
- static ZusammenElement buildStructuralElement(StructureElement structureElement, Action action) {
- return ZusammenUtil.buildStructuralElement(structureElement.name(), action);
- }
-
static ZusammenElement getZusammenElement(ElementInfo elementInfo) {
ZusammenElement zusammenElement = new ZusammenElement();
zusammenElement.setElementId(elementInfo.getId());
@@ -67,6 +31,9 @@
}
public static Integer toInteger(Object val) {
+ if (val == null) {
+ return null;
+ }
if (val instanceof Double) {
return ((Double) val).intValue();
} else if (val instanceof String) {
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToEntitlementPoolConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToEntitlementPoolConvertor.java
new file mode 100644
index 0000000..75fc6f2
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToEntitlementPoolConvertor.java
@@ -0,0 +1,95 @@
+package org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.item.Info;
+import com.amdocs.zusammen.datatypes.item.Relation;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther;
+import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope;
+import org.openecomp.sdc.vendorlicense.dao.types.ThresholdUnit;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import static org.openecomp.sdc.vendorlicense.dao.impl.zusammen.VlmZusammenUtil.toInteger;
+
+
+public class ElementToEntitlementPoolConvertor extends ElementConvertor {
+ @Override
+ public EntitlementPoolEntity convert(Element element) {
+ if (element == null) {
+ return null;
+ }
+ return mapElementToEntitlementPoolEntity(element);
+ }
+
+ @Override
+ public EntitlementPoolEntity convert(ElementInfo elementInfo) {
+ if (elementInfo == null) {
+ return null;
+ }
+ return mapElementInfoToEntitlementPoolEntity(elementInfo);
+ }
+
+ private EntitlementPoolEntity mapElementToEntitlementPoolEntity(Element element) {
+ EntitlementPoolEntity entitlementPool =
+ new EntitlementPoolEntity();
+ entitlementPool.setId(element.getElementId().getValue());
+ mapInfoToEntitlementPoolEntity(entitlementPool, element.getInfo());
+ mapRelationsToEntitlementPoolEntity(entitlementPool, element.getRelations());
+ return entitlementPool;
+ }
+
+ private EntitlementPoolEntity mapElementInfoToEntitlementPoolEntity(ElementInfo elementInfo) {
+ EntitlementPoolEntity entitlementPool =
+ new EntitlementPoolEntity();
+ entitlementPool.setId(elementInfo.getId().getValue());
+ mapInfoToEntitlementPoolEntity(entitlementPool, elementInfo.getInfo());
+ mapRelationsToEntitlementPoolEntity(entitlementPool, elementInfo.getRelations());
+ return entitlementPool;
+ }
+
+ private void mapInfoToEntitlementPoolEntity(EntitlementPoolEntity entitlementPool, Info info) {
+ entitlementPool.setName(info.getName());
+ entitlementPool.setDescription(info.getDescription());
+ entitlementPool.setVersionUuId(info.getProperty("version_uuid"));
+ entitlementPool.setThresholdValue(toInteger(info.getProperty("thresholdValue")));
+ String thresholdUnit = info.getProperty("threshold_unit");
+ entitlementPool
+ .setThresholdUnit(thresholdUnit == null ? null : ThresholdUnit.valueOf(thresholdUnit));
+ entitlementPool.setIncrements(info.getProperty("increments"));
+ entitlementPool.setOperationalScope(
+ getOperationalScopeMultiChoiceOrOther(info.getProperty("operational_scope")));
+ entitlementPool.setStartDate(info.getProperty("startDate"));
+ entitlementPool.setExpiryDate(info.getProperty("expiryDate"));
+ }
+
+ private void mapRelationsToEntitlementPoolEntity(EntitlementPoolEntity entitlementPool,
+ Collection<Relation> relations) {
+ if (relations != null && relations.size() > 0) {
+ entitlementPool
+ .setReferencingFeatureGroups(relations.stream().map(relation -> relation
+ .getEdge2().getElementId().getValue()).collect(Collectors.toSet()));
+ }
+ }
+
+ private MultiChoiceOrOther<OperationalScope> getOperationalScopeMultiChoiceOrOther(
+ Map<String, Object> operationalScope) {
+ if (operationalScope == null || operationalScope.isEmpty()) {
+ return null;
+ }
+
+ Set<OperationalScope> choices = new HashSet<>();
+ ((List<String>) operationalScope.get("choices")).
+ forEach(choice -> choices.add(OperationalScope.valueOf(choice)));
+
+ Object other = operationalScope.get("other");
+ return new MultiChoiceOrOther<>(choices, other == null ? null : (String) other);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToFeatureGroupConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToFeatureGroupConvertor.java
new file mode 100644
index 0000000..e39c22e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToFeatureGroupConvertor.java
@@ -0,0 +1,83 @@
+package org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.item.Info;
+import com.amdocs.zusammen.datatypes.item.Relation;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.RelationType;
+import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+
+public class ElementToFeatureGroupConvertor extends ElementConvertor {
+ @Override
+ public FeatureGroupEntity convert(Element element) {
+ if (element == null) {
+ return null;
+ }
+ return mapElementToFeatureGroupEntity(element);
+
+ }
+
+ @Override
+ public FeatureGroupEntity convert(ElementInfo elementInfo) {
+ if (elementInfo == null) {
+ return null;
+ }
+ return mapElementInfoToFeatureGroupEntity(elementInfo);
+
+ }
+
+
+ private FeatureGroupEntity mapElementToFeatureGroupEntity(Element element) {
+ FeatureGroupEntity featureGroup =
+ new FeatureGroupEntity();
+ featureGroup.setId(element.getElementId().getValue());
+ mapInfoToFeatureGroup(featureGroup, element.getInfo());
+ mapRelationsToFeatureGroup(featureGroup, element.getRelations());
+ return featureGroup;
+ }
+
+
+ private FeatureGroupEntity mapElementInfoToFeatureGroupEntity(ElementInfo elementInfo) {
+ FeatureGroupEntity featureGroup = new FeatureGroupEntity();
+ featureGroup.setId(elementInfo.getId().getValue());
+ mapInfoToFeatureGroup(featureGroup, elementInfo.getInfo());
+ mapRelationsToFeatureGroup(featureGroup, elementInfo.getRelations());
+ return featureGroup;
+ }
+
+ private void mapInfoToFeatureGroup(FeatureGroupEntity featureGroup, Info info) {
+ featureGroup.setName(info.getName());
+ featureGroup.setDescription(info.getDescription());
+ featureGroup.setPartNumber(info.getProperty("partNumber"));
+ featureGroup.setManufacturerReferenceNumber(info.getProperty("manufacturerReferenceNumber"));
+ }
+
+ private void mapRelationsToFeatureGroup(FeatureGroupEntity featureGroup,
+ Collection<Relation> relations) {
+ Set<String> entitlementPoolIds = new HashSet<>();
+ Set<String> licenseAgreements = new HashSet<>();
+ Set<String> licenseKeyGroupIds = new HashSet<>();
+
+ if (relations != null) {
+ for (Relation relation : relations) {
+ if (RelationType.FeatureGroupToEntitlmentPool.name().equals(relation.getType())) {
+ entitlementPoolIds.add(relation.getEdge2().getElementId().getValue());
+ } else if (RelationType.FeatureGroupToLicenseKeyGroup.name().equals(relation.getType())) {
+ licenseKeyGroupIds.add(relation.getEdge2().getElementId().getValue());
+ } else if (RelationType.FeatureGroupToReferencingLicenseAgreement.name()
+ .equals(relation.getType())) {
+ licenseAgreements.add(relation.getEdge2().getElementId().getValue());
+ }
+ }
+ }
+ featureGroup.setEntitlementPoolIds(entitlementPoolIds);
+ featureGroup.setLicenseKeyGroupIds(licenseKeyGroupIds);
+ featureGroup.setReferencingLicenseAgreements(licenseAgreements);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToLicenseAgreementConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToLicenseAgreementConvertor.java
new file mode 100644
index 0000000..a0caa0c
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToLicenseAgreementConvertor.java
@@ -0,0 +1,86 @@
+package org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.item.Info;
+import com.amdocs.zusammen.datatypes.item.Relation;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther;
+import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.LicenseTerm;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+
+public class ElementToLicenseAgreementConvertor extends ElementConvertor {
+ @Override
+ public LicenseAgreementEntity convert(Element element) {
+ if (element == null) {
+ return null;
+ }
+ return mapElementToLicenseAgreementEntity(element);
+
+ }
+
+
+ @Override
+ public LicenseAgreementEntity convert(ElementInfo elementInfo) {
+ if (elementInfo == null) {
+ return null;
+ }
+ return mapElementInfoToLicenseAgreementEntity(elementInfo);
+
+ }
+
+
+ private LicenseAgreementEntity mapElementToLicenseAgreementEntity(Element element) {
+ LicenseAgreementEntity licenseAgreement =
+ new LicenseAgreementEntity();
+ licenseAgreement.setId(element.getElementId().getValue());
+ mapInfoToLicenseAgreementEntity(licenseAgreement, element.getInfo());
+ mapRelationsToLicenseAgreementEntity(licenseAgreement, element.getRelations());
+ return licenseAgreement;
+ }
+
+
+ private LicenseAgreementEntity mapElementInfoToLicenseAgreementEntity(ElementInfo elementInfo) {
+ LicenseAgreementEntity licenseAgreement =
+ new LicenseAgreementEntity();
+ licenseAgreement.setId( elementInfo.getId().getValue());
+ mapInfoToLicenseAgreementEntity(licenseAgreement, elementInfo.getInfo());
+ mapRelationsToLicenseAgreementEntity(licenseAgreement, elementInfo.getRelations());
+ return licenseAgreement;
+ }
+
+ private void mapRelationsToLicenseAgreementEntity(LicenseAgreementEntity licenseAgreementEntity,
+ Collection<Relation> relations) {
+ if (relations != null && relations.size() > 0) {
+ licenseAgreementEntity.setFeatureGroupIds(relations.stream()
+ .map(relation -> relation.getEdge2().getElementId().getValue())
+ .collect(Collectors.toSet()));
+ }
+
+ }
+
+ private void mapInfoToLicenseAgreementEntity(LicenseAgreementEntity licenseAgreement, Info info) {
+
+
+ licenseAgreement.setName(info.getName());
+ licenseAgreement.setDescription(info.getDescription());
+
+ licenseAgreement
+ .setLicenseTerm(getCoiceOrOther(info.getProperty("licenseTerm")));
+ licenseAgreement.setRequirementsAndConstrains(
+ info.getProperty("requirementsAndConstrains"));
+
+ }
+
+ private ChoiceOrOther<LicenseTerm> getCoiceOrOther(Map licenseTerm) {
+ return new ChoiceOrOther<>(LicenseTerm.valueOf((String) licenseTerm.get("choice")),
+ (String) licenseTerm.get("other"));
+ }
+
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToLicenseKeyGroupConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToLicenseKeyGroupConvertor.java
new file mode 100644
index 0000000..5956c3e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToLicenseKeyGroupConvertor.java
@@ -0,0 +1,104 @@
+package org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.item.Info;
+import com.amdocs.zusammen.datatypes.item.Relation;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyType;
+import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther;
+import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope;
+import org.openecomp.sdc.vendorlicense.dao.types.ThresholdUnit;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import static org.openecomp.sdc.vendorlicense.dao.impl.zusammen.VlmZusammenUtil.toInteger;
+
+
+public class ElementToLicenseKeyGroupConvertor extends ElementConvertor {
+ @Override
+ public LicenseKeyGroupEntity convert(Element element) {
+ if (element == null) {
+ return null;
+ }
+ return mapElementToLicenseKeyGroupEntity(element);
+
+ }
+
+ @Override
+ public LicenseKeyGroupEntity convert(ElementInfo elementInfo) {
+ if (elementInfo == null) {
+ return null;
+ }
+ return mapElementInfoToLicenseKeyGroupEntity(elementInfo);
+
+ }
+
+ private LicenseKeyGroupEntity mapElementToLicenseKeyGroupEntity(
+ Element element) {
+ LicenseKeyGroupEntity licenseKeyGroup =
+ new LicenseKeyGroupEntity();
+ licenseKeyGroup.setId(element.getElementId().getValue());
+ mapInfoToLicenseKeyGroup(licenseKeyGroup, element.getInfo());
+ mapRelationsToLicenseKeyGroup(licenseKeyGroup, element.getRelations());
+ return licenseKeyGroup;
+ }
+
+
+ private LicenseKeyGroupEntity mapElementInfoToLicenseKeyGroupEntity(ElementInfo elementInfo) {
+ LicenseKeyGroupEntity licenseKeyGroup =
+ new LicenseKeyGroupEntity();
+ licenseKeyGroup.setId(elementInfo.getId().getValue());
+
+ mapInfoToLicenseKeyGroup(licenseKeyGroup, elementInfo.getInfo());
+ mapRelationsToLicenseKeyGroup(licenseKeyGroup, elementInfo.getRelations());
+ return licenseKeyGroup;
+ }
+
+ private void mapInfoToLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, Info info) {
+ licenseKeyGroup.setName(info.getName());
+ licenseKeyGroup.setDescription(info.getDescription());
+ licenseKeyGroup.setVersionUuId(info.getProperty("version_uuid"));
+ licenseKeyGroup.setType(LicenseKeyType.valueOf(info.getProperty("LicenseKeyType")));
+ licenseKeyGroup.setOperationalScope(
+ getOperationalScopeMultiChoiceOrOther(info.getProperty("operational_scope")));
+ licenseKeyGroup.setStartDate(info.getProperty("startDate"));
+ licenseKeyGroup.setExpiryDate(info.getProperty("expiryDate"));
+
+ String thresholdUnit = info.getProperty("thresholdUnits");
+ licenseKeyGroup
+ .setThresholdUnits(thresholdUnit == null ? null : ThresholdUnit.valueOf(thresholdUnit));
+
+ licenseKeyGroup.setThresholdValue(toInteger(info.getProperty("thresholdValue")));
+ licenseKeyGroup.setIncrements(info.getProperty("increments"));
+ }
+
+ private void mapRelationsToLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup,
+ Collection<Relation> relations) {
+ if (relations != null && relations.size() > 0) {
+ licenseKeyGroup
+ .setReferencingFeatureGroups((relations.stream().map(relation -> relation
+ .getEdge2().getElementId().getValue()).collect(Collectors.toSet())));
+ }
+ }
+
+ private MultiChoiceOrOther<OperationalScope> getOperationalScopeMultiChoiceOrOther(
+ Map<String, Object> operationalScope) {
+ if (operationalScope == null || operationalScope.isEmpty()) {
+ return null;
+ }
+
+ Set<OperationalScope> choices = new HashSet<>();
+ ((List<String>) operationalScope.get("choices")).
+ forEach(choice -> choices.add(OperationalScope.valueOf(choice)));
+
+ Object other = operationalScope.get("other");
+ return new MultiChoiceOrOther<>(choices, other == null ? null : (String) other);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToLimitConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToLimitConvertor.java
new file mode 100644
index 0000000..4b2370a
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToLimitConvertor.java
@@ -0,0 +1,44 @@
+package org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.LimitType;
+
+/**
+ * Created by ayalaben on 9/26/2017
+ */
+public class ElementToLimitConvertor extends ElementConvertor {
+ @Override
+ public Object convert(Element element) {
+ if (element == null) {
+ return null;
+ }
+ return mapElementToLimitEntity(element);
+ }
+
+ private LimitEntity mapElementToLimitEntity(Element element) {
+ LimitEntity limit = new LimitEntity();
+ limit.setId(element.getElementId().getValue());
+ limit.setName(element.getInfo().getName());
+ limit.setDescription(element.getInfo().getDescription());
+ limit.setUnit(element.getInfo().getProperty("unit"));
+ limit.setMetric(element.getInfo().getProperty("metric"));
+ limit.setValue(element.getInfo().getProperty("value"));
+ limit.setTime(element.getInfo().getProperty("time"));
+ limit.setAggregationFunction(element.getInfo().getProperty("aggregationFunction"));
+ setLimitType(limit,element.getInfo().getProperty("type"));
+
+ return limit;
+ }
+
+ private void setLimitType(LimitEntity limit, String type) {
+ switch (LimitType.valueOf(type)) {
+ case ServiceProvider:
+ limit.setType(LimitType.ServiceProvider);
+ break;
+ case Vendor:
+ limit.setType(LimitType.Vendor);
+ }
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToVLMGeneralConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToVLMGeneralConvertor.java
new file mode 100644
index 0000000..c2ef5a6
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToVLMGeneralConvertor.java
@@ -0,0 +1,52 @@
+package org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.item.Info;
+import com.amdocs.zusammen.datatypes.item.Item;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.VendorLicenseModelDaoZusammenImpl;
+import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
+
+
+public class ElementToVLMGeneralConvertor extends ElementConvertor {
+ @Override
+ public VendorLicenseModelEntity convert(Element element) {
+ if(element == null) return null;
+ return mapInfoToVendorLicenseModelEntity( element.getInfo());
+
+ }
+
+ @Override
+ public VendorLicenseModelEntity convert(Item item) {
+ if(item == null) return null;
+ return mapInfoToVendorLicenseModelEntity( item.getInfo());
+ }
+
+ @Override
+ public VendorLicenseModelEntity convert(ElementInfo elementInfo) {
+ if(elementInfo == null) return null;
+ return mapInfoToVendorLicenseModelEntity( elementInfo.getInfo());
+
+ }
+
+
+ private VendorLicenseModelEntity mapInfoToVendorLicenseModelEntity(Info info) {
+
+ VendorLicenseModelEntity vendorLicenseModelEntity = new VendorLicenseModelEntity();
+
+ vendorLicenseModelEntity.setVendorName(info.getProperty(
+ VendorLicenseModelDaoZusammenImpl.InfoPropertyName.name.name()));
+ vendorLicenseModelEntity.setDescription(info.getProperty(
+ VendorLicenseModelDaoZusammenImpl.InfoPropertyName.description.name()));
+ vendorLicenseModelEntity.setIconRef(info.getProperty(
+ VendorLicenseModelDaoZusammenImpl.InfoPropertyName.iconRef.name()));
+ vendorLicenseModelEntity.setOldVersion(info.getProperty(
+ VendorLicenseModelDaoZusammenImpl.InfoPropertyName.oldVersion.name()));
+
+
+ return vendorLicenseModelEntity;
+ }
+
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/facade/impl/VendorLicenseFacadeImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/facade/impl/VendorLicenseFacadeImpl.java
index b2f2d48..0898e48 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/facade/impl/VendorLicenseFacadeImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/facade/impl/VendorLicenseFacadeImpl.java
@@ -20,18 +20,12 @@
package org.openecomp.sdc.vendorlicense.facade.impl;
-import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE;
-import static org.openecomp.sdc.vendorlicense.errors.UncompletedVendorLicenseModelErrorType.SUBMIT_UNCOMPLETED_VLM_MSG_FG_MISSING_EP;
-import static org.openecomp.sdc.vendorlicense.errors.UncompletedVendorLicenseModelErrorType.SUBMIT_UNCOMPLETED_VLM_MSG_LA_MISSING_FG;
-
import org.apache.commons.collections4.CollectionUtils;
import org.openecomp.core.util.UniqueValueUtil;
import org.openecomp.core.utilities.CommonMethods;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
import org.openecomp.sdc.logging.types.LoggerConstants;
@@ -62,23 +56,21 @@
import org.openecomp.sdc.vendorlicense.errors.SubmitUncompletedLicenseModelErrorBuilder;
import org.openecomp.sdc.vendorlicense.errors.VendorLicenseModelNotFoundErrorBuilder;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
-import org.openecomp.sdc.vendorlicense.types.VersionedVendorLicenseModel;
-import org.openecomp.sdc.versioning.VersioningManager;
-import org.openecomp.sdc.versioning.VersioningManagerFactory;
import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.errors.RequestedVersionInvalidErrorBuilder;
import org.openecomp.sdc.versioning.errors.VersionableSubEntityNotFoundErrorBuilder;
-import org.openecomp.sdc.versioning.types.VersionInfo;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Objects;
+
+import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE;
+import static org.openecomp.sdc.vendorlicense.errors.UncompletedVendorLicenseModelErrorType.SUBMIT_UNCOMPLETED_VLM_MSG_FG_MISSING_EP;
+import static org.openecomp.sdc.vendorlicense.errors.UncompletedVendorLicenseModelErrorType.SUBMIT_UNCOMPLETED_VLM_MSG_LA_MISSING_FG;
public class VendorLicenseFacadeImpl implements VendorLicenseFacade {
-
- private static final VersioningManager versioningManager =
- VersioningManagerFactory.getInstance().createInterface();
-
private static final VendorLicenseModelDao
vendorLicenseModelDao = VendorLicenseModelDaoFactory.getInstance().createInterface();
private static final LicenseAgreementDao
@@ -91,7 +83,6 @@
licenseKeyGroupDao = LicenseKeyGroupDaoFactory.getInstance().createInterface();
private static final LimitDao limitDao = LimitDaoFactory.getInstance().createInterface();
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
- private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
/**
* Instantiates a new Vendor license facade.
@@ -106,32 +97,7 @@
}
@Override
- public Version checkin(String vendorLicenseModelId, String user) {
- Version newVersion = versioningManager
- .checkin(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vendorLicenseModelId, user, null);
- updateVlmLastModificationTime(vendorLicenseModelId, newVersion);
- return newVersion;
- }
-
- @Override
- public Version submit(String vendorLicenseModelId, String user) {
- validateCompletedVendorLicenseModel(vendorLicenseModelId, user);
- Version newVersion = versioningManager
- .submit(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vendorLicenseModelId, user, null);
- updateVlmLastModificationTime(vendorLicenseModelId, newVersion);
- return newVersion;
- }
-
- @Override
- public FeatureGroupEntity getFeatureGroup(FeatureGroupEntity featureGroup, String user) {
- Version version = VersioningUtil.resolveVersion(featureGroup.getVersion(),
- getVersionInfo(featureGroup.getVendorLicenseModelId(), VersionableEntityAction.Read,
- user), user);
- featureGroup.setVersion(version);
- return getFeatureGroup(featureGroup);
- }
-
- private FeatureGroupEntity getFeatureGroup(FeatureGroupEntity featureGroup) {
+ public FeatureGroupEntity getFeatureGroup(FeatureGroupEntity featureGroup) {
FeatureGroupEntity retrieved = featureGroupDao.get(featureGroup);
VersioningUtil
.validateEntityExistence(retrieved, featureGroup, VendorLicenseModelEntity.ENTITY_TYPE);
@@ -142,8 +108,8 @@
}
@Override
- public FeatureGroupModel getFeatureGroupModel(FeatureGroupEntity featureGroup, String user) {
- FeatureGroupEntity retrieved = getFeatureGroup(featureGroup, user);
+ public FeatureGroupModel getFeatureGroupModel(FeatureGroupEntity featureGroup) {
+ FeatureGroupEntity retrieved = getFeatureGroup(featureGroup);
FeatureGroupModel featureGroupModel = new FeatureGroupModel();
featureGroupModel.setFeatureGroup(retrieved);
@@ -164,9 +130,9 @@
@Override
public LicenseAgreementModel getLicenseAgreementModel(String vlmId, Version version,
- String licenseAgreementId, String user) {
+ String licenseAgreementId) {
LicenseAgreementEntity retrieved =
- getLicenseAgreement(vlmId, version, licenseAgreementId, user);
+ getLicenseAgreement(vlmId, version, licenseAgreementId);
LicenseAgreementModel licenseAgreementModel = new LicenseAgreementModel();
licenseAgreementModel.setLicenseAgreement(retrieved);
@@ -180,103 +146,71 @@
}
@Override
- public EntitlementPoolEntity createEntitlementPool(EntitlementPoolEntity entitlementPool,
- String user) {
- entitlementPool.setVersion(VersioningUtil.resolveVersion(entitlementPool.getVersion(),
- getVersionInfo(entitlementPool.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user), user));
- //entitlementPool.setId(CommonMethods.nextUuId());
+ public EntitlementPoolEntity createEntitlementPool(EntitlementPoolEntity entitlementPool) {
entitlementPool.setVersionUuId(CommonMethods.nextUuId());
UniqueValueUtil.createUniqueValue(VendorLicenseConstants.UniqueValues.ENTITLEMENT_POOL_NAME,
- entitlementPool.getVendorLicenseModelId(), entitlementPool.getVersion().toString(),
+ entitlementPool.getVendorLicenseModelId(), entitlementPool.getVersion().getId(),
entitlementPool.getName());
entitlementPoolDao.create(entitlementPool);
- updateVlmLastModificationTime(entitlementPool.getVendorLicenseModelId(),
- entitlementPool.getVersion());
return entitlementPool;
}
@Override
- public void updateEntitlementPool(EntitlementPoolEntity entitlementPool, String user) {
- entitlementPool.setVersion(VersioningUtil.resolveVersion(entitlementPool.getVersion(),
- getVersionInfo(entitlementPool.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user), user));
+ public void updateEntitlementPool(EntitlementPoolEntity entitlementPool) {
EntitlementPoolEntity retrieved = entitlementPoolDao.get(entitlementPool);
VersioningUtil
.validateEntityExistence(retrieved, entitlementPool, VendorLicenseModelEntity.ENTITY_TYPE);
-
+ if (retrieved.equals(entitlementPool)) {
+ return;
+ }
UniqueValueUtil.updateUniqueValue(VendorLicenseConstants.UniqueValues.ENTITLEMENT_POOL_NAME,
retrieved.getName(), entitlementPool.getName(), entitlementPool.getVendorLicenseModelId(),
- entitlementPool.getVersion().toString());
+ entitlementPool.getVersion().getId());
entitlementPool.setVersionUuId(CommonMethods.nextUuId());
entitlementPoolDao.update(entitlementPool);
-
- updateVlmLastModificationTime(entitlementPool.getVendorLicenseModelId(),
- entitlementPool.getVersion());
-
}
@Override
- public Collection<LicenseKeyGroupEntity> listLicenseKeyGroups(String vlmId, Version version,
- String user) {
- return licenseKeyGroupDao.list(new LicenseKeyGroupEntity(vlmId, VersioningUtil
- .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Read, user), user),
- null));
+ public Collection<LicenseKeyGroupEntity> listLicenseKeyGroups(String vlmId, Version version) {
+ return licenseKeyGroupDao.list(new LicenseKeyGroupEntity(vlmId, version, null));
}
@Override
- public Collection<EntitlementPoolEntity> listEntitlementPools(String vlmId, Version version,
- String user) {
- return entitlementPoolDao.list(new EntitlementPoolEntity(vlmId, VersioningUtil
- .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Read, user), user),
- null));
+ public Collection<EntitlementPoolEntity> listEntitlementPools(String vlmId, Version version) {
+ return entitlementPoolDao.list(new EntitlementPoolEntity(vlmId, version, null));
}
@Override
- public void updateLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user) {
- licenseKeyGroup.setVersion(VersioningUtil.resolveVersion(licenseKeyGroup.getVersion(),
- getVersionInfo(licenseKeyGroup.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user), user));
+ public void updateLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup) {
LicenseKeyGroupEntity retrieved = licenseKeyGroupDao.get(licenseKeyGroup);
+ if (retrieved.equals(licenseKeyGroup)) {
+ return;
+ }
licenseKeyGroup.setVersionUuId((CommonMethods.nextUuId()));
VersioningUtil
.validateEntityExistence(retrieved, licenseKeyGroup, VendorLicenseModelEntity.ENTITY_TYPE);
UniqueValueUtil.updateUniqueValue(VendorLicenseConstants.UniqueValues.LICENSE_KEY_GROUP_NAME,
retrieved.getName(), licenseKeyGroup.getName(), licenseKeyGroup.getVendorLicenseModelId(),
- licenseKeyGroup.getVersion().toString());
+ licenseKeyGroup.getVersion().getId());
licenseKeyGroupDao.update(licenseKeyGroup);
-
- updateVlmLastModificationTime(licenseKeyGroup.getVendorLicenseModelId(),
- licenseKeyGroup.getVersion());
}
@Override
- public LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup,
- String user) {
- licenseKeyGroup.setVersion(VersioningUtil.resolveVersion(licenseKeyGroup.getVersion(),
- getVersionInfo(licenseKeyGroup.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user), user));
- //licenseKeyGroup.setId(CommonMethods.nextUuId());
+ public LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup) {
licenseKeyGroup.setVersionUuId(CommonMethods.nextUuId());
UniqueValueUtil.createUniqueValue(VendorLicenseConstants.UniqueValues.LICENSE_KEY_GROUP_NAME,
- licenseKeyGroup.getVendorLicenseModelId(), licenseKeyGroup.getVersion().toString(),
+ licenseKeyGroup.getVendorLicenseModelId(), licenseKeyGroup.getVersion().getId(),
licenseKeyGroup.getName());
licenseKeyGroupDao.create(licenseKeyGroup);
- updateVlmLastModificationTime(licenseKeyGroup.getVendorLicenseModelId(),
- licenseKeyGroup.getVersion());
return licenseKeyGroup;
}
@Override
- public VersionedVendorLicenseModel getVendorLicenseModel(String vlmId, Version version,
- String user) {
+ public VendorLicenseModelEntity getVendorLicenseModel(String vlmId, Version version) {
mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId);
- VersionInfo versionInfo = getVersionInfo(vlmId, VersionableEntityAction.Read, user);
-
- VendorLicenseModelEntity vendorLicenseModel = vendorLicenseModelDao.get(
- new VendorLicenseModelEntity(vlmId,
- VersioningUtil.resolveVersion(version, versionInfo, user)));
+ VendorLicenseModelEntity vendorLicenseModel =
+ vendorLicenseModelDao.get(new VendorLicenseModelEntity(vlmId, version));
if (vendorLicenseModel == null) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.GET_VLM, ErrorLevel.ERROR.name(),
@@ -285,90 +219,61 @@
}
mdcDataDebugMessage.debugExitMessage("VLM id", vlmId);
- return new VersionedVendorLicenseModel(vendorLicenseModel, versionInfo);
+ return vendorLicenseModel;
}
@Override
- public VendorLicenseModelEntity createVendorLicenseModel(
- VendorLicenseModelEntity vendorLicenseModelEntity, String user) {
-
- mdcDataDebugMessage.debugEntryMessage(null, null);
-
- UniqueValueUtil.validateUniqueValue(VendorLicenseConstants.UniqueValues.VENDOR_NAME,
- vendorLicenseModelEntity.getVendorName());
- //vendorLicenseModelEntity.setId(CommonMethods.nextUuId());
-
- vendorLicenseModelDao.create(vendorLicenseModelEntity);
- UniqueValueUtil.createUniqueValue(VendorLicenseConstants.UniqueValues.VENDOR_NAME,
- vendorLicenseModelEntity.getVendorName());
-
- Version version = versioningManager
- .create(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vendorLicenseModelEntity.getId(), user);
- vendorLicenseModelEntity.setVersion(version);
-
- mdcDataDebugMessage.debugExitMessage(null, null);
- return vendorLicenseModelEntity;
- }
-
- @Override
- public LicenseAgreementEntity createLicenseAgreement(LicenseAgreementEntity licenseAgreement,
- String user) {
- Version version = VersioningUtil.resolveVersion(licenseAgreement.getVersion(),
- getVersionInfo(licenseAgreement.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user), user);
- licenseAgreement.setVersion(version);
+ public LicenseAgreementEntity createLicenseAgreement(LicenseAgreementEntity licenseAgreement) {
//licenseAgreement.setId(CommonMethods.nextUuId());
VersioningUtil.validateEntitiesExistence(licenseAgreement.getFeatureGroupIds(),
- new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(), version, null),
+ new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(),
+ licenseAgreement.getVersion(),
+ null),
featureGroupDao, VendorLicenseModelEntity.ENTITY_TYPE);
UniqueValueUtil.validateUniqueValue(VendorLicenseConstants.UniqueValues.LICENSE_AGREEMENT_NAME,
- licenseAgreement.getVendorLicenseModelId(), licenseAgreement.getVersion().toString(),
+ licenseAgreement.getVendorLicenseModelId(), licenseAgreement.getVersion().getId(),
licenseAgreement.getName());
licenseAgreementDao.create(licenseAgreement);
UniqueValueUtil.createUniqueValue(VendorLicenseConstants.UniqueValues.LICENSE_AGREEMENT_NAME,
- licenseAgreement.getVendorLicenseModelId(), licenseAgreement.getVersion().toString(),
+ licenseAgreement.getVendorLicenseModelId(), licenseAgreement.getVersion().getId(),
licenseAgreement.getName());
if (licenseAgreement.getFeatureGroupIds() != null) {
for (String addedFgId : licenseAgreement.getFeatureGroupIds()) {
featureGroupDao.addReferencingLicenseAgreement(
- new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(), version,
+ new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(),
+ licenseAgreement.getVersion(),
addedFgId), licenseAgreement.getId());
}
}
- updateVlmLastModificationTime(licenseAgreement.getVendorLicenseModelId(),
- licenseAgreement.getVersion());
-
return licenseAgreement;
}
@Override
- public FeatureGroupEntity createFeatureGroup(FeatureGroupEntity featureGroup, String user) {
- Version version = VersioningUtil.resolveVersion(featureGroup.getVersion(),
- getVersionInfo(featureGroup.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user), user);
- //featureGroup.setId(CommonMethods.nextUuId());
- featureGroup.setVersion(version);
+ public FeatureGroupEntity createFeatureGroup(FeatureGroupEntity featureGroup) {
VersioningUtil.validateEntitiesExistence(featureGroup.getLicenseKeyGroupIds(),
- new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(), version, null),
+ new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(), featureGroup.getVersion(),
+ null),
licenseKeyGroupDao, VendorLicenseModelEntity.ENTITY_TYPE);
VersioningUtil.validateEntitiesExistence(featureGroup.getEntitlementPoolIds(),
- new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(), version, null),
+ new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(), featureGroup.getVersion(),
+ null),
entitlementPoolDao, VendorLicenseModelEntity.ENTITY_TYPE);
UniqueValueUtil.validateUniqueValue(VendorLicenseConstants.UniqueValues.FEATURE_GROUP_NAME,
- featureGroup.getVendorLicenseModelId(), featureGroup.getVersion().toString(),
+ featureGroup.getVendorLicenseModelId(), featureGroup.getVersion().getId(),
featureGroup.getName());
featureGroupDao.create(featureGroup);
UniqueValueUtil.createUniqueValue(VendorLicenseConstants.UniqueValues.FEATURE_GROUP_NAME,
- featureGroup.getVendorLicenseModelId(), featureGroup.getVersion().toString(),
+ featureGroup.getVendorLicenseModelId(), featureGroup.getVersion().getId(),
featureGroup.getName());
if (featureGroup.getLicenseKeyGroupIds() != null) {
for (String addedLkgId : featureGroup.getLicenseKeyGroupIds()) {
licenseKeyGroupDao.addReferencingFeatureGroup(
- new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(), version, addedLkgId),
+ new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion(), addedLkgId),
featureGroup.getId());
}
}
@@ -376,27 +281,20 @@
if (featureGroup.getEntitlementPoolIds() != null) {
for (String addedEpId : featureGroup.getEntitlementPoolIds()) {
entitlementPoolDao.addReferencingFeatureGroup(
- new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(), version, addedEpId),
- featureGroup.getId());
+ new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion(), addedEpId), featureGroup.getId());
}
}
-
- updateVlmLastModificationTime(featureGroup.getVendorLicenseModelId(),
- featureGroup.getVersion());
-
return featureGroup;
}
@Override
- public Collection<FeatureGroupEntity> listFeatureGroups(String vlmId, Version version,
- String user) {
+ public Collection<FeatureGroupEntity> listFeatureGroups(String vlmId, Version version) {
Collection<FeatureGroupEntity> featureGroupEntities =
- featureGroupDao.list(new FeatureGroupEntity(vlmId, VersioningUtil
- .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Read, user),
- user), null));
+ featureGroupDao.list(new FeatureGroupEntity(vlmId, version, null));
featureGroupEntities.stream()
.filter(fgEntity -> Objects.isNull(fgEntity.getManufacturerReferenceNumber()))
- .forEach(fgEntity -> updateManufacturerNumberInFeatureGroup(fgEntity));
+ .forEach(this::updateManufacturerNumberInFeatureGroup);
return featureGroupEntities;
}
@@ -405,23 +303,22 @@
public Collection<ErrorCode> validateLicensingData(String vlmId, Version version,
String licenseAgreementId,
Collection<String> featureGroupIds) {
- try {
+ // TODO: 5/21/2017 validate version exists and final
+/* try {
VersionInfo versionInfo = getVersionInfo(vlmId, VersionableEntityAction.Read, "");
if (version == null || !version.isFinal()
|| !versionInfo.getViewableVersions().contains(version)) {
return Collections.singletonList(new RequestedVersionInvalidErrorBuilder().build());
}
} catch (CoreException exception) {
- log.debug("",exception);
return Collections.singletonList(exception.code());
- }
+ }*/
List<ErrorCode> errorMessages = new ArrayList<>();
try {
- getLicenseAgreement(vlmId, licenseAgreementId, version);
+ getLicenseAgreement(vlmId, version, licenseAgreementId);
} catch (CoreException exception) {
- log.debug("",exception);
errorMessages.add(exception.code());
}
@@ -438,7 +335,6 @@
version).build());
}
} catch (CoreException exception) {
- log.debug("",exception);
errorMessages.add(exception.code());
}
}
@@ -447,71 +343,34 @@
}
@Override
- public VersionInfo getVersionInfo(String vendorLicenseModelId, VersionableEntityAction action,
- String user) {
- return versioningManager
- .getEntityVersionInfo(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vendorLicenseModelId, user,
- action);
- }
-
- @Override
- public void updateVlmLastModificationTime(String vendorLicenseModelId, Version version) {
- VendorLicenseModelEntity retrieved =
- vendorLicenseModelDao.get(new VendorLicenseModelEntity(vendorLicenseModelId, version));
- vendorLicenseModelDao.update(retrieved);
- }
-
- @Override
public LicenseAgreementEntity getLicenseAgreement(String vlmId, Version version,
- String licenseAgreementId, String user) {
- return getLicenseAgreement(vlmId, licenseAgreementId, VersioningUtil
- .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Read, user), user));
- }
-
- @Override
- public LimitEntity createLimit(LimitEntity limit, String user) {
- limit.setVersion(VersioningUtil.resolveVersion(limit.getVersion(),
- getVersionInfo(limit.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user), user));
- //limit.setVersionUuId(CommonMethods.nextUuId());
- limitDao.create(limit);
- updateVlmLastModificationTime(limit.getVendorLicenseModelId(),
- limit.getVersion());
- return limit;
- }
-
- @Override
- public Collection<LimitEntity> listLimits(String vlmId, Version version, String epLkgId,
- String user) {
- return limitDao.list(new LimitEntity(vlmId, VersioningUtil
- .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Read, user), user),
- epLkgId, null));
-
- }
-
- @Override
- public void updateLimit(LimitEntity limit, String user) {
- limit.setVersion(VersioningUtil.resolveVersion(limit.getVersion(),
- getVersionInfo(limit.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user), user));
- //limit.setVersionUuId(CommonMethods.nextUuId());
- limitDao.update(limit);
- updateVlmLastModificationTime(limit.getVendorLicenseModelId(),
- limit.getVersion());
- }
-
- private LicenseAgreementEntity getLicenseAgreement(String vlmId, String licenseAgreementId,
- Version version) {
+ String licenseAgreementId) {
LicenseAgreementEntity input = new LicenseAgreementEntity(vlmId, version, licenseAgreementId);
LicenseAgreementEntity retrieved = licenseAgreementDao.get(input);
VersioningUtil.validateEntityExistence(retrieved, input, VendorLicenseModelEntity.ENTITY_TYPE);
return retrieved;
}
+ @Override
+ public Collection<LimitEntity> listLimits(String vlmId, Version version, String epLkgId) {
+ return limitDao.list(new LimitEntity(vlmId, version, epLkgId, null));
+ }
+
+ @Override
+ public LimitEntity createLimit(LimitEntity limit) {
+ limitDao.create(limit);
+ return limit;
+ }
+
+ @Override
+ public void updateLimit(LimitEntity limit) {
+ limitDao.update(limit);
+ }
+
private void updateManufacturerNumberInFeatureGroup(FeatureGroupEntity featureGroupEntity) {
if (CollectionUtils.isNotEmpty(featureGroupEntity.getEntitlementPoolIds())) {
Object[] entitlementPoolIdsList = featureGroupEntity.getEntitlementPoolIds().toArray();
- if (entitlementPoolIdsList != null && entitlementPoolIdsList.length > 0) {
+ if (entitlementPoolIdsList.length > 0) {
String entitlementPoolId = entitlementPoolIdsList[0].toString();
EntitlementPoolEntity entitlementPoolEntity =
new EntitlementPoolEntity(featureGroupEntity.getVendorLicenseModelId(),
@@ -523,35 +382,40 @@
}
}
}
- private void validateCompletedVendorLicenseModel(String vendorLicenseModelId, String user) {
+
+ @Override
+ public void validate(String vendorLicenseModelId, Version version) {
Collection<String> allFeatureGroupEntities = new HashSet<>();
- Version version = VersioningUtil.resolveVersion(null,
- getVersionInfo(vendorLicenseModelId, VersionableEntityAction.Read, user), user);
Collection<LicenseAgreementEntity> licenseAgreements = licenseAgreementDao
- .list(new LicenseAgreementEntity(vendorLicenseModelId, version, null));
+ .list(new LicenseAgreementEntity(vendorLicenseModelId, version, null));
if (CollectionUtils.isNotEmpty(licenseAgreements)) {
licenseAgreements.forEach(licenseAgreement -> {
if (CollectionUtils.isEmpty(licenseAgreement.getFeatureGroupIds())) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.SUBMIT_ENTITY, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.SUBMIT_ENTITY);
+ LoggerTragetServiceName.SUBMIT_ENTITY, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.SUBMIT_ENTITY);
throw new CoreException(
- new SubmitUncompletedLicenseModelErrorBuilder(SUBMIT_UNCOMPLETED_VLM_MSG_LA_MISSING_FG).build());
+ new SubmitUncompletedLicenseModelErrorBuilder(
+ SUBMIT_UNCOMPLETED_VLM_MSG_LA_MISSING_FG).build());
}
allFeatureGroupEntities.addAll(licenseAgreement.getFeatureGroupIds());
});
allFeatureGroupEntities.forEach(fg -> {
- FeatureGroupEntity featureGroupEntity = featureGroupDao.get(new FeatureGroupEntity(vendorLicenseModelId, version, fg));
- if(CollectionUtils.isEmpty(featureGroupEntity.getEntitlementPoolIds())) {
+ FeatureGroupEntity featureGroupEntity =
+ featureGroupDao.get(new FeatureGroupEntity(vendorLicenseModelId, version, fg));
+ if (CollectionUtils.isEmpty(featureGroupEntity.getEntitlementPoolIds())) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.SUBMIT_ENTITY, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.SUBMIT_ENTITY);
+ LoggerTragetServiceName.SUBMIT_ENTITY, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.SUBMIT_ENTITY);
throw new CoreException(
- new SubmitUncompletedLicenseModelErrorBuilder(SUBMIT_UNCOMPLETED_VLM_MSG_FG_MISSING_EP).build());
+ new SubmitUncompletedLicenseModelErrorBuilder(
+ SUBMIT_UNCOMPLETED_VLM_MSG_FG_MISSING_EP).build());
}
});
}
}
+
+
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/healing/impl/SimpleHealingServiceImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/healing/impl/SimpleHealingServiceImpl.java
index 7cb3e2e..c62061e 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/healing/impl/SimpleHealingServiceImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/healing/impl/SimpleHealingServiceImpl.java
@@ -40,14 +40,14 @@
public class SimpleHealingServiceImpl implements HealingService {
private static final EntitlementPoolDao entitlementPoolDao =
- EntitlementPoolDaoFactory.getInstance().createInterface();
+ EntitlementPoolDaoFactory.getInstance().createInterface();
private static final LicenseKeyGroupDao licenseKeyGroupDao =
- LicenseKeyGroupDaoFactory.getInstance().createInterface();
+ LicenseKeyGroupDaoFactory.getInstance().createInterface();
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
@Override
- public VersionableEntity heal(VersionableEntity toHeal, String user) {
- return handleMissingVersionId(toHeal, user);
+ public VersionableEntity heal(VersionableEntity toHeal) {
+ return handleMissingVersionId(toHeal);
}
@Override
@@ -59,10 +59,10 @@
}
}
- private VersionableEntity handleMissingVersionId(VersionableEntity toHeal, String user) {
+ private VersionableEntity handleMissingVersionId(VersionableEntity toHeal) {
- mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugEntryMessage(null);
if (toHeal != null && toHeal.getVersionUuId() != null) {
return toHeal;
@@ -76,13 +76,13 @@
licenseKeyGroupDao.update((LicenseKeyGroupEntity) toHeal);
} else {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.SELF_HEALING, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.UNSUPPORTED_OPERATION);
+ LoggerTragetServiceName.SELF_HEALING, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.UNSUPPORTED_OPERATION);
throw new UnsupportedOperationException(
- "Unsupported operation for 1610 release/1607->1610 migration.");
+ "Unsupported operation for 1610 release/1607->1610 migration.");
}
- mdcDataDebugMessage.debugExitMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null);
return toHeal;
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/VendorLicenseArtifactsServiceImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/VendorLicenseArtifactsServiceImpl.java
index 6dbed22..07f19b1 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/VendorLicenseArtifactsServiceImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/VendorLicenseArtifactsServiceImpl.java
@@ -20,9 +20,6 @@
package org.openecomp.sdc.vendorlicense.licenseartifacts.impl;
-import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.VENDOR_LICENSE_MODEL_ARTIFACT_NAME_WITH_PATH;
-import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.VNF_ARTIFACT_NAME_WITH_PATH;
-
import org.apache.commons.collections.CollectionUtils;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
@@ -58,15 +55,14 @@
public class VendorLicenseArtifactsServiceImpl implements VendorLicenseArtifactsService {
public static final VendorLicenseFacade vendorLicenseFacade =
- VendorLicenseFacadeFactory.getInstance().createInterface();
+ VendorLicenseFacadeFactory.getInstance().createInterface();
public static final HealingService healingService =
- HealingServiceFactory.getInstance().createInterface();
+ HealingServiceFactory.getInstance().createInterface();
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
- private static byte[] createVnfArtifact(String vspId, String vlmId, Version vlmVersion,
- String vendorName,
- List<String> featureGroups, String user) {
+ private static byte[] createVnfArtifact(String vspId, String vlmId, Version vlmVersion, String vendorName,
+ List<String> featureGroups) {
mdcDataDebugMessage.debugEntryMessage("VLM name", vendorName);
@@ -78,30 +74,31 @@
if (featureGroups != null) {
for (String featureGroupId : featureGroups) {
FeatureGroupModel featureGroupModel = vendorLicenseFacade
- .getFeatureGroupModel(new FeatureGroupEntity(vlmId, vlmVersion, featureGroupId), user);
+ .getFeatureGroupModel(new FeatureGroupEntity(vlmId, vlmVersion, featureGroupId));
Set<EntitlementPoolEntity> entitlementPoolEntities =
- featureGroupModel.getEntitlementPools();
+ featureGroupModel.getEntitlementPools();
for (EntitlementPoolEntity entitlementPoolEntity : entitlementPoolEntities) {
entitlementPoolEntity.setLimits(vendorLicenseFacade.listLimits(vlmId, vlmVersion,
- entitlementPoolEntity.getId(), user));
+ entitlementPoolEntity.getId()));
entitlementPoolEntity.setManufacturerReferenceNumber(featureGroupModel.
- getEntityManufacturerReferenceNumber());
+ getEntityManufacturerReferenceNumber());
}
+
Set<LicenseKeyGroupEntity> licenseKeyGroupEntities =
- featureGroupModel.getLicenseKeyGroups();
+ featureGroupModel.getLicenseKeyGroups();
for (LicenseKeyGroupEntity licenseKeyGroupEntity : licenseKeyGroupEntities) {
licenseKeyGroupEntity.setLimits(vendorLicenseFacade.listLimits(vlmId, vlmVersion,
- licenseKeyGroupEntity.getId(), user));
+ licenseKeyGroupEntity.getId()));
licenseKeyGroupEntity.setManufacturerReferenceNumber(featureGroupModel.
- getEntityManufacturerReferenceNumber());
+ getEntityManufacturerReferenceNumber());
}
featureGroupModel.setEntitlementPools(entitlementPoolEntities.stream().map(
- entitlementPoolEntity -> (EntitlementPoolEntity) healingService
- .heal(entitlementPoolEntity, user)).collect(Collectors.toSet()));
+ entitlementPoolEntity -> (EntitlementPoolEntity) healingService
+ .heal(entitlementPoolEntity)).collect(Collectors.toSet()));
featureGroupModel.setLicenseKeyGroups(licenseKeyGroupEntities.stream().map(
- licenseKeyGroupEntity -> (LicenseKeyGroupEntity) healingService
- .heal(licenseKeyGroupEntity, user)).collect(Collectors.toSet()));
+ licenseKeyGroupEntity -> (LicenseKeyGroupEntity) healingService
+ .heal(licenseKeyGroupEntity)).collect(Collectors.toSet()));
artifact.getFeatureGroups().add(featureGroupModel);
}
}
@@ -110,7 +107,7 @@
return artifact.toXml().getBytes();
}
- private static byte[] createVendorLicenseArtifact(String vlmId, String vendorName, String user) {
+ private static byte[] createVendorLicenseArtifact(String vlmId, String vendorName) {
mdcDataDebugMessage.debugEntryMessage("VLM name", vendorName);
@@ -122,40 +119,37 @@
List<Version> finalVersions = getFinalVersionsForVlm(vlmId);
for (Version finalVersion : finalVersions) {
- Collection<EntitlementPoolEntity> coll = vendorLicenseFacade.listEntitlementPools(vlmId,
- finalVersion, user);
- coll.stream().forEach(entitlementPoolEntity -> {
+ Collection<EntitlementPoolEntity> eps =
+ vendorLicenseFacade.listEntitlementPools(vlmId, finalVersion);
+ eps.forEach(entitlementPoolEntity -> {
entitlementPoolEntity.setLimits(vendorLicenseFacade.listLimits(vlmId, finalVersion,
- entitlementPoolEntity.getId(), user));
+ entitlementPoolEntity.getId()));
Optional<String> manufacturerReferenceNumber = getFeatureGroupManufactureRefNumber
- (entitlementPoolEntity.getReferencingFeatureGroups(), vlmId, finalVersion, user);
+ (entitlementPoolEntity.getReferencingFeatureGroups(), vlmId, finalVersion);
manufacturerReferenceNumber
- .ifPresent(entitlementPoolEntity::setManufacturerReferenceNumber);
+ .ifPresent(entitlementPoolEntity::setManufacturerReferenceNumber);
});
+ entitlementPoolEntities.addAll(eps);
- entitlementPoolEntities.addAll(coll);
+ Collection<LicenseKeyGroupEntity> lkgs =
+ vendorLicenseFacade.listLicenseKeyGroups(vlmId, finalVersion);
- Collection<LicenseKeyGroupEntity> coll2 = vendorLicenseFacade.listLicenseKeyGroups(vlmId,
- finalVersion, user);
-
- coll2.stream().forEach(licenseKeyGroupEntity -> {
+ lkgs.forEach(licenseKeyGroupEntity -> {
licenseKeyGroupEntity.setLimits(vendorLicenseFacade.listLimits(vlmId, finalVersion,
- licenseKeyGroupEntity.getId(), user));
+ licenseKeyGroupEntity.getId()));
Optional<String> manufacturerReferenceNumber = getFeatureGroupManufactureRefNumber
- (licenseKeyGroupEntity.getReferencingFeatureGroups(), vlmId, finalVersion, user);
+ (licenseKeyGroupEntity.getReferencingFeatureGroups(), vlmId, finalVersion);
manufacturerReferenceNumber
- .ifPresent(licenseKeyGroupEntity::setManufacturerReferenceNumber);
+ .ifPresent(licenseKeyGroupEntity::setManufacturerReferenceNumber);
});
-
- licenseKeyGroupEntities.addAll(coll2);
+ licenseKeyGroupEntities.addAll(lkgs);
}
+
entitlementPoolEntities =
- healEPs(user, filterChangedEntities(prepareForFiltering(entitlementPoolEntities, user,
- true)));
+ healEPs(filterChangedEntities(prepareForFiltering(entitlementPoolEntities, true)));
licenseKeyGroupEntities =
- healLkgs(user, filterChangedEntities(prepareForFiltering(licenseKeyGroupEntities, user,
- false)));
+ healLkgs(filterChangedEntities(prepareForFiltering(licenseKeyGroupEntities, false)));
vendorLicenseArtifact.setEntitlementPoolEntities(entitlementPoolEntities);
vendorLicenseArtifact.setLicenseKeyGroupEntities(licenseKeyGroupEntities);
@@ -165,21 +159,20 @@
private static Optional<String> getFeatureGroupManufactureRefNumber(Set<String> featureGroupIds,
String vlmId,
- Version finalVersion,
- String user) {
+ Version finalVersion) {
String manufactureReferenceNumber = null;
if (CollectionUtils.isNotEmpty(featureGroupIds)) {
Object[] featureGroupIdsList = featureGroupIds.toArray();
if (featureGroupIdsList.length > 0) {
FeatureGroupEntity featureGroup =
- vendorLicenseFacade.getFeatureGroup(new FeatureGroupEntity(vlmId, finalVersion,
- featureGroupIdsList[0].toString()), user);
+ vendorLicenseFacade.getFeatureGroup(new FeatureGroupEntity(vlmId, finalVersion,
+ featureGroupIdsList[0].toString()));
manufactureReferenceNumber = featureGroup != null ? featureGroup
- .getManufacturerReferenceNumber() : null;
+ .getManufacturerReferenceNumber() : null;
}
}
return manufactureReferenceNumber != null ? Optional.of(manufactureReferenceNumber) :
- Optional.empty();
+ Optional.empty();
}
@@ -190,22 +183,21 @@
* @param vlmId vlmId
* @param vlmVersion vlmVersion
* @param featureGroups featureGroups
- * @param user user
* @return FileContentHandler
*/
public FileContentHandler createLicenseArtifacts(String vspId, String vlmId, Version vlmVersion,
- List<String> featureGroups, String user) {
+ List<String> featureGroups) {
mdcDataDebugMessage.debugEntryMessage("VSP Id", vspId);
FileContentHandler artifacts = new FileContentHandler();
- String vendorName = getVendorName(vlmId, user);
+ String vendorName = getVendorName(vlmId);
artifacts.addFile(VNF_ARTIFACT_NAME_WITH_PATH,
- createVnfArtifact(vspId, vlmId, vlmVersion, vendorName, featureGroups, user));
+ createVnfArtifact(vspId, vlmId, vlmVersion, vendorName, featureGroups));
artifacts.addFile(VENDOR_LICENSE_MODEL_ARTIFACT_NAME_WITH_PATH,
- createVendorLicenseArtifact(vlmId, vendorName, user));
+ createVendorLicenseArtifact(vlmId, vendorName));
mdcDataDebugMessage.debugExitMessage("VSP Id", vspId);
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/VnfLicenseArtifact.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/VnfLicenseArtifact.java
index b2cb710..91a73b6 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/VnfLicenseArtifact.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/VnfLicenseArtifact.java
@@ -38,11 +38,11 @@
import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins.MixinLicenseKeyGroupEntityForVnfArtifact;
import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins.MixinLimitArtifact;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
@JacksonXmlRootElement(localName = "vf-license-model",
namespace = "http://xmlns.openecomp.org/asdc/license-model/1.0")
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinEntitlementPoolEntityForVendorLicenseArtifact.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinEntitlementPoolEntityForVendorLicenseArtifact.java
index ac45528..70ef26f 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinEntitlementPoolEntityForVendorLicenseArtifact.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinEntitlementPoolEntityForVendorLicenseArtifact.java
@@ -62,12 +62,18 @@
@JsonProperty(value = "version")
abstract String getVersionForArtifact();
- @JsonProperty(value = "start-date")
+ @JsonIgnore
abstract String getStartDate();
- @JsonProperty(value = "expiry-date")
+ @JsonIgnore
abstract String getExpiryDate();
+ @JsonProperty(value = "start-date")
+ abstract String getIsoFormatStartDate();
+
+ @JsonProperty(value = "expiry-date")
+ abstract String getIsoFormatExpiryDate();
+
@JsonIgnore
abstract String getVendorLicenseModelId();
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinEntitlementPoolEntityForVnfArtifact.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinEntitlementPoolEntityForVnfArtifact.java
index ad1a9a6..7618b7a 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinEntitlementPoolEntityForVnfArtifact.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinEntitlementPoolEntityForVnfArtifact.java
@@ -42,7 +42,7 @@
@JsonProperty(value = "threshold-value")
abstract ThresholdForXml getThresholdForArtifact();
- @JsonIgnore
+ @JsonProperty(value = "entitlement-pool-invariant-uuid")
abstract String getId();
@JsonProperty(value = "manufacturer-reference-number")
@@ -60,7 +60,7 @@
@JsonIgnore
abstract String getVersion();
- @JsonIgnore
+ @JsonProperty(value = "version")
abstract String getVersionForArtifact();
@JsonIgnore
@@ -72,12 +72,18 @@
@JsonIgnore
abstract float getThresholdValue();
- @JsonProperty(value = "start-date")
+ @JsonIgnore
abstract String getStartDate();
- @JsonProperty(value = "expiry-date")
+ @JsonIgnore
abstract String getExpiryDate();
+ @JsonProperty(value = "start-date")
+ abstract String getIsoFormatStartDate();
+
+ @JsonProperty(value = "expiry-date")
+ abstract String getIsoFormatExpiryDate();
+
@JsonIgnore
abstract ChoiceOrOther<EntitlementMetric> getEntitlementMetric();
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinLicenseKeyGroupEntityForVendorLicenseArtifact.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinLicenseKeyGroupEntityForVendorLicenseArtifact.java
index 5a8e996..eeaa7c0 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinLicenseKeyGroupEntityForVendorLicenseArtifact.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinLicenseKeyGroupEntityForVendorLicenseArtifact.java
@@ -79,12 +79,18 @@
@JsonIgnore
abstract Collection<LimitEntity> getLimits();
- @JsonProperty(value = "start-date")
+ @JsonIgnore
abstract String getStartDate();
- @JsonProperty(value = "expiry-date")
+ @JsonIgnore
abstract String getExpiryDate();
+ @JsonProperty(value = "start-date")
+ abstract String getIsoFormatStartDate();
+
+ @JsonProperty(value = "expiry-date")
+ abstract String getIsoFormatExpiryDate();
+
@JsonProperty(value = "threshold-value")
abstract ThresholdForXml getThresholdForArtifact();
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinLicenseKeyGroupEntityForVnfArtifact.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinLicenseKeyGroupEntityForVnfArtifact.java
index 4af4b59..f560f36 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinLicenseKeyGroupEntityForVnfArtifact.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinLicenseKeyGroupEntityForVnfArtifact.java
@@ -34,7 +34,7 @@
import java.util.Set;
public abstract class MixinLicenseKeyGroupEntityForVnfArtifact {
- @JsonIgnore
+ @JsonProperty(value = "license-key-group-invariant-uuid")
abstract String getId();
@JsonProperty(value = "manufacturer-reference-number")
@@ -46,7 +46,7 @@
@JsonIgnore
abstract String getVersion();
- @JsonIgnore
+ @JsonProperty(value = "version")
abstract String getVersionForArtifact();
@JsonIgnore
@@ -87,12 +87,18 @@
@JsonIgnore
abstract Collection<LimitEntity> getLimits();
- @JsonProperty(value = "start-date")
+ @JsonIgnore
abstract String getStartDate();
- @JsonProperty(value = "expiry-date")
+ @JsonIgnore
abstract String getExpiryDate();
+ @JsonProperty(value = "start-date")
+ abstract String getIsoFormatStartDate();
+
+ @JsonProperty(value = "expiry-date")
+ abstract String getIsoFormatExpiryDate();
+
@JsonIgnore
abstract String getThresholdUnits();
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/util/VendorLicenseArtifactsServiceUtils.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/util/VendorLicenseArtifactsServiceUtils.java
index 502aa35..bd209f9 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/util/VendorLicenseArtifactsServiceUtils.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/util/VendorLicenseArtifactsServiceUtils.java
@@ -27,16 +27,19 @@
import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
import org.openecomp.sdc.vendorlicense.healing.HealingService;
import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.VendorLicenseArtifactsServiceImpl;
+import org.openecomp.sdc.versioning.ItemManagerFactory;
+import org.openecomp.sdc.versioning.VersioningManager;
+import org.openecomp.sdc.versioning.VersioningManagerFactory;
import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.dao.types.VersionStatus;
import org.openecomp.sdc.versioning.dao.types.VersionableEntity;
-import org.openecomp.sdc.versioning.types.VersionInfo;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.stream.Collectors;
/**
* @author katyr
@@ -45,7 +48,7 @@
public class VendorLicenseArtifactsServiceUtils {
private static final HealingService healingService =
- HealingServiceFactory.getInstance().createInterface();
+ HealingServiceFactory.getInstance().createInterface();
/**
* maps the entities by id
@@ -53,7 +56,7 @@
* @return a Map of id -> list of versionable entities with that id
*/
private static MultiValuedMap<String, VersionableEntity> mapById(
- Collection<? extends VersionableEntity> versionableEntities) {
+ Collection<? extends VersionableEntity> versionableEntities) {
MultiValuedMap<String, VersionableEntity> mappedById = new ArrayListValuedHashMap<>();
for (VersionableEntity ve : versionableEntities) {
mappedById.put(ve.getId(), ve);
@@ -62,17 +65,18 @@
}
/**
- * For all entities with same id, only entities that differ from one another will be returned.
- * If no change has occured, the entity with the earlier VLM version will be returned.
- * If only one version of said entities exists it will be returned
+ * For all entities with same id, only entities that differ from one another will be returned.
+ * If no change has occured, the entity with the earlier VLM version will be returned.
+ * If only one version of said entities exists it will be returned
+ *
* @return a list of entities that has been changed
*/
public static List<VersionableEntity> filterChangedEntities(
- Collection<? extends VersionableEntity> versionableEntities) {
+ Collection<? extends VersionableEntity> versionableEntities) {
MultiValuedMap<String, VersionableEntity> entitiesById = mapById(
- versionableEntities);
+ versionableEntities);
MultiValuedMap<String, VersionableEntity> entitiesByVersionUuId =
- new ArrayListValuedHashMap<>();
+ new ArrayListValuedHashMap<>();
List<VersionableEntity> changedOnly = new ArrayList<>();
for (String epId : entitiesById.keySet()) {
@@ -85,7 +89,7 @@
//for every list of eps which have the same uuid, get the one with the earliest vlm version.
for (String versionUid : entitiesByVersionUuId.keySet()) {
List<VersionableEntity> versionableEntitiesForUuid =
- (List<VersionableEntity>) entitiesByVersionUuId.get(versionUid);
+ (List<VersionableEntity>) entitiesByVersionUuId.get(versionUid);
versionableEntitiesForUuid.sort(new VersionableEntitySortByVlmMajorVersion());
changedOnly.add(versionableEntitiesForUuid.get(0));
}
@@ -93,40 +97,38 @@
return changedOnly;
}
- public static Set<LicenseKeyGroupEntity> healLkgs(String user,
- Collection<? extends VersionableEntity> licenseKeyGroupEntities) {
+ public static Set<LicenseKeyGroupEntity> healLkgs(
+ Collection<? extends VersionableEntity> licenseKeyGroupEntities) {
Set<LicenseKeyGroupEntity> healed = new HashSet<>();
for (VersionableEntity licenseKeyGroupEntity : licenseKeyGroupEntities) {
healed.add((LicenseKeyGroupEntity) VendorLicenseArtifactsServiceImpl.healingService
- .heal(licenseKeyGroupEntity, user));
+ .heal(licenseKeyGroupEntity));
}
return healed;
}
- public static Set<EntitlementPoolEntity> healEPs(String user,
- Collection<? extends VersionableEntity> entitlementPoolEntities) {
+ public static Set<EntitlementPoolEntity> healEPs(
+ Collection<? extends VersionableEntity> entitlementPoolEntities) {
Set<EntitlementPoolEntity> healed = new HashSet<>();
for (VersionableEntity entitlementPoolEntity : entitlementPoolEntities) {
healed.add((EntitlementPoolEntity) VendorLicenseArtifactsServiceImpl.healingService
- .heal(entitlementPoolEntity, user));
+ .heal(entitlementPoolEntity));
}
return healed;
}
public static List<Version> getFinalVersionsForVlm(String vlmId) {
- VersionInfo versionInfo =
- VendorLicenseArtifactsServiceImpl.vendorLicenseFacade
- .getVersionInfo(vlmId, VersionableEntityAction.Read, "");
- return versionInfo.getFinalVersions();
-
+ VersioningManager versioningManager = VersioningManagerFactory.getInstance().createInterface();
+ return versioningManager.list(vlmId).stream()
+ .filter(version -> VersionStatus.Certified == version.getStatus())
+ .map(certifiedVersion -> versioningManager.get(vlmId, certifiedVersion)) //sync to private
+ .collect(Collectors.toList());
}
- public static String getVendorName(String vendorLicenseModelId, String user) {
- return VendorLicenseArtifactsServiceImpl.vendorLicenseFacade
- .getVendorLicenseModel(vendorLicenseModelId, null, user)
- .getVendorLicenseModel().getVendorName();
+ public static String getVendorName(String vendorLicenseModelId) {
+ return ItemManagerFactory.getInstance().createInterface().get(vendorLicenseModelId).getName();
}
@@ -140,38 +142,36 @@
* to healing as before. For VLMs created post-bugfix this code should not update any element
*/
public static Collection<? extends VersionableEntity> prepareForFiltering(Collection<? extends
- VersionableEntity> versionableEntities, String user, boolean isEP) {
+ VersionableEntity> versionableEntities, boolean isEP) {
MultiValuedMap<String, VersionableEntity> entitiesById = mapById(
- versionableEntities);
+ versionableEntities);
for (String epId : entitiesById.keySet()) {
List<VersionableEntity> versionableEntitiesForId = new ArrayList<>();
versionableEntitiesForId.addAll(entitiesById.get(epId));
versionableEntitiesForId.sort(new VersionableEntitySortByVlmMajorVersion());
- healingService.heal(versionableEntitiesForId.get(0), user);
+ healingService.heal(versionableEntitiesForId.get(0));
for (int i = 1; i < versionableEntitiesForId.size(); i++) {
if (isEP) {
EntitlementPoolEntity current = (EntitlementPoolEntity) versionableEntitiesForId.get(i);
EntitlementPoolEntity previous = (EntitlementPoolEntity) versionableEntitiesForId
- .get(i - 1);
+ .get(i - 1);
if (current.equals(previous) && current.getVersionUuId() == null) {
current.setVersionUuId(previous.getVersionUuId());
healingService.persistNoHealing(current);
} else {
- versionableEntitiesForId.set(i, healingService.heal(versionableEntitiesForId.get(i),
- user));
+ versionableEntitiesForId.set(i, healingService.heal(versionableEntitiesForId.get(i)));
}
} else {
LicenseKeyGroupEntity current = (LicenseKeyGroupEntity) versionableEntitiesForId.get(i);
LicenseKeyGroupEntity previous = (LicenseKeyGroupEntity) versionableEntitiesForId
- .get(i - 1);
+ .get(i - 1);
if (current.equals(previous) && current.getVersionUuId() == null) {
current.setVersionUuId(previous.getVersionUuId());
healingService.persistNoHealing(current);
} else {
- versionableEntitiesForId.set(i, healingService.heal(versionableEntitiesForId.get(i),
- user));
+ versionableEntitiesForId.set(i, healingService.heal(versionableEntitiesForId.get(i)));
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductConstants.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductConstants.java
index 8010c40..bf48bfb 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductConstants.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductConstants.java
@@ -22,14 +22,14 @@
public final class VendorSoftwareProductConstants {
public static final String VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE = "VendorSoftwareProduct";
- public static final String GENERAL_COMPONENT_ID = "General";
public static final String VSP_PACKAGE_ZIP = "VSPPackage.zip";
public static final String CSAR = "CSAR";
public static final String UPLOAD_RAW_DATA = "UPLOAD_RAW_DATA";
public static final String INFORMATION_ARTIFACT_NAME = "VSP_%s_Information.txt";
- public static final String UNSUPPORTED_OPERATION_ERROR =
- "An error has occurred: Unsupported operation for 1707 release.";
+ public static final String UNSUPPORTED_OPERATION_ERROR =
+ "An error has occurred: Unsupported operation for 1707 release.";
public static final String NAME_PATTERN = "^[a-zA-Z0-9_]*$";
+ public static final String VALIDATION_VSP_NAME = "validationOnlyVspName";
public final class UniqueValues {
public static final String VENDOR_SOFTWARE_PRODUCT_NAME = "Vendor Software Product name";
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDependencyModelDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDependencyModelDao.java
index a980918..cbbb97b 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDependencyModelDao.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ComponentDependencyModelDao.java
@@ -3,10 +3,7 @@
import org.openecomp.core.dao.BaseDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
import org.openecomp.sdc.versioning.dao.VersionableDao;
-import org.openecomp.sdc.versioning.dao.types.Version;
public interface ComponentDependencyModelDao extends VersionableDao,
BaseDao<ComponentDependencyModelEntity> {
-
- public void deleteAll(String vspId, Version version);
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateCandidateDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateCandidateDao.java
index fceac0a..3d7c621 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateCandidateDao.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateCandidateDao.java
@@ -31,7 +31,9 @@
OrchestrationTemplateCandidateData get(String vspId, Version version);
- void update(String vspId, OrchestrationTemplateCandidateData candidateData);
+ OrchestrationTemplateCandidateData getInfo(String vspId, Version version);
+
+ void update(String vspId, Version version, OrchestrationTemplateCandidateData candidateData);
void updateStructure(String vspId, Version version, FilesDataStructure fileDataStructure);
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateDao.java
index a8c2eb8..4d82ed3 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateDao.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateDao.java
@@ -20,17 +20,16 @@
package org.openecomp.sdc.vendorsoftwareproduct.dao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadData;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadDataEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
import org.openecomp.sdc.versioning.dao.VersionableDao;
import org.openecomp.sdc.versioning.dao.types.Version;
public interface OrchestrationTemplateDao extends VersionableDao {
- String getValidationData(String vspId, Version version);
+ OrchestrationTemplateEntity getInfo(String vspId, Version version);
- UploadDataEntity getOrchestrationTemplate(String vspId, Version version);
+ OrchestrationTemplateEntity get(String vspId, Version version);
- void updateOrchestrationTemplateData(String vspId, UploadData uploadData);
+ void update(String vspId, Version version, OrchestrationTemplateEntity uploadData);
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/PackageInfoDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/PackageInfoDao.java
index d12069f..36fff1e 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/PackageInfoDao.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/PackageInfoDao.java
@@ -22,17 +22,9 @@
import org.openecomp.core.dao.BaseDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import java.nio.ByteBuffer;
import java.util.List;
public interface PackageInfoDao extends BaseDao<PackageInfo> {
List<PackageInfo> listByCategory(String category, String subCategory);
-
- public void deleteRowTranslateContent(String vspId, Version version);
-
- void updateTranslatedContent(String vspId, Version version, ByteBuffer translateContent);
-
-
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ProcessDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ProcessDao.java
index c6622ef..aea93a3 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ProcessDao.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ProcessDao.java
@@ -12,6 +12,11 @@
public interface ProcessDao extends VersionableDao, BaseDao<ProcessEntity> {
void deleteAll(ProcessEntity entity);
-
void deleteVspAll(String vspId, Version version);
+
+ ProcessEntity getArtifact(ProcessEntity entity);
+
+ void uploadArtifact(ProcessEntity entity);
+
+ void deleteArtifact(ProcessEntity entity);
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDao.java
deleted file mode 100644
index cdc3a77..0000000
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDao.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.vendorsoftwareproduct.dao;
-
-import org.openecomp.core.dao.BaseDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadDataEntity;
-import org.openecomp.sdc.versioning.dao.types.Version;
-
-import java.nio.ByteBuffer;
-
-public interface UploadDataDao extends BaseDao<UploadDataEntity> {
-
- void deleteContentDataAndValidationData(String vspId, Version version);
-
- ByteBuffer getContentData(String vspId, Version version);
-}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductDao.java
deleted file mode 100644
index 48d1e16..0000000
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductDao.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.vendorsoftwareproduct.dao;
-
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
-import org.openecomp.sdc.versioning.dao.VersionableDao;
-import org.openecomp.sdc.versioning.dao.types.Version;
-
-import java.util.Collection;
-import java.util.List;
-
-
-public interface VendorSoftwareProductDao extends VersionableDao {
-
- //VspDetails getVendorSoftwareProductInfo(VspDetails vspDetails);
-
- Collection<ComponentEntity> listComponents(String vspId, Version version);
-
- Collection<ComponentEntity> listComponentsQuestionnaire(String vspId, Version version);
-
- Collection<ComponentEntity> listComponentsCompositionAndQuestionnaire(String vspId,
- Version version);
-
-
- Collection<ProcessEntity> listProcesses(String vspId, Version version, String componentId);
-
- void deleteProcesses(String vspId, Version version, String componentId);
-
- ProcessEntity getProcess(String vspId, Version version, String componentId, String processId);
-
- void createProcess(ProcessEntity processEntity);
-
- void updateProcess(ProcessEntity processEntity);
-
- void deleteProcess(String vspId, Version version, String componentId, String processId);
-
-
- void uploadProcessArtifact(String vspId, Version version, String componentId, String processId,
- byte[] artifact, String artifactFileName);
-
- ProcessEntity getProcessArtifact(String vspId, Version version, String componentId,
- String processId);
-
- void deleteProcessArtifact(String vspId, Version version, String componentId, String processId);
-
-
- Collection<NicEntity> listNicsByVsp(String vspId, Version version);
-
-
- void deleteUploadData(String vspId, Version version);
-
- //void updateVspLatestModificationTime(String vspId, Version version);
- void createComponentDependencyModel(
- List<ComponentDependencyModelEntity> componentDependencyModelEntity, String vspId,
- Version version);
-
- Collection<ComponentDependencyModelEntity> listComponentDependencies(String vspId,Version
- version);
-
- void createDeploymentFlavor(DeploymentFlavorEntity deploymentFlavor);
-
- Collection<DeploymentFlavorEntity> listDeploymentFlavors(String vspId, Version version);
-
- DeploymentFlavorEntity getDeploymentFlavor(String vspId, Version version, String
- deploymentFlavorId);
- void deleteDeploymentFlavor(String vspId, Version version, String deploymentFlavorId);
-
-
- void createImage(ImageEntity imageEntity);
-
- Collection<ImageEntity> listImages(String vspId, Version version, String componentId);
-
- ImageEntity getImage(String vspId, Version version, String componentId, String imageId);
-
- Collection<ImageEntity> listImagesByVsp(String vspId, Version version);
-
- void createCompute(ComputeEntity computeEntity);
-
- Collection<ComputeEntity> listComputes(String vspId, Version version, String componentId);
-
- Collection<ComputeEntity> listComputesByVsp(String vspId, Version version);
-
- ComputeEntity getCompute(String vspId, Version version, String componentId, String
- computeFlavorId);
-
- void deleteImage(String vspId, Version version, String componentId, String imageId);
-
- void updateDeploymentFlavor(DeploymentFlavorEntity deploymentFlavorEntity);
-
- void updateImage(ImageEntity imageEntity);
-
- void updateImageQuestionnaire(String vspId, Version activeVersion, String componentId,
- String imageId, String questionnaireData);
-
- void updateComputeQuestionnaire(String vspId, Version activeVersion, String componentId,
- String computeId, String questionnaireData);
-
- void updateCompute(ComputeEntity compute);
-
- void deleteCompute(String vspId, Version version, String componentId, String computeFlavorId);
-
-}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductInfoDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductInfoDao.java
index 0481829..c44a9cd 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductInfoDao.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VendorSoftwareProductInfoDao.java
@@ -28,15 +28,9 @@
public interface VendorSoftwareProductInfoDao extends VersionableDao, BaseDao<VspDetails> {
- void updateOldVersionIndication(VspDetails vspDetails);
-
void updateQuestionnaireData(String vspId, Version version, String questionnaireData);
- String getQuestionnaireData(String vspId, Version version);
-
VspQuestionnaireEntity getQuestionnaire(String vspId, Version version);
- void deleteAll(String vspId, Version version);
-
boolean isManual(String vspId, Version version);
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VspMergeDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VspMergeDao.java
new file mode 100644
index 0000000..c9525bf
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VspMergeDao.java
@@ -0,0 +1,16 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao;
+
+import com.amdocs.zusammen.datatypes.item.Resolution;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+public interface VspMergeDao {
+
+ boolean isVspModelConflicted(String vspId, Version version);
+
+ void updateVspModelId(String vspId, Version version);
+
+ // TODO: 11/7/2017 change to sdc Resolution
+ void updateVspModelConflictResolution(String vspId, Version version, Resolution resolution);
+
+ void applyVspModelConflictResolution(String vspId, Version version);
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VspMergeDaoFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VspMergeDaoFactory.java
new file mode 100644
index 0000000..40ef50a
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/VspMergeDaoFactory.java
@@ -0,0 +1,11 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+public abstract class VspMergeDaoFactory extends AbstractComponentFactory<VspMergeDao> {
+
+ public static VspMergeDaoFactory getInstance() {
+ return AbstractFactory.getInstance(VspMergeDaoFactory.class);
+ }
+}
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/DeploymentFlavorEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/DeploymentFlavorEntity.java
index b20e110..57161fb 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/DeploymentFlavorEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/DeploymentFlavorEntity.java
@@ -1,6 +1,10 @@
package org.openecomp.sdc.vendorsoftwareproduct.dao.type;
-import com.datastax.driver.mapping.annotations.*;
+import com.datastax.driver.mapping.annotations.ClusteringColumn;
+import com.datastax.driver.mapping.annotations.Column;
+import com.datastax.driver.mapping.annotations.Frozen;
+import com.datastax.driver.mapping.annotations.PartitionKey;
+import com.datastax.driver.mapping.annotations.Table;
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OnboardingMethod.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OnboardingMethod.java
new file mode 100644
index 0000000..108fd22
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OnboardingMethod.java
@@ -0,0 +1,6 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.type;
+
+public enum OnboardingMethod {
+ NetworkPackage,
+ Manual;
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateCandidateData.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateCandidateData.java
index de70434..7b19e86 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateCandidateData.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateCandidateData.java
@@ -5,15 +5,18 @@
public class OrchestrationTemplateCandidateData {
private ByteBuffer contentData;
private String filesDataStructure;
-
+ private String fileSuffix;
+ private String fileName;
public OrchestrationTemplateCandidateData() {
}
- public OrchestrationTemplateCandidateData(ByteBuffer contentData,
- String dataStructureJson) {
+ public OrchestrationTemplateCandidateData(ByteBuffer contentData, String dataStructureJson,
+ String fileSuffix, String fileName) {
this.contentData = contentData;
this.filesDataStructure = dataStructureJson;
+ this.fileSuffix = fileSuffix;
+ this.fileName = fileName;
}
public ByteBuffer getContentData() {
@@ -31,4 +34,20 @@
public void setFilesDataStructure(String filesDataStructure) {
this.filesDataStructure = filesDataStructure;
}
+
+ public String getFileSuffix() {
+ return fileSuffix;
+ }
+
+ public void setFileSuffix(String fileSuffix) {
+ this.fileSuffix = fileSuffix;
+ }
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/UploadDataEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateEntity.java
similarity index 84%
rename from openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/UploadDataEntity.java
rename to openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateEntity.java
index 2ade95b..ef3a4b6 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/UploadDataEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateEntity.java
@@ -7,9 +7,9 @@
* 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.
@@ -27,25 +27,22 @@
import java.nio.ByteBuffer;
-public class UploadDataEntity implements VersionableEntity {
- private static final String ENTITY_TYPE = "Vendor Software Product Upload data";
+public class OrchestrationTemplateEntity implements VersionableEntity {
+ private static final String ENTITY_TYPE = "Vendor Software Product Orchestration Template";
private String id;
-
private Version version;
-
+ private String fileSuffix;
+ private String fileName;
private String packageName;
-
private String packageVersion;
-
private String validationData;
-
private ByteBuffer contentData;
- public UploadDataEntity() {
+ public OrchestrationTemplateEntity() {
}
- public UploadDataEntity(String id, Version version) {
+ public OrchestrationTemplateEntity(String id, Version version) {
this.id = id;
this.version = version;
}
@@ -78,6 +75,22 @@
this.version = version;
}
+ public String getFileSuffix() {
+ return fileSuffix;
+ }
+
+ public void setFileSuffix(String fileSuffix) {
+ this.fileSuffix = fileSuffix;
+ }
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+
public String getPackageName() {
return packageName;
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/PackageInfo.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/PackageInfo.java
index ad02883..3403f28 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/PackageInfo.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/PackageInfo.java
@@ -21,7 +21,6 @@
package org.openecomp.sdc.vendorsoftwareproduct.dao.type;
import com.datastax.driver.mapping.annotations.Column;
-import com.datastax.driver.mapping.annotations.Frozen;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
import org.openecomp.sdc.versioning.dao.types.Version;
@@ -38,8 +37,7 @@
private String vspId;
@PartitionKey(value = 1)
- @Frozen
- private Version version;
+ private String version;
@Column(name = "display_name")
private String displayName;
@@ -75,7 +73,7 @@
public PackageInfo(String packageId, Version version) {
this.vspId = packageId;
- this.version = version;
+ this.version = version.getName();
}
public String getDisplayName() {
@@ -94,11 +92,11 @@
this.vspDescription = vspDescription;
}
- public Version getVersion() {
+ public String getVersion() {
return version;
}
- public void setVersion(Version version) {
+ public void setVersion(String version) {
this.version = version;
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/UploadData.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/UploadData.java
deleted file mode 100644
index 071af91..0000000
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/UploadData.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.vendorsoftwareproduct.dao.type;
-
-import org.openecomp.core.utilities.json.JsonUtil;
-import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList;
-
-import java.nio.ByteBuffer;
-
-
-public class UploadData {
-
- private String id;
-
- private String packageName;
-
- private String packageVersion;
-
- private String validationData;
-
- private ByteBuffer contentData;
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getPackageName() {
- return packageName;
- }
-
- public void setPackageName(String packageName) {
- this.packageName = packageName;
- }
-
- public String getPackageVersion() {
- return packageVersion;
- }
-
- public void setPackageVersion(String packageVersion) {
- this.packageVersion = packageVersion;
- }
-
- public String getValidationData() {
- return validationData;
- }
-
- public void setValidationData(String validationData) {
- this.validationData = validationData;
- }
-
- public ValidationStructureList getValidationDataStructure() {
- return validationData == null ? null
- : JsonUtil.json2Object(validationData, ValidationStructureList.class);
- }
-
- public void setValidationDataStructure(ValidationStructureList validationData) {
- this.validationData = validationData == null ? null
- : JsonUtil.object2Json(validationData);
- }
-
- public ByteBuffer getContentData() {
- return contentData;
- }
-
- public void setContentData(ByteBuffer contentData) {
- this.contentData = contentData;
- }
-}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java
index 3f9768b..3ba77ad 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java
@@ -20,13 +20,10 @@
package org.openecomp.sdc.vendorsoftwareproduct.dao.type;
-import org.openecomp.core.utilities.json.JsonUtil;
-import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdc.versioning.dao.types.VersionableEntity;
import java.util.List;
-import java.util.Objects;
public class VspDetails implements VersionableEntity {
@@ -55,18 +52,10 @@
private List<String> featureGroups;
- private String validationData;
-
- private String oldVersion;
-
private Long writetimeMicroSeconds;
private String onboardingMethod;
- private String onboardingOrigin;
-
- private String networkPackageName;
-
public VspDetails() {
}
@@ -183,24 +172,6 @@
this.featureGroups = featureGroups;
}
- public String getValidationData() {
- return validationData;
- }
-
- public void setValidationData(String validationData) {
- this.validationData = validationData;
- }
-
- public ValidationStructureList getValidationDataStructure() {
- return validationData == null ? null
- : JsonUtil.json2Object(validationData, ValidationStructureList.class);
- }
-
- public void setValidationDataStructure(ValidationStructureList validationData) {
- this.validationData = validationData == null ? null
- : JsonUtil.object2Json(validationData);
- }
-
public Long getWritetimeMicroSeconds() {
return this.writetimeMicroSeconds;
}
@@ -213,36 +184,14 @@
return this.oldVersion;
}*/
- public String getOldVersion(){
- return this.oldVersion;
- }
-
- public void setOldVersion(String oldVersion) {
- this.oldVersion = oldVersion;
- }
-
- public String getOnboardingOrigin() {
- return onboardingOrigin;
- }
-
- public void setOnboardingOrigin(String onboardingOrigin) {
- this.onboardingOrigin = onboardingOrigin;
- }
-
public String getOnboardingMethod() {
return onboardingMethod;
}
+
public void setOnboardingMethod(String onboardingMethod) {
this.onboardingMethod = onboardingMethod;
}
- public String getNetworkPackageName() {
- return networkPackageName;
- }
-
- public void setNetworkPackageName(String networkPackageName) {
- this.networkPackageName = networkPackageName;
- }
@Override
public String toString() {
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/composition/CompositionEntityDataManager.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/composition/CompositionEntityDataManager.java
index b77012e..ff78fff 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/composition/CompositionEntityDataManager.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/composition/CompositionEntityDataManager.java
@@ -22,7 +22,6 @@
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.CompositionEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity;
@@ -64,12 +63,10 @@
void saveComponents(String vspId, Version version, CompositionData compositionData,
Map<String, String> networkIdByName);
- void saveNicsByComponent(String vspId, Version version,
- Map<String, String> networkIdByName, Component component,
- String componentId);
+ void saveNicsByComponent(String vspId, Version version, Map<String, String> networkIdByName,
+ Component component, String componentId);
- Map<String, String> saveNetworks(String vspId, Version version,
- CompositionData compositionData);
+ Map<String, String> saveNetworks(String vspId, Version version, CompositionData compositionData);
NetworkEntity createNetwork(NetworkEntity network);
@@ -77,15 +74,14 @@
NicEntity createNic(NicEntity nic);
- public ComputeEntity createCompute(ComputeEntity compute);
+ DeploymentFlavorEntity createDeploymentFlavor(DeploymentFlavorEntity deploymentFlavor);
- public DeploymentFlavorEntity createDeploymentFlavor(DeploymentFlavorEntity deploymentFlavor);
+ ImageEntity createImage(ImageEntity image);
- public ImageEntity createImage(ImageEntity image);
+ void saveComputesFlavorByComponent(String vspId, Version version, Component component,
+ String componentId);
- public void saveComputesFlavorByComponent(String vspId, Version version, Component component, String
- componentId);
- public void saveImagesByComponent(String vspId, Version version, Component component, String
- componentId);
+ void saveImagesByComponent(String vspId, Version version, Component component,
+ String componentId);
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java
index 6cc639f..697dab2 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java
@@ -45,19 +45,23 @@
Optional<ErrorMessage> validateRawZipData(byte[] uploadedFileData);
OrchestrationTemplateCandidateData createCandidateDataEntity(
- CandidateDataEntityTo candidateDataEntityTo, InputStream zipFileManifest, AnalyzedZipHeatFiles analyzedZipHeatFiles) throws Exception;
+ CandidateDataEntityTo candidateDataEntityTo, InputStream zipFileManifest,
+ AnalyzedZipHeatFiles analyzedZipHeatFiles) throws Exception;
- void updateCandidateUploadData(OrchestrationTemplateCandidateData uploadData, String
- itemId);
+ void updateCandidateUploadData(String vspId, Version version,
+ OrchestrationTemplateCandidateData uploadData);
Optional<FilesDataStructure> getOrchestrationTemplateCandidateFileDataStructure(String vspId,
- Version activeVersion);
+ Version version);
- void updateOrchestrationTemplateCandidateFileDataStructure(String vspId, Version activeVersion,
- FilesDataStructure fileDataStructure);
+ void updateOrchestrationTemplateCandidateFileDataStructure(String vspId, Version version,
+ FilesDataStructure fileDataStructure);
OrchestrationTemplateCandidateData getOrchestrationTemplateCandidate(String vspId,
- Version activeVersion);
+ Version version);
+
+ OrchestrationTemplateCandidateData getOrchestrationTemplateCandidateInfo(String vspId,
+ Version version);
Optional<ByteArrayInputStream> fetchZipFileByteArrayInputStream(String vspId,
OrchestrationTemplateCandidateData candidateDataEntity,
@@ -66,11 +70,11 @@
Map<String, List<ErrorMessage>> uploadErrors);
byte[] replaceManifestInZip(ByteBuffer contentData, String manifest, String vspId,
- OnboardingTypesEnum type)
- throws IOException;
+ OnboardingTypesEnum type) throws IOException;
Optional<ManifestContent> createManifest(VspDetails vspDetails,
- FileContentHandler fileContentHandler, AnalyzedZipHeatFiles analyzedZipHeatFiles);
+ FileContentHandler fileContentHandler,
+ AnalyzedZipHeatFiles analyzedZipHeatFiles);
String createManifest(VspDetails vspDetails, FilesDataStructure structure);
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/HeatFileAnalyzerRowDataImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/HeatFileAnalyzerRowDataImpl.java
index dd303c7..8ed5160 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/HeatFileAnalyzerRowDataImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/HeatFileAnalyzerRowDataImpl.java
@@ -28,7 +28,11 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.util.*;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
import java.util.regex.Pattern;
public class HeatFileAnalyzerRowDataImpl implements HeatFileAnalyzer {
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java
index 41510ec..c34e654 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/utils/CandidateEntityBuilder.java
@@ -57,22 +57,22 @@
public OrchestrationTemplateCandidateData buildCandidateEntityFromZip(
VspDetails vspDetails, byte[] uploadedFileData, FileContentHandler contentMap,
- Map<String, List<ErrorMessage>> uploadErrors, String user) throws Exception {
+ Map<String, List<ErrorMessage>> uploadErrors) throws Exception {
//mdcDataDebugMessage.debugEntryMessage("VSP Id", vspDetails.getId());
try (InputStream zipFileManifest = contentMap.getFileContent(SdcCommon.MANIFEST_NAME)) {
HeatFileAnalyzer heatFileAnalyzer = new HeatFileAnalyzerRowDataImpl();
AnalyzedZipHeatFiles analyzedZipHeatFiles =
- heatFileAnalyzer.analyzeFilesNotEligibleForModulesFromFileAnalyzer(contentMap.getFiles());
+ heatFileAnalyzer.analyzeFilesNotEligibleForModulesFromFileAnalyzer(contentMap.getFiles());
HeatStructureTree tree = getHeatStructureTree(vspDetails, contentMap, analyzedZipHeatFiles);
CandidateDataEntityTo candidateDataEntityTo =
- new CandidateDataEntityTo(vspDetails.getId(), user, uploadedFileData, tree, contentMap,
- vspDetails.getVersion());
+ new CandidateDataEntityTo(vspDetails.getId(), vspDetails.getVersion(), uploadedFileData,
+ tree, contentMap);
candidateDataEntityTo.setErrors(uploadErrors);
OrchestrationTemplateCandidateData candidateDataEntity =
- candidateService.createCandidateDataEntity(candidateDataEntityTo, zipFileManifest,
- analyzedZipHeatFiles);
+ candidateService.createCandidateDataEntity(candidateDataEntityTo, zipFileManifest,
+ analyzedZipHeatFiles);
MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP Id", vspDetails.getId());
return candidateDataEntity;
@@ -81,7 +81,8 @@
private HeatStructureTree getHeatStructureTree(VspDetails vspDetails,
FileContentHandler contentMap,
- AnalyzedZipHeatFiles analyzedZipHeatFiles) throws IOException {
+ AnalyzedZipHeatFiles analyzedZipHeatFiles)
+ throws IOException {
addManifestToFileContentMapIfNotExist(vspDetails, contentMap, analyzedZipHeatFiles);
HeatTreeManager heatTreeManager = HeatTreeManagerUtil.initHeatTreeManager(contentMap);
heatTreeManager.createTree();
@@ -90,21 +91,22 @@
private void addManifestToFileContentMapIfNotExist(VspDetails vspDetails,
FileContentHandler fileContentHandler,
- AnalyzedZipHeatFiles analyzedZipHeatFiles) throws IOException {
+ AnalyzedZipHeatFiles analyzedZipHeatFiles)
+ throws IOException {
MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP Id", vspDetails.getId());
try (InputStream manifest = fileContentHandler.getFileContent(SdcCommon.MANIFEST_NAME)) {
if (Objects.isNull(manifest)) {
Optional<ManifestContent> manifestContentOptional =
- candidateService.createManifest(vspDetails, fileContentHandler, analyzedZipHeatFiles);
+ candidateService.createManifest(vspDetails, fileContentHandler, analyzedZipHeatFiles);
if (!manifestContentOptional.isPresent()) {
throw new RuntimeException(Messages.CREATE_MANIFEST_FROM_ZIP.getErrorMessage());
}
ManifestContent manifestContent = manifestContentOptional.get();
fileContentHandler.addFile(
- SdcCommon.MANIFEST_NAME,
- String.valueOf(JsonUtil.sbObject2Json(manifestContent)).getBytes());
+ SdcCommon.MANIFEST_NAME,
+ String.valueOf(JsonUtil.sbObject2Json(manifestContent)).getBytes());
}
} finally {
MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP Id", vspDetails.getId());
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/CandidateDataEntityTo.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/CandidateDataEntityTo.java
index 4ea0a02..cf6e6f7 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/CandidateDataEntityTo.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/CandidateDataEntityTo.java
@@ -31,32 +31,26 @@
public class CandidateDataEntityTo {
private final String vspId;
- private final String user;
-// private final UploadFileResponse uploadFileResponse;
- private Map<String, List<ErrorMessage>> errors = new HashMap<>();
+ private final Version version;
private final byte[] uploadedFileData;
private final HeatStructureTree tree;
- private final Version activeVersion;
private final FileContentHandler contentMap;
+ private Map<String, List<ErrorMessage>> errors = new HashMap<>();
/**
* Instantiates a new Candidate data entity to.
- * @param vspId the vsp id
- * @param user the user
- * @param uploadedFileData the uploaded file data
- * @param tree the tree
- * @param contentMap the content map
- * @param activeVersion the active version
+ *
+ * @param vspId the vsp id
+ * @param uploadedFileData the uploaded file data
+ * @param tree the tree
+ * @param contentMap the content map
*/
- public CandidateDataEntityTo(String vspId, String user,
- byte[] uploadedFileData, HeatStructureTree tree,
- FileContentHandler contentMap, Version activeVersion) {
+ public CandidateDataEntityTo(String vspId, Version version, byte[] uploadedFileData,
+ HeatStructureTree tree, FileContentHandler contentMap) {
this.vspId = vspId;
- this.user = user;
- this.errors = errors;
+ this.version = version;
this.uploadedFileData = uploadedFileData;
this.tree = tree;
- this.activeVersion = activeVersion;
this.contentMap = contentMap;
}
@@ -64,10 +58,6 @@
return vspId;
}
- public String getUser() {
- return user;
- }
-
public byte[] getUploadedFileData() {
return uploadedFileData;
}
@@ -76,15 +66,19 @@
return tree;
}
- public Version getActiveVersion() {
- return activeVersion;
+ public Version getVersion() {
+ return version;
}
public FileContentHandler getContentMap() {
return contentMap;
}
- public Map<String, List<ErrorMessage>> getErrors() {return errors;}
+ public Map<String, List<ErrorMessage>> getErrors() {
+ return errors;
+ }
- public void setErrors(Map<String, List<ErrorMessage>> errors) {this.errors = errors;}
+ public void setErrors(Map<String, List<ErrorMessage>> errors) {
+ this.errors = errors;
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/GuestOS.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/GuestOS.java
index db22b3a..489557c 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/GuestOS.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/GuestOS.java
@@ -26,7 +26,7 @@
public class GuestOS {
private String name;
private String tools;
- private int bitSize;
+ private Number bitSize;
public String getName() {
return name;
@@ -44,11 +44,11 @@
this.tools = tools;
}
- public int getBitSize() {
+ public Number getBitSize() {
return bitSize;
}
- public void setBitSize(int bitSize) {
+ public void setBitSize(Number bitSize) {
this.bitSize = bitSize;
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/VmSizing.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/VmSizing.java
index fb4aaa6..a6a8b40 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/VmSizing.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/compute/VmSizing.java
@@ -23,8 +23,8 @@
public class VmSizing {
private int numOfCPUs;
private String fileSystemSizeGB;
- private int persistentStorageVolumeSize;
- private int IOOperationsPerSec;
+ private Number persistentStorageVolumeSize;
+ private Number IOOperationsPerSec;
private String cpuOverSubscriptionRatio;
private String memoryRAM;
@@ -44,19 +44,19 @@
this.fileSystemSizeGB = fileSystemSizeGB;
}
- public int getPersistentStorageVolumeSize() {
+ public Number getPersistentStorageVolumeSize() {
return persistentStorageVolumeSize;
}
- public void setPersistentStorageVolumeSize(int persistentStorageVolumeSize) {
+ public void setPersistentStorageVolumeSize(Number persistentStorageVolumeSize) {
this.persistentStorageVolumeSize = persistentStorageVolumeSize;
}
- public int getIOOperationsPerSec() {
+ public Number getIOOperationsPerSec() {
return IOOperationsPerSec;
}
- public void setIOOperationsPerSec(int IOOperationsPerSec) {
+ public void setIOOperationsPerSec(Number IOOperationsPerSec) {
this.IOOperationsPerSec = IOOperationsPerSec;
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Image.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Image.java
index 09e83b8..e87c0fd 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Image.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Image.java
@@ -26,8 +26,8 @@
public class Image {
private String format;
private String providedBy;
- private int bootDiskSizePerVM;
- private int ephemeralDiskSizePerVM;
+ private Number bootDiskSizePerVM;
+ private Number ephemeralDiskSizePerVM;
public String getFormat() {
return format;
@@ -45,19 +45,19 @@
this.providedBy = providedBy;
}
- public int getBootDiskSizePerVM() {
+ public Number getBootDiskSizePerVM() {
return bootDiskSizePerVM;
}
- public void setBootDiskSizePerVM(int bootDiskSizePerVM) {
+ public void setBootDiskSizePerVM(Number bootDiskSizePerVM) {
this.bootDiskSizePerVM = bootDiskSizePerVM;
}
- public int getEphemeralDiskSizePerVM() {
+ public Number getEphemeralDiskSizePerVM() {
return ephemeralDiskSizePerVM;
}
- public void setEphemeralDiskSizePerVM(int ephemeralDiskSizePerVM) {
+ public void setEphemeralDiskSizePerVM(Number ephemeralDiskSizePerVM) {
this.ephemeralDiskSizePerVM = ephemeralDiskSizePerVM;
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Recovery.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Recovery.java
index 4a13829..f1f8017 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Recovery.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/general/Recovery.java
@@ -24,23 +24,23 @@
* Created by TALIO on 11/22/2016.
*/
public class Recovery {
- private int pointObjective;
- private int timeObjective;
+ private Number pointObjective;
+ private Number timeObjective;
private String vmProcessFailuresHandling;
- public int getPointObjective() {
+ public Number getPointObjective() {
return pointObjective;
}
- public void setPointObjective(int pointObjective) {
+ public void setPointObjective(Number pointObjective) {
this.pointObjective = pointObjective;
}
- public int getTimeObjective() {
+ public Number getTimeObjective() {
return timeObjective;
}
- public void setTimeObjective(int timeObjective) {
+ public void setTimeObjective(Number timeObjective) {
this.timeObjective = timeObjective;
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/Backup.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/Backup.java
index df5bcb0..2357ddf 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/Backup.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/Backup.java
@@ -27,7 +27,7 @@
private String backupType;
private String backupSolution;
private String backupNIC;
- private int backupStorageSize;
+ private Number backupStorageSize;
public String getBackupType() {
return backupType;
@@ -53,11 +53,11 @@
this.backupNIC = backupNIC;
}
- public int getBackupStorageSize() {
+ public Number getBackupStorageSize() {
return backupStorageSize;
}
- public void setBackupStorageSize(int backupStorageSize) {
+ public void setBackupStorageSize(Number backupStorageSize) {
this.backupStorageSize = backupStorageSize;
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/LogBackup.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/LogBackup.java
index cbf1fbe..1b6453a 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/LogBackup.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/component/storage/LogBackup.java
@@ -24,24 +24,24 @@
* Created by TALIO on 11/22/2016.
*/
public class LogBackup {
- private int sizeOfLogFiles;
- private int logBackupFrequency;
+ private Number sizeOfLogFiles;
+ private Number logBackupFrequency;
private int logRetentionPeriod;
private String logFileLocation;
- public int getSizeOfLogFiles() {
+ public Number getSizeOfLogFiles() {
return sizeOfLogFiles;
}
- public void setSizeOfLogFiles(int sizeOfLogFiles) {
+ public void setSizeOfLogFiles(Number sizeOfLogFiles) {
this.sizeOfLogFiles = sizeOfLogFiles;
}
- public int getLogBackupFrequency() {
+ public Number getLogBackupFrequency() {
return logBackupFrequency;
}
- public void setLogBackupFrequency(int logBackupFrequency) {
+ public void setLogBackupFrequency(Number logBackupFrequency) {
this.logBackupFrequency = logBackupFrequency;
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/PeakAndAvg.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/PeakAndAvg.java
index 3d80224..1e44327 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/PeakAndAvg.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/PeakAndAvg.java
@@ -25,7 +25,7 @@
*/
public class PeakAndAvg {
private int peak;
- private int avg;
+ private Number avg;
public int getPeak() {
return peak;
@@ -35,11 +35,11 @@
this.peak = peak;
}
- public int getAvg() {
+ public Number getAvg() {
return avg;
}
- public void setAvg(int avg) {
+ public void setAvg(Number avg) {
this.avg = avg;
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/Sizing.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/Sizing.java
index 32a9e5a..4160cba 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/Sizing.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/nic/Sizing.java
@@ -25,7 +25,7 @@
*/
public class Sizing {
private String describeQualityOfService;
- private int acceptablePacketLoss;
+ private Number acceptablePacketLoss;
private PacketsAndBytes inflowTrafficPerSecond;
private PacketsAndBytes outflowTrafficPerSecond;
private PacketsAndBytes flowLength;
@@ -39,11 +39,11 @@
this.describeQualityOfService = describeQualityOfService;
}
- public int getAcceptablePacketLoss() {
+ public Number getAcceptablePacketLoss() {
return acceptablePacketLoss;
}
- public void setAcceptablePacketLoss(int acceptablePacketLoss) {
+ public void setAcceptablePacketLoss(Number acceptablePacketLoss) {
this.acceptablePacketLoss = acceptablePacketLoss;
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/StorageDataReplication.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/StorageDataReplication.java
index 7c073af..cf48703 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/StorageDataReplication.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/questionnaire/vsp/general/StorageDataReplication.java
@@ -25,8 +25,8 @@
*/
public class StorageDataReplication {
private boolean storageReplicationAcrossRegion;
- private int storageReplicationSize;
- private int storageReplicationFrequency;
+ private Number storageReplicationSize;
+ private Number storageReplicationFrequency;
private String storageReplicationSource;
private String storageReplicationDestination;
@@ -38,19 +38,19 @@
this.storageReplicationDestination = storageReplicationDestination;
}
- public int getStorageReplicationSize() {
+ public Number getStorageReplicationSize() {
return storageReplicationSize;
}
- public void setStorageReplicationSize(int storageReplicationSize) {
+ public void setStorageReplicationSize(Number storageReplicationSize) {
this.storageReplicationSize = storageReplicationSize;
}
- public int getStorageReplicationFrequency() {
+ public Number getStorageReplicationFrequency() {
return storageReplicationFrequency;
}
- public void setStorageReplicationFrequency(int storageReplicationFrequency) {
+ public void setStorageReplicationFrequency(Number storageReplicationFrequency) {
this.storageReplicationFrequency = storageReplicationFrequency;
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/resources/factoryConfiguration.json b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/resources/factoryConfiguration.json
index 52c6119..90160c4 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/resources/factoryConfiguration.json
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/resources/factoryConfiguration.json
@@ -1,8 +1,6 @@
{
- "org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.VendorSoftwareProductDaoFactoryImpl",
"org.openecomp.sdc.vendorsoftwareproduct.dao.VspDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.VspDaoFactoryImpl",
"org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.VendorSoftwareProductInfoDaoFactoryImpl",
- "org.openecomp.sdc.vendorsoftwareproduct.dao.UploadDataDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.UploadDataDaoFactoryImpl",
"org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.OrchestrationTemplateCandidateDaoFactoryImpl",
"org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.OrchestrationTemplateDaoFactoryImpl",
"org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.PackageInfoDaoFactoryImpl",
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComponentDependencyModelDaoCassandraImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComponentDependencyModelDaoCassandraImpl.java
index aa611c0..2fcbc1a 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComponentDependencyModelDaoCassandraImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComponentDependencyModelDaoCassandraImpl.java
@@ -52,12 +52,6 @@
}
@Override
- public void deleteAll(String vspId, Version version) {
- accessor.deleteAll(vspId, versionMapper.toUDT(version));
- }
-
-
- @Override
public void registerVersioning(String versionableEntityType) {
VersionableEntityMetadata metadata = new VersionableEntityMetadata(
mapper.getTableMetadata().getName(),
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/PackageInfoDaoImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/PackageInfoDaoImpl.java
index 0b29fda..41ab1a3 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/PackageInfoDaoImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/PackageInfoDaoImpl.java
@@ -20,10 +20,8 @@
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl;
-import com.datastax.driver.core.UDTValue;
import com.datastax.driver.mapping.Mapper;
import com.datastax.driver.mapping.Result;
-import com.datastax.driver.mapping.UDTMapper;
import com.datastax.driver.mapping.annotations.Accessor;
import com.datastax.driver.mapping.annotations.Query;
import org.openecomp.core.dao.impl.CassandraBaseDao;
@@ -32,9 +30,7 @@
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -46,8 +42,6 @@
noSqlDb.getMappingManager().mapper(PackageInfo.class);
private static final PackageInfoAccessor accessor =
noSqlDb.getMappingManager().createAccessor(PackageInfoAccessor.class);
- private static final UDTMapper<Version> versionMapper =
- noSqlDb.getMappingManager().udtMapper(Version.class);
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
@@ -58,7 +52,7 @@
@Override
protected Object[] getKeys(PackageInfo entity) {
- return new Object[]{entity.getVspId(), versionMapper.toUDT(entity.getVersion())};
+ return new Object[]{entity.getVspId(), entity.getVersion()};
}
@Override
@@ -68,8 +62,7 @@
@Override
public List<PackageInfo> listByCategory(String category, String subCategory) {
-
- mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugEntryMessage(null);
Result<PackageInfo> packages = accessor.listInfo();
List<PackageInfo> filteredPackages = new ArrayList<>();
@@ -86,20 +79,10 @@
filteredPackages.add(packageInfo);
}
}
- mdcDataDebugMessage.debugExitMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null);
return filteredPackages;
}
- @Override
- public void deleteRowTranslateContent(String vspId, Version version) {
- accessor.deleteRowTranslateContent(vspId, version);
- }
-
- @Override
- public void updateTranslatedContent(String vspId, Version version, ByteBuffer translateContent){
- accessor.updateTranslateContent(translateContent, vspId, versionMapper.toUDT(version));
- }
-
@Accessor
interface PackageInfoAccessor {
@@ -107,13 +90,5 @@
"SELECT vsp_id,version,display_name,vsp_name,vsp_description,vendor_name,category"
+ " ,sub_category, vendor_release,package_checksum,package_type FROM package_details")
Result<PackageInfo> listInfo();
-
- @Query("DELETE TRANSLATE_CONTENT FROM package_details WHERE vsp_id=? and version=?")
- Result<PackageInfo> deleteRowTranslateContent(String vspId, Version version);
-
- @Query("UPDATE package_details set translate_content = ? where vsp_id = ? and version = ?")
- Result<PackageInfo> updateTranslateContent(ByteBuffer translateContent, String vspId,
- UDTValue version);
-
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ProcessDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ProcessDaoFactoryImpl.java
index ada76e7..0205446 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ProcessDaoFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ProcessDaoFactoryImpl.java
@@ -21,8 +21,8 @@
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl;
import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ProcessDaoZusammenImpl;
public class ProcessDaoFactoryImpl extends ProcessDaoFactory {
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductDaoImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductDaoImpl.java
deleted file mode 100644
index 832f36b..0000000
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductDaoImpl.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.vendorsoftwareproduct.dao.impl;
-
-import org.openecomp.core.model.dao.EnrichedServiceArtifactDao;
-import org.openecomp.core.model.dao.EnrichedServiceArtifactDaoFactory;
-import org.openecomp.core.model.dao.EnrichedServiceModelDao;
-import org.openecomp.core.model.dao.EnrichedServiceModelDaoFactory;
-import org.openecomp.core.model.dao.ServiceArtifactDaoFactory;
-import org.openecomp.core.model.dao.ServiceArtifactDaoInter;
-import org.openecomp.core.model.dao.ServiceModelDao;
-import org.openecomp.core.model.dao.ServiceModelDaoFactory;
-import org.openecomp.core.model.dao.ServiceTemplateDaoFactory;
-import org.openecomp.core.model.dao.ServiceTemplateDaoInter;
-import org.openecomp.core.utilities.CommonMethods;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
-import org.openecomp.sdc.versioning.dao.types.Version;
-
-import java.nio.ByteBuffer;
-import java.util.Collection;
-import java.util.List;
-
-public class VendorSoftwareProductDaoImpl implements VendorSoftwareProductDao {
-
- private static final VendorSoftwareProductInfoDao vspInfoDao = VendorSoftwareProductInfoDaoFactory
- .getInstance().createInterface();
- private static final PackageInfoDao packageInfoDao =
- PackageInfoDaoFactory.getInstance().createInterface();
- private static final OrchestrationTemplateCandidateDao orchestrationTemplateCandidateDataDao =
- OrchestrationTemplateCandidateDaoFactory.getInstance().createInterface();
- private static final NetworkDao networkDao = NetworkDaoFactory.getInstance().createInterface();
- private static final ComponentDao componentDao =
- ComponentDaoFactory.getInstance().createInterface();
- private static final NicDao nicDao = NicDaoFactory.getInstance().createInterface();
- private static final ProcessDao processDao = ProcessDaoFactory.getInstance().createInterface();
- private static final ServiceArtifactDaoInter
- artifactDao = ServiceArtifactDaoFactory.getInstance().createInterface();
- public static final ServiceTemplateDaoInter
- templateDao = ServiceTemplateDaoFactory.getInstance().createInterface();
- private static final EnrichedServiceArtifactDao enrichArtifactDao =
- EnrichedServiceArtifactDaoFactory.getInstance().createInterface();
- private static final EnrichedServiceModelDao enrichedServiceModelDao =
- EnrichedServiceModelDaoFactory.getInstance().createInterface();
- private static final ServiceModelDao serviceModelDao =
- ServiceModelDaoFactory.getInstance().createInterface();
- private static final ComponentDependencyModelDao componentDependencyModelDao =
- ComponentDependencyModelDaoFactory.getInstance().createInterface();
- private static final DeploymentFlavorDao
- deploymentFlavorDao = DeploymentFlavorDaoFactory.getInstance().createInterface();
- private static final ImageDao imageDao = ImageDaoFactory.getInstance().createInterface();
- private static final ComputeDao computeDao = ComputeDaoFactory.getInstance().createInterface();
-
-
- @Override
- public void registerVersioning(String versionableEntityType) {
- vspInfoDao.registerVersioning(versionableEntityType);
- networkDao.registerVersioning(versionableEntityType);
- componentDao.registerVersioning(versionableEntityType);
- nicDao.registerVersioning(versionableEntityType);
- processDao.registerVersioning(versionableEntityType);
- orchestrationTemplateCandidateDataDao.registerVersioning(versionableEntityType);
- componentDependencyModelDao.registerVersioning(versionableEntityType);
- computeDao.registerVersioning(versionableEntityType);
- deploymentFlavorDao.registerVersioning(versionableEntityType);
- imageDao.registerVersioning(versionableEntityType);
- }
-
- @Override
- public Collection<ComponentEntity> listComponents(String vspId, Version version) {
- return componentDao.list(new ComponentEntity(vspId, version, null));
- }
-
- @Override
- public Collection<ComponentEntity> listComponentsQuestionnaire(String vspId, Version version) {
- return componentDao.listQuestionnaires(vspId, version);
- }
-
- @Override
- public Collection<ComponentEntity> listComponentsCompositionAndQuestionnaire(String vspId,
- Version version) {
- return componentDao.listCompositionAndQuestionnaire(vspId, version);
- }
-
- @Override
- public Collection<ProcessEntity> listProcesses(String vspId, Version version,
- String componentId) {
- return processDao.list(new ProcessEntity(vspId, version, componentId, null));
- }
-
- @Override
- public void deleteProcesses(String vspId, Version version, String componentId) {
- processDao.delete(new ProcessEntity(vspId, version, componentId, null));
- }
-
- @Override
- public ProcessEntity getProcess(String vspId, Version version, String componentId,
- String processId) {
- return processDao.get(new ProcessEntity(vspId, version, componentId, processId));
- }
-
- @Override
- public void createProcess(ProcessEntity processEntity) {
- processDao.create(processEntity);
- }
-
- @Override
- public void updateProcess(ProcessEntity processEntity) {
- ProcessEntity process = processDao.get(new ProcessEntity(processEntity.getVspId(), processEntity.getVersion(),
- processEntity.getComponentId(), processEntity.getId()));
- processEntity.setArtifact(process.getArtifact());
- processEntity.setArtifactName(process.getArtifactName());
- processDao.update(processEntity);
- }
-
- @Override
- public void deleteProcess(String vspId, Version version, String componentId, String processId) {
- processDao.delete(new ProcessEntity(vspId, version, componentId, processId));
- }
-
- @Override
- public void uploadProcessArtifact(String vspId, Version version, String componentId,
- String processId, byte[] artifact, String artifactName) {
- ProcessEntity
- processArtifact = new ProcessEntity(vspId, version, componentId, processId);
- processArtifact = processDao.get(processArtifact);
- processArtifact.setArtifact(ByteBuffer.wrap(artifact));
- processArtifact.setArtifactName(artifactName);
- processDao.update(processArtifact);
- }
-
- @Override
- public ProcessEntity getProcessArtifact(String vspId, Version version, String componentId,
- String processId) {
- return processDao
- .get(new ProcessEntity(vspId, version, componentId, processId));
- }
-
- @Override
- public void deleteProcessArtifact(String vspId, Version version, String componentId,
- String processId) {
- processDao.delete(new ProcessEntity(vspId, version, componentId, processId));
- }
-
- @Override
- public Collection<NicEntity> listNicsByVsp(String vspId, Version version) {
- return nicDao.listByVsp(vspId, version);
- }
-
- @Override
- public void deleteUploadData(String vspId, Version version) {
- networkDao.deleteAll(vspId, version);
- enrichedServiceModelDao.deleteAll(vspId, version);
- serviceModelDao.deleteAll(vspId, version);
- componentDao.deleteAll(vspId, version);
- }
-
- @Override
- public void createComponentDependencyModel(List<ComponentDependencyModelEntity>
- componentDependencyModel, String vspId,
- Version version) {
- componentDependencyModelDao.deleteAll(vspId, version);
- for (ComponentDependencyModelEntity entity : componentDependencyModel) {
- entity.setId(CommonMethods.nextUuId());
- componentDependencyModelDao.create(entity);
- }
- }
-
- @Override
- public Collection<ComponentDependencyModelEntity> listComponentDependencies(String vspId,
- Version version) {
- return componentDependencyModelDao.list(new ComponentDependencyModelEntity(vspId, version,
- null));
- }
-
- @Override
- public void createDeploymentFlavor(DeploymentFlavorEntity deploymentFlavor) {
- deploymentFlavorDao.create(deploymentFlavor);
- }
-
- @Override
- public Collection<DeploymentFlavorEntity> listDeploymentFlavors(String vspId, Version version) {
- return deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null));
- }
-
- @Override
- public DeploymentFlavorEntity getDeploymentFlavor(String vspId, Version version,
- String deploymentFlavorId) {
- return deploymentFlavorDao.get(new DeploymentFlavorEntity(vspId, version, deploymentFlavorId));
- }
-
- @Override
- public void deleteDeploymentFlavor(String vspId, Version version, String deploymentFlavorId) {
- deploymentFlavorDao.delete(new DeploymentFlavorEntity(vspId,version,
- deploymentFlavorId));
- }
-
- @Override
- public void createImage(ImageEntity imageEntity) {
- imageDao.create(imageEntity);
- }
-
- @Override
- public Collection<ImageEntity> listImages(String vspId, Version version, String componentId) {
- return imageDao.list(new ImageEntity(vspId, version, componentId, null));
- }
-
- @Override
- public ImageEntity getImage(String vspId, Version version, String componentId, String imageId) {
- return imageDao.get(new ImageEntity(vspId, version, componentId, imageId));
- }
-
- @Override
- public Collection<ImageEntity> listImagesByVsp(String vspId, Version version) {
- return imageDao.listByVsp(vspId, version);
- }
-
- @Override
- public void createCompute(ComputeEntity computeEntity) {
- computeDao.create(computeEntity);
- }
-
- @Override
- public Collection<ComputeEntity> listComputes(String vspId, Version version, String componentId) {
- return computeDao.list(new ComputeEntity(vspId, version, componentId, null));
- }
-
- @Override
- public Collection<ComputeEntity> listComputesByVsp(String vspId, Version version) {
- return computeDao.listByVsp(vspId, version);
- }
-
- @Override
- public ComputeEntity getCompute(String vspId, Version version, String componentId,
- String computeFlavorId) {
- return computeDao.get(new ComputeEntity(vspId, version, componentId, computeFlavorId));
- }
-
- @Override
- public void deleteImage(String vspId, Version version, String componentId, String imageId) {
- ImageEntity imageEntity = new ImageEntity(vspId, version, componentId, imageId);
- imageDao.delete(imageEntity);
- }
-
- @Override
- public void updateDeploymentFlavor(DeploymentFlavorEntity deploymentFlavorEntity) {
- deploymentFlavorDao.update(deploymentFlavorEntity);
- }
-
- @Override
- public void updateImage(ImageEntity imageEntity) {
- imageDao.update(imageEntity);
- }
-
- @Override
- public void updateImageQuestionnaire(String vspId, Version version, String componentId,
- String imageId, String questionnaireData) {
- imageDao.updateQuestionnaireData(vspId, version, componentId, imageId, questionnaireData);
- }
-
- @Override
- public void updateComputeQuestionnaire(String vspId, Version version, String componentId,
- String computeId, String questionnaireData) {
- computeDao.updateQuestionnaireData(vspId, version, componentId, computeId, questionnaireData);
- }
-
- @Override
- public void updateCompute(ComputeEntity compute) {
- computeDao.update(compute);
- }
-
- @Override
- public void deleteCompute(String vspId, Version version, String componentId, String
- computeFlavorId) {
- computeDao.delete(new ComputeEntity(vspId, version, componentId, computeFlavorId));
- }
-}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductInfoDaoImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductInfoDaoImpl.java
index d9b629c..fef49c8 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductInfoDaoImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductInfoDaoImpl.java
@@ -73,32 +73,17 @@
}
@Override
- public void updateOldVersionIndication(VspDetails vspDetails) {
-
- }
-
- @Override
public void updateQuestionnaireData(String vspId, Version version,
String questionnaireData) {
}
@Override
- public String getQuestionnaireData(String vspId, Version version) {
- return null;
- }
-
- @Override
public VspQuestionnaireEntity getQuestionnaire(String vspId, Version version) {
return null;
}
@Override
- public void deleteAll(String vspId, Version version) {
-
- }
-
- @Override
public boolean isManual(String vspId, Version version) {
return false;
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VspMergeDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VspMergeDaoFactoryImpl.java
new file mode 100644
index 0000000..478681f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VspMergeDaoFactoryImpl.java
@@ -0,0 +1,17 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl;
+
+
+import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VspMergeDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VspMergeDaoFactory;
+
+public class VspMergeDaoFactoryImpl extends VspMergeDaoFactory {
+
+ private static final VspMergeDao INSTANCE = new
+ VspMergeDaoImpl(ZusammenAdaptorFactory.getInstance().createInterface());
+
+ @Override
+ public VspMergeDao createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VspMergeDaoImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VspMergeDaoImpl.java
new file mode 100644
index 0000000..2ccc47a
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VspMergeDaoImpl.java
@@ -0,0 +1,158 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.Action;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import com.amdocs.zusammen.datatypes.item.Resolution;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+import com.datastax.driver.mapping.annotations.Accessor;
+import com.datastax.driver.mapping.annotations.Query;
+import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
+import org.openecomp.core.zusammen.api.ZusammenAdaptor;
+import org.openecomp.sdc.common.session.SessionContextProviderFactory;
+import org.openecomp.sdc.datatypes.model.ElementType;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VspMergeDao;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
+public class VspMergeDaoImpl implements VspMergeDao {
+ private static final String VSP_MODEL_NOT_EXIST =
+ "Vsp model does not exist for Vsp %s, version %s.";
+
+ private static VspMergeHintAccessor accessor =
+ NoSqlDbFactory.getInstance().createInterface()
+ .getMappingManager().createAccessor(VspMergeHintAccessor.class);
+
+ private ZusammenAdaptor zusammenAdaptor;
+
+ public VspMergeDaoImpl(ZusammenAdaptor zusammenAdaptor) {
+ this.zusammenAdaptor = zusammenAdaptor;
+ }
+
+ @Override
+ public boolean isVspModelConflicted(String vspId, Version version) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(new Id(vspId), new Id(version.getId()));
+
+ return listVspModels(context, elementContext).size() > 1;
+ }
+
+ @Override
+ public void updateVspModelId(String vspId, Version version) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(new Id(vspId), new Id(version.getId()));
+
+ String vspModelId = zusammenAdaptor
+ .getElementInfoByName(context, elementContext, null, ElementType.VspModel.name())
+ .orElseThrow(() -> new IllegalStateException(
+ String.format(VSP_MODEL_NOT_EXIST, vspId, version.getId())))
+ .getId().getValue();
+
+ updateVspModelId(vspId, version, vspModelId);
+ }
+
+ @Override
+ public void updateVspModelConflictResolution(String vspId, Version version,
+ Resolution resolution) {
+ accessor.updateModelResolution(resolution, getUser(), vspId, version.getId());
+ }
+
+ @Override
+ public void applyVspModelConflictResolution(String vspId, Version version) {
+ //called only when no conflicts
+
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(new Id(vspId), new Id(version.getId()));
+
+ List<ElementInfo> vspModels = listVspModels(context, elementContext);
+ if (vspModels.size() == 1) {
+ updateVspModelId(vspId, version, vspModels.iterator().next().getId().getValue());
+ return;
+ }
+
+ if (vspModels.size() != 2) {
+ return;
+ }
+
+ String user = getUser();
+ Row row = accessor.getModelMergeHint(user, vspId, version.getId()).one();
+ if (row == null) {
+ throw new IllegalStateException(
+ "Vsp model id must exists if its conflict is being resolved");
+ }
+ String resolutionValue = row.getString("model_resolution");
+ if (resolutionValue == null) {
+ return; // model conflict is not resolved yet
+ }
+
+ Resolution resolution = Resolution.valueOf(resolutionValue);
+ String localModelId = row.getString("model_id");
+
+ String chosenModelId =
+ keepOnlyChosenVspModel(context, elementContext, vspModels, resolution, localModelId);
+
+ accessor.updateModelMergeHint(chosenModelId, null, user, vspId, version.getId());
+ }
+
+ private String keepOnlyChosenVspModel(SessionContext context, ElementContext elementContext,
+ List<ElementInfo> vspModels, Resolution resolution,
+ String localModelId) {
+ String newLocalModelId = null;
+ for (ElementInfo vspModel : vspModels) {
+ if (isRedundantModel(vspModel.getId().getValue(), localModelId, resolution)) {
+ zusammenAdaptor
+ .saveElement(context, elementContext, buildElement(vspModel.getId(), Action.DELETE),
+ "Delete Redundant Vsp Model");
+ } else {
+ newLocalModelId = vspModel.getId().getValue();
+ }
+ }
+ return newLocalModelId;
+ }
+
+ private boolean isRedundantModel(String modelId, String localModelId, Resolution resolution) {
+ return resolution == Resolution.THEIRS && modelId.equals(localModelId) ||
+ resolution == Resolution.YOURS && !modelId.equals(localModelId);
+ }
+
+ private List<ElementInfo> listVspModels(SessionContext context, ElementContext elementContext) {
+ return zusammenAdaptor.listElements(context, elementContext, null).stream()
+ .filter(elementInfo -> ElementType.VspModel.name().equals(elementInfo.getInfo().getName()))
+ .collect(Collectors.toList());
+ }
+
+ private void updateVspModelId(String vspId, Version version, String vspModelId) {
+ accessor.updateModelMergeHint(vspModelId, null, getUser(), vspId, version.getId());
+ }
+
+ private String getUser() {
+ return SessionContextProviderFactory.getInstance().createInterface()
+ .get().getUser().getUserId();
+ }
+
+ @Accessor
+ interface VspMergeHintAccessor {
+
+ @Query("UPDATE vsp_merge_hint SET model_id=?, model_resolution=? " +
+ "WHERE space=? AND item_id=? AND version_id=?")
+ void updateModelMergeHint(String vspModelId, Resolution modelResolution, String space,
+ String itemId, String versionId);
+
+ @Query(
+ "UPDATE vsp_merge_hint SET model_resolution=? WHERE space=? AND item_id=? AND version_id=?")
+ void updateModelResolution(Resolution modelResolution, String space, String itemId,
+ String versionId);
+
+ @Query("SELECT model_id, model_resolution FROM vsp_merge_hint " +
+ "WHERE space=? AND item_id=? AND version_id=?")
+ ResultSet getModelMergeHint(String space, String itemId, String versionId);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentArtifactDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentArtifactDaoZusammenImpl.java
index 517f2fd..01be738 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentArtifactDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentArtifactDaoZusammenImpl.java
@@ -1,7 +1,6 @@
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
-import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.SessionContext;
@@ -10,10 +9,10 @@
import org.openecomp.core.enrichment.types.MonitoringUploadType;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentArtifactDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToComponentMonitoringUploadConvertor;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity;
-import org.openecomp.sdc.versioning.dao.types.Version;
import java.io.ByteArrayInputStream;
import java.nio.ByteBuffer;
@@ -21,13 +20,17 @@
import java.util.Optional;
import java.util.stream.Collectors;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
/**
* @author Avrahamg.
* @since March 21, 2017
*/
public class ComponentArtifactDaoZusammenImpl implements ComponentArtifactDao {
- private static final String ARTIFACT_NAME = "name";
+ private static final String ARTIFACT_NAME = "artifactName";
private ZusammenAdaptor zusammenAdaptor;
@@ -43,28 +46,25 @@
@Override
public Optional<ComponentMonitoringUploadEntity> getByType(
ComponentMonitoringUploadEntity componentMonitoringUploadEntity) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(componentMonitoringUploadEntity.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(componentMonitoringUploadEntity.getVersion()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(componentMonitoringUploadEntity.getVspId(),
+ componentMonitoringUploadEntity.getVersion().getId());
+
Optional<Element> mibsElement =
- zusammenAdaptor.getElementByName(context, elementContext, new Id(
- componentMonitoringUploadEntity
- .getComponentId()), StructureElement.Mibs.toString());
+ zusammenAdaptor.getElementByName(context, elementContext,
+ new Id(componentMonitoringUploadEntity.getComponentId()), ElementType.Mibs.toString());
if (mibsElement.isPresent()) {
Optional<Element> monitoringElement = zusammenAdaptor
.getElementByName(context, elementContext, mibsElement.get().getElementId(),
- getMonitoringStructuralElement(componentMonitoringUploadEntity.getType())
- .toString());
+ getMonitoringStructuralElement(componentMonitoringUploadEntity.getType()).toString());
if (monitoringElement.isPresent()) {
- componentMonitoringUploadEntity.setId(monitoringElement.get().getElementId().getValue());
- componentMonitoringUploadEntity
- .setArtifactName(
- (String) monitoringElement.get().getInfo().getProperties().get(ARTIFACT_NAME));
- componentMonitoringUploadEntity
- .setArtifact(ByteBuffer.wrap(FileUtils.toByteArray(monitoringElement.get().getData())));
- return Optional.of(componentMonitoringUploadEntity);
+ ComponentMonitoringUploadEntity entity =
+ new ElementToComponentMonitoringUploadConvertor().convert(monitoringElement.get());
+ entity.setVspId(componentMonitoringUploadEntity.getVspId());
+ entity.setVersion(componentMonitoringUploadEntity.getVersion());
+ entity.setComponentId(componentMonitoringUploadEntity.getComponentId());
+ return Optional.of(entity);
}
}
@@ -75,93 +75,113 @@
public void create(ComponentMonitoringUploadEntity entity) {
ZusammenElement mibElement = buildMibElement(entity);
- ZusammenElement mibsElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Mibs, null);
+ ZusammenElement mibsElement = buildStructuralElement(ElementType.Mibs, null);
- ZusammenElement componentElement = buildComponentElement(entity);
+ ZusammenElement componentElement = buildElement(new Id(entity.getComponentId()), Action.IGNORE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(entity.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(entity.getVspId(), entity.getVersion().getId());
- Optional<Element> savedElement = zusammenAdaptor.saveElement(context, elementContext,
+ Element savedElement = zusammenAdaptor.saveElement(context, elementContext,
VspZusammenUtil.aggregateElements(componentElement, mibsElement, mibElement),
"Create monitoring upload");
- savedElement.ifPresent(element ->
- entity.setId(element.getSubElements().iterator().next()
- .getSubElements().iterator().next().getElementId().getValue()));
+ entity.setId(savedElement.getSubElements().iterator().next()
+ .getSubElements().iterator().next().getElementId().getValue());
}
@Override
public void delete(ComponentMonitoringUploadEntity componentMonitoringUploadEntity) {
- ZusammenElement mibElement = new ZusammenElement();
- mibElement.setElementId(new Id(componentMonitoringUploadEntity.getId()));
- mibElement.setAction(Action.DELETE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(componentMonitoringUploadEntity.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ ZusammenElement mibElement = buildMibElementStructure(componentMonitoringUploadEntity);
+ mibElement.setElementId(new Id(componentMonitoringUploadEntity.getId()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(componentMonitoringUploadEntity.getVspId(),
+ componentMonitoringUploadEntity.getVersion().getId());
zusammenAdaptor.saveElement(context, elementContext, mibElement,
String.format("Delete mib with id %s", componentMonitoringUploadEntity.getId()));
}
- @Override
- public Collection<ComponentMonitoringUploadEntity> list(ComponentMonitoringUploadEntity mib) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(mib.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(mib.getVersion()));
- return zusammenAdaptor.listElementsByName(context, elementContext, new Id(mib.getComponentId()),
- StructureElement.Mibs.toString()).stream()
- .map(elementInfo ->
- mapElementInfoToMib(mib.getVspId(), mib.getVersion(), mib.getComponentId(),
- elementInfo))
+
+ @Override
+ public Collection<ComponentMonitoringUploadEntity> list(
+ ComponentMonitoringUploadEntity mibEntity) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(mibEntity.getVspId(), mibEntity.getVersion().getId());
+ ElementToComponentMonitoringUploadConvertor
+ convertor = new ElementToComponentMonitoringUploadConvertor();
+ return zusammenAdaptor
+ .listElementsByName(context, elementContext, new Id(mibEntity.getComponentId()),
+ ElementType.Mibs.toString()).stream()
+ .map(elementInfo -> convertor.convert(elementInfo))
+ .map(mib -> {
+ mib.setVspId(mibEntity.getVspId());
+ mib.setVersion(mibEntity.getVersion());
+ mib.setComponentId(mibEntity.getComponentId());
+ return mib;
+ })
.collect(Collectors.toList());
}
@Override
public void deleteAll(ComponentMonitoringUploadEntity componentMonitoringUploadEntity) {
- ZusammenElement mibsElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Mibs, Action.DELETE);
+ /*ZusammenElement mibsElement =
+ buildStructuralElement(ElementType.Mibs, Action.DELETE);
ZusammenElement componentElement = buildComponentElement(componentMonitoringUploadEntity);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(componentMonitoringUploadEntity.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(componentMonitoringUploadEntity.getVspId(),
+ componentMonitoringUploadEntity.getVersion().getId());
zusammenAdaptor.saveElement(context, elementContext,
- VspZusammenUtil.aggregateElements(componentElement, mibsElement), "Delete mibs");
+ VspaggregateElements(componentElement, mibsElement), "Delete mibs");
+
+*/
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(componentMonitoringUploadEntity.getVspId(),
+ componentMonitoringUploadEntity.getVersion().getId());
+
+ Optional<Element> optionalElement = zusammenAdaptor.getElementByName(context,
+ elementContext, new Id(componentMonitoringUploadEntity.getComponentId()), ElementType.Mibs
+ .name());
+
+ if (optionalElement.isPresent()) {
+ Element mibsElement = optionalElement.get();
+ Collection<Element> mibs = mibsElement.getSubElements();
+
+ mibs.forEach(mib -> {
+ ZusammenElement mibZusammenElement = buildElement(mib.getElementId(), Action.DELETE);
+ zusammenAdaptor.saveElement(context, elementContext, mibZusammenElement,
+ "Delete mib with id " + mib.getElementId());
+ });
+ }
}
@Override
public Collection<ComponentMonitoringUploadEntity> listArtifacts(
ComponentMonitoringUploadEntity monitoringUploadEntity) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(monitoringUploadEntity.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(monitoringUploadEntity.getVersion()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(monitoringUploadEntity.getVspId(),
+ monitoringUploadEntity.getVersion().getId());
final Optional<Element> elementByName =
zusammenAdaptor.getElementByName(context, elementContext,
- new Id(monitoringUploadEntity.getComponentId()
- ), StructureElement.Mibs.name());
+ new Id(monitoringUploadEntity.getComponentId()), ElementType.Mibs.name());
- if(!elementByName.isPresent())
+ if (!elementByName.isPresent()) {
return null;
- else {
+ } else {
final Id elementId = elementByName.get().getElementId();
return zusammenAdaptor.listElementData(context, elementContext, elementId).stream()
- .map(element ->
- buildMibEntity(element, monitoringUploadEntity)
- ).collect(Collectors.toList());
+ .map(element -> buildMibEntity(element, monitoringUploadEntity))
+ .collect(Collectors.toList());
}
}
@@ -179,18 +199,10 @@
return createdMib;
}
- private ZusammenElement buildComponentElement(
- ComponentMonitoringUploadEntity componentMonitoringUploadEntity) {
- ZusammenElement componentElement = new ZusammenElement();
- componentElement.setElementId(new Id(componentMonitoringUploadEntity.getComponentId()));
- componentElement.setAction(Action.IGNORE);
- return componentElement;
- }
+ private ZusammenElement buildMibElement(
+ ComponentMonitoringUploadEntity monitoringUploadEntity) {
- private ZusammenElement buildMibElement(ComponentMonitoringUploadEntity monitoringUploadEntity) {
- ZusammenElement monitoringElement = VspZusammenUtil
- .buildStructuralElement(getMonitoringStructuralElement(monitoringUploadEntity.getType()),
- Action.UPDATE);
+ ZusammenElement monitoringElement = buildMibElementStructure(monitoringUploadEntity);
monitoringElement.getInfo().getProperties()
.put(ARTIFACT_NAME, monitoringUploadEntity.getArtifactName());
monitoringElement
@@ -198,27 +210,23 @@
return monitoringElement;
}
- private ComponentMonitoringUploadEntity mapElementInfoToMib(String vspId, Version version,
- String componentId,
- ElementInfo elementInfo) {
- ComponentMonitoringUploadEntity
- monitoringUploadEntity = new ComponentMonitoringUploadEntity(vspId, version, componentId,
- elementInfo.getId().getValue());
- monitoringUploadEntity
- .setArtifactName((String) elementInfo.getInfo().getProperties().get(ARTIFACT_NAME));
- monitoringUploadEntity.setType(MonitoringUploadType.valueOf(elementInfo.getInfo().getName()));
- return monitoringUploadEntity;
+ private ZusammenElement buildMibElementStructure(
+ ComponentMonitoringUploadEntity componentMonitoringUploadEntity) {
+ ZusammenElement monitoringElement =
+ buildStructuralElement(getMonitoringStructuralElement(componentMonitoringUploadEntity.getType()),
+ Action.UPDATE);
+ return monitoringElement;
}
- private StructureElement getMonitoringStructuralElement(MonitoringUploadType type)
+ private ElementType getMonitoringStructuralElement(MonitoringUploadType type)
throws IllegalArgumentException {
switch (type) {
case SNMP_POLL:
- return StructureElement.SNMP_POLL;
+ return ElementType.SNMP_POLL;
case SNMP_TRAP:
- return StructureElement.SNMP_TRAP;
+ return ElementType.SNMP_TRAP;
case VES_EVENTS:
- return StructureElement.VES_EVENTS;
+ return ElementType.VES_EVENTS;
default:
throw new IllegalArgumentException();
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDaoZusammenImpl.java
index ed6a13d..e658ea5 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDaoZusammenImpl.java
@@ -8,20 +8,26 @@
import com.amdocs.zusammen.datatypes.item.Action;
import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.datatypes.item.Info;
-import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToComponentConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToComponentQuestionnnaireConvertor;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.types.ElementPropertyName;
import java.io.ByteArrayInputStream;
-import java.util.Arrays;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Optional;
import java.util.stream.Collectors;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
public class ComponentDaoZusammenImpl implements ComponentDao {
private ZusammenAdaptor zusammenAdaptor;
@@ -36,105 +42,97 @@
@Override
public Collection<ComponentEntity> list(ComponentEntity component) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(component.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(component.getVersion()));
+ SessionContext context = createSessionContext();
- return listComponents(zusammenAdaptor, context, elementContext, component.getVspId(),
- component.getVersion());
+ return listComponents(zusammenAdaptor, context, component.getVspId(), component.getVersion());
}
static Collection<ComponentEntity> listComponents(ZusammenAdaptor zusammenAdaptor,
SessionContext context,
- ElementContext elementContext,
String vspId, Version version) {
- return zusammenAdaptor
- .listElementsByName(context, elementContext, null, StructureElement.Components.name())
- .stream().map(elementInfo -> mapElementInfoToComponent(vspId, version, elementInfo))
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+
+ Optional<ElementInfo> vspModel = zusammenAdaptor
+ .getElementInfoByName(context, elementContext, null, ElementType.VspModel.name());
+ if (!vspModel.isPresent()) {
+ return new ArrayList<>();
+ }
+
+ ElementToComponentConvertor convertor = new ElementToComponentConvertor();
+ return zusammenAdaptor.listElementsByName(context, elementContext, vspModel.get().getId(),
+ ElementType.Components.name()).stream()
+ .map(elementInfo -> {
+ ComponentEntity entity = convertor.convert(elementInfo);
+ entity.setVspId(vspId);
+ entity.setVersion(version);
+ return entity;
+ })
.collect(Collectors.toList());
}
- private static ComponentEntity mapElementInfoToComponent(String vspId, Version version,
- ElementInfo elementInfo) {
- ComponentEntity componentEntity =
- new ComponentEntity(vspId, version, elementInfo.getId().getValue());
- componentEntity.setCompositionData(
- elementInfo.getInfo().getProperty(ElementPropertyName.compositionData.name()));
- return componentEntity;
- }
@Override
public void create(ComponentEntity component) {
ZusammenElement componentElement = componentToZusammen(component, Action.CREATE);
+
ZusammenElement componentsElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Components, null);
+ buildStructuralElement(ElementType.Components, Action.IGNORE);
componentsElement.getSubElements().add(componentElement);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(component.getVspId());
- Optional<Element> savedElement = zusammenAdaptor.saveElement(context,
- new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
- componentsElement, "Create component");
- savedElement.ifPresent(element ->
- component.setId(element.getSubElements().iterator().next().getElementId().getValue()));
+ ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.IGNORE);
+ vspModel.addSubElement(componentsElement);
+
+ SessionContext context = createSessionContext();
+ Element savedVspModel = zusammenAdaptor.saveElement(context,
+ new ElementContext(component.getVspId(), component.getVersion().getId()),
+ vspModel, "Create component");
+ component.setId(savedVspModel.getSubElements().iterator().next()
+ .getSubElements().iterator().next().getElementId().getValue());
}
@Override
public void update(ComponentEntity component) {
ZusammenElement componentElement = componentToZusammen(component, Action.UPDATE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(component.getVspId());
+ SessionContext context = createSessionContext();
zusammenAdaptor.saveElement(context,
- new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
+ new ElementContext(component.getVspId(), component.getVersion().getId()),
componentElement, String.format("Update component with id %s", component.getId()));
}
@Override
public ComponentEntity get(ComponentEntity component) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(component.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(component.getVersion()));
+ SessionContext context = createSessionContext();
Optional<Element> element =
- zusammenAdaptor.getElement(context, elementContext, component.getId());
+ zusammenAdaptor.getElement(context,
+ new ElementContext(component.getVspId(), component.getVersion().getId()),
+ component.getId());
if (element.isPresent()) {
- component.setCompositionData(new String(FileUtils.toByteArray(element.get().getData())));
- return component;
+ ComponentEntity entity = new ElementToComponentConvertor().convert(element.get());
+ entity.setVspId(component.getVspId());
+ entity.setVersion(component.getVersion());
+ return entity;
}
return null;
}
@Override
public void delete(ComponentEntity component) {
- ZusammenElement componentElement = new ZusammenElement();
- componentElement.setElementId(new Id(component.getId()));
- componentElement.setAction(Action.DELETE);
+ ZusammenElement componentElement = buildElement(new Id(component.getId()), Action.DELETE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(component.getVspId());
+ SessionContext context = createSessionContext();
zusammenAdaptor.saveElement(context,
- new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
+ new ElementContext(component.getVspId(), component.getVersion().getId()),
componentElement, String.format("Delete component with id %s", component.getId()));
}
@Override
public ComponentEntity getQuestionnaireData(String vspId, Version version, String componentId) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(version));
+ SessionContext context = createSessionContext();
- return getQuestionnaire(context, elementContext,
+ return getQuestionnaire(context, new ElementContext(vspId, version.getId()),
new ComponentEntity(vspId, version, componentId));
}
@@ -142,14 +140,12 @@
ComponentEntity component) {
Optional<Element> questionnaireElement = zusammenAdaptor
.getElementByName(context, elementContext, new Id(component.getId()),
- StructureElement.Questionnaire.name());
- return questionnaireElement.map(
- element -> element.getData() == null
- ? null
- : new String(FileUtils.toByteArray(element.getData())))
- .map(questionnaireData -> {
- component.setQuestionnaireData(questionnaireData);
- return component;
+ ElementType.ComponentQuestionnaire.name());
+ return questionnaireElement.map(new ElementToComponentQuestionnnaireConvertor()::convert)
+ .map(entity -> {
+ entity.setVspId(component.getVspId());
+ entity.setVersion(component.getVersion());
+ return entity;
})
.orElse(null);
}
@@ -160,16 +156,11 @@
ZusammenElement questionnaireElement =
componentQuestionnaireToZusammen(questionnaireData, Action.UPDATE);
- ZusammenElement componentElement = new ZusammenElement();
- componentElement.setAction(Action.IGNORE);
- componentElement.setElementId(new Id(componentId));
+ ZusammenElement componentElement = buildElement(new Id(componentId), Action.IGNORE);
componentElement.setSubElements(Collections.singletonList(questionnaireElement));
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- zusammenAdaptor.saveElement(context,
- new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
+ SessionContext context = createSessionContext();
+ zusammenAdaptor.saveElement(context, new ElementContext(vspId, version.getId()),
componentElement, "Update component questionnaire");
}
@@ -181,45 +172,57 @@
@Override
public Collection<ComponentEntity> listCompositionAndQuestionnaire(String vspId,
Version version) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(version));
+ SessionContext context = createSessionContext();
Collection<ComponentEntity> components =
- listComponents(zusammenAdaptor, context, elementContext, vspId, version);
+ listComponents(zusammenAdaptor, context, vspId, version);
- components.forEach(component -> getQuestionnaire(context, elementContext, component));
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+ components.forEach(component -> component.setQuestionnaireData(
+ getQuestionnaire(context, elementContext, component).getQuestionnaireData()));
return components;
}
@Override
public void deleteAll(String vspId, Version version) {
- ZusammenElement componentsElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Components, Action.DELETE);
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- zusammenAdaptor.saveElement(context,
- new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
- componentsElement, "Delete all components");
+ Collection<ElementInfo> vspModelSubs = zusammenAdaptor
+ .listElementsByName(context, elementContext, null, ElementType.VspModel.name());
+
+ Optional<ElementInfo> componentsElement = vspModelSubs.stream()
+ .filter(elementInfo -> elementInfo.getInfo() != null
+ && ElementType.Components.name().equals(elementInfo.getInfo().getName()))
+ .findFirst();
+ if (!componentsElement.isPresent()) {
+ return;
+ }
+
+ ZusammenElement components = buildElement(componentsElement.get().getId(), Action.IGNORE);
+ components.setSubElements(componentsElement.get().getSubElements().stream()
+ .map(component -> buildElement(component.getId(), Action.DELETE))
+ .collect(Collectors.toList()));
+
+ zusammenAdaptor.saveElement(context, elementContext, components, "Delete all components");
}
private ZusammenElement componentToZusammen(ComponentEntity component, Action action) {
ZusammenElement componentElement = buildComponentElement(component, action);
+
if (action == Action.CREATE) {
- componentElement
- .setSubElements(Arrays.asList(
- componentQuestionnaireToZusammen(component.getQuestionnaireData(), Action.CREATE),
- VspZusammenUtil.buildStructuralElement(StructureElement.Nics, Action.CREATE),
- VspZusammenUtil.buildStructuralElement(StructureElement.Processes, Action.CREATE),
- VspZusammenUtil.buildStructuralElement(StructureElement.Mibs, Action.CREATE),
- VspZusammenUtil.buildStructuralElement(StructureElement.Computes, Action.CREATE),
- VspZusammenUtil.buildStructuralElement(StructureElement.Images, Action.CREATE)));
+ ZusammenElement mibs = buildStructuralElement(ElementType.Mibs, Action.CREATE);
+ mibs.addSubElement(buildStructuralElement(ElementType.SNMP_TRAP, Action.CREATE));
+ mibs.addSubElement(buildStructuralElement(ElementType.VES_EVENTS, Action.CREATE));
+ mibs.addSubElement(buildStructuralElement(ElementType.SNMP_POLL, Action.CREATE));
-
+ componentElement.addSubElement(mibs);
+ componentElement.addSubElement(
+ componentQuestionnaireToZusammen(component.getQuestionnaireData(), Action.CREATE));
+ componentElement.addSubElement(buildStructuralElement(ElementType.Nics, Action.CREATE));
+ componentElement.addSubElement(buildStructuralElement(ElementType.Processes, Action.CREATE));
+ componentElement.addSubElement(buildStructuralElement(ElementType.Computes, Action.CREATE));
+ componentElement.addSubElement(buildStructuralElement(ElementType.Images, Action.CREATE));
}
return componentElement;
}
@@ -227,22 +230,21 @@
private ZusammenElement componentQuestionnaireToZusammen(String questionnaireData,
Action action) {
ZusammenElement questionnaireElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Questionnaire, action);
+ buildStructuralElement(ElementType.ComponentQuestionnaire, action);
questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes()));
return questionnaireElement;
}
private ZusammenElement buildComponentElement(ComponentEntity component, Action action) {
- ZusammenElement componentElement = new ZusammenElement();
- componentElement.setAction(action);
- if (component.getId() != null) {
- componentElement.setElementId(new Id(component.getId()));
- }
+ ZusammenElement componentElement =
+ buildElement(component.getId() == null ? null : new Id(component.getId()), action);
Info info = new Info();
- info.addProperty(ElementPropertyName.type.name(), ElementType.Component);
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.Component);
info.addProperty(ElementPropertyName.compositionData.name(), component.getCompositionData());
componentElement.setInfo(info);
componentElement.setData(new ByteArrayInputStream(component.getCompositionData().getBytes()));
return componentElement;
}
+
+
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDependencyModelDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDependencyModelDaoZusammenImpl.java
index e36b6c7..6741d72 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDependencyModelDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComponentDependencyModelDaoZusammenImpl.java
@@ -9,17 +9,23 @@
import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.datatypes.item.Info;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToComponentDependencyModelConvertor;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
-import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.types.ElementPropertyName;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Optional;
import java.util.stream.Collectors;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
/**
* Created by ayalaben on 5/16/2017.
*/
@@ -35,19 +41,22 @@
}
@Override
- public ComponentDependencyModelEntity get(ComponentDependencyModelEntity entity) {
+ public ComponentDependencyModelEntity get(ComponentDependencyModelEntity dependency) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(entity.getVspId()); // entity.getId()?
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(entity.getVersion()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(dependency.getVspId(), dependency.getVersion().getId());
Optional<ElementInfo> componentDependencyElement =
- zusammenAdaptor.getElementInfo(context, elementContext, new Id(entity.getId()));
+ zusammenAdaptor.getElementInfo(context, elementContext, new Id(dependency.getId()));
if (componentDependencyElement.isPresent()) {
- addComponentDependencyData(entity, componentDependencyElement.get());
+ ElementToComponentDependencyModelConvertor convertor = new
+ ElementToComponentDependencyModelConvertor();
+
+ ComponentDependencyModelEntity entity = convertor.convert(componentDependencyElement.get());
+ entity.setVspId(dependency.getVspId());
+ entity.setVersion(dependency.getVersion());
return entity;
}
@@ -55,70 +64,52 @@
}
@Override
- public void create(ComponentDependencyModelEntity entity) {
+ public void create(ComponentDependencyModelEntity dependency) {
+ ZusammenElement componentDependency =
+ buildComponentDependencyElement(dependency, Action.CREATE);
ZusammenElement componentDependencies =
- VspZusammenUtil.buildStructuralElement(StructureElement.ComponentDependencies, null);
+ buildStructuralElement(ElementType.ComponentDependencies, Action.IGNORE);
+ componentDependencies.addSubElement(componentDependency);
- ZusammenElement componentDependency = buildComponentDependencyElement(entity);
- componentDependency.setAction(Action.CREATE);
+ ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.IGNORE);
+ vspModel.addSubElement(componentDependencies);
- Id itemId = new Id(entity.getVspId());
- SessionContext context = ZusammenUtil.createSessionContext();
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(dependency.getVspId(), dependency.getVersion().getId());
- Optional<Element> savedElement = zusammenAdaptor.saveElement(context, elementContext,
- VspZusammenUtil.aggregateElements(componentDependencies, componentDependency),
- "Create component dependency model");
+ Element compDepsSavedElement = zusammenAdaptor
+ .saveElement(context, elementContext, vspModel, "Create component dependency model");
- savedElement.ifPresent(element ->
- entity.setId(element.getSubElements().iterator().next().getElementId().getValue()));
+ dependency.setId(compDepsSavedElement.getSubElements().iterator().next()
+ .getSubElements().iterator().next().getElementId().getValue());
}
@Override
- public void update(ComponentDependencyModelEntity entity) {
- ZusammenElement componentDependencyElement = buildComponentDependencyElement(entity);
- componentDependencyElement.setAction(Action.UPDATE);
+ public void update(ComponentDependencyModelEntity dependency) {
+ ZusammenElement componentDependencyElement =
+ buildComponentDependencyElement(dependency, Action.UPDATE);
- Id itemId = new Id(entity.getVspId());
- SessionContext context = ZusammenUtil.createSessionContext();
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(dependency.getVspId(), dependency.getVersion().getId());
- zusammenAdaptor.saveElement(context, elementContext,
- componentDependencyElement,
- String.format("Update component dependency model with id %s", entity.getId()));
+ zusammenAdaptor.saveElement(context, elementContext, componentDependencyElement,
+ String.format("Update component dependency model with id %s", dependency.getId()));
}
@Override
- public void delete(ComponentDependencyModelEntity entity) {
- ZusammenElement componentDependencyElement = new ZusammenElement();
- componentDependencyElement.setElementId(new Id(entity.getId()));
- componentDependencyElement.setAction(Action.DELETE);
+ public void delete(ComponentDependencyModelEntity dependency) {
+ ZusammenElement componentDependencyElement =
+ buildElement(new Id(dependency.getId()), Action.DELETE);
- Id itemId = new Id(entity.getVspId());
- SessionContext context = ZusammenUtil.createSessionContext();
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(dependency.getVspId(), dependency.getVersion().getId());
-
- zusammenAdaptor.saveElement(context, elementContext,
- componentDependencyElement,
- String.format("Delete component dependency model with id %s", entity.getId()));
- }
-
- @Override
- public void deleteAll(String vspId, Version version) {
- ZusammenElement componentDependenciesElement =
- VspZusammenUtil
- .buildStructuralElement(StructureElement.ComponentDependencies, Action.DELETE);
-
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- zusammenAdaptor.saveElement(context, new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
- componentDependenciesElement, "Delete all component dependencies");
+ zusammenAdaptor.saveElement(context, elementContext, componentDependencyElement,
+ String.format("Delete component dependency model with id %s", dependency.getId()));
}
@Override
@@ -127,75 +118,55 @@
}
@Override
- public Collection<ComponentDependencyModelEntity> list(ComponentDependencyModelEntity entity) {
+ public Collection<ComponentDependencyModelEntity> list(
+ ComponentDependencyModelEntity dependency) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(dependency.getVspId(), dependency.getVersion().getId());
- Id itemId = new Id(entity.getVspId());
- SessionContext context = ZusammenUtil.createSessionContext();
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(entity.getVersion()));
+ Optional<ElementInfo> vspModel = zusammenAdaptor
+ .getElementInfoByName(context, elementContext, null, ElementType.VspModel.name());
+ if (!vspModel.isPresent()) {
+ return new ArrayList<>();
+ }
- return zusammenAdaptor.listElementsByName(context, elementContext,
- null, StructureElement.ComponentDependencies.name())
- .stream().map(elementInfo -> mapElementInfoToComponentDependencyModel(entity.getVspId(),
- entity.getVersion(), elementInfo))
+ ElementToComponentDependencyModelConvertor convertor =
+ new ElementToComponentDependencyModelConvertor();
+ return zusammenAdaptor.listElementsByName(context, elementContext, vspModel.get().getId(),
+ ElementType.ComponentDependencies.name()).stream()
+ .map(elementInfo -> {
+ ComponentDependencyModelEntity entity = convertor.convert(elementInfo);
+ entity.setVspId(dependency.getVspId());
+ entity.setVersion(dependency.getVersion());
+ entity.setId(elementInfo.getId().getValue());
+ return entity;
+ })
.collect(Collectors.toList());
}
- private static ComponentDependencyModelEntity mapElementInfoToComponentDependencyModel(
- String vspId, Version version,
- ElementInfo elementInfo) {
- ComponentDependencyModelEntity componentDependencyModelEntity =
- new ComponentDependencyModelEntity(vspId, version, elementInfo.getId().getValue());
- componentDependencyModelEntity.setSourceComponentId(elementInfo.getInfo()
- .getProperty(ComponentDependencyModelPropertyName.sourcecomponent_id.name()));
- componentDependencyModelEntity.setTargetComponentId(elementInfo.getInfo()
- .getProperty(ComponentDependencyModelPropertyName.targetcomponent_id.name()));
- componentDependencyModelEntity.setRelation(elementInfo.getInfo()
- .getProperty(ComponentDependencyModelPropertyName.relation.name()));
-
- return componentDependencyModelEntity;
- }
-
-
- private ZusammenElement buildComponentDependencyElement(ComponentDependencyModelEntity entity) {
- ZusammenElement componentDependencyElement = new ZusammenElement();
-
- if (entity.getId() != null) {
- componentDependencyElement.setElementId(new Id(entity.getId()));
- }
+ private ZusammenElement buildComponentDependencyElement(ComponentDependencyModelEntity compDep,
+ Action action) {
+ ZusammenElement componentDependencyElement =
+ buildElement(compDep.getId() == null ? null : new Id(compDep.getId()), action);
Info info = new Info();
- info.addProperty(ComponentDependencyModelPropertyName.id.name(), entity.getId());
- info.addProperty(ComponentDependencyModelPropertyName.relation.name(), entity.getRelation());
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.ComponentDependency);
+ //info.addProperty(ComponentDependencyModelPropertyName.id.name(), entity.getId());
+ info.addProperty(ComponentDependencyModelPropertyName.relation.name(), compDep.getRelation());
info.addProperty(ComponentDependencyModelPropertyName.sourcecomponent_id.name(),
- entity.getSourceComponentId());
+ compDep.getSourceComponentId());
info.addProperty(ComponentDependencyModelPropertyName.targetcomponent_id.name(),
- entity.getTargetComponentId());
+ compDep.getTargetComponentId());
componentDependencyElement.setInfo(info);
return componentDependencyElement;
}
- private void addComponentDependencyData(ComponentDependencyModelEntity componentDependency,
- ElementInfo componentDependencyElement) {
- componentDependency.setId(componentDependencyElement.getInfo()
- .getProperty(ComponentDependencyModelPropertyName.id.name()));
- componentDependency.setRelation(componentDependencyElement.getInfo()
- .getProperty(ComponentDependencyModelPropertyName.id.name()));
- componentDependency.setSourceComponentId(componentDependencyElement.getInfo()
- .getProperty(ComponentDependencyModelPropertyName.sourcecomponent_id.name()));
- componentDependency.setTargetComponentId(componentDependencyElement.getInfo()
- .getProperty(ComponentDependencyModelPropertyName.targetcomponent_id.name()));
- }
-
-
private enum ComponentDependencyModelPropertyName {
id,
relation,
sourcecomponent_id,
targetcomponent_id,
}
-
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComputeDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComputeDaoZusammenImpl.java
index aa4bab6..0f92c95 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComputeDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ComputeDaoZusammenImpl.java
@@ -2,7 +2,6 @@
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
-import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.SessionContext;
@@ -11,11 +10,13 @@
import com.amdocs.zusammen.datatypes.item.Info;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToComputeConvertor;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.types.ElementPropertyName;
import java.io.ByteArrayInputStream;
import java.util.Collection;
@@ -23,6 +24,10 @@
import java.util.Optional;
import java.util.stream.Collectors;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
public class ComputeDaoZusammenImpl implements ComputeDao {
private ZusammenAdaptor zusammenAdaptor;
@@ -37,83 +42,78 @@
@Override
public Collection<ComputeEntity> list(ComputeEntity compute) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(compute.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(compute.getVersion()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(compute.getVspId(), compute.getVersion().getId());
return listComputes(context, elementContext, compute);
}
private Collection<ComputeEntity> listComputes(SessionContext context,
- ElementContext elementContext, ComputeEntity compute) {
+ ElementContext elementContext,
+ ComputeEntity compute) {
+ ElementToComputeConvertor convertor = new ElementToComputeConvertor();
return zusammenAdaptor
.listElementsByName(context, elementContext, new Id(compute.getComponentId()),
- StructureElement.Computes.name())
- .stream().map(elementInfo -> mapElementInfoToCompute(
- compute.getVspId(), compute.getVersion(), compute.getComponentId(), elementInfo))
+ ElementType.Computes.name())
+ .stream().map(elementInfo -> convertor.convert(elementInfo))
+ .map(computeEntity -> {
+ computeEntity.setComponentId(compute.getComponentId());
+ computeEntity.setVspId(compute.getVspId());
+ computeEntity.setVersion(compute.getVersion());
+ return computeEntity;
+ })
.collect(Collectors.toList());
}
- private static ComputeEntity mapElementInfoToCompute(String vspId, Version version,
- String componentId, ElementInfo elementInfo) {
- ComputeEntity componentEntity =
- new ComputeEntity(vspId, version, componentId, elementInfo.getId().getValue());
- componentEntity.setCompositionData(
- elementInfo.getInfo().getProperty(ElementPropertyName.compositionData.name()));
- return componentEntity;
- }
-
@Override
public void create(ComputeEntity compute) {
ZusammenElement computeElement = computeToZusammen(compute, Action.CREATE);
- ZusammenElement computesElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Computes, null);
+ ZusammenElement computesElement = buildStructuralElement(ElementType.Computes, Action.IGNORE);
computesElement.setSubElements(Collections.singletonList(computeElement));
- ZusammenElement componentElement = new ZusammenElement();
- componentElement.setElementId(new Id(compute.getComponentId()));
- componentElement.setAction(Action.IGNORE);
+ ZusammenElement componentElement =
+ buildElement(new Id(compute.getComponentId()), Action.IGNORE);
componentElement.setSubElements(Collections.singletonList(computesElement));
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(compute.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(compute.getVspId(), compute.getVersion().getId());
- Optional<Element> savedElement =
+ Element savedElement =
zusammenAdaptor.saveElement(context, elementContext, componentElement, "Create compute");
- savedElement.ifPresent(element ->
- compute.setId(element.getSubElements().iterator().next()
- .getSubElements().iterator().next().getElementId().getValue()));
+ compute.setId(savedElement.getSubElements().iterator().next()
+ .getSubElements().iterator().next().getElementId().getValue());
}
@Override
public void update(ComputeEntity compute) {
ZusammenElement computeElement = computeToZusammen(compute, Action.UPDATE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(compute.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(compute.getVspId(), compute.getVersion().getId());
zusammenAdaptor.saveElement(context, elementContext, computeElement,
String.format("Update compute with id %s", compute.getId()));
}
@Override
public ComputeEntity get(ComputeEntity compute) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(compute.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(compute.getVersion()));
- Optional<Element> element = zusammenAdaptor.getElement(context, elementContext, compute.getId());
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(compute.getVspId(), compute.getVersion().getId());
+ Optional<Element> element =
+ zusammenAdaptor.getElement(context, elementContext, compute.getId());
if (element.isPresent()) {
- compute.setCompositionData(new String(FileUtils.toByteArray(element.get().getData())));
- return compute;
+
+ ElementToComputeConvertor convertor = new ElementToComputeConvertor();
+ ComputeEntity entity = convertor.convert(element.get());
+ entity.setVspId(compute.getVspId());
+ entity.setVersion(compute.getVersion());
+ entity.setComponentId(compute.getComponentId());
+ return entity;
} else {
return null;
}
@@ -121,36 +121,30 @@
@Override
public void delete(ComputeEntity compute) {
- ZusammenElement computeElement = new ZusammenElement();
- computeElement.setElementId(new Id(compute.getId()));
- computeElement.setAction(Action.DELETE);
+ ZusammenElement computeElement = buildElement(new Id(compute.getId()), Action.DELETE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(compute.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(compute.getVspId(), compute.getVersion().getId());
zusammenAdaptor.saveElement(context, elementContext, computeElement,
String.format("Delete compute with id %s", compute.getId()));
}
@Override
public ComputeEntity getQuestionnaireData(String vspId, Version version, String componentId,
- String computeId) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(version));
+ String computeId) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
return getQuestionnaire(context, elementContext,
new ComputeEntity(vspId, version, componentId, computeId));
}
private ComputeEntity getQuestionnaire(SessionContext context, ElementContext elementContext,
- ComputeEntity compute) {
+ ComputeEntity compute) {
Optional<Element> questionnaireElement = zusammenAdaptor
.getElementByName(context, elementContext, new Id(compute.getId()),
- StructureElement.Questionnaire.name());
+ ElementType.ComputeQuestionnaire.name());
return questionnaireElement.map(
element -> element.getData() == null
? null
@@ -168,29 +162,22 @@
ZusammenElement questionnaireElement =
computeQuestionnaireToZusammen(questionnaireData, Action.UPDATE);
- ZusammenElement computeElement = new ZusammenElement();
- computeElement.setAction(Action.IGNORE);
- computeElement.setElementId(new Id(computeId));
+ ZusammenElement computeElement = buildElement(new Id(computeId), Action.IGNORE);
computeElement.setSubElements(Collections.singletonList(questionnaireElement));
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
zusammenAdaptor.saveElement(context, elementContext, computeElement, "Update compute "
+ "questionnaire");
}
@Override
public Collection<ComputeEntity> listByVsp(String vspId, Version version) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(version));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
Collection<ComponentEntity> components = ComponentDaoZusammenImpl
- .listComponents(zusammenAdaptor, context, elementContext, vspId, version);
+ .listComponents(zusammenAdaptor, context, vspId, version);
return components.stream()
.map(component ->
@@ -204,15 +191,23 @@
@Override
public void deleteAll(String vspId, Version version) {
- ZusammenElement computesElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Computes, Action.DELETE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- zusammenAdaptor.saveElement(context,
- new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
- computesElement, "Delete all computes");
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+
+ Optional<Element> optionalElement = zusammenAdaptor.getElementByName(context,
+ elementContext, null, ElementType.Computes.name());
+
+ if (optionalElement.isPresent()) {
+ Element computesElement = optionalElement.get();
+ Collection<Element> computes = computesElement.getSubElements();
+
+ computes.forEach(compute -> {
+ ZusammenElement computeElement = buildElement(compute.getElementId(), Action.DELETE);
+ zusammenAdaptor.saveElement(context, elementContext, computeElement,
+ "Delete compute with id " + compute.getElementId());
+ });
+ }
}
private ZusammenElement computeToZusammen(ComputeEntity compute, Action action) {
@@ -225,27 +220,21 @@
}
private ZusammenElement computeQuestionnaireToZusammen(String questionnaireData,
- Action action) {
+ Action action) {
ZusammenElement questionnaireElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Questionnaire, action);
+ buildStructuralElement(ElementType.ComputeQuestionnaire, action);
questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes()));
return questionnaireElement;
}
private ZusammenElement buildComputeElement(ComputeEntity compute, Action action) {
- ZusammenElement computeElement = new ZusammenElement();
- computeElement.setAction(action);
- if (compute.getId() != null) {
- computeElement.setElementId(new Id(compute.getId()));
- }
+ ZusammenElement computeElement =
+ buildElement(compute.getId() == null ? null : new Id(compute.getId()), action);
Info info = new Info();
- info.addProperty(ElementPropertyName.type.name(), ElementType.Compute);
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.Compute);
info.addProperty(ElementPropertyName.compositionData.name(), compute.getCompositionData());
computeElement.setInfo(info);
computeElement.setData(new ByteArrayInputStream(compute.getCompositionData().getBytes()));
return computeElement;
}
-
-
-
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/DeploymentFlavorDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/DeploymentFlavorDaoZusammenImpl.java
index 947bcc2..17580b2 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/DeploymentFlavorDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/DeploymentFlavorDaoZusammenImpl.java
@@ -1,7 +1,6 @@
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
-import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.SessionContext;
@@ -10,16 +9,22 @@
import com.amdocs.zusammen.datatypes.item.Info;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToDeploymentFlavorConvertor;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.types.ElementPropertyName;
import java.io.ByteArrayInputStream;
import java.util.Collection;
import java.util.Optional;
import java.util.stream.Collectors;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
public class DeploymentFlavorDaoZusammenImpl implements DeploymentFlavorDao {
private ZusammenAdaptor zusammenAdaptor;
@@ -34,52 +39,49 @@
@Override
public Collection<DeploymentFlavorEntity> list(DeploymentFlavorEntity deploymentFlavor) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(deploymentFlavor.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(deploymentFlavor.getVersion()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(deploymentFlavor.getVspId(), deploymentFlavor.getVersion().getId());
- return listDeploymentFlavor(zusammenAdaptor, context, elementContext, deploymentFlavor.getVspId(),
+ return listDeploymentFlavor(zusammenAdaptor, context, elementContext,
+ deploymentFlavor.getVspId(),
deploymentFlavor.getVersion());
}
- static Collection<DeploymentFlavorEntity> listDeploymentFlavor(ZusammenAdaptor zusammenAdaptor,
- SessionContext context,
- ElementContext elementContext,
- String vspId, Version version) {
+ private static Collection<DeploymentFlavorEntity> listDeploymentFlavor(
+ ZusammenAdaptor zusammenAdaptor,
+ SessionContext context,
+ ElementContext elementContext,
+ String vspId, Version version) {
+ ElementToDeploymentFlavorConvertor convertor = new ElementToDeploymentFlavorConvertor();
return zusammenAdaptor
- .listElementsByName(context, elementContext, null, StructureElement.DeploymentFlavors.name())
- .stream().map(elementInfo -> mapElementInfoToComponent(vspId, version, elementInfo))
+ .listElementsByName(context, elementContext, null,
+ ElementType.DeploymentFlavors.name())
+ .stream().map(elementInfo -> {
+ DeploymentFlavorEntity entity = convertor.convert(
+ elementInfo);
+ entity.setVspId(vspId);
+ entity.setVersion(version);
+ return entity;
+ })
.collect(Collectors.toList());
}
- private static DeploymentFlavorEntity mapElementInfoToComponent(String vspId, Version version,
- ElementInfo elementInfo) {
- DeploymentFlavorEntity deploymentFlavorEntity =
- new DeploymentFlavorEntity(vspId, version, elementInfo.getId().getValue());
- deploymentFlavorEntity.setCompositionData(
- elementInfo.getInfo().getProperty(ElementPropertyName.compositionData.name()));
- return deploymentFlavorEntity;
- }
@Override
public void create(DeploymentFlavorEntity deploymentFlavor) {
ZusammenElement deploymentFlavorElement = deploymentFlavorToZusammen(deploymentFlavor,
Action.CREATE);
ZusammenElement deploymentFlavorElements =
- VspZusammenUtil.buildStructuralElement(StructureElement.DeploymentFlavors, null);
+ buildStructuralElement(ElementType.DeploymentFlavors, Action.IGNORE);
deploymentFlavorElements.getSubElements().add(deploymentFlavorElement);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(deploymentFlavor.getVspId());
- Optional<Element> savedElement = zusammenAdaptor.saveElement(context,
- new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
+ SessionContext context = createSessionContext();
+ Element savedElement = zusammenAdaptor.saveElement(context,
+ new ElementContext(deploymentFlavor.getVspId(), deploymentFlavor.getVersion().getId()),
deploymentFlavorElements, "Create deloymentFlavor");
- savedElement.ifPresent(element ->
- deploymentFlavor.setId(element.getSubElements().iterator().next().getElementId()
- .getValue()));
+ deploymentFlavor.setId(savedElement.getSubElements().iterator().next().getElementId()
+ .getValue());
}
@Override
@@ -87,87 +89,83 @@
ZusammenElement deploymentFlavorElement = deploymentFlavorToZusammen(deploymentFlavor,
Action.UPDATE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(deploymentFlavor.getVspId());
+ SessionContext context = createSessionContext();
zusammenAdaptor.saveElement(context,
- new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
+ new ElementContext(deploymentFlavor.getVspId(), deploymentFlavor.getVersion().getId()),
deploymentFlavorElement, String.format("Update deloymentFlavor with id %s",
deploymentFlavor.getId()));
}
@Override
public DeploymentFlavorEntity get(DeploymentFlavorEntity deploymentFlavor) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(deploymentFlavor.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(deploymentFlavor.getVersion()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(deploymentFlavor.getVspId(), deploymentFlavor.getVersion().getId());
Optional<Element> element =
zusammenAdaptor.getElement(context, elementContext, deploymentFlavor.getId());
if (element.isPresent()) {
+ ElementToDeploymentFlavorConvertor convertor = new ElementToDeploymentFlavorConvertor();
+ DeploymentFlavorEntity entity = convertor.convert(element.get());
deploymentFlavor.setCompositionData(new String(FileUtils.toByteArray(element.get()
.getData())));
- return deploymentFlavor;
+ entity.setVspId(deploymentFlavor.getVspId());
+ entity.setVersion(deploymentFlavor.getVersion());
+ return entity;
}
return null;
}
@Override
public void delete(DeploymentFlavorEntity deploymentFlavor) {
- ZusammenElement componentElement = new ZusammenElement();
- componentElement.setElementId(new Id(deploymentFlavor.getId()));
- componentElement.setAction(Action.DELETE);
+ ZusammenElement componentElement =
+ buildElement(new Id(deploymentFlavor.getId()), Action.DELETE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(deploymentFlavor.getVspId());
+ SessionContext context = createSessionContext();
zusammenAdaptor.saveElement(context,
- new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
+ new ElementContext(deploymentFlavor.getVspId(), deploymentFlavor.getVersion().getId()),
componentElement, String.format("Delete deloymentFlavor with id %s",
deploymentFlavor.getId()));
}
@Override
public void deleteAll(String vspId, Version version) {
- ZusammenElement deploymentFlavorsElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.DeploymentFlavors, Action.DELETE);
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- zusammenAdaptor.saveElement(context,
- new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
- deploymentFlavorsElement, "Delete all deploymentFlavors");
- }
+ Optional<Element> optionalElement = zusammenAdaptor.getElementByName(context,
+ elementContext, null, ElementType.DeploymentFlavors.name());
- private ZusammenElement deploymentFlavorToZusammen(DeploymentFlavorEntity deploymentFlavor,
- Action action) {
- ZusammenElement deploymentFlavorElement = buildDeploymentFlavorElement
- (deploymentFlavor, action);
+ if (optionalElement.isPresent()) {
+ Element deploymentFlavorsElement = optionalElement.get();
+ Collection<Element> deploymentFlavors = deploymentFlavorsElement.getSubElements();
- return deploymentFlavorElement;
+ deploymentFlavors.forEach(deplymentFlavor -> {
+ ZusammenElement deplymentFlavorZusammenElement =
+ buildElement(deplymentFlavor.getElementId(), Action.DELETE);
+ zusammenAdaptor.saveElement(context,
+ elementContext, deplymentFlavorZusammenElement, " Delete Deplyment Flavor with id "
+ + deplymentFlavor.getElementId());
+ });
+ }
}
/*private ZusammenElement deplymentFlavorQuestionnaireToZusammen(String questionnaireData,
Action action) {
ZusammenElement questionnaireElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Questionnaire, action);
+ VspbuildStructuralElement(ElementType.Questionnaire, action);
questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes()));
return questionnaireElement;
}*/
- private ZusammenElement buildDeploymentFlavorElement(DeploymentFlavorEntity deploymentFlavor,
- Action action) {
- ZusammenElement deploymentFlavorElement = new ZusammenElement();
- deploymentFlavorElement.setAction(action);
- if (deploymentFlavor.getId() != null) {
- deploymentFlavorElement.setElementId(new Id(deploymentFlavor.getId()));
- }
+ private ZusammenElement deploymentFlavorToZusammen(DeploymentFlavorEntity deploymentFlavor,
+ Action action) {
+ ZusammenElement deploymentFlavorElement =
+ buildElement(deploymentFlavor.getId() == null ? null : new Id(deploymentFlavor.getId()),
+ action);
Info info = new Info();
- info.addProperty(ElementPropertyName.type.name(), ElementType.DeploymentFlavor);
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.DeploymentFlavor);
info.addProperty(ElementPropertyName.compositionData.name(), deploymentFlavor
.getCompositionData());
deploymentFlavorElement.setInfo(info);
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ElementPropertyName.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ElementPropertyName.java
deleted file mode 100644
index 9ca0bf7..0000000
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ElementPropertyName.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
-
-public enum ElementPropertyName {
- type,
- compositionData
-}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ElementType.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ElementType.java
deleted file mode 100644
index 9da0780..0000000
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ElementType.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
-
-public enum ElementType {
- Network,
- Component,
- Nic,
- Process,
- Mib,
- LKG,
- Compute,
- DeploymentFlavor,
- Image
-}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ImageDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ImageDaoZusammenImpl.java
index d913b18..24ca072 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ImageDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ImageDaoZusammenImpl.java
@@ -2,7 +2,6 @@
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
-import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.SessionContext;
@@ -11,11 +10,13 @@
import com.amdocs.zusammen.datatypes.item.Info;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToImageConvertor;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.types.ElementPropertyName;
import java.io.ByteArrayInputStream;
import java.util.Collection;
@@ -23,6 +24,10 @@
import java.util.Optional;
import java.util.stream.Collectors;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
public class ImageDaoZusammenImpl implements ImageDao {
private ZusammenAdaptor zusammenAdaptor;
@@ -37,83 +42,76 @@
@Override
public Collection<ImageEntity> list(ImageEntity image) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(image.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(image.getVersion()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(image.getVspId(), image.getVersion().getId());
return listImages(context, elementContext, image);
}
private Collection<ImageEntity> listImages(SessionContext context,
- ElementContext elementContext, ImageEntity image) {
+ ElementContext elementContext, ImageEntity image) {
+ ElementToImageConvertor convertor = new ElementToImageConvertor();
return zusammenAdaptor
.listElementsByName(context, elementContext, new Id(image.getComponentId()),
- StructureElement.Images.name())
- .stream().map(elementInfo -> mapElementInfoToImage(
- image.getVspId(), image.getVersion(), image.getComponentId(), elementInfo))
+ ElementType.Images.name())
+ .stream().map(convertor::convert)
+ .map(imageEntity -> {
+ imageEntity.setComponentId(image.getComponentId());
+ imageEntity.setVspId(image.getVspId());
+ imageEntity.setVersion(image.getVersion());
+ return imageEntity;
+ })
.collect(Collectors.toList());
}
- private static ImageEntity mapElementInfoToImage(String vspId, Version version,
- String componentId, ElementInfo elementInfo) {
- ImageEntity imageEntity =
- new ImageEntity(vspId, version, componentId, elementInfo.getId().getValue());
- imageEntity.setCompositionData(
- elementInfo.getInfo().getProperty(ElementPropertyName.compositionData.name()));
- return imageEntity;
- }
-
@Override
public void create(ImageEntity image) {
ZusammenElement imageElement = imageToZusammen(image, Action.CREATE);
ZusammenElement imagesElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Images, null);
+ buildStructuralElement(ElementType.Images, Action.IGNORE);
imagesElement.setSubElements(Collections.singletonList(imageElement));
- ZusammenElement componentElement = new ZusammenElement();
- componentElement.setElementId(new Id(image.getComponentId()));
- componentElement.setAction(Action.IGNORE);
+ ZusammenElement componentElement = buildElement(new Id(image.getComponentId()), Action.IGNORE);
componentElement.setSubElements(Collections.singletonList(imagesElement));
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(image.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(image.getVspId(), image.getVersion().getId());
- Optional<Element> savedElement =
+ Element savedElement =
zusammenAdaptor.saveElement(context, elementContext, componentElement, "Create image");
- savedElement.ifPresent(element ->
- image.setId(element.getSubElements().iterator().next()
- .getSubElements().iterator().next().getElementId().getValue()));
+ image.setId(savedElement.getSubElements().iterator().next()
+ .getSubElements().iterator().next().getElementId().getValue());
}
@Override
public void update(ImageEntity image) {
ZusammenElement imageElement = imageToZusammen(image, Action.UPDATE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(image.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(image.getVspId(), image.getVersion().getId());
zusammenAdaptor.saveElement(context, elementContext, imageElement,
String.format("Update image with id %s", image.getId()));
}
@Override
public ImageEntity get(ImageEntity image) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(image.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(image.getVersion()));
+ SessionContext context = createSessionContext();
+
+ ElementContext elementContext =
+ new ElementContext(image.getVspId(), image.getVersion().getId());
Optional<Element> element = zusammenAdaptor.getElement(context, elementContext, image.getId());
if (element.isPresent()) {
- image.setCompositionData(new String(FileUtils.toByteArray(element.get().getData())));
- return image;
+ ElementToImageConvertor convertor = new ElementToImageConvertor();
+ ImageEntity entity = convertor.convert(element.get());
+ entity.setComponentId(image.getComponentId());
+ entity.setVspId(image.getVspId());
+ entity.setVersion(image.getVersion());
+ return entity;
} else {
return null;
}
@@ -121,41 +119,41 @@
@Override
public void delete(ImageEntity image) {
- ZusammenElement imageElement = new ZusammenElement();
- imageElement.setElementId(new Id(image.getId()));
- imageElement.setAction(Action.DELETE);
+ ZusammenElement imageElement = buildElement(new Id(image.getId()), Action.DELETE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(image.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(image.getVspId(), image.getVersion().getId());
zusammenAdaptor.saveElement(context, elementContext, imageElement,
String.format("Delete image with id %s", image.getId()));
}
@Override
public void deleteByVspId(String vspId, Version version) {
- ZusammenElement imagesElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Images, Action.DELETE);
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- zusammenAdaptor.saveElement(context,
- new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
- imagesElement, String.format("Delete all images with vsp id %s", vspId));
+ Optional<Element> elementOptional = zusammenAdaptor.getElementByName(context, elementContext,
+ null, ElementType.Images.name());
+
+ if (elementOptional.isPresent()) {
+ Element ImagesElement = elementOptional.get();
+ Collection<Element> Images = ImagesElement.getSubElements();
+ Images.forEach(image -> {
+ ZusammenElement imageZusammenElement = buildElement(image.getElementId(), Action.DELETE);
+ zusammenAdaptor.saveElement(context, elementContext, imageZusammenElement, "Delete image " +
+ "with id " + image.getElementId());
+ });
+ }
}
@Override
public Collection<ImageEntity> listByVsp(String vspId, Version version) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(version));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
Collection<ComponentEntity> components = ComponentDaoZusammenImpl
- .listComponents(zusammenAdaptor, context, elementContext, vspId, version);
+ .listComponents(zusammenAdaptor, context, vspId, version);
return components.stream()
.map(component ->
@@ -169,12 +167,9 @@
@Override
public ImageEntity getQuestionnaireData(String vspId, Version version, String componentId,
- String imageId) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(version));
+ String imageId) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
return getQuestionnaire(context, elementContext,
new ImageEntity(vspId, version, componentId, imageId));
@@ -184,7 +179,7 @@
ImageEntity image) {
Optional<Element> questionnaireElement = zusammenAdaptor
.getElementByName(context, elementContext, new Id(image.getId()),
- StructureElement.Questionnaire.name());
+ ElementType.ImageQuestionnaire.name());
return questionnaireElement.map(
element -> element.getData() == null
? null
@@ -202,21 +197,16 @@
ZusammenElement questionnaireElement =
imageQuestionnaireToZusammen(questionnaireData, Action.UPDATE);
- ZusammenElement imageElement = new ZusammenElement();
- imageElement.setAction(Action.IGNORE);
- imageElement.setElementId(new Id(imageId));
+ ZusammenElement imageElement = buildElement(new Id(imageId), Action.IGNORE);
imageElement.setSubElements(Collections.singletonList(questionnaireElement));
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
zusammenAdaptor.saveElement(context, elementContext, imageElement, "Update image "
+ "questionnaire");
}
-
private ZusammenElement imageToZusammen(ImageEntity image, Action action) {
ZusammenElement imageElement = buildImageElement(image, action);
if (action == Action.CREATE) {
@@ -227,21 +217,18 @@
}
private ZusammenElement imageQuestionnaireToZusammen(String questionnaireData,
- Action action) {
+ Action action) {
ZusammenElement questionnaireElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Questionnaire, action);
+ buildStructuralElement(ElementType.ImageQuestionnaire, action);
questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes()));
return questionnaireElement;
}
private ZusammenElement buildImageElement(ImageEntity image, Action action) {
- ZusammenElement imageElement = new ZusammenElement();
- imageElement.setAction(action);
- if (image.getId() != null) {
- imageElement.setElementId(new Id(image.getId()));
- }
+ ZusammenElement imageElement =
+ buildElement(image.getId() == null ? null : new Id(image.getId()), action);
Info info = new Info();
- info.addProperty(ElementPropertyName.type.name(), ElementType.Image);
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.Image);
info.addProperty(ElementPropertyName.compositionData.name(), image.getCompositionData());
imageElement.setInfo(info);
imageElement.setData(new ByteArrayInputStream(image.getCompositionData().getBytes()));
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/NetworkDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/NetworkDaoZusammenImpl.java
index b22c9f3..bccea3a 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/NetworkDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/NetworkDaoZusammenImpl.java
@@ -8,19 +8,25 @@
import com.amdocs.zusammen.datatypes.item.Action;
import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.datatypes.item.Info;
-import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToNetworkConvertor;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity;
import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.types.ElementPropertyName;
import java.io.ByteArrayInputStream;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Optional;
import java.util.stream.Collectors;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
public class NetworkDaoZusammenImpl implements NetworkDao {
private ZusammenAdaptor zusammenAdaptor;
@@ -36,71 +42,70 @@
@Override
public Collection<NetworkEntity> list(NetworkEntity network) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(network.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(network.getVersion()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(network.getVspId(), network.getVersion().getId());
- return zusammenAdaptor
- .listElementsByName(context, elementContext, null, StructureElement.Networks.name())
- .stream().map(elementInfo ->
- mapElementInfoToNetwork(network.getVspId(), network.getVersion(), elementInfo))
+ Optional<ElementInfo> vspModel = zusammenAdaptor
+ .getElementInfoByName(context, elementContext, null, ElementType.VspModel.name());
+ if (!vspModel.isPresent()) {
+ return new ArrayList<>();
+ }
+
+ ElementToNetworkConvertor convertor = new ElementToNetworkConvertor();
+ return zusammenAdaptor.listElementsByName(context, elementContext, vspModel.get().getId(),
+ ElementType.Networks.name()).stream()
+ .map(convertor::convert)
+ .map(entity -> {
+ entity.setVspId(network.getVspId());
+ entity.setVersion(network.getVersion());
+ return entity;
+ })
.collect(Collectors.toList());
}
- private NetworkEntity mapElementInfoToNetwork(String vspId, Version version,
- ElementInfo elementInfo) {
- NetworkEntity networkEntity =
- new NetworkEntity(vspId, version, elementInfo.getId().getValue());
- networkEntity.setCompositionData(
- elementInfo.getInfo().getProperty(ElementPropertyName.compositionData.name()));
- return networkEntity;
- }
-
@Override
public void create(NetworkEntity network) {
ZusammenElement networkElement = buildNetworkElement(network, Action.CREATE);
- ZusammenElement networksElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Networks, null);
+
+ ZusammenElement networksElement = buildStructuralElement(ElementType.Networks, Action.IGNORE);
networksElement.setSubElements(Collections.singletonList(networkElement));
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(network.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
- Optional<Element> savedElement =
- zusammenAdaptor.saveElement(context, elementContext, networksElement, "Create network");
- savedElement.ifPresent(element ->
- network.setId(element.getSubElements().iterator().next().getElementId().getValue()));
+ ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.IGNORE);
+ vspModel.addSubElement(networksElement);
+
+ SessionContext context = createSessionContext();
+ Element savedElement = zusammenAdaptor
+ .saveElement(context, new ElementContext(network.getVspId(), network.getVersion().getId()),
+ vspModel, "Create network");
+ network.setId(savedElement.getSubElements().iterator().next()
+ .getSubElements().iterator().next().getElementId().getValue());
}
@Override
public void update(NetworkEntity network) {
ZusammenElement networkElement = buildNetworkElement(network, Action.UPDATE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(network.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
- zusammenAdaptor.saveElement(context, elementContext, networkElement,
- String.format("Update network with id %s", network.getId()));
+ SessionContext context = createSessionContext();
+ zusammenAdaptor
+ .saveElement(context, new ElementContext(network.getVspId(), network.getVersion().getId()),
+ networkElement, String.format("Update network with id %s", network.getId()));
}
@Override
public NetworkEntity get(NetworkEntity network) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(network.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(network.getVersion()));
+ SessionContext context = createSessionContext();
Optional<Element> element =
- zusammenAdaptor.getElement(context, elementContext, network.getId());
+ zusammenAdaptor.getElement(context,
+ new ElementContext(network.getVspId(), network.getVersion().getId()), network.getId());
if (element.isPresent()) {
- network.setCompositionData(new String(FileUtils.toByteArray(element.get().getData())));
- return network;
+ ElementToNetworkConvertor convertor = new ElementToNetworkConvertor();
+ NetworkEntity entity = convertor.convert(element.get());
+ entity.setVspId(network.getVspId());
+ entity.setVersion(network.getVersion());
+ return entity;
} else {
return null;
}
@@ -108,39 +113,44 @@
@Override
public void delete(NetworkEntity network) {
- ZusammenElement networkElement = new ZusammenElement();
- networkElement.setElementId(new Id(network.getId()));
- networkElement.setAction(Action.DELETE);
+ ZusammenElement networkElement = buildElement(new Id(network.getId()), Action.DELETE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(network.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
- zusammenAdaptor.saveElement(context, elementContext,
- networkElement, String.format("Delete network with id %s", network.getId()));
+ SessionContext context = createSessionContext();
+ zusammenAdaptor
+ .saveElement(context, new ElementContext(network.getVspId(), network.getVersion().getId()),
+ networkElement, String.format("Delete network with id %s", network.getId()));
}
@Override
public void deleteAll(String vspId, Version version) {
- ZusammenElement networksElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Networks, Action.DELETE);
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
- zusammenAdaptor.saveElement(context, elementContext, networksElement, "Delete all networks");
+ Collection<ElementInfo> vspModelSubs = zusammenAdaptor
+ .listElementsByName(context, elementContext, null, ElementType.VspModel.name());
+
+ Optional<ElementInfo> networksElement = vspModelSubs.stream()
+ .filter(elementInfo -> elementInfo.getInfo() != null
+ && ElementType.Networks.name().equals(elementInfo.getInfo().getName()))
+ .findFirst();
+ if (!networksElement.isPresent()) {
+ return;
+ }
+
+ ZusammenElement networks = buildElement(networksElement.get().getId(), Action.IGNORE);
+ networks.setSubElements(networksElement.get().getSubElements().stream()
+ .map(network -> buildElement(network.getId(), Action.DELETE))
+ .collect(Collectors.toList()));
+
+ zusammenAdaptor.saveElement(context, elementContext, networks, "Delete all networks");
}
private ZusammenElement buildNetworkElement(NetworkEntity network, Action action) {
- ZusammenElement networkElement = new ZusammenElement();
- networkElement.setAction(action);
- if (network.getId() != null) {
- networkElement.setElementId(new Id(network.getId()));
- }
+ ZusammenElement networkElement =
+ buildElement(network.getId() == null ? null : new Id(network.getId()), action);
Info info = new Info();
- info.addProperty(ElementPropertyName.type.name(), ElementType.Network);
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.Network);
info.addProperty(ElementPropertyName.compositionData.name(), network.getCompositionData());
networkElement.setInfo(info);
networkElement.setData(new ByteArrayInputStream(network.getCompositionData().getBytes()));
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/NicDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/NicDaoZusammenImpl.java
index e597068..268e254 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/NicDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/NicDaoZusammenImpl.java
@@ -1,20 +1,21 @@
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
-import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.SessionContext;
import com.amdocs.zusammen.datatypes.item.Action;
import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.datatypes.item.Info;
-import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToNicConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToNicQuestionnaireConvertor;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.types.ElementPropertyName;
import java.io.ByteArrayInputStream;
import java.util.Collection;
@@ -22,6 +23,10 @@
import java.util.Optional;
import java.util.stream.Collectors;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
public class NicDaoZusammenImpl implements NicDao {
private ZusammenAdaptor zusammenAdaptor;
@@ -37,82 +42,70 @@
@Override
public Collection<NicEntity> list(NicEntity nic) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(nic.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(nic.getVersion()));
-
- return listNics(context, elementContext, nic);
+ SessionContext context = createSessionContext();
+ return listNics(context, new ElementContext(nic.getVspId(), nic.getVersion().getId()), nic);
}
private Collection<NicEntity> listNics(SessionContext context, ElementContext elementContext,
NicEntity nic) {
- return zusammenAdaptor
- .listElementsByName(context, elementContext, new Id(nic.getComponentId()),
- StructureElement.Nics.name())
- .stream().map(elementInfo -> mapElementInfoToNic(
- nic.getVspId(), nic.getVersion(), nic.getComponentId(), elementInfo))
+ ElementToNicConvertor convertor = new ElementToNicConvertor();
+ return zusammenAdaptor.listElementsByName(context, elementContext, new Id(nic.getComponentId()),
+ ElementType.Nics.name())
+ .stream().map(convertor::convert)
+ .map(nicEntity -> {
+ nicEntity.setComponentId(nicEntity.getComponentId());
+ nicEntity.setVspId(nic.getVspId());
+ nicEntity.setVersion(nic.getVersion());
+ return nicEntity;
+ })
.collect(Collectors.toList());
}
- private NicEntity mapElementInfoToNic(String vspId, Version version,
- String componentId, ElementInfo elementInfo) {
- NicEntity nicEntity =
- new NicEntity(vspId, version, componentId, elementInfo.getId().getValue());
- nicEntity.setCompositionData(
- elementInfo.getInfo().getProperty(ElementPropertyName.compositionData.name()));
- return nicEntity;
- }
@Override
public void create(NicEntity nic) {
ZusammenElement nicElement = nicToZusammen(nic, Action.CREATE);
- ZusammenElement nicsElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Nics, null);
+ ZusammenElement nicsElement = buildStructuralElement(ElementType.Nics, Action.IGNORE);
nicsElement.setSubElements(Collections.singletonList(nicElement));
- ZusammenElement componentElement =
- buildZusammenElement(new Id(nic.getComponentId()), Action.IGNORE);
+ ZusammenElement componentElement = buildElement(new Id(nic.getComponentId()), Action.IGNORE);
componentElement.setSubElements(Collections.singletonList(nicsElement));
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(nic.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(nic.getVspId(), nic.getVersion().getId());
- Optional<Element> savedElement =
+ Element savedElement =
zusammenAdaptor.saveElement(context, elementContext, componentElement, "Create nic");
- savedElement.ifPresent(element ->
- nic.setId(element.getSubElements().iterator().next()
- .getSubElements().iterator().next().getElementId().getValue()));
+ nic.setId(savedElement.getSubElements().iterator().next()
+ .getSubElements().iterator().next().getElementId().getValue());
}
@Override
public void update(NicEntity nic) {
ZusammenElement nicElement = nicToZusammen(nic, Action.UPDATE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(nic.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
- zusammenAdaptor.saveElement(context, elementContext, nicElement,
- String.format("Update nic with id %s", nic.getId()));
+ SessionContext context = createSessionContext();
+ zusammenAdaptor
+ .saveElement(context, new ElementContext(nic.getVspId(), nic.getVersion().getId()),
+ nicElement, String.format("Update nic with id %s", nic.getId()));
}
@Override
public NicEntity get(NicEntity nic) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(nic.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(nic.getVersion()));
- Optional<Element> element = zusammenAdaptor.getElement(context, elementContext, nic.getId());
+ SessionContext context = createSessionContext();
+ ElementToNicConvertor convertor = new ElementToNicConvertor();
+ Optional<Element> element = zusammenAdaptor
+ .getElement(context, new ElementContext(nic.getVspId(), nic.getVersion().getId()),
+ nic.getId());
if (element.isPresent()) {
- nic.setCompositionData(new String(FileUtils.toByteArray(element.get().getData())));
- return nic;
+ NicEntity entity = convertor.convert(element.get());
+ entity.setVspId(nic.getVspId());
+ entity.setVersion(nic.getVersion());
+ entity.setComponentId(nic.getComponentId());
+
+ return entity;
} else {
return null;
}
@@ -120,26 +113,20 @@
@Override
public void delete(NicEntity nic) {
- ZusammenElement nicElement = buildZusammenElement(new Id(nic.getId()), Action.DELETE);
+ ZusammenElement nicElement = buildElement(new Id(nic.getId()), Action.DELETE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(nic.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
- zusammenAdaptor.saveElement(context, elementContext, nicElement,
- String.format("Delete nic with id %s", nic.getId()));
+ SessionContext context = createSessionContext();
+ zusammenAdaptor
+ .saveElement(context, new ElementContext(nic.getVspId(), nic.getVersion().getId()),
+ nicElement, String.format("Delete nic with id %s", nic.getId()));
}
@Override
public NicEntity getQuestionnaireData(String vspId, Version version, String componentId,
String nicId) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(version));
+ SessionContext context = createSessionContext();
- return getQuestionnaire(context, elementContext,
+ return getQuestionnaire(context, new ElementContext(vspId, version.getId()),
new NicEntity(vspId, version, componentId, nicId));
}
@@ -147,14 +134,13 @@
NicEntity nic) {
Optional<Element> questionnaireElement = zusammenAdaptor
.getElementByName(context, elementContext, new Id(nic.getId()),
- StructureElement.Questionnaire.name());
- return questionnaireElement.map(
- element -> element.getData() == null
- ? null
- : new String(FileUtils.toByteArray(element.getData())))
- .map(questionnaireData -> {
- nic.setQuestionnaireData(questionnaireData);
- return nic;
+ ElementType.NicQuestionnaire.name());
+ return questionnaireElement.map(new ElementToNicQuestionnaireConvertor()::convert)
+ .map(entity -> {
+ entity.setVspId(nic.getVspId());
+ entity.setVersion(nic.getVersion());
+ entity.setComponentId(nic.getComponentId());
+ return entity;
})
.orElse(null);
}
@@ -165,29 +151,22 @@
ZusammenElement questionnaireElement =
nicQuestionnaireToZusammen(questionnaireData, Action.UPDATE);
- ZusammenElement nicElement = new ZusammenElement();
- nicElement.setAction(Action.IGNORE);
- nicElement.setElementId(new Id(nicId));
+ ZusammenElement nicElement = buildElement(new Id(nicId), Action.IGNORE);
nicElement.setSubElements(Collections.singletonList(questionnaireElement));
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
- zusammenAdaptor.saveElement(context, elementContext, nicElement, "Update nic questionnaire");
+ SessionContext context = createSessionContext();
+ zusammenAdaptor.saveElement(context, new ElementContext(vspId, version.getId()), nicElement,
+ "Update nic questionnaire");
}
@Override
public Collection<NicEntity> listByVsp(String vspId, Version version) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(version));
+ SessionContext context = createSessionContext();
Collection<ComponentEntity> components = ComponentDaoZusammenImpl
- .listComponents(zusammenAdaptor, context, elementContext, vspId, version);
+ .listComponents(zusammenAdaptor, context, vspId, version);
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
return components.stream()
.map(component ->
listNics(context, elementContext,
@@ -200,16 +179,22 @@
@Override
public void deleteByComponentId(String vspId, Version version, String componentId) {
- ZusammenElement componentElement = buildZusammenElement(new Id(componentId), Action.IGNORE);
- componentElement.setSubElements(Collections.singletonList(
- VspZusammenUtil.buildStructuralElement(StructureElement.Nics, Action.DELETE)));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
- zusammenAdaptor.saveElement(context, elementContext, componentElement,
- String.format("Delete all nics of component %s", componentId));
+ Optional<Element> optionalElement = zusammenAdaptor.getElementByName(context,
+ elementContext, new Id(componentId), ElementType.Nics.name());
+
+ if (optionalElement.isPresent()) {
+ Element nicsElement = optionalElement.get();
+ Collection<Element> nics = nicsElement.getSubElements();
+
+ nics.forEach(nic -> {
+ ZusammenElement nicZusammenElement = buildElement(nic.getElementId(), Action.DELETE);
+ zusammenAdaptor.saveElement(context, elementContext, nicZusammenElement,
+ "Delete nic with id " + nic.getElementId());
+ });
+ }
}
@Override
@@ -229,26 +214,16 @@
private ZusammenElement nicQuestionnaireToZusammen(String questionnaireData,
Action action) {
ZusammenElement questionnaireElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Questionnaire, action);
+ buildStructuralElement(ElementType.NicQuestionnaire, action);
questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes()));
return questionnaireElement;
}
- private ZusammenElement buildZusammenElement(Id elementId, Action action) {
- ZusammenElement element = new ZusammenElement();
- element.setElementId(elementId);
- element.setAction(action);
- return element;
- }
-
private ZusammenElement buildNicElement(NicEntity nic, Action action) {
- ZusammenElement nicElement = new ZusammenElement();
- nicElement.setAction(action);
- if (nic.getId() != null) {
- nicElement.setElementId(new Id(nic.getId()));
- }
+ ZusammenElement nicElement =
+ buildElement(nic.getId() == null ? null : new Id(nic.getId()), action);
Info info = new Info();
- info.addProperty(ElementPropertyName.type.name(), ElementType.Nic);
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.Nic);
info.addProperty(ElementPropertyName.compositionData.name(), nic.getCompositionData());
nicElement.setInfo(info);
nicElement.setData(new ByteArrayInputStream(nic.getCompositionData().getBytes()));
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateCandidateDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateCandidateDaoZusammenImpl.java
index ea51b77..5d1ef12 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateCandidateDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateCandidateDaoZusammenImpl.java
@@ -1,15 +1,16 @@
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
-import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.SessionContext;
import com.amdocs.zusammen.datatypes.item.Action;
import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.utils.fileutils.FileUtils;
+import org.apache.commons.io.IOUtils;
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDao;
@@ -18,11 +19,18 @@
import org.openecomp.sdc.versioning.dao.types.Version;
import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
import java.nio.ByteBuffer;
+import java.util.Arrays;
import java.util.Optional;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
public class OrchestrationTemplateCandidateDaoZusammenImpl
implements OrchestrationTemplateCandidateDao {
+
private static final Logger logger =
LoggerFactory.getLogger(OrchestrationTemplateCandidateDaoZusammenImpl.class);
@@ -39,95 +47,163 @@
@Override
public OrchestrationTemplateCandidateData get(String vspId, Version version) {
- logger.info("Getting orchestration template for vsp id -> " + vspId);
+ logger.info("Getting orchestration template for VendorSoftwareProduct id -> " + vspId);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- Id versionId = VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor);
- ElementContext elementContext = new ElementContext(itemId, versionId,
- VspZusammenUtil.getVersionTag(version));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
Optional<Element> candidateElement =
zusammenAdaptor.getElementByName(context, elementContext, null,
- StructureElement.OrchestrationTemplateCandidate.name());
+ ElementType.OrchestrationTemplateCandidate.name());
if (candidateElement.isPresent()) {
+ if (hasEmptyData(candidateElement.get().getData())) {
+ return null;
+ }
OrchestrationTemplateCandidateData candidateData = new OrchestrationTemplateCandidateData();
candidateData.setFilesDataStructure(
new String(FileUtils.toByteArray(candidateElement.get().getData())));
- zusammenAdaptor
+ Optional<Element> candidateContentElement = zusammenAdaptor
.getElementByName(context, elementContext, candidateElement.get().getElementId(),
- StructureElement.OrchestrationTemplateCandidateContent.name())
- .ifPresent(candidateContentElement -> candidateData.setContentData(
- ByteBuffer.wrap(FileUtils.toByteArray(candidateContentElement.getData()))));
- logger.info("Finished getting orchestration template for vsp id -> " + vspId);
+ ElementType.OrchestrationTemplateCandidateContent.name());
+
+ if (candidateContentElement.isPresent()) {
+ candidateData.setContentData(
+ ByteBuffer.wrap(FileUtils.toByteArray(candidateContentElement.get().getData())));
+ candidateData.setFileSuffix(candidateContentElement.get().getInfo()
+ .getProperty(InfoPropertyName.fileSuffix.name()));
+ candidateData.setFileName(candidateContentElement.get().getInfo()
+ .getProperty(InfoPropertyName.fileName.name()));
+ }
+ logger
+ .info("Finished getting orchestration template for VendorSoftwareProduct id -> " + vspId);
return candidateData;
}
- logger.info(String.format("Orchestration template for vsp id %s does not exist", vspId));
+ logger.info(String
+ .format("Orchestration template for VendorSoftwareProduct id %s does not exist", vspId));
return null;
}
@Override
- public void update(String vspId, OrchestrationTemplateCandidateData candidateData) {
- logger.info("Uploading candidate data entity for vsp id -> " + vspId);
+ public OrchestrationTemplateCandidateData getInfo(String vspId, Version version) {
+ logger.info("Getting orchestration template info for VendorSoftwareProduct id -> " + vspId);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- Id versionId = VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor);
- ElementContext elementContext = new ElementContext(itemId, versionId);
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
- ZusammenElement candidateElement = VspZusammenUtil
- .buildStructuralElement(StructureElement.OrchestrationTemplateCandidate, Action.UPDATE);
+ Optional<ElementInfo> candidateElement =
+ zusammenAdaptor.getElementInfoByName(context, elementContext, null,
+ ElementType.OrchestrationTemplateCandidate.name());
+ if (candidateElement.isPresent()) {
+ OrchestrationTemplateCandidateData candidateData = new OrchestrationTemplateCandidateData();
+
+ Optional<Element> candidateContentElement = zusammenAdaptor
+ .getElementByName(context, elementContext, candidateElement.get().getId(),
+ ElementType.OrchestrationTemplateCandidateContent.name());
+
+ if (candidateContentElement.isPresent()) {
+ candidateData.setFileSuffix(candidateContentElement.get().getInfo()
+ .getProperty(InfoPropertyName.fileSuffix.name()));
+ candidateData.setFileName(candidateContentElement.get().getInfo()
+ .getProperty(InfoPropertyName.fileName.name()));
+ }
+ logger.info(
+ "Finished getting orchestration template info for VendorSoftwareProduct id -> " + vspId);
+ return candidateData;
+ }
+ logger.info(String
+ .format("Orchestration template info for VendorSoftwareProduct id %s does not exist",
+ vspId));
+ return null;
+ }
+
+ @Override
+ public void update(String vspId, Version version,
+ OrchestrationTemplateCandidateData candidateData) {
+ logger.info("Uploading candidate data entity for VendorSoftwareProduct id -> " + vspId);
+
+ ZusammenElement candidateElement =
+ buildStructuralElement(ElementType.OrchestrationTemplateCandidate, Action.UPDATE);
candidateElement
.setData(new ByteArrayInputStream(candidateData.getFilesDataStructure().getBytes()));
- ZusammenElement candidateContentElement = VspZusammenUtil
- .buildStructuralElement(StructureElement.OrchestrationTemplateCandidateContent, Action.UPDATE);
+
+ ZusammenElement candidateContentElement =
+ buildStructuralElement(ElementType.OrchestrationTemplateCandidateContent, Action.UPDATE);
candidateContentElement
.setData(new ByteArrayInputStream(candidateData.getContentData().array()));
+ candidateContentElement.getInfo()
+ .addProperty(InfoPropertyName.fileSuffix.name(), candidateData.getFileSuffix());
+ candidateContentElement.getInfo()
+ .addProperty(InfoPropertyName.fileName.name(), candidateData.getFileName());
candidateElement.addSubElement(candidateContentElement);
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
zusammenAdaptor.saveElement(context, elementContext, candidateElement,
"Update Orchestration Template Candidate");
- logger.info("Finished uploading candidate data entity for vsp id -> " + vspId);
+ logger
+ .info("Finished uploading candidate data entity for VendorSoftwareProduct id -> " + vspId);
}
+
@Override
public void updateStructure(String vspId, Version version, FilesDataStructure fileDataStructure) {
logger.info("Updating orchestration template for VSP id -> " + vspId);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- Id versionId = VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor);
- ElementContext elementContext = new ElementContext(itemId, versionId);
-
- ZusammenElement candidateElement = VspZusammenUtil
- .buildStructuralElement(StructureElement.OrchestrationTemplateCandidate, Action.UPDATE);
+ ZusammenElement candidateElement =
+ buildStructuralElement(ElementType.OrchestrationTemplateCandidate, Action.UPDATE);
candidateElement
.setData(new ByteArrayInputStream(JsonUtil.object2Json(fileDataStructure).getBytes()));
+
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
zusammenAdaptor.saveElement(context, elementContext, candidateElement,
"Update Orchestration Template Candidate structure");
- logger.info("Finished uploading candidate data entity for vsp id -> " + vspId);
+ logger
+ .info("Finished uploading candidate data entity for VendorSoftwareProduct id -> " + vspId);
}
@Override
public Optional<String> getStructure(String vspId, Version version) {
- logger.info("Getting orchestration template structure for vsp id -> " + vspId);
+ logger
+ .info("Getting orchestration template structure for VendorSoftwareProduct id -> " + vspId);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- Id versionId = VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor);
- ElementContext elementContext = new ElementContext(itemId, versionId,
- VspZusammenUtil.getVersionTag(version));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
- logger.info("Finished getting orchestration template structure for vsp id -> " + vspId);
+ logger.info(
+ "Finished getting orchestration template structure for VendorSoftwareProduct id -> " +
+ vspId);
Optional<Element> element = zusammenAdaptor.getElementByName(context, elementContext, null,
- StructureElement.OrchestrationTemplateCandidate.name());
+ ElementType.OrchestrationTemplateCandidate.name());
if (element.isPresent()) {
+ if (hasEmptyData(element.get().getData())) {
+ return Optional.empty();
+ }
return Optional.of(new String(FileUtils.toByteArray(element.get().getData())));
} else {
return Optional.empty();
}
+ }
+ private boolean hasEmptyData(InputStream elementData) {
+ String emptyData = "{}";
+ byte[] byteElementData;
+ try {
+ byteElementData = IOUtils.toByteArray(elementData);
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ return false;
+ }
+ if (Arrays.equals(emptyData.getBytes(), byteElementData)) {
+ return true;
+ }
+ return false;
+ }
+
+ public enum InfoPropertyName {
+ fileSuffix,
+ fileName
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateDaoZusammenImpl.java
index 2b6d52a..d02e854 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateDaoZusammenImpl.java
@@ -3,22 +3,27 @@
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
-import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.SessionContext;
import com.amdocs.zusammen.datatypes.item.Action;
import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.utils.fileutils.FileUtils;
+import org.apache.commons.io.IOUtils;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadData;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadDataEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
import org.openecomp.sdc.versioning.dao.types.Version;
import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
import java.nio.ByteBuffer;
+import java.util.Arrays;
import java.util.Optional;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
public class OrchestrationTemplateDaoZusammenImpl implements OrchestrationTemplateDao {
private ZusammenAdaptor zusammenAdaptor;
@@ -33,79 +38,128 @@
}
@Override
- public String getValidationData(String vspId, Version version) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(version));
+ public OrchestrationTemplateEntity getInfo(String vspId, Version version) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+
+ Optional<ElementInfo> vspModel = zusammenAdaptor
+ .getElementInfoByName(context, elementContext, null, ElementType.VspModel.name());
+ if (!vspModel.isPresent()) {
+ return null;
+ }
Optional<ElementInfo> elementInfo = zusammenAdaptor
- .getElementInfoByName(context, elementContext, null,
- StructureElement.OrchestrationTemplate.name());
- if (elementInfo.isPresent()) {
- Optional<Element> element =
- zusammenAdaptor.getElementByName(context, elementContext, elementInfo.get().getId(),
- StructureElement.OrchestrationTemplateValidationData.name());
- if (element.isPresent()) {
- return new String(FileUtils.toByteArray(element.get().getData()));
+ .getElementInfoByName(context, elementContext, vspModel.get().getId(),
+ ElementType.OrchestrationTemplate.name());
+ if (!elementInfo.isPresent()) {
+ return null;
+ }
+
+ Optional<Element> element =
+ zusammenAdaptor.getElementByName(context, elementContext, elementInfo.get().getId(),
+ ElementType.OrchestrationTemplateValidationData.name());
+
+ OrchestrationTemplateEntity orchestrationTemplate = new OrchestrationTemplateEntity();
+ if (!element.isPresent()) {
+ return orchestrationTemplate;
+ }
+ orchestrationTemplate
+ .setFileSuffix(element.get().getInfo().getProperty(InfoPropertyName.fileSuffix.name()));
+ orchestrationTemplate
+ .setFileName(element.get().getInfo().getProperty(InfoPropertyName.fileName.name()));
+ if (!hasEmptyData(element.get().getData())) {
+ orchestrationTemplate
+ .setValidationData(new String(FileUtils.toByteArray(element.get().getData())));
+ }
+ return orchestrationTemplate;
+ }
+
+ @Override
+ public OrchestrationTemplateEntity get(String vspId, Version version) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+
+ OrchestrationTemplateEntity orchestrationTemplate = new OrchestrationTemplateEntity();
+
+ Optional<ElementInfo> vspModel = zusammenAdaptor
+ .getElementInfoByName(context, elementContext, null, ElementType.VspModel.name());
+ if (!vspModel.isPresent()) {
+ return orchestrationTemplate;
+ }
+
+ Optional<Element> orchestrationTemplateElement = zusammenAdaptor
+ .getElementByName(context, elementContext, vspModel.get().getId(),
+ ElementType.OrchestrationTemplate.name());
+ if (!orchestrationTemplateElement.isPresent()) {
+ return orchestrationTemplate;
+ }
+
+ if (!hasEmptyData(orchestrationTemplateElement.get().getData())) {
+ orchestrationTemplate.setContentData(
+ ByteBuffer.wrap(FileUtils.toByteArray(orchestrationTemplateElement.get().getData())));
+ }
+
+ Optional<Element> validationDataElement =
+ zusammenAdaptor.getElementByName(context, elementContext,
+ orchestrationTemplateElement.get().getElementId(),
+ ElementType.OrchestrationTemplateValidationData.name());
+ if (validationDataElement.isPresent()) {
+ orchestrationTemplate.setFileSuffix(validationDataElement.get().getInfo()
+ .getProperty(InfoPropertyName.fileSuffix.name()));
+ orchestrationTemplate.setFileName(validationDataElement.get().getInfo()
+ .getProperty(InfoPropertyName.fileName.name()));
+ if (!hasEmptyData(validationDataElement.get().getData())) {
+ orchestrationTemplate.setValidationData(
+ new String(FileUtils.toByteArray(validationDataElement.get().getData())));
}
}
-
- return null;
+ return orchestrationTemplate;
}
@Override
- public UploadDataEntity getOrchestrationTemplate(String vspId, Version version) {
+ public void update(String vspId, Version version,
+ OrchestrationTemplateEntity orchestrationTemplate) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
- UploadDataEntity uploadData = new UploadDataEntity();
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(version));
+ ZusammenElement validationData =
+ buildStructuralElement(ElementType.OrchestrationTemplateValidationData, Action.UPDATE);
+ validationData
+ .setData(new ByteArrayInputStream(orchestrationTemplate.getValidationData().getBytes()));
+ validationData.getInfo()
+ .addProperty(InfoPropertyName.fileSuffix.name(), orchestrationTemplate.getFileSuffix());
+ validationData.getInfo()
+ .addProperty(InfoPropertyName.fileName.name(), orchestrationTemplate.getFileName());
- Optional<ElementInfo> elementInfo = zusammenAdaptor
- .getElementInfoByName(context, elementContext, null,
- StructureElement.OrchestrationTemplate.name());
- if (elementInfo.isPresent()) {
- Optional<Element> element =
- zusammenAdaptor.getElementByName(context, elementContext, elementInfo.get().getId(),
- StructureElement.OrchestrationTemplateValidationData.name());
- element.ifPresent(element1 -> uploadData
- .setValidationData(new String(FileUtils.toByteArray(element1.getData()))));
- element =
- zusammenAdaptor.getElementByName(context, elementContext, elementInfo.get().getId(),
- StructureElement.OrchestrationTemplateContent.name());
- element.ifPresent(element1 -> uploadData
- .setContentData(ByteBuffer.wrap(FileUtils.toByteArray(element1.getData()))));
- }
- return uploadData;
- }
-
- @Override
- public void updateOrchestrationTemplateData(String vspId, UploadData uploadData) {
ZusammenElement orchestrationTemplateElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.OrchestrationTemplate, null);
- ZusammenElement orchestrationTemplateValidationDataElement =
- VspZusammenUtil
- .buildStructuralElement(StructureElement.OrchestrationTemplateValidationData, Action.UPDATE);
- orchestrationTemplateValidationDataElement.setData(new ByteArrayInputStream(uploadData
- .getValidationData().getBytes()));
- ZusammenElement orchestrationTemplateContent =
- VspZusammenUtil.buildStructuralElement(StructureElement.OrchestrationTemplateContent, Action.UPDATE);
- orchestrationTemplateContent
- .setData(new ByteArrayInputStream(uploadData.getContentData().array()));
- orchestrationTemplateElement.addSubElement(orchestrationTemplateValidationDataElement);
- orchestrationTemplateElement.addSubElement(orchestrationTemplateContent);
+ buildStructuralElement(ElementType.OrchestrationTemplate, Action.UPDATE);
+ orchestrationTemplateElement
+ .setData(new ByteArrayInputStream(orchestrationTemplate.getContentData().array()));
+ orchestrationTemplateElement.addSubElement(validationData);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.IGNORE);
+ vspModel.addSubElement(orchestrationTemplateElement);
- zusammenAdaptor.saveElement(context, elementContext, orchestrationTemplateElement, "Update " +
- "Orchestration Template");
+ zusammenAdaptor.saveElement(context, elementContext, vspModel, "Update Orchestration Template");
}
+ private boolean hasEmptyData(InputStream elementData) {
+ String emptyData = "{}";
+ byte[] byteElementData;
+ try {
+ byteElementData = IOUtils.toByteArray(elementData);
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ return false;
+ }
+ if (Arrays.equals(emptyData.getBytes(), byteElementData)) {
+ return true;
+ }
+ return false;
+ }
+
+ private enum InfoPropertyName {
+ fileSuffix,
+ fileName
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ProcessDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ProcessDaoZusammenImpl.java
index b0cff43..d74900b 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ProcessDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/ProcessDaoZusammenImpl.java
@@ -8,34 +8,35 @@
import com.amdocs.zusammen.datatypes.item.Action;
import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.datatypes.item.Info;
-import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToProcessConvertor;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessType;
import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.types.ElementPropertyName;
import java.io.ByteArrayInputStream;
-import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+import static org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToProcessConvertor.ARTIFACT_NAME;
+import static org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToProcessConvertor.DESCRIPTION;
+import static org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToProcessConvertor.NAME;
+import static org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToProcessConvertor.PROCESS_TYPE;
+
/**
* @author Avrahamg.
* @since March 23, 2017
*/
public class ProcessDaoZusammenImpl implements ProcessDao {
- private static final String NAME = "name";
- private static final String ELEMENT_TYPE = "type";
- private static final String ARTIFACT_NAME = "artifactName";
- private static final String DESCRIPTION = "description";
- private static final String PROCESS_TYPE = "processType";
-
private ZusammenAdaptor zusammenAdaptor;
public ProcessDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
@@ -52,85 +53,59 @@
ZusammenElement processElement = buildProcessElement(processEntity, Action.CREATE);
ZusammenElement processesElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Processes, null);
+ buildStructuralElement(ElementType.Processes, Action.IGNORE);
ZusammenElement aggregatedElement = VspZusammenUtil.aggregateElements(processesElement,
processElement);
ZusammenElement componentElement;
if (processEntity.getComponentId() != null) {
- componentElement = createParentElement(processEntity);
+ componentElement = buildElement(new Id(processEntity.getComponentId()), Action.IGNORE);
aggregatedElement =
VspZusammenUtil.aggregateElements(componentElement, aggregatedElement);
}
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(processEntity.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(processEntity.getVspId(), processEntity.getVersion().getId());
- Optional<Element> savedElement =
+ Element savedElement =
zusammenAdaptor.saveElement(context, elementContext, aggregatedElement, "Create process");
- savedElement.ifPresent(element -> {
- if (processEntity.getComponentId() == null) {
- processEntity.setId(element.getSubElements().iterator().next()
- .getElementId().getValue());
- } else {
- processEntity.setId(element.getSubElements().iterator().next()
- .getSubElements().iterator().next().getElementId().getValue());
- }
- });
+ processEntity
+ .setId(processEntity.getComponentId() == null
+ ? savedElement.getSubElements().iterator().next().getElementId().getValue()
+ : savedElement.getSubElements().iterator().next().getSubElements()
+ .iterator().next().getElementId().getValue());
}
@Override
- public ProcessEntity get(ProcessEntity process) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(process.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(process.getVersion()));
+ public ProcessEntity get(ProcessEntity processEntity) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(processEntity.getVspId(), processEntity.getVersion().getId());
- Optional<Element> elementOptional =
- zusammenAdaptor.getElement(context, elementContext, process.getId());
-
- if (elementOptional.isPresent()) {
- Element element = elementOptional.get();
- process.setName(element.getInfo().getProperty(NAME));
- process.setArtifactName(element.getInfo().getProperty(ARTIFACT_NAME));
- process.setDescription(element.getInfo().getProperty(DESCRIPTION));
- process.setType(element.getInfo().getProperty
- (PROCESS_TYPE) != null ? ProcessType.valueOf(element.getInfo().getProperty
- (PROCESS_TYPE)) : null);
-
- process.setArtifact(ByteBuffer.wrap(FileUtils.toByteArray(element.getData())));
- return process;
- } else {
- return null;
- }
+ return zusammenAdaptor.getElementInfo(context, elementContext, new Id(processEntity.getId()))
+ .map(elementInfo -> convertToProcessEntity(elementInfo, new ElementToProcessConvertor(),
+ processEntity))
+ .orElse(null);
}
@Override
public void update(ProcessEntity processEntity) {
- ZusammenElement processElement = buildProcessElement(processEntity, Action.UPDATE);
+ ProcessEntity retrieved = getArtifact(processEntity);
+ if (retrieved != null && retrieved.getArtifact() != null) {
+ processEntity.setArtifactName(retrieved.getArtifactName());
+ processEntity.setArtifact(retrieved.getArtifact());
+ }
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(processEntity.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
-
- Optional<Element> element =
- zusammenAdaptor.saveElement(context, elementContext, processElement, "Create process");
- System.out.println(element.get().getElementId());
+ update(processEntity, "Update process");
}
@Override
public void delete(ProcessEntity processEntity) {
- ZusammenElement processElement = new ZusammenElement();
- processElement.setElementId(new Id(processEntity.getId()));
- processElement.setAction(Action.DELETE);
+ ZusammenElement processElement = buildElement(new Id(processEntity.getId()), Action.DELETE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(processEntity.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(processEntity.getVspId(), processEntity.getVersion().getId());
zusammenAdaptor.saveElement(context, elementContext, processElement,
String.format("Delete process with id %s", processEntity.getId()));
@@ -138,84 +113,158 @@
@Override
public void deleteAll(ProcessEntity processEntity) {
- ZusammenElement aggregatedElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Processes, Action.DELETE);
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(processEntity.getVspId(), processEntity.getVersion().getId());
+
+ Optional<Element> optionalElement = zusammenAdaptor.getElementByName(context,
+ elementContext, new Id(processEntity.getComponentId()), ElementType.Processes.name());
+
+ /* ZusammenElement aggregatedElement =
+ buildStructuralElement(ElementType.Processes, Action.DELETE);
if (processEntity.getComponentId() != null) {
ZusammenElement componentElement = createParentElement(processEntity);
- aggregatedElement = VspZusammenUtil.aggregateElements(componentElement,
+ aggregatedElement = VspaggregateElements(componentElement,
aggregatedElement);
}
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(processEntity.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
- zusammenAdaptor.saveElement(context, elementContext, aggregatedElement, "Delete All processes");
+ zusammenAdaptor.saveElement(context, elementContext, aggregatedElement, "Delete All
+ processes");*/
+
+ if (optionalElement.isPresent()) {
+ Element processesElement = optionalElement.get();
+ Collection<Element> processes = processesElement.getSubElements();
+
+ processes.forEach(process -> {
+ ZusammenElement processZusammenElement =
+ buildElement(process.getElementId(), Action.DELETE);
+ zusammenAdaptor.saveElement(context, elementContext, processZusammenElement,
+ "Delete Process with id " + process.getElementId());
+ });
+ }
}
@Override
public void deleteVspAll(String vspId, Version version) {
- ProcessEntity processEntity = new ProcessEntity();
+ /* ProcessEntity processEntity = new ProcessEntity();
processEntity.setVersion(version);
processEntity.setVspId(vspId);
- deleteAll(processEntity);
+ deleteAll(processEntity); */
+
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(vspId, version.getId());
+
+ Optional<Element> optionalElement = zusammenAdaptor.getElementByName(context,
+ elementContext, null, ElementType.Processes.name());
+
+ if (optionalElement.isPresent()) {
+ Element processesElement = optionalElement.get();
+ Collection<Element> processes = processesElement.getSubElements();
+
+ processes.forEach(process -> {
+ ZusammenElement processZusammenElement =
+ buildElement(process.getElementId(), Action.DELETE);
+ zusammenAdaptor.saveElement(context, elementContext, processZusammenElement,
+ "Delete Process with id " + process.getElementId());
+ });
+ }
}
@Override
- public Collection<ProcessEntity> list(ProcessEntity process) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(process.getVspId());
- ElementContext elementContext = new ElementContext(itemId,
- VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VspZusammenUtil.getVersionTag(process.getVersion()));
+ public ProcessEntity getArtifact(ProcessEntity processEntity) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(processEntity.getVspId(), processEntity.getVersion().getId());
+
+ return zusammenAdaptor.getElement(context, elementContext, processEntity.getId())
+ .map(element -> {
+ ProcessEntity process = new ElementToProcessConvertor().convert(element);
+ process.setVspId(processEntity.getVspId());
+ process.setVersion(processEntity.getVersion());
+ process.setComponentId(processEntity.getComponentId());
+ return process;
+ })
+ .orElse(null);
+ }
+
+ @Override
+ public void uploadArtifact(ProcessEntity processEntity) {
+ ProcessEntity retrieved = get(processEntity);
+ if (retrieved != null) {
+ retrieved.setArtifactName(processEntity.getArtifactName());
+ retrieved.setArtifact(processEntity.getArtifact());
+
+ update(retrieved, "Upload process artifact");
+ }
+ }
+
+ @Override
+ public void deleteArtifact(ProcessEntity processEntity) {
+ ProcessEntity retrieved = get(processEntity);
+ if (retrieved != null) {
+ retrieved.setArtifactName(null);
+ retrieved.setArtifact(null);
+
+ update(retrieved, "Delete process artifact");
+ }
+ }
+
+ @Override
+ public Collection<ProcessEntity> list(ProcessEntity processEntity) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(processEntity.getVspId(), processEntity.getVersion().getId());
Optional<ElementInfo> processesOptional =
zusammenAdaptor.getElementInfoByName(context, elementContext,
- extractParentElementId(process), StructureElement.Processes.name());
+ extractParentElementId(processEntity), ElementType.Processes.name());
if (!processesOptional.isPresent()) {
return new ArrayList<>();
}
+ ElementToProcessConvertor convertor = new ElementToProcessConvertor();
return zusammenAdaptor.listElements(context, elementContext, processesOptional.get().getId())
.stream()
- .map(elementInfo -> mapElementInfoToProcess(
- process.getVspId(), process.getVersion(), process.getComponentId(),
- elementInfo))
+ .map(elementInfo -> convertToProcessEntity(elementInfo, convertor, processEntity))
.collect(Collectors.toList());
}
+ private ProcessEntity convertToProcessEntity(ElementInfo elementInfo,
+ ElementToProcessConvertor convertor,
+ ProcessEntity inputProcess) {
+ ProcessEntity process = convertor.convert(elementInfo);
+ process.setVspId(inputProcess.getVspId());
+ process.setVersion(inputProcess.getVersion());
+ process.setComponentId(inputProcess.getComponentId());
+ return process;
+ }
+
+ private void update(ProcessEntity processEntity, String message) {
+ ZusammenElement processElement = buildProcessElement(processEntity, Action.UPDATE);
+
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(processEntity.getVspId(), processEntity.getVersion().getId());
+
+ zusammenAdaptor.saveElement(context, elementContext, processElement, message);
+ }
+
private Id extractParentElementId(ProcessEntity processEntity) {
return processEntity.getComponentId() == null ? null : new Id(processEntity.getComponentId());
}
- private ProcessEntity mapElementInfoToProcess(String vspId, Version version,
- String componentId,
- ElementInfo elementInfo) {
- ProcessEntity processEntity = new ProcessEntity(vspId, version, componentId, elementInfo
- .getId().getValue());
- processEntity.setName((String) elementInfo.getInfo().getProperties().get(NAME));
- processEntity
- .setArtifactName((String) elementInfo.getInfo().getProperties().get(ARTIFACT_NAME));
- processEntity.setDescription((String) elementInfo.getInfo().getProperties().get(DESCRIPTION));
- processEntity.setType( elementInfo.getInfo().getProperties().get(PROCESS_TYPE) != null ?
- ProcessType.valueOf((String) elementInfo.getInfo().getProperties().get(PROCESS_TYPE)) :
- null);
- return processEntity;
- }
-
private ZusammenElement buildProcessElement(ProcessEntity process, Action action) {
Info info = new Info();
info.setName(process.getName());
info.addProperty(NAME, process.getName());
- info.addProperty(ELEMENT_TYPE, ElementType.Process);
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.Process);
info.addProperty(ARTIFACT_NAME, process.getArtifactName());
info.addProperty(DESCRIPTION, process.getDescription());
info.addProperty(PROCESS_TYPE, process.getType() != null ? process.getType().name() : null);
- ZusammenElement processElement = new ZusammenElement();
- processElement.setElementId(new Id(process.getId()));
- processElement.setAction(action);
+ ZusammenElement processElement = buildElement(new Id(process.getId()), action);
processElement.setInfo(info);
if (Objects.nonNull(process.getArtifact())) {
processElement.setData(new ByteArrayInputStream(process.getArtifact().array()));
@@ -223,10 +272,4 @@
return processElement;
}
- private ZusammenElement createParentElement(ProcessEntity entity) {
- ZusammenElement componentElement = new ZusammenElement();
- componentElement.setElementId(new Id(entity.getComponentId()));
- componentElement.setAction(Action.IGNORE);
- return componentElement;
- }
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/StructureElement.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/StructureElement.java
deleted file mode 100644
index 6f15f5c..0000000
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/StructureElement.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
-
-public enum StructureElement {
- General,
- OrchestrationTemplateCandidate,
- OrchestrationTemplate,
- OrchestrationTemplateValidationData,
- OrchestrationTemplateContent,
- OrchestrationTemplateCandidateValidationData,
- OrchestrationTemplateCandidateContent,
- Networks,
- Components,
- Nics,
- Processes,
- Mibs,
- SNMP_TRAP,
- SNMP_POLL,
- VES_EVENTS,
- Questionnaire,
- ComponentDependencies,
- Computes,
- Images,
- DeploymentFlavors
-}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java
index 517a01e..aa192ed 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java
@@ -1,16 +1,15 @@
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
-import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.SessionContext;
import com.amdocs.zusammen.datatypes.item.Action;
import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.datatypes.item.Info;
-import com.amdocs.zusammen.datatypes.item.ItemVersion;
-import com.amdocs.zusammen.utils.fileutils.FileUtils;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToVSPGeneralConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToVSPQuestionnaireConvertor;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspQuestionnaireEntity;
import org.openecomp.sdc.versioning.VersioningManagerFactory;
@@ -20,10 +19,14 @@
import java.io.ByteArrayInputStream;
import java.util.Collection;
-import java.util.Date;
import java.util.stream.Collectors;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
public class VendorSoftwareProductInfoDaoZusammenImpl implements VendorSoftwareProductInfoDao {
+ private static final String EMPTY_DATA = "{}";
+
private ZusammenAdaptor zusammenAdaptor;
public VendorSoftwareProductInfoDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
@@ -33,7 +36,8 @@
@Override
public void registerVersioning(String versionableEntityType) {
VersionableEntityMetadata metadata =
- new VersionableEntityMetadata(VersionableEntityStoreType.Zusammen, "vsp", null, null);
+ new VersionableEntityMetadata(VersionableEntityStoreType.Zusammen, "VendorSoftwareProduct",
+ null, null);
VersioningManagerFactory.getInstance().createInterface()
.register(versionableEntityType, metadata);
@@ -41,114 +45,174 @@
@Override
public Collection<VspDetails> list(VspDetails entity) {
- return zusammenAdaptor.listItems(ZusammenUtil.createSessionContext()).stream().filter
- (vspEntity-> "vsp".equals(vspEntity.getInfo().getProperty("type")))
- .map(item -> mapInfoToVspDetails(
- item.getId().getValue(), null, item.getInfo(),
- item.getModificationTime(), item.getCreationTime()))
+ ElementToVSPGeneralConvertor convertor = new ElementToVSPGeneralConvertor();
+
+
+ return zusammenAdaptor.listItems(createSessionContext()).stream()
+ .filter(item -> "VendorSoftwareProduct".equals(item.getInfo().getProperty("item_type")))
+ .map(item -> convertor.convert(item))
.collect(Collectors.toList());
}
+
@Override
public void create(VspDetails vspDetails) {
- SessionContext context = ZusammenUtil.createSessionContext();
-
- Id itemId = zusammenAdaptor.createItem(context, mapVspDetailsToZusammenItemInfo(vspDetails));
- Id versionId =
- zusammenAdaptor.createVersion(context, itemId, null, ZusammenUtil.createFirstVersionData());
-
ZusammenElement generalElement = mapVspDetailsToZusammenElement(vspDetails, Action.CREATE);
- zusammenAdaptor.saveElement(context, new ElementContext(itemId, versionId),
- generalElement, "Create VSP General Info Element");
- vspDetails.setId(itemId.getValue());//set id for caller
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(vspDetails.getId(), vspDetails.getVersion().getId());
+ zusammenAdaptor.saveElement(context, elementContext, generalElement,
+ "Create VSP General Info Element");
+
+ createVspStructure(context, elementContext);
+ }
+
+ private void createVspStructure(SessionContext context, ElementContext elementContext) {
+ createOrchestrationTemplateCandidateStructure(context, elementContext);
+ createVspModelStructure(context, elementContext);
+
+ zusammenAdaptor.saveElement(context, elementContext,
+ buildStructuralElement(ElementType.DeploymentFlavors, Action.CREATE),
+ "Create VSP Deployment Flavors Element");
+
+ zusammenAdaptor.saveElement(context, elementContext,
+ buildStructuralElement(ElementType.Processes, Action.CREATE),
+ "Create VSP Processes Element");
+ }
+
+ private void createOrchestrationTemplateCandidateStructure(SessionContext context,
+ ElementContext elementContext) {
+ ByteArrayInputStream emptyData = new ByteArrayInputStream(EMPTY_DATA.getBytes());
+
+ ZusammenElement candidateContentElement =
+ buildStructuralElement(ElementType.OrchestrationTemplateCandidateContent, Action.CREATE);
+ candidateContentElement.setData(emptyData);
+
+ ZusammenElement candidateElement =
+ buildStructuralElement(ElementType.OrchestrationTemplateCandidate, Action.CREATE);
+ candidateElement.setData(emptyData);
+ candidateElement.addSubElement(candidateContentElement);
+
+ zusammenAdaptor.saveElement(context, elementContext, candidateElement,
+ "Create Orchestration Template Candidate Elements");
+ }
+
+ private void createVspModelStructure(SessionContext context, ElementContext elementContext) {
+ ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.CREATE);
+ vspModel.addSubElement(buildOrchestrationTemplateStructure());
+ vspModel.addSubElement(buildStructuralElement(ElementType.Networks, Action.CREATE));
+ vspModel.addSubElement(buildStructuralElement(ElementType.Components, Action.CREATE));
+ vspModel
+ .addSubElement(buildStructuralElement(ElementType.ComponentDependencies, Action.CREATE));
+
+ ZusammenElement templates = buildStructuralElement(ElementType.Templates, Action.CREATE);
+ ZusammenElement artifacts = buildStructuralElement(ElementType.Artifacts, Action.CREATE);
+ vspModel.addSubElement(
+ buildServiceModelStructure(ElementType.ServiceModel, templates, artifacts));
+ vspModel.addSubElement(
+ buildServiceModelStructure(ElementType.EnrichedServiceModel, templates, artifacts));
+
+ zusammenAdaptor.saveElement(context, elementContext, vspModel, "Create VSP Model Elements");
+ }
+
+ private ZusammenElement buildOrchestrationTemplateStructure() {
+ ByteArrayInputStream emptyData = new ByteArrayInputStream(EMPTY_DATA.getBytes());
+
+ ZusammenElement validationData =
+ buildStructuralElement(ElementType.OrchestrationTemplateValidationData, Action.CREATE);
+ validationData.setData(emptyData);
+
+ ZusammenElement orchestrationTemplate =
+ buildStructuralElement(ElementType.OrchestrationTemplate, Action.CREATE);
+ orchestrationTemplate.setData(emptyData);
+ orchestrationTemplate.addSubElement(validationData);
+
+ return orchestrationTemplate;
+ }
+
+ private ZusammenElement buildServiceModelStructure(ElementType serviceModelElementType,
+ ZusammenElement templates,
+ ZusammenElement artifacts) {
+ ZusammenElement serviceModel = buildStructuralElement(serviceModelElementType, Action.CREATE);
+ serviceModel.addSubElement(templates);
+ serviceModel.addSubElement(artifacts);
+ return serviceModel;
}
@Override
public void update(VspDetails vspDetails) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspDetails.getId());
- Id versionId = VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor);
-
- zusammenAdaptor.updateItem(context, itemId, mapVspDetailsToZusammenItemInfo(vspDetails));
-
ZusammenElement generalElement = mapVspDetailsToZusammenElement(vspDetails, Action.UPDATE);
- zusammenAdaptor.saveElement(context, new ElementContext(itemId, versionId),
- generalElement, "Update VSP General Info Element");
+
+ SessionContext context = createSessionContext();
+ zusammenAdaptor.saveElement(context,
+ new ElementContext(vspDetails.getId(), vspDetails.getVersion().getId()), generalElement,
+ "Update VSP General Info Element");
}
@Override
public VspDetails get(VspDetails vspDetails) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspDetails.getId());
- ItemVersion itemVersion = VspZusammenUtil.getFirstVersion(context, itemId, zusammenAdaptor);
- ElementContext elementContext = new ElementContext(itemId, itemVersion.getId(),
- VspZusammenUtil.getVersionTag(vspDetails.getVersion()));
-
- return zusammenAdaptor
- .getElementInfoByName(context, elementContext, null, StructureElement.General.name())
- .map(generalElementInfo -> mapInfoToVspDetails(
- vspDetails.getId(), vspDetails.getVersion(), generalElementInfo.getInfo(),
- itemVersion.getModificationTime(), itemVersion.getCreationTime()))
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(vspDetails.getId(), vspDetails.getVersion().getId());
+ VspDetails vsp = zusammenAdaptor.getElementInfoByName(context, elementContext, null,
+ ElementType.VendorSoftwareProduct.name())
+ .map(new ElementToVSPGeneralConvertor()::convert)
.orElse(null);
- }
-
-
- @Override
- public void delete(VspDetails entity) {
-
+ vsp.setId(vspDetails.getId());
+ vsp.setVersion(vspDetails.getVersion());
+ return vsp;
}
@Override
- public void updateOldVersionIndication(VspDetails vspDetails) {
- VspDetails retrieved = get(vspDetails);
- if (retrieved != null) {
- retrieved.setOldVersion(vspDetails.getOldVersion());
- update(retrieved);
- }
+ public void delete(VspDetails vspDetails) {
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(vspDetails.getId(), vspDetails.getVersion().getId());
+
+ zusammenAdaptor.saveElement(context, elementContext,
+ buildStructuralElement(ElementType.VspModel, Action.DELETE),
+ "Delete VSP Model Elements");
+
+ createVspModelStructure(context, elementContext);
}
@Override
public void updateQuestionnaireData(String vspId, Version version, String questionnaireData) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- Id versionId = VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor);
+ SessionContext context = createSessionContext();
ZusammenElement questionnaireElement = mapQuestionnaireToZusammenElement(questionnaireData);
- zusammenAdaptor.saveElement(context, new ElementContext(itemId, versionId),
+ zusammenAdaptor.saveElement(context, new ElementContext(vspId, version.getId()),
questionnaireElement, "Update VSP Questionnaire");
}
- @Override
+ /* @Override
public String getQuestionnaireData(String vspId, Version version) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vspId);
- Id versionId = VspZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor);
+ SessionContext context = createSessionContext();
- return zusammenAdaptor.getElementByName(context,
- new ElementContext(itemId, versionId, VspZusammenUtil.getVersionTag(version)), null,
- StructureElement.Questionnaire.name())
+ return zusammenAdaptor
+ .getElementByName(context, new ElementContext(vspId, version.getId()), null,
+ ElementType.Questionnaire.name())
.map(questionnaireElement ->
new String(FileUtils.toByteArray(questionnaireElement.getData())))
.orElse(null);
- }
+ }*/
@Override
public VspQuestionnaireEntity getQuestionnaire(String vspId, Version version) {
- VspQuestionnaireEntity entity = new VspQuestionnaireEntity();
+
+ SessionContext context = createSessionContext();
+ ElementToVSPQuestionnaireConvertor convertor = new ElementToVSPQuestionnaireConvertor();
+ VspQuestionnaireEntity entity = convertor.convert(zusammenAdaptor
+ .getElementByName(context, new ElementContext(vspId, version.getId()), null,
+ ElementType.VSPQuestionnaire.name()).map(element -> element).orElse(null));
entity.setId(vspId);
entity.setVersion(version);
- entity.setQuestionnaireData(getQuestionnaireData(vspId, version));
return entity;
}
@Override
- public void deleteAll(String vspId, Version version) {
-
- }
-
- @Override
public boolean isManual(String vspId, Version version) {
final VspDetails vspDetails = get(new VspDetails(vspId, version));
if (vspDetails != null) {
@@ -159,29 +223,27 @@
return false;
}
- private Info mapVspDetailsToZusammenItemInfo(VspDetails vspDetails) {
- Info info = new Info();
- info.setName(vspDetails.getName());
- info.setDescription(vspDetails.getDescription());
- info.addProperty("type", "vsp");
- addVspDetailsToInfo(info, vspDetails);
- return info;
- }
-
private ZusammenElement mapVspDetailsToZusammenElement(VspDetails vspDetails, Action action) {
ZusammenElement generalElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.General, action);
+ buildStructuralElement(ElementType.VendorSoftwareProduct, action);
addVspDetailsToInfo(generalElement.getInfo(), vspDetails);
return generalElement;
}
private ZusammenElement mapQuestionnaireToZusammenElement(String questionnaireData) {
ZusammenElement questionnaireElement =
- VspZusammenUtil.buildStructuralElement(StructureElement.Questionnaire, Action.UPDATE);
+ buildStructuralElement(ElementType.VSPQuestionnaire, Action.UPDATE);
questionnaireElement.setData(new ByteArrayInputStream(questionnaireData.getBytes()));
return questionnaireElement;
}
+ private ZusammenElement mapTestElementToZusammenElement(String elementData) {
+ ZusammenElement testElement =
+ buildStructuralElement(ElementType.test, Action.UPDATE);
+ testElement.setData(new ByteArrayInputStream(elementData.getBytes()));
+ return testElement;
+ }
+
private void addVspDetailsToInfo(Info info, VspDetails vspDetails) {
info.addProperty(InfoPropertyName.name.name(), vspDetails.getName());
info.addProperty(InfoPropertyName.description.name(), vspDetails.getDescription());
@@ -191,45 +253,14 @@
info.addProperty(InfoPropertyName.vendorId.name(), vspDetails.getVendorId());
info.addProperty(InfoPropertyName.vendorName.name(), vspDetails.getVendorName());
if (vspDetails.getVlmVersion() != null) {
- info.addProperty(
- InfoPropertyName.vendorVersion.name(), vspDetails.getVlmVersion().toString());
+ info.addProperty(InfoPropertyName.vendorVersion.name(), vspDetails.getVlmVersion().getId());
}
info.addProperty(InfoPropertyName.licenseAgreement.name(), vspDetails.getLicenseAgreement());
info.addProperty(InfoPropertyName.featureGroups.name(), vspDetails.getFeatureGroups());
- info.addProperty(InfoPropertyName.oldVersion.name(), vspDetails.getOldVersion());
info.addProperty(InfoPropertyName.onboardingMethod.name(), vspDetails.getOnboardingMethod());
- info.addProperty(InfoPropertyName.obBoardingOrigin.name(), vspDetails.getOnboardingOrigin());
- info.addProperty(InfoPropertyName.networkPackageName.name(), vspDetails.getNetworkPackageName());
}
- private VspDetails mapInfoToVspDetails(String vspId, Version version, Info info,
- Date modificationTime, Date creationTime) {
- VspDetails vspDetails = new VspDetails(vspId, version);
- vspDetails.setName(info.getProperty(InfoPropertyName.name.name()));
- vspDetails.setDescription(info.getProperty(InfoPropertyName.description.name()));
- vspDetails.setCategory(info.getProperty(InfoPropertyName.category.name()));
- vspDetails.setSubCategory(info.getProperty(InfoPropertyName.subCategory.name()));
- vspDetails.setVendorId(info.getProperty(InfoPropertyName.vendorId.name()));
- vspDetails.setVendorName(info.getProperty(InfoPropertyName.vendorName.name()));
- vspDetails.setVlmVersion(
- Version.valueOf(info.getProperty(InfoPropertyName.vendorVersion.name())));
- vspDetails.setLicenseAgreement(info.getProperty(InfoPropertyName.licenseAgreement.name()));
- vspDetails.setFeatureGroups(info.getProperty(InfoPropertyName.featureGroups.name()));
-
- vspDetails.setWritetimeMicroSeconds(
- modificationTime == null ? creationTime.getTime() : modificationTime.getTime());
- vspDetails.setVersion(version);
- String oldVersion = info.getProperty(InfoPropertyName.oldVersion.name());
-
- //Boolean oldVersion = ind == null || "true".equals( ind.toLowerCase());
- vspDetails.setOldVersion(oldVersion);
- vspDetails.setOnboardingMethod(info.getProperty(InfoPropertyName.onboardingMethod.name()));
- vspDetails.setOnboardingOrigin(info.getProperty(InfoPropertyName.obBoardingOrigin.name()));
- vspDetails.setNetworkPackageName(info.getProperty(InfoPropertyName.networkPackageName.name()));
- return vspDetails;
- }
-
- private enum InfoPropertyName {
+ public enum InfoPropertyName {
name,
description,
icon,
@@ -240,10 +271,7 @@
vendorVersion,
licenseAgreement,
featureGroups,
- oldVersion,
- onboardingMethod,
- obBoardingOrigin,
- networkPackageName
+ onboardingMethod
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VspZusammenUtil.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VspZusammenUtil.java
index 5e80d4c..d4dc7e0 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VspZusammenUtil.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VspZusammenUtil.java
@@ -1,49 +1,11 @@
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
-import com.amdocs.zusammen.datatypes.Id;
-import com.amdocs.zusammen.datatypes.SessionContext;
-import com.amdocs.zusammen.datatypes.item.Action;
-import com.amdocs.zusammen.datatypes.item.ItemVersion;
-import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
-import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.errors.VendorSoftwareProductNotFoundErrorBuilder;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.dao.types.VersionStatus;
import java.util.Objects;
-import java.util.Optional;
class VspZusammenUtil {
- static ItemVersion getFirstVersion(SessionContext context, Id itemId, ZusammenAdaptor
- zusammenAdaptor) {
-
- Optional<ItemVersion> itemVersion = zusammenAdaptor.getFirstVersion(context, itemId);
-
- if (!itemVersion.isPresent()) {
- throw new CoreException(
- new VendorSoftwareProductNotFoundErrorBuilder(itemId.getValue()).build());
- }
- return itemVersion.get();
- }
-
- static Id getFirstVersionId(SessionContext context, Id itemId, ZusammenAdaptor zusammenAdaptor) {
- return getFirstVersion(context, itemId, zusammenAdaptor).getId();
- }
-
- // TODO: 4/25/2017 remove upon working with more than one single version
- static String getVersionTag(Version version) {
- return version.getStatus() == VersionStatus.Locked
- ? null
- : version.toString();
- }
-
- static ZusammenElement buildStructuralElement(StructureElement structureElement, Action action) {
- return ZusammenUtil.buildStructuralElement(structureElement.name(), action);
- }
-
static ZusammenElement aggregateElements(ZusammenElement... elements) {
ZusammenElement head = null;
ZusammenElement father = null;
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentConvertor.java
new file mode 100644
index 0000000..ae88a7e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentConvertor.java
@@ -0,0 +1,38 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.item.Info;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
+import org.openecomp.types.ElementPropertyName;
+
+public class ElementToComponentConvertor extends ElementConvertor<ComponentEntity> {
+
+ @Override
+ public ComponentEntity convert(Element element) {
+ ComponentEntity componentEntity = new ComponentEntity();
+ componentEntity.setId(element.getElementId().getValue());
+ componentEntity.setCompositionData(new String(FileUtils.toByteArray(element.getData())));
+ mapInfoToComponentEntity(componentEntity,element.getInfo());
+ return componentEntity;
+ }
+
+ @Override
+ public ComponentEntity convert( ElementInfo elementInfo) {
+ ComponentEntity componentEntity = new ComponentEntity();
+ componentEntity.setId(elementInfo.getId().getValue());
+ mapInfoToComponentEntity(componentEntity,elementInfo.getInfo());
+ return componentEntity;
+ }
+
+
+ public void mapInfoToComponentEntity(ComponentEntity componentEntity,Info info){
+
+
+ componentEntity.setCompositionData(
+ info.getProperty(ElementPropertyName.compositionData.name()));
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentDependencyModelConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentDependencyModelConvertor.java
new file mode 100644
index 0000000..0864ad3
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentDependencyModelConvertor.java
@@ -0,0 +1,41 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.item.Info;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ComponentDependencyModelPropertyName;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
+
+public class ElementToComponentDependencyModelConvertor extends ElementConvertor <ComponentDependencyModelEntity>{
+
+ @Override
+ public ComponentDependencyModelEntity convert( Element element) {
+ ComponentDependencyModelEntity componentDependencyModelEntity = new ComponentDependencyModelEntity();
+ componentDependencyModelEntity.setId(element.getElementId().getValue());
+ mapInfoToComponentDependencyModelEntity(componentDependencyModelEntity,element.getInfo());
+ return componentDependencyModelEntity;
+ }
+
+ @Override
+ public ComponentDependencyModelEntity convert(ElementInfo elementInfo) {
+ ComponentDependencyModelEntity componentDependencyModelEntity = new ComponentDependencyModelEntity();
+
+ componentDependencyModelEntity.setId(elementInfo.getId().getValue());
+ mapInfoToComponentDependencyModelEntity(componentDependencyModelEntity,elementInfo.getInfo());
+ return componentDependencyModelEntity;
+ }
+
+
+ public void mapInfoToComponentDependencyModelEntity(ComponentDependencyModelEntity componentDependencyModelEntity,Info info){
+
+ componentDependencyModelEntity.setSourceComponentId(info
+ .getProperty(ComponentDependencyModelPropertyName.sourcecomponent_id.name()));
+ componentDependencyModelEntity.setTargetComponentId(info
+ .getProperty(ComponentDependencyModelPropertyName.targetcomponent_id.name()));
+ componentDependencyModelEntity.setRelation(info
+ .getProperty(ComponentDependencyModelPropertyName.relation.name()));
+
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentMonitoringUploadConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentMonitoringUploadConvertor.java
new file mode 100644
index 0000000..dd3d122
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentMonitoringUploadConvertor.java
@@ -0,0 +1,45 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.item.Info;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.core.enrichment.types.MonitoringUploadType;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity;
+
+import java.nio.ByteBuffer;
+
+import static org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToProcessConvertor.ARTIFACT_NAME;
+
+public class ElementToComponentMonitoringUploadConvertor extends ElementConvertor<ComponentMonitoringUploadEntity> {
+
+ @Override
+ public ComponentMonitoringUploadEntity convert(Element element) {
+ ComponentMonitoringUploadEntity mibEntity = new ComponentMonitoringUploadEntity();
+
+ mibEntity.setId(element.getElementId().getValue());
+ mibEntity.setArtifact(ByteBuffer.wrap(FileUtils.toByteArray(element.getData())));
+ mapInfoToComponentMonitoringUploadEntity(mibEntity, element.getInfo());
+ return mibEntity;
+ }
+
+ @Override
+ public ComponentMonitoringUploadEntity convert(ElementInfo elementInfo) {
+ ComponentMonitoringUploadEntity mibEntity = new ComponentMonitoringUploadEntity();
+
+ mibEntity.setId(elementInfo.getId().getValue());
+ mapInfoToComponentMonitoringUploadEntity(mibEntity, elementInfo.getInfo());
+ return mibEntity;
+ }
+
+
+ public void mapInfoToComponentMonitoringUploadEntity(ComponentMonitoringUploadEntity mibEntity,
+ Info info) {
+
+ mibEntity.setArtifactName((String) info.getProperties().get(ARTIFACT_NAME));
+ mibEntity.setType(MonitoringUploadType.valueOf(info.getName()));
+ }
+
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentQuestionnnaireConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentQuestionnnaireConvertor.java
new file mode 100644
index 0000000..1554a1c
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComponentQuestionnnaireConvertor.java
@@ -0,0 +1,21 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
+
+
+/**
+ * Created by ayalaben on 9/27/2017
+ */
+public class ElementToComponentQuestionnnaireConvertor extends ElementConvertor<ComponentEntity> {
+ @Override
+ public ComponentEntity convert( Element element) {
+ ComponentEntity componentEntity = new ComponentEntity();
+
+ componentEntity.setId(element.getElementId().getValue());
+ componentEntity.setQuestionnaireData(new String(FileUtils.toByteArray(element.getData())));
+ return componentEntity;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToCompositionEntityConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToCompositionEntityConvertor.java
new file mode 100644
index 0000000..f73da6a
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToCompositionEntityConvertor.java
@@ -0,0 +1,45 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.CompositionEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspQuestionnaireEntity;
+
+public class ElementToCompositionEntityConvertor extends ElementConvertor <CompositionEntity>{
+
+ @Override
+ public CompositionEntity convert(Element element) {
+
+ CompositionEntity compositionEntity = null;
+ switch (getElementType(element)) {
+ case ComponentQuestionnaire:
+ compositionEntity = new ComponentEntity();
+ break;
+ case VSPQuestionnaire:
+ compositionEntity = new VspQuestionnaireEntity();
+ break;
+ case ImageQuestionnaire:
+ compositionEntity = new ImageEntity();
+ break;
+ case ComputeQuestionnaire:
+ compositionEntity = new ComponentEntity();
+ break;
+ case NicQuestionnaire:
+ compositionEntity = new NicEntity();
+ }
+ if (compositionEntity != null) {
+ compositionEntity.setId(element.getElementId().getValue());
+ compositionEntity.setQuestionnaireData(element.getData() == null
+ ? null
+ : new String(FileUtils.toByteArray(element.getData())));
+ return compositionEntity;
+ } else {
+ return null;
+ }
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComputeConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComputeConvertor.java
new file mode 100644
index 0000000..0412e03
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComputeConvertor.java
@@ -0,0 +1,40 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.item.Info;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
+import org.openecomp.types.ElementPropertyName;
+
+public class ElementToComputeConvertor extends ElementConvertor <ComputeEntity>{
+
+ @Override
+ public ComputeEntity convert( Element element) {
+ ComputeEntity computeEntity = new ComputeEntity();
+
+ computeEntity.setId(element.getElementId().getValue());
+ computeEntity.setCompositionData(new String(FileUtils.toByteArray(element.getData())));
+ mapInfoToComputeEntity(computeEntity,element.getInfo());
+ return computeEntity;
+ }
+
+ @Override
+ public ComputeEntity convert( ElementInfo elementInfo) {
+ ComputeEntity computeEntity = new ComputeEntity();
+
+ computeEntity.setId(elementInfo.getId().getValue());
+ mapInfoToComputeEntity(computeEntity,elementInfo.getInfo());
+ return computeEntity;
+ }
+
+
+ public void mapInfoToComputeEntity(ComputeEntity computeEntity,Info info){
+
+
+ computeEntity.setCompositionData(
+ info.getProperty(ElementPropertyName.compositionData.name()));
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComputeQuestionnaireConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComputeQuestionnaireConvertor.java
new file mode 100644
index 0000000..7ac2576
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToComputeQuestionnaireConvertor.java
@@ -0,0 +1,19 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
+
+public class ElementToComputeQuestionnaireConvertor extends ElementConvertor <ComputeEntity>{
+
+ @Override
+ public ComputeEntity convert( Element element) {
+ ComputeEntity computeEntity = new ComputeEntity();
+
+ computeEntity.setId(element.getElementId().getValue());
+ computeEntity.setQuestionnaireData(new String(FileUtils.toByteArray(element.getData())));
+ return computeEntity;
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToDeploymentFlavorConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToDeploymentFlavorConvertor.java
new file mode 100644
index 0000000..48265bf
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToDeploymentFlavorConvertor.java
@@ -0,0 +1,40 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.item.Info;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
+import org.openecomp.types.ElementPropertyName;
+
+public class ElementToDeploymentFlavorConvertor extends ElementConvertor <DeploymentFlavorEntity>{
+
+ @Override
+ public DeploymentFlavorEntity convert( Element element) {
+ DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity();
+
+ deploymentFlavorEntity.setId(element.getElementId().getValue());
+ deploymentFlavorEntity.setCompositionData(new String(FileUtils.toByteArray(element.getData())));
+ mapInfoToDeploymentFlavorEntity(deploymentFlavorEntity,element.getInfo());
+ return deploymentFlavorEntity;
+ }
+
+ @Override
+ public DeploymentFlavorEntity convert( ElementInfo elementInfo) {
+ DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity();
+
+ deploymentFlavorEntity.setId(elementInfo.getId().getValue());
+ mapInfoToDeploymentFlavorEntity(deploymentFlavorEntity,elementInfo.getInfo());
+ return deploymentFlavorEntity;
+ }
+
+
+ public void mapInfoToDeploymentFlavorEntity(DeploymentFlavorEntity deploymentFlavorEntity,Info info){
+
+
+ deploymentFlavorEntity.setCompositionData(
+ info.getProperty(ElementPropertyName.compositionData.name()));
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToImageConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToImageConvertor.java
new file mode 100644
index 0000000..8aa59c5
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToImageConvertor.java
@@ -0,0 +1,40 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.item.Info;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
+import org.openecomp.types.ElementPropertyName;
+
+public class ElementToImageConvertor extends ElementConvertor <ImageEntity>{
+
+ @Override
+ public ImageEntity convert( Element element) {
+ ImageEntity imageEntity = new ImageEntity();
+
+ imageEntity.setId(element.getElementId().getValue());
+ imageEntity.setCompositionData(new String(FileUtils.toByteArray(element.getData())));
+ mapInfoToImageEntity(imageEntity,element.getInfo());
+ return imageEntity;
+ }
+
+ @Override
+ public ImageEntity convert( ElementInfo elementInfo) {
+ ImageEntity imageEntity = new ImageEntity();
+
+ imageEntity.setId(elementInfo.getId().getValue());
+ mapInfoToImageEntity(imageEntity,elementInfo.getInfo());
+ return imageEntity;
+ }
+
+
+ public void mapInfoToImageEntity(ImageEntity imageEntity,Info info){
+
+
+ imageEntity.setCompositionData(
+ info.getProperty(ElementPropertyName.compositionData.name()));
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToImageQuestionnaireConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToImageQuestionnaireConvertor.java
new file mode 100644
index 0000000..2e9cfa0
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToImageQuestionnaireConvertor.java
@@ -0,0 +1,19 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
+
+public class ElementToImageQuestionnaireConvertor extends ElementConvertor <ImageEntity>{
+
+ @Override
+ public ImageEntity convert( Element element) {
+ ImageEntity imageEntity = new ImageEntity();
+
+ imageEntity.setId(element.getElementId().getValue());
+ imageEntity.setQuestionnaireData(new String(FileUtils.toByteArray(element.getData())));
+ return imageEntity;
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToMonitoringUploadMapConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToMonitoringUploadMapConvertor.java
new file mode 100644
index 0000000..5da9dc4
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToMonitoringUploadMapConvertor.java
@@ -0,0 +1,23 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import org.openecomp.convertor.ElementConvertor;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToProcessConvertor.ARTIFACT_NAME;
+
+/**
+ * Created by ayalaben on 9/5/2017.
+ */
+
+public class ElementToMonitoringUploadMapConvertor extends ElementConvertor<Map<String ,String>> {
+
+ @Override
+ public Map<String ,String> convert(Element element) {
+ HashMap<String,String> map = new HashMap<>();
+ map.put("File Name",element.getInfo().getProperty(ARTIFACT_NAME));
+ return map;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNetworkConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNetworkConvertor.java
new file mode 100644
index 0000000..6ce2416
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNetworkConvertor.java
@@ -0,0 +1,38 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.item.Info;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity;
+import org.openecomp.types.ElementPropertyName;
+
+public class ElementToNetworkConvertor extends ElementConvertor <NetworkEntity>{
+
+ @Override
+ public NetworkEntity convert( Element element) {
+ NetworkEntity networkEntity = new NetworkEntity();
+
+ networkEntity.setId(element.getElementId().getValue());
+ networkEntity.setCompositionData(new String(FileUtils.toByteArray(element.getData())));
+ mapInfoToNetworkEntity(networkEntity,element.getInfo());
+ return networkEntity;
+ }
+
+ @Override
+ public NetworkEntity convert( ElementInfo elementInfo) {
+ NetworkEntity networkEntity = new NetworkEntity();
+
+ networkEntity.setId(elementInfo.getId().getValue());
+ mapInfoToNetworkEntity(networkEntity,elementInfo.getInfo());
+ return networkEntity;
+ }
+
+
+ public void mapInfoToNetworkEntity(NetworkEntity networkEntity,Info info){
+ networkEntity.setCompositionData(
+ info.getProperty(ElementPropertyName.compositionData.name()));
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNicConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNicConvertor.java
new file mode 100644
index 0000000..33788af
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNicConvertor.java
@@ -0,0 +1,39 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.item.Info;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
+import org.openecomp.types.ElementPropertyName;
+
+public class ElementToNicConvertor extends ElementConvertor <NicEntity>{
+
+ @Override
+ public NicEntity convert( Element element) {
+ NicEntity nicEntity = new NicEntity();
+
+ nicEntity.setId(element.getElementId().getValue());
+ nicEntity.setCompositionData(new String(FileUtils.toByteArray(element.getData())));
+ mapInfoToNicEntity(nicEntity,element.getInfo());
+ return nicEntity;
+ }
+
+ @Override
+ public NicEntity convert( ElementInfo elementInfo) {
+ NicEntity nicEntity = new NicEntity();
+
+ nicEntity.setId(elementInfo.getId().getValue());
+ mapInfoToNicEntity(nicEntity,elementInfo.getInfo());
+ return nicEntity;
+ }
+
+
+ public void mapInfoToNicEntity(NicEntity nicEntity,Info info){
+
+ nicEntity.setCompositionData(
+ info.getProperty(ElementPropertyName.compositionData.name()));
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNicQuestionnaireConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNicQuestionnaireConvertor.java
new file mode 100644
index 0000000..ff53153
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToNicQuestionnaireConvertor.java
@@ -0,0 +1,21 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
+
+public class ElementToNicQuestionnaireConvertor extends ElementConvertor <NicEntity>{
+
+ @Override
+ public NicEntity convert( Element element) {
+ NicEntity nicEntity = new NicEntity();
+
+ nicEntity.setId(element.getElementId().getValue());
+ nicEntity.setQuestionnaireData( element.getData() == null
+ ? null
+ : new String(FileUtils.toByteArray(element.getData())));
+ return nicEntity;
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToOrchestrationTemplateCandidateMapConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToOrchestrationTemplateCandidateMapConvertor.java
new file mode 100644
index 0000000..b07df95
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToOrchestrationTemplateCandidateMapConvertor.java
@@ -0,0 +1,20 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure;
+
+/**
+ * Created by ayalaben on 9/6/2017
+ */
+public class ElementToOrchestrationTemplateCandidateMapConvertor
+ extends ElementConvertor<FilesDataStructure> {
+
+ @Override
+ public FilesDataStructure convert(Element element) {
+ return JsonUtil.json2Object(new String(FileUtils.toByteArray(element.getData())),
+ FilesDataStructure.class);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToProcessConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToProcessConvertor.java
new file mode 100644
index 0000000..5d3ebc3
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToProcessConvertor.java
@@ -0,0 +1,53 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.item.Info;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessType;
+
+import java.nio.ByteBuffer;
+
+public class ElementToProcessConvertor extends ElementConvertor<ProcessEntity> {
+
+ @Override
+ public ProcessEntity convert(Element element) {
+ if (element == null) {
+ return null;
+ }
+ ProcessEntity processEntity = new ProcessEntity();
+ processEntity.setId(element.getElementId().getValue());
+ processEntity.setArtifact(ByteBuffer.wrap(FileUtils.toByteArray(element.getData())));
+ mapInfoToProcessEntity(processEntity, element.getInfo());
+ return processEntity;
+ }
+
+ @Override
+ public ProcessEntity convert(ElementInfo elementInfo) {
+ if (elementInfo == null) {
+ return null;
+ }
+ ProcessEntity processEntity = new ProcessEntity();
+ processEntity.setId(elementInfo.getId().getValue());
+ mapInfoToProcessEntity(processEntity, elementInfo.getInfo());
+ return processEntity;
+ }
+
+
+ public void mapInfoToProcessEntity(ProcessEntity processEntity, Info info) {
+ processEntity.setName(info.getProperty(NAME));
+ processEntity.setArtifactName(info.getProperty(ARTIFACT_NAME));
+ processEntity.setDescription(info.getProperty(DESCRIPTION));
+ processEntity.setType(info.getProperty
+ (PROCESS_TYPE) != null ? ProcessType.valueOf(info.getProperty
+ (PROCESS_TYPE)) : null);
+ }
+
+
+ public static final String NAME = "name";
+ public static final String ARTIFACT_NAME = "artifactName";
+ public static final String DESCRIPTION = "description";
+ public static final String PROCESS_TYPE = "processType";
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToServiceModelMapConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToServiceModelMapConvertor.java
new file mode 100644
index 0000000..bb7e8bb
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToServiceModelMapConvertor.java
@@ -0,0 +1,20 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import org.openecomp.convertor.ElementConvertor;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Created by ayalaben on 9/11/2017
+ */
+public class ElementToServiceModelMapConvertor extends ElementConvertor<Map<String ,String>> {
+ @Override
+ public Map<String ,String> convert(Element element) {
+ //TODO : after merge with 1802 change to heat fle name/TOSCA file name
+ HashMap<String,String> map = new HashMap<>();
+ map.put("Service Model Definition Entry", element.getInfo().getProperty("base"));
+ return map;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToVSPGeneralConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToVSPGeneralConvertor.java
new file mode 100644
index 0000000..c5c2f91
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToVSPGeneralConvertor.java
@@ -0,0 +1,78 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.item.Info;
+import com.amdocs.zusammen.datatypes.item.Item;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.VendorSoftwareProductInfoDaoZusammenImpl;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+
+public class ElementToVSPGeneralConvertor extends ElementConvertor {
+ @Override
+ public VspDetails convert(Element element) {
+ if (element == null) {
+ return null;
+ }
+ return mapInfoToVspDetails(element.getInfo());
+
+ }
+
+ @Override
+ public VspDetails convert(Item item) {
+ if (item == null) {
+ return null;
+ }
+ VspDetails vspDetails = mapInfoToVspDetails(item.getInfo());
+ vspDetails.setId(item.getId().getValue());
+ return vspDetails;
+ }
+
+ @Override
+ public VspDetails convert(ElementInfo elementInfo) {
+ if (elementInfo == null) {
+ return null;
+ }
+ return mapInfoToVspDetails(elementInfo.getInfo());
+
+ }
+
+
+ private VspDetails mapInfoToVspDetails(Info info) {
+
+ VspDetails vspDetails = new VspDetails();
+
+ vspDetails.setName(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl
+ .InfoPropertyName.name.name()));
+ vspDetails.setDescription(info.getProperty(
+ VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.description.name()));
+ vspDetails.setIcon(info.getProperty(
+ VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.icon.name()));
+ vspDetails.setCategory(info.getProperty(
+ VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.category.name()));
+ vspDetails.setSubCategory(info.getProperty(
+ VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.subCategory.name()));
+ vspDetails.setVendorId(info.getProperty(
+ VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.vendorId.name()));
+ vspDetails.setVendorName(info.getProperty(
+ VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.vendorName.name()));
+ if (info.getProperty(
+ VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.vendorVersion.name()) != null) {
+ vspDetails.setVlmVersion(new Version(info.getProperty(
+ VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.vendorVersion.name())));
+ }
+
+ vspDetails.setLicenseAgreement(info.getProperty(
+ VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.licenseAgreement.name()));
+ vspDetails.setFeatureGroups(info.getProperty(
+ VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.featureGroups.name()));
+ vspDetails.setOnboardingMethod(info.getProperty(
+ VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.onboardingMethod.name()));
+
+ return vspDetails;
+ }
+
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToVSPQuestionnaireConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToVSPQuestionnaireConvertor.java
new file mode 100644
index 0000000..d51b8b2
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToVSPQuestionnaireConvertor.java
@@ -0,0 +1,17 @@
+package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.utils.fileutils.FileUtils;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspQuestionnaireEntity;
+
+public class ElementToVSPQuestionnaireConvertor extends ElementConvertor {
+ @Override
+ public VspQuestionnaireEntity convert( Element element) {
+ if(element == null) return null;
+ VspQuestionnaireEntity entity = new VspQuestionnaireEntity();
+ entity.setQuestionnaireData(new String(FileUtils.toByteArray(element.getData())));
+ return entity;
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java
index d3c2a22..b4c0d29 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java
@@ -60,9 +60,6 @@
public static final String SAME_SOURCE_TARGET_COMPONENT = "SAME_SOURCE_TARGET_COMPONENT";
- public static final String VSP_ONBOARD_METHOD_UPDATE_NOT_ALLOWED =
- "VSP_ONBOARD_METHOD_UPDATE_NOT_ALLOWED";
-
public static final String DUPLICATE_NIC_NAME_NOT_ALLOWED = "DUPLICATE_NIC_NAME_NOT_ALLOWED";
public static final String NIC_NAME_FORMAT_NOT_ALLOWED = "NIC_NAME_FORMAT_NOT_ALLOWED";
@@ -129,4 +126,7 @@
public static final String INVALID_EXTENSION = "INVALID_EXTENSION";
+ public static final String VSP_ONBOARD_METHOD_UPDATE_NOT_ALLOWED =
+ "VSP_ONBOARD_METHOD_UPDATE_NOT_ALLOWED";
+
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/CompositionEntityDataManagerFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/CompositionEntityDataManagerFactoryImpl.java
index a7e55bd..08d911b 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/CompositionEntityDataManagerFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/factory/impl/CompositionEntityDataManagerFactoryImpl.java
@@ -26,7 +26,6 @@
import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionEntityDataManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
@@ -42,9 +41,8 @@
ComponentDaoFactory.getInstance().createInterface(),
NicDaoFactory.getInstance().createInterface(),
NetworkDaoFactory.getInstance().createInterface(),
- ImageDaoFactory.getInstance().createInterface() ,
+ ImageDaoFactory.getInstance().createInterface(),
ComputeDaoFactory.getInstance().createInterface(),
- DeploymentFlavorDaoFactory.getInstance().createInterface(),
- VendorSoftwareProductDaoFactory.getInstance().createInterface());
+ DeploymentFlavorDaoFactory.getInstance().createInterface());
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/quiestionnaire/QuestionnaireDataServiceImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/quiestionnaire/QuestionnaireDataServiceImpl.java
index de29d5b..78914aa 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/quiestionnaire/QuestionnaireDataServiceImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/quiestionnaire/QuestionnaireDataServiceImpl.java
@@ -23,8 +23,10 @@
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
@@ -47,8 +49,9 @@
* Created by TALIO on 11/22/2016
*/
public class QuestionnaireDataServiceImpl implements QuestionnaireDataService {
- private static final VendorSoftwareProductDao vendorSoftwareProductDao =
- VendorSoftwareProductDaoFactory.getInstance().createInterface();
+ private static final ComponentDao componentDao =
+ ComponentDaoFactory.getInstance().createInterface();
+ private static final NicDao nicDao = NicDaoFactory.getInstance().createInterface();
private static final VendorSoftwareProductInfoDao vspInfoDao =
VendorSoftwareProductInfoDaoFactory.getInstance().createInterface();
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
@@ -56,15 +59,11 @@
public InformationArtifactData generateQuestionnaireDataForInformationArtifact(String vspId,
Version version) {
-
-
mdcDataDebugMessage.debugEntryMessage("VSP Id", vspId);
- VspDetails vspDetails =
- vspInfoDao.get(new VspDetails(vspId, version));
- Collection<ComponentEntity> componentEntities =
- vendorSoftwareProductDao.listComponentsQuestionnaire(vspId, version);
- Collection<NicEntity> nicEntities = vendorSoftwareProductDao.listNicsByVsp(vspId, version);
+ VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));
+ Collection<ComponentEntity> componentEntities = componentDao.listQuestionnaires(vspId, version);
+ Collection<NicEntity> nicEntities = nicDao.listByVsp(vspId, version);
VspQuestionnaire vspQuestionnaire = getVspQuestionnaireFromJson(vspId, version);
List<ComponentQuestionnaire> componentQuestionnaireList =
@@ -100,7 +99,6 @@
return componentQuestionnaireList;
}
-
private List<NicQuestionnaire> getListOfNicQuestionnaireFromJson(Collection<NicEntity> entities) {
List<NicQuestionnaire> nicQuestionnaireList = new ArrayList<>();
@@ -112,5 +110,4 @@
return nicQuestionnaireList;
}
-
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/ManualVspDataCollectionService.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/ManualVspDataCollectionService.java
index 1004258..73b9491 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/ManualVspDataCollectionService.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/ManualVspDataCollectionService.java
@@ -23,12 +23,12 @@
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
@@ -57,10 +57,10 @@
public class ManualVspDataCollectionService {
- private static final VendorSoftwareProductDao vendorSoftwareProductDao =
- VendorSoftwareProductDaoFactory.getInstance().createInterface();
private static final VendorSoftwareProductInfoDao vendorSoftwareProductInfoDao =
VendorSoftwareProductInfoDaoFactory.getInstance().createInterface();
+ private static final DeploymentFlavorDao deploymentFlavorDao =
+ DeploymentFlavorDaoFactory.getInstance().createInterface();
private static final ComputeDao computeDao =
ComputeDaoFactory.getInstance().createInterface();
private static final ImageDao imageDao =
@@ -75,16 +75,14 @@
private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
-
/**
* Gets vendor name for the vsp.
*
* @param vspId the vsp id
* @param version the version
- * @param user the user
* @return the release vendor name
*/
- public Optional<String> getReleaseVendor(String vspId, Version version, String user) {
+ public Optional<String> getReleaseVendor(String vspId, Version version) {
String vendorName = null;
VspDetails vspDetails = vendorSoftwareProductInfoDao.get(new VspDetails(vspId, version));
if (Objects.nonNull(vspDetails)) {
@@ -98,14 +96,12 @@
*
* @param vspId the vsp id
* @param version the version
- * @param user the user
* @return the allowed flavors
*/
- public Map<String, DeploymentFlavorModel> getAllowedFlavors(String vspId, Version version,
- String user) {
+ public Map<String, DeploymentFlavorModel> getAllowedFlavors(String vspId, Version version) {
Map<String, DeploymentFlavorModel> allowedFlavors = new HashMap<>();
Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
- vendorSoftwareProductDao.listDeploymentFlavors(vspId, version);
+ deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null));
if (CollectionUtils.isNotEmpty(deploymentFlavorEntities)) {
for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) {
DeploymentFlavor deploymentFlavorCompositionData =
@@ -129,13 +125,12 @@
LicenseFlavor licenseFlavor = getLicenseFlavor(featureGroupId);
deploymentFlavorModel.setLicense_flavor(licenseFlavor);
//Get sp_part_number
- Optional<String> partNumber = getPartNumber(vspVlmId, vlmVersion, featureGroupId,
- user);
+ Optional<String> partNumber = getPartNumber(vspVlmId, vlmVersion, featureGroupId);
partNumber.ifPresent(deploymentFlavorModel::setSp_part_number);
//Gather and set Vendor Info
String vendorModel = deploymentFlavorCompositionData.getModel();
Optional<VendorInfo> vendorInfo = getVendorInfo(vspVlmId, vendorModel, vlmVersion,
- featureGroupId, user);
+ featureGroupId);
vendorInfo.ifPresent(deploymentFlavorModel::setVendor_info);
//Gather and set Compute info
List<ComponentComputeAssociation> componentComputeAssociations =
@@ -146,7 +141,7 @@
String componentId = componentComputeAssociation.getComponentId();
String computeFlavorId = componentComputeAssociation.getComputeFlavorId();
Optional<ComputeFlavor> computeFlavor =
- getComputeFlavor(vspId, version, componentId, computeFlavorId, user);
+ getComputeFlavor(vspId, version, componentId, computeFlavorId);
computeFlavor.ifPresent(deploymentFlavorModel::setCompute_flavor);
}
}
@@ -164,15 +159,13 @@
*
* @param vspId the vsp id
* @param version the version
- * @param user the user
* @return the vsp component images
*/
public Map<String, List<MultiFlavorVfcImage>> getVspComponentImages(String vspId,
- Version version,
- String user) {
+ Version version) {
Map<String, List<MultiFlavorVfcImage>> vspComponentImages = new HashMap<>();
Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
- vendorSoftwareProductDao.listDeploymentFlavors(vspId, version);
+ deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null));
for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) {
DeploymentFlavor deploymentFlavorCompositionData =
deploymentFlavorEntity.getDeploymentFlavorCompositionData();
@@ -184,7 +177,7 @@
componentComputeAssociations) {
String componentId = componentComputeAssociation.getComponentId();
List<MultiFlavorVfcImage> componentImages =
- getComponentImages(vspId, version, componentId, user);
+ getComponentImages(vspId, version, componentId);
if (CollectionUtils.isNotEmpty(componentImages)) {
vspComponentImages.put(componentId, componentImages);
}
@@ -199,13 +192,12 @@
*
* @param vspId the vsp id
* @param version the version
- * @param user the user
* @return the vsp components
*/
- public Map<String, String> getVspComponents(String vspId, Version version, String user) {
+ public Map<String, String> getVspComponents(String vspId, Version version) {
Map<String, String> componentIdNameMap = new HashMap<>();
Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
- vendorSoftwareProductDao.listDeploymentFlavors(vspId, version);
+ deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null));
for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) {
DeploymentFlavor deploymentFlavorCompositionData =
deploymentFlavorEntity.getDeploymentFlavorCompositionData();
@@ -216,7 +208,7 @@
for (ComponentComputeAssociation componentComputeAssociation :
componentComputeAssociations) {
String componentId = componentComputeAssociation.getComponentId();
- Optional<String> componentName = getComponentName(vspId, version, componentId, user);
+ Optional<String> componentName = getComponentName(vspId, version, componentId);
componentName.ifPresent(name -> componentIdNameMap.put(componentId, name));
}
}
@@ -229,13 +221,12 @@
*
* @param vspId the vsp id
* @param version the version
- * @param user the user
* @return the vsp component nics
*/
- public Map<String, List<Nic>> getVspComponentNics(String vspId, Version version, String user) {
+ public Map<String, List<Nic>> getVspComponentNics(String vspId, Version version) {
Map<String, List<Nic>> vspComponentNics = new HashMap<>();
Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
- vendorSoftwareProductDao.listDeploymentFlavors(vspId, version);
+ deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null));
if (CollectionUtils.isNotEmpty(deploymentFlavorEntities)) {
for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) {
DeploymentFlavor deploymentFlavorCompositionData =
@@ -247,7 +238,7 @@
for (ComponentComputeAssociation componentComputeAssociation :
componentComputeAssociations) {
String componentId = componentComputeAssociation.getComponentId();
- List<Nic> componentNics = getComponentNics(vspId, version, componentId, user);
+ List<Nic> componentNics = getComponentNics(vspId, version, componentId);
if (CollectionUtils.isNotEmpty(componentNics)) {
vspComponentNics.put(componentId, componentNics);
}
@@ -259,8 +250,7 @@
return vspComponentNics;
}
- private List<Nic> getComponentNics(String vspId, Version version, String componentId,
- String user) {
+ private List<Nic> getComponentNics(String vspId, Version version, String componentId) {
List<Nic> componentNics = new ArrayList<>();
Collection<NicEntity> nics = nicDao.list(new NicEntity(vspId, version, componentId, null));
if (Objects.nonNull(nics)) {
@@ -283,8 +273,8 @@
}
private Optional<String> getPartNumber(String vlmId, Version version,
- String featureGroupId, String user) {
- FeatureGroupModel featureGroup = getFeatureGroup(vlmId, version, featureGroupId, user);
+ String featureGroupId) {
+ FeatureGroupModel featureGroup = getFeatureGroup(vlmId, version, featureGroupId);
if (Objects.nonNull(featureGroup)) {
return Optional.ofNullable(featureGroup.getFeatureGroup().getPartNumber());
}
@@ -292,9 +282,9 @@
}
private Optional<VendorInfo> getVendorInfo(String vlmId, String vendorModel, Version version,
- String featureGroupId, String user) {
+ String featureGroupId) {
VendorInfo vendorInfo = null;
- FeatureGroupModel featureGroup = getFeatureGroup(vlmId, version, featureGroupId, user);
+ FeatureGroupModel featureGroup = getFeatureGroup(vlmId, version, featureGroupId);
if (Objects.nonNull(featureGroup)) {
//Process Feature group to get Manufacturer ref no.
String manufacturerReferenceNumber = featureGroup.getEntityManufacturerReferenceNumber();
@@ -308,29 +298,28 @@
}
private Optional<ComputeFlavor> getComputeFlavor(String vspId, Version version,
- String componentId, String computeFlavorId,
- String user) {
+ String componentId, String computeFlavorId) {
ComputeFlavor computeFlavor = null;
ComputeEntity computeQuestionnaire = null;
try {
computeQuestionnaire = computeDao.getQuestionnaireData(vspId, version, componentId,
computeFlavorId);
} catch (Exception ex) {
- log.debug("",ex);
+ log.debug("", ex);
computeQuestionnaire = null;
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
LoggerTragetServiceName.COLLECT_MANUAL_VSP_TOSCA_DATA, ErrorLevel.INFO.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), "Failed to get compute questionnaire : "
+ ex.getMessage());
}
- if (computeQuestionnaire != null && Objects.nonNull(computeQuestionnaire)) {
+ if (Objects.nonNull(computeQuestionnaire)) {
String computeQuestionnaireData = computeQuestionnaire.getQuestionnaireData();
if (Objects.nonNull(computeQuestionnaireData)) {
Compute compute;
try {
compute = JsonUtil.json2Object(computeQuestionnaireData, Compute.class);
} catch (Exception ex) {
- log.debug("",ex);
+ log.debug("", ex);
compute = null;
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
LoggerTragetServiceName.COLLECT_MANUAL_VSP_TOSCA_DATA, ErrorLevel.INFO.name(),
@@ -354,17 +343,15 @@
return Optional.ofNullable(computeFlavor);
}
- private FeatureGroupModel getFeatureGroup(String vlmId, Version version, String featureGroupId,
- String user) {
+ private FeatureGroupModel getFeatureGroup(String vlmId, Version version, String featureGroupId) {
FeatureGroupEntity fgInput = new FeatureGroupEntity();
fgInput.setVendorLicenseModelId(vlmId);
fgInput.setVersion(version);
fgInput.setId(featureGroupId);
- return vendorLicenseFacade.getFeatureGroupModel(fgInput, user);
+ return vendorLicenseFacade.getFeatureGroupModel(fgInput);
}
- private Optional<String> getComponentName(String vspId, Version version, String componentId,
- String user) {
+ private Optional<String> getComponentName(String vspId, Version version, String componentId) {
ComponentEntity componentEntity =
componentDao.get(new ComponentEntity(vspId, version, componentId));
@@ -377,18 +364,16 @@
}
private List<MultiFlavorVfcImage> getComponentImages(String vspId, Version version,
- String componentId, String user) {
+ String componentId) {
List<MultiFlavorVfcImage> multiFlavorVfcImages = new ArrayList<>();
- MultiFlavorVfcImage multiFlavorVfcImage = null;
+ MultiFlavorVfcImage multiFlavorVfcImage;
Collection<ImageEntity> componentImages =
- vendorSoftwareProductDao.listImages(vspId, version, componentId);
+ imageDao.list(new ImageEntity(vspId, version, componentId, null));
if (Objects.nonNull(componentImages)) {
for (ImageEntity componentImage : componentImages) {
- String imageId = componentImage.getId();
- ImageEntity imageEntity = vendorSoftwareProductDao.getImage(vspId, version, componentId,
- imageId);
+ ImageEntity imageEntity = imageDao.get(componentImage);
ImageEntity imageQuestionnaireDataEntity = imageDao.getQuestionnaireData(vspId, version,
- componentId, imageId);
+ componentId, componentImage.getId());
Image imageCompositionData = imageEntity.getImageCompositionData();
if (Objects.nonNull(imageEntity)
&& Objects.nonNull(imageQuestionnaireDataEntity)
@@ -398,14 +383,14 @@
imageDetails = JsonUtil.json2Object(imageQuestionnaireDataEntity
.getQuestionnaireData(), ImageDetails.class);
} catch (Exception ex) {
- log.debug("",ex);
+ log.debug("", ex);
imageDetails = null;
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
LoggerTragetServiceName.COLLECT_MANUAL_VSP_TOSCA_DATA, ErrorLevel.INFO.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), "Unable to parse image questionnaire : "
+ ex.getMessage());
}
- if (imageDetails != null && Objects.nonNull(imageDetails)
+ if (Objects.nonNull(imageDetails)
&& Objects.nonNull(imageDetails.getVersion())) {
//Image version is used as a key for the image block
//So excluding the population if questionnaire data is absent or invalid
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImpl.java
index 19e48ec..6b57649 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImpl.java
@@ -47,8 +47,8 @@
import org.openecomp.sdc.tosca.errors.ToscaMissingSubstitutionMappingForReqCapErrorBuilder;
import org.openecomp.sdc.tosca.services.ToscaAnalyzerService;
import org.openecomp.sdc.tosca.services.ToscaConstants;
-import org.openecomp.sdc.tosca.services.impl.ToscaAnalyzerServiceImpl;
import org.openecomp.sdc.tosca.services.ToscaExtensionYamlUtil;
+import org.openecomp.sdc.tosca.services.impl.ToscaAnalyzerServiceImpl;
import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionDataExtractor;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Component;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData;
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionEntityDataManagerImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionEntityDataManagerImpl.java
index 39534cf..ab5ee6c 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionEntityDataManagerImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionEntityDataManagerImpl.java
@@ -37,7 +37,6 @@
import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.CompositionEntity;
@@ -78,14 +77,14 @@
public class CompositionEntityDataManagerImpl implements CompositionEntityDataManager {
private static final String COMPOSITION_ENTITY_DATA_MANAGER_ERR =
- "COMPOSITION_ENTITY_DATA_MANAGER_ERR";
+ "COMPOSITION_ENTITY_DATA_MANAGER_ERR";
private static final String COMPOSITION_ENTITY_DATA_MANAGER_ERR_MSG =
- "Invalid input: %s may not be null";
+ "Invalid input: %s may not be null";
private static final String MISSING_OR_INVALID_QUESTIONNAIRE_MSG =
"Data is missing/invalid for this %s. Please refill and resubmit.";
private static final Logger logger =
- LoggerFactory.getLogger(CompositionEntityDataManagerImpl.class);
+ LoggerFactory.getLogger(CompositionEntityDataManagerImpl.class);
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
private Map<CompositionEntityId, CompositionEntityData> entities = new HashMap<>();
@@ -99,14 +98,12 @@
private ImageDao imageDao;
private ComputeDao computeDao;
private DeploymentFlavorDao deploymentFlavorDao;
- private VendorSoftwareProductDao vendorSoftwareProductDao;
public CompositionEntityDataManagerImpl(VendorSoftwareProductInfoDao vspInfoDao,
ComponentDao componentDao,
NicDao nicDao, NetworkDao networkDao,
ImageDao imageDao, ComputeDao computeDao,
- DeploymentFlavorDao deploymentFlavorDao,
- VendorSoftwareProductDao vendorSoftwareProductDao) {
+ DeploymentFlavorDao deploymentFlavorDao) {
this.vspInfoDao = vspInfoDao;
this.componentDao = componentDao;
this.nicDao = nicDao;
@@ -114,7 +111,6 @@
this.imageDao = imageDao;
this.computeDao = computeDao;
this.deploymentFlavorDao = deploymentFlavorDao;
- this.vendorSoftwareProductDao = vendorSoftwareProductDao;
}
/**
@@ -133,27 +129,27 @@
if (entity == null) {
throw new CoreException(
- new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
- .withId(COMPOSITION_ENTITY_DATA_MANAGER_ERR).withMessage(
- String.format(COMPOSITION_ENTITY_DATA_MANAGER_ERR_MSG, "composition entity"))
- .build());
+ new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
+ .withId(COMPOSITION_ENTITY_DATA_MANAGER_ERR).withMessage(
+ String.format(COMPOSITION_ENTITY_DATA_MANAGER_ERR_MSG, "composition entity"))
+ .build());
}
if (schemaTemplateContext == null) {
throw new CoreException(
- new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
- .withId(COMPOSITION_ENTITY_DATA_MANAGER_ERR).withMessage(
- String.format(COMPOSITION_ENTITY_DATA_MANAGER_ERR_MSG, "schema template context"))
- .build());
+ new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
+ .withId(COMPOSITION_ENTITY_DATA_MANAGER_ERR).withMessage(
+ String.format(COMPOSITION_ENTITY_DATA_MANAGER_ERR_MSG, "schema template context"))
+ .build());
}
CompositionEntityValidationData validationData =
- new CompositionEntityValidationData(entity.getType(), entity.getId());
+ new CompositionEntityValidationData(entity.getType(), entity.getId());
String json =
- schemaTemplateContext == SchemaTemplateContext.composition ? entity.getCompositionData()
- : entity.getQuestionnaireData();
+ schemaTemplateContext == SchemaTemplateContext.composition ? entity.getCompositionData()
+ : entity.getQuestionnaireData();
validationData.setErrors(JsonUtil.validate(
- json == null ? JsonUtil.object2Json(new Object()) : json,
- generateSchema(schemaTemplateContext, entity.getType(), schemaTemplateInput)));
+ json == null ? JsonUtil.object2Json(new Object()) : json,
+ generateSchema(schemaTemplateContext, entity.getType(), schemaTemplateInput)));
mdcDataDebugMessage.debugExitMessage(null);
return validationData;
@@ -169,13 +165,13 @@
public void addEntity(CompositionEntity entity, SchemaTemplateInput schemaTemplateInput) {
if (entity == null) {
throw new CoreException(
- new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
- .withId(COMPOSITION_ENTITY_DATA_MANAGER_ERR).withMessage(
- String.format(COMPOSITION_ENTITY_DATA_MANAGER_ERR_MSG, "composition entity"))
- .build());
+ new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
+ .withId(COMPOSITION_ENTITY_DATA_MANAGER_ERR).withMessage(
+ String.format(COMPOSITION_ENTITY_DATA_MANAGER_ERR_MSG, "composition entity"))
+ .build());
}
entities.put(entity.getCompositionEntityId(),
- new CompositionEntityData(entity, schemaTemplateInput));
+ new CompositionEntityData(entity, schemaTemplateInput));
}
/**
@@ -205,10 +201,10 @@
@Override
public void buildTrees() {
Map<CompositionEntityId, CompositionEntityValidationData> entitiesValidationData =
- new HashMap<>();
+ new HashMap<>();
entities.entrySet().forEach(
- entry -> addValidationDataEntity(entitiesValidationData, entry.getKey(),
- entry.getValue().entity));
+ entry -> addValidationDataEntity(entitiesValidationData, entry.getKey(),
+ entry.getValue().entity));
}
public Collection<CompositionEntityValidationData> getTrees() {
@@ -259,14 +255,14 @@
}
Collection<CompositionEntityValidationData> subEntitiesValidationData =
- entity.getSubEntitiesValidationData();
+ entity.getSubEntitiesValidationData();
return !CollectionUtils.isEmpty(subEntitiesValidationData) &&
- checkForErrorsInChildren(subEntitiesValidationData);
+ checkForErrorsInChildren(subEntitiesValidationData);
}
private boolean checkForErrorsInChildren(
- Collection<CompositionEntityValidationData> subEntitiesValidationData) {
+ Collection<CompositionEntityValidationData> subEntitiesValidationData) {
boolean result = false;
for (CompositionEntityValidationData subEntity : subEntitiesValidationData) {
if (CollectionUtils.isNotEmpty(subEntity.getErrors())) {
@@ -360,10 +356,10 @@
//component.setId(CommonMethods.nextUuId()); will be set by the dao
component.setQuestionnaireData(
- new JsonSchemaDataGenerator(
- generateSchema(SchemaTemplateContext.questionnaire, CompositionEntityType.component,
- null))
- .generateData());
+ new JsonSchemaDataGenerator(
+ generateSchema(SchemaTemplateContext.questionnaire, CompositionEntityType.component,
+ null))
+ .generateData());
componentDao.create(component);
@@ -377,9 +373,9 @@
//nic.setId(CommonMethods.nextUuId()); will be set by the dao
nic.setQuestionnaireData(
- new JsonSchemaDataGenerator(
- generateSchema(SchemaTemplateContext.questionnaire, CompositionEntityType.nic, null))
- .generateData());
+ new JsonSchemaDataGenerator(
+ generateSchema(SchemaTemplateContext.questionnaire, CompositionEntityType.nic, null))
+ .generateData());
nicDao.create(nic);
@@ -412,28 +408,26 @@
return treeAsList;
}
- public void getEntityListWithErrors(CompositionEntityValidationData entity,
+ private void getEntityListWithErrors(CompositionEntityValidationData entity,
Set<CompositionEntityValidationData> compositionSet) {
- Collection<CompositionEntityValidationData> childNodes =
- entity.getSubEntitiesValidationData();
+ if(CollectionUtils.isNotEmpty(entity.getErrors())){
+ addNodeWithErrors(entity, compositionSet);
+ }
- if (CollectionUtils.isEmpty(childNodes)) {
+ if (CollectionUtils.isEmpty(entity.getSubEntitiesValidationData())) {
return;
}
- for (CompositionEntityValidationData child : childNodes) {
- if (CollectionUtils.isNotEmpty(child.getErrors())) {
- addNodeWithErrors(child, compositionSet);
- }
+ for (CompositionEntityValidationData child : entity.getSubEntitiesValidationData()) {
getEntityListWithErrors(child, compositionSet);
}
}
- public void addNodeWithErrors(CompositionEntityValidationData node,
+ private void addNodeWithErrors(CompositionEntityValidationData node,
Set<CompositionEntityValidationData> entitiesWithErrors) {
CompositionEntityValidationData compositionNodeToAdd = new CompositionEntityValidationData(node
- .getEntityType(), node.getEntityId());
+ .getEntityType(), node.getEntityId());
compositionNodeToAdd.setErrors(node.getErrors());
compositionNodeToAdd.setSubEntitiesValidationData(null);
@@ -446,9 +440,9 @@
private CompositionEntityData getCompositionEntityDataById(CompositionEntityValidationData
- entity) {
+ entity) {
for (Map.Entry<CompositionEntityId, CompositionEntityData> entityEntry : entities
- .entrySet()) {
+ .entrySet()) {
if (entityEntry.getKey().getId().equals(entity.getEntityId())) {
return entityEntry.getValue();
}
@@ -458,11 +452,11 @@
private void updateValidationCompositionEntityName(Set<CompositionEntityValidationData>
- compositionSet) {
+ compositionSet) {
for (CompositionEntityValidationData entity : compositionSet) {
String compositionData = getCompositionDataAsString(entity);
if (entity.getEntityType().equals(CompositionEntityType.vsp) ||
- Objects.nonNull(compositionData)) {
+ Objects.nonNull(compositionData)) {
entity.setEntityName(getEntityNameByEntityType(compositionData, entity));
}
}
@@ -497,8 +491,8 @@
CompositionEntityData vspEntity = getCompositionEntityDataById(entity);
VspQuestionnaireEntity vspQuestionnaireEntity = (VspQuestionnaireEntity) vspEntity.entity;
VspDetails vspDetails =
- vspInfoDao.get(new VspDetails(vspQuestionnaireEntity.getId(),
- vspQuestionnaireEntity.getVersion()));
+ vspInfoDao.get(new VspDetails(vspQuestionnaireEntity.getId(),
+ vspQuestionnaireEntity.getVersion()));
return vspDetails.getName();
}
@@ -514,7 +508,7 @@
if (hasChildren(node)) {
Collection<CompositionEntityValidationData> subNodes =
- new ArrayList<>(node.getSubEntitiesValidationData());
+ new ArrayList<>(node.getSubEntitiesValidationData());
subNodes.forEach(subNode -> removeNodesWithoutErrors(subNode, node));
node.setSubEntitiesValidationData(subNodes);
@@ -543,14 +537,14 @@
private void addValidationDataEntity(
- Map<CompositionEntityId, CompositionEntityValidationData> entitiesValidationData,
- CompositionEntityId entityId, CompositionEntity entity) {
+ Map<CompositionEntityId, CompositionEntityValidationData> entitiesValidationData,
+ CompositionEntityId entityId, CompositionEntity entity) {
if (entitiesValidationData.containsKey(entityId)) {
return;
}
CompositionEntityValidationData validationData =
- new CompositionEntityValidationData(entity.getType(), entity.getId());
+ new CompositionEntityValidationData(entity.getType(), entity.getId());
entitiesValidationData.put(entityId, validationData);
CompositionEntityId parentEntityId = entityId.getParentId();
@@ -578,16 +572,16 @@
if (node.getSubEntitiesValidationData() != null) {
node.getSubEntitiesValidationData()
- .forEach(subNode -> addErrorsToTree(subNode, nodeId, errors));
+ .forEach(subNode -> addErrorsToTree(subNode, nodeId, errors));
}
}
private Collection<String> validateQuestionnaire(CompositionEntityData compositionEntityData) {
logger.debug(String.format("validateQuestionnaire start: " +
- "[entity.type]=%s, [entity.id]=%s, [entity.questionnaireString]=%s",
- compositionEntityData.entity.getType().name(),
- compositionEntityData.entity.getCompositionEntityId().toString(),
- compositionEntityData.entity.getQuestionnaireData()));
+ "[entity.type]=%s, [entity.id]=%s, [entity.questionnaireString]=%s",
+ compositionEntityData.entity.getType().name(),
+ compositionEntityData.entity.getCompositionEntityId().toString(),
+ compositionEntityData.entity.getQuestionnaireData()));
if (Objects.isNull(compositionEntityData.entity.getQuestionnaireData()) ||
!JsonUtil.isValidJson(compositionEntityData.entity.getQuestionnaireData())) {
@@ -596,20 +590,20 @@
}
return JsonUtil.validate(
- compositionEntityData.entity.getQuestionnaireData() == null
- ? JsonUtil.object2Json(new Object())
- : compositionEntityData.entity.getQuestionnaireData(),
- getSchema(compositionEntityData.entity.getType(), SchemaTemplateContext.questionnaire,
- compositionEntityData.schemaTemplateInput));
+ compositionEntityData.entity.getQuestionnaireData() == null
+ ? JsonUtil.object2Json(new Object())
+ : compositionEntityData.entity.getQuestionnaireData(),
+ getSchema(compositionEntityData.entity.getType(), SchemaTemplateContext.questionnaire,
+ compositionEntityData.schemaTemplateInput));
}
private String getSchema(CompositionEntityType compositionEntityType,
SchemaTemplateContext schemaTemplateContext,
SchemaTemplateInput schemaTemplateInput) {
return schemaTemplateInput == null
- ? nonDynamicSchemas.computeIfAbsent(compositionEntityType,
- k -> generateSchema(schemaTemplateContext, compositionEntityType, null))
- : generateSchema(schemaTemplateContext, compositionEntityType, schemaTemplateInput);
+ ? nonDynamicSchemas.computeIfAbsent(compositionEntityType,
+ k -> generateSchema(schemaTemplateContext, compositionEntityType, null))
+ : generateSchema(schemaTemplateContext, compositionEntityType, schemaTemplateInput);
}
private static class CompositionEntityData {
@@ -630,7 +624,7 @@
CompositionEntityType compositionEntityType,
SchemaTemplateInput schemaTemplateInput) {
return SchemaGenerator
- .generate(schemaTemplateContext, compositionEntityType, schemaTemplateInput);
+ .generate(schemaTemplateContext, compositionEntityType, schemaTemplateInput);
}
@Override
@@ -649,46 +643,33 @@
image.setId(CommonMethods.nextUuId());
image.setQuestionnaireData(
- new JsonSchemaDataGenerator(SchemaGenerator
- .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.image, null))
- .generateData());
+ new JsonSchemaDataGenerator(SchemaGenerator
+ .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.image, null))
+ .generateData());
imageDao.create(image);
mdcDataDebugMessage.debugExitMessage(null, null);
return image;
}
- @Override
- public ComputeEntity createCompute(ComputeEntity compute) {
- mdcDataDebugMessage.debugEntryMessage("VSP id, component id", compute.getVspId(),
- compute.getComponentId());
-
- compute.setId(CommonMethods.nextUuId());
- compute.setQuestionnaireData(
- new JsonSchemaDataGenerator(SchemaGenerator
- .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.compute,
- null)).generateData());
-
- computeDao.create(compute);
-
- mdcDataDebugMessage.debugExitMessage("VSP id, component id", compute.getVspId(),
- compute.getComponentId());
- return compute;
- }
-
public void saveComputesFlavorByComponent(String vspId, Version version, Component component,
String componentId) {
if (CollectionUtils.isNotEmpty(component.getCompute())) {
for (ComputeData flavor : component.getCompute()) {
ComputeEntity computeEntity = new ComputeEntity(vspId, version, componentId, null);
computeEntity.setComputeCompositionData(flavor);
- createCompute(computeEntity);
+ computeEntity.setQuestionnaireData(
+ new JsonSchemaDataGenerator(SchemaGenerator
+ .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.compute,
+ null)).generateData());
+
+ computeDao.create(computeEntity);
}
}
}
public void saveImagesByComponent(String vspId, Version version, Component component, String
- componentId) {
+ componentId) {
if (CollectionUtils.isNotEmpty(component.getImages())) {
for (Image img : component.getImages()) {
ImageEntity imageEntity = new ImageEntity(vspId, version, componentId, null);
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java
index 640777e..45746ed 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java
@@ -72,577 +72,591 @@
import java.util.zip.ZipOutputStream;
public class CandidateServiceImpl implements CandidateService {
- protected static final Logger logger = LoggerFactory.getLogger(CandidateServiceImpl.class);
- private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ protected static final Logger logger = LoggerFactory.getLogger(CandidateServiceImpl.class);
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
- private CandidateServiceValidator candidateServiceValidator = new CandidateServiceValidator();
- private ManifestCreator manifestCreator;
- private OrchestrationTemplateCandidateDao orchestrationTemplateCandidateDataDao;
+ private CandidateServiceValidator candidateServiceValidator = new CandidateServiceValidator();
+ private ManifestCreator manifestCreator;
+ private OrchestrationTemplateCandidateDao orchestrationTemplateCandidateDao;
- public CandidateServiceImpl(ManifestCreator manifestCreator,
- OrchestrationTemplateCandidateDao orchestrationTemplateCandidateDataDao) {
- this.manifestCreator = manifestCreator;
- this.orchestrationTemplateCandidateDataDao = orchestrationTemplateCandidateDataDao;
+ public CandidateServiceImpl(ManifestCreator manifestCreator,
+ OrchestrationTemplateCandidateDao orchestrationTemplateCandidateDao) {
+ this.manifestCreator = manifestCreator;
+ this.orchestrationTemplateCandidateDao = orchestrationTemplateCandidateDao;
- }
+ }
- public CandidateServiceImpl() {
- }
+ public CandidateServiceImpl() {
+ }
- @Override
- public Optional<ErrorMessage> validateNonEmptyFileToUpload(InputStream fileToUpload) {
+ @Override
+ public Optional<ErrorMessage> validateNonEmptyFileToUpload(InputStream fileToUpload) {
- mdcDataDebugMessage.debugEntryMessage(null);
+ mdcDataDebugMessage.debugEntryMessage(null);
- if (Objects.isNull(fileToUpload)) {
- return Optional.of(new ErrorMessage(ErrorLevel.ERROR,
- Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage()));
- } else {
- try {
- int available = fileToUpload.available();
- if (available == 0) {
- mdcDataDebugMessage.debugExitMessage(null);
- return Optional.of(new ErrorMessage(ErrorLevel.ERROR,
- Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage()));
- }
- } catch (IOException e) {
- logger.debug(e.getMessage(), e);
- mdcDataDebugMessage.debugExitMessage(null);
- return Optional.of(new ErrorMessage(ErrorLevel.ERROR,
- Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage()));
- }
+ if (Objects.isNull(fileToUpload)) {
+ return Optional.of(new ErrorMessage(ErrorLevel.ERROR,
+ Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage()));
+ } else {
+ try {
+ int available = fileToUpload.available();
+ if (available == 0) {
+ mdcDataDebugMessage.debugExitMessage(null);
+ return Optional.of(new ErrorMessage(ErrorLevel.ERROR,
+ Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage()));
}
-
+ } catch (IOException e) {
+ logger.debug(e.getMessage(), e);
mdcDataDebugMessage.debugExitMessage(null);
- return Optional.empty();
+ return Optional.of(new ErrorMessage(ErrorLevel.ERROR,
+ Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage()));
+ }
}
- @Override
- public Optional<ErrorMessage> validateRawZipData(byte[] uploadedFileData) {
- if (Objects.isNull(uploadedFileData)) {
- return Optional.of(new ErrorMessage(ErrorLevel.ERROR,
- Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage()));
+ mdcDataDebugMessage.debugExitMessage(null);
+ return Optional.empty();
+ }
+
+ @Override
+ public Optional<ErrorMessage> validateRawZipData(byte[] uploadedFileData) {
+ if (Objects.isNull(uploadedFileData)) {
+ return Optional.of(new ErrorMessage(ErrorLevel.ERROR,
+ Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage()));
+ }
+ return Optional.empty();
+ }
+
+ private String heatStructureTreeToFileDataStructure(HeatStructureTree tree,
+ FileContentHandler zipContentMap,
+ Map<String, List<ErrorMessage>> uploadErrors,
+ AnalyzedZipHeatFiles analyzedZipHeatFiles)
+ throws Exception {
+ FilesDataStructure structure = new FilesDataStructure();
+ Set<String> usedEnvFiles = new HashSet<>();
+ addHeatsToFileDataStructure(tree, usedEnvFiles, structure, uploadErrors,
+ analyzedZipHeatFiles);
+ handleOtherResources(tree, usedEnvFiles, structure);
+ FilesDataStructure fileDataStructureFromManifest =
+ createFileDataStructureFromManifest(zipContentMap.getFileContent
+ (SdcCommon.MANIFEST_NAME));
+ List<String> structureArtifacts = structure.getArtifacts();
+ structureArtifacts.addAll(fileDataStructureFromManifest.getArtifacts().stream().filter
+ (artifact -> isNotStrctureArtifact(structureArtifacts, artifact))
+ .collect((Collectors.toList())));
+ handleArtifactsFromTree(tree, structure);
+
+ return JsonUtil.object2Json(structure);
+ }
+
+ private boolean isNotStrctureArtifact(List<String> structureArtifacts, String artifact) {
+ return !structureArtifacts.contains(artifact);
+ }
+
+ @Override
+ public OrchestrationTemplateCandidateData createCandidateDataEntity(
+ CandidateDataEntityTo candidateDataEntityTo, InputStream zipFileManifest,
+ AnalyzedZipHeatFiles analyzedZipHeatFiles) throws Exception {
+
+
+ mdcDataDebugMessage.debugEntryMessage(null);
+
+ FileContentHandler zipContentMap = candidateDataEntityTo.getContentMap();
+ FilesDataStructure filesDataStructure;
+ String dataStructureJson;
+
+ if (zipFileManifest != null) {
+ // create data structure from manifest
+ filesDataStructure = createFileDataStructureFromManifest(zipFileManifest);
+ Set<String> zipFileList = zipContentMap.getFileList();
+ balanceManifestFilesWithZipFiles(filesDataStructure,
+ zipContentMap, analyzedZipHeatFiles);
+ Set<String> filesDataStructureFiles = getFlatFileNames(filesDataStructure);
+ filesDataStructure.getUnassigned().addAll(zipFileList.stream()
+ .filter(fileName -> (!filesDataStructureFiles.contains(fileName) &&
+ !filesDataStructure.getNested().contains(fileName) &&
+ !fileName.equals(SdcCommon.MANIFEST_NAME)))
+ .collect(Collectors.toList()));
+ dataStructureJson = JsonUtil.object2Json(filesDataStructure);
+ } else {
+ // create data structure from based on naming convention
+ dataStructureJson =
+ heatStructureTreeToFileDataStructure(candidateDataEntityTo.getTree(), zipContentMap,
+ candidateDataEntityTo.getErrors(), analyzedZipHeatFiles);
+ }
+
+ OrchestrationTemplateCandidateData candidateData = new OrchestrationTemplateCandidateData();
+ candidateData.setContentData(ByteBuffer.wrap(candidateDataEntityTo.getUploadedFileData()));
+ candidateData.setFilesDataStructure(dataStructureJson);
+
+ mdcDataDebugMessage.debugExitMessage(null);
+ return candidateData;
+ }
+
+ private void balanceManifestFilesWithZipFiles(
+ FilesDataStructure filesDataStructure,
+ FileContentHandler fileContentHandler, AnalyzedZipHeatFiles analyzedZipHeatFiles)
+ throws Exception {
+ Set<String> zipFileList = fileContentHandler.getFileList();
+ filesDataStructure.getNested().addAll(analyzedZipHeatFiles.getNestedFiles());
+ List<Module> modules = filesDataStructure.getModules();
+ if (CollectionUtils.isEmpty(modules)) {
+ return;
+ }
+
+ for (int i = 0; i < modules.size(); i++) {
+ Module module = modules.get(i);
+ if (!isFileExistInZipContains(zipFileList, module.getYaml())) {
+ addFileToUnassigned(filesDataStructure, zipFileList, module.getEnv());
+ addFileToUnassigned(filesDataStructure, zipFileList, module.getVol());
+ addFileToUnassigned(filesDataStructure, zipFileList, module.getVolEnv());
+ modules.remove(i--);
+ } else if (Objects.nonNull(module.getVol()) && !zipFileList.contains(module.getVol())) {
+ module.setVol(null);
+ CollectionUtils
+ .addIgnoreNull(filesDataStructure.getUnassigned(), module.getVolEnv());
+ } else {
+ if (filesDataStructure.getNested().contains(module.getYaml())) {
+ moveModuleFileToNested(filesDataStructure, i--, module);
}
- return Optional.empty();
+ }
+ }
+ }
+
+ private void addFileToUnassigned(FilesDataStructure filesDataStructure, Set<String> zipFileList,
+ String fileName) {
+ if (isFileExistInZipContains(zipFileList, fileName)) {
+ filesDataStructure.getUnassigned().add(fileName);
+ }
+ }
+
+ private boolean isFileExistInZipContains(Set<String> zipFileList, String fileName) {
+ return Objects.nonNull(fileName) && zipFileList.contains(fileName);
+ }
+
+ private void moveModuleFileToNested(FilesDataStructure filesDataStructure, int i,
+ Module module) {
+ if (!filesDataStructure.getNested().contains(module.getYaml())) {
+ filesDataStructure.getNested().add(module.getYaml());
+ }
+ if (Objects.nonNull(module.getEnv())) {
+ filesDataStructure.getNested().add(module.getEnv());
+ }
+ if (Objects.nonNull(module.getVol())) {
+ filesDataStructure.getNested().add(module.getVol());
+ }
+ if (Objects.nonNull(module.getVolEnv())) {
+ filesDataStructure.getNested().add(module.getVolEnv());
+ }
+ filesDataStructure.getModules().remove(i);
+ }
+
+ private Set<String> getFlatFileNames(FilesDataStructure filesDataStructure) {
+ Set<String> fileNames = new HashSet<>();
+ if (!CollectionUtils.isEmpty(filesDataStructure.getModules())) {
+ for (Module module : filesDataStructure.getModules()) {
+ CollectionUtils.addIgnoreNull(fileNames, module.getEnv());
+ CollectionUtils.addIgnoreNull(fileNames, module.getVol());
+ CollectionUtils.addIgnoreNull(fileNames, module.getVolEnv());
+ CollectionUtils.addIgnoreNull(fileNames, module.getYaml());
+ }
+ }
+ fileNames.addAll(filesDataStructure.getArtifacts().stream().collect(Collectors.toSet()));
+ fileNames.addAll(filesDataStructure.getNested().stream().collect(Collectors.toSet()));
+ fileNames.addAll(filesDataStructure.getUnassigned().stream().collect(Collectors.toSet()));
+
+ return fileNames;
+ }
+
+ private FilesDataStructure createFileDataStructureFromManifest(InputStream isManifestContent) {
+
+
+ mdcDataDebugMessage.debugEntryMessage(null);
+
+ ManifestContent manifestContent =
+ JsonUtil.json2Object(isManifestContent, ManifestContent.class);
+ FilesDataStructure structure = new FilesDataStructure();
+ for (FileData fileData : manifestContent.getData()) {
+ if (Objects.nonNull(fileData.getType()) &&
+ fileData.getType().equals(FileData.Type.HEAT)) {
+ Module module = new Module();
+ module.setYaml(fileData.getFile());
+ module.setIsBase(fileData.getBase());
+ addHeatDependenciesToModule(module, fileData.getData());
+ structure.getModules().add(module);
+ } else if (HeatFileAnalyzer.isYamlOrEnvFile(fileData.getFile()) &&
+ !FileData.Type.isArtifact(fileData.getType())) {
+ structure.getUnassigned().add(fileData.getFile());
+ } else {
+ structure.getArtifacts().add(fileData.getFile());
+ }
}
- private String heatStructureTreeToFileDataStructure(HeatStructureTree tree,
- FileContentHandler zipContentMap,
- Map<String, List<ErrorMessage>> uploadErrors,
- AnalyzedZipHeatFiles analyzedZipHeatFiles)
- throws Exception {
- FilesDataStructure structure = new FilesDataStructure();
- Set<String> usedEnvFiles = new HashSet<>();
- addHeatsToFileDataStructure(tree, usedEnvFiles, structure, uploadErrors,
- analyzedZipHeatFiles);
- handleOtherResources(tree, usedEnvFiles, structure);
- FilesDataStructure fileDataStructureFromManifest =
- createFileDataStructureFromManifest(zipContentMap.getFileContent
- (SdcCommon.MANIFEST_NAME));
- List<String> structureArtifacts = structure.getArtifacts();
- structureArtifacts.addAll(fileDataStructureFromManifest.getArtifacts().stream().filter
- (artifact -> isNotStrctureArtifact(structureArtifacts, artifact)).collect((Collectors.toList())));
- handleArtifactsFromTree(tree, structure);
+ mdcDataDebugMessage.debugExitMessage(null);
+ return structure;
+ }
- return JsonUtil.object2Json(structure);
+ private void addHeatDependenciesToModule(Module module, List<FileData> data) {
+ if (CollectionUtils.isEmpty(data)) {
+ return;
}
- private boolean isNotStrctureArtifact(List<String> structureArtifacts, String artifact) {
- return !structureArtifacts.contains(artifact);
- }
-
- @Override
- public OrchestrationTemplateCandidateData createCandidateDataEntity(
- CandidateDataEntityTo candidateDataEntityTo, InputStream zipFileManifest,
- AnalyzedZipHeatFiles analyzedZipHeatFiles) throws Exception {
-
-
- mdcDataDebugMessage.debugEntryMessage(null);
-
- FileContentHandler zipContentMap = candidateDataEntityTo.getContentMap();
- FilesDataStructure filesDataStructure;
- String dataStructureJson;
-
- if (zipFileManifest != null) {
- // create data structure from manifest
- filesDataStructure = createFileDataStructureFromManifest(zipFileManifest);
- Set<String> zipFileList = zipContentMap.getFileList();
- balanceManifestFilesWithZipFiles(filesDataStructure,
- zipContentMap, analyzedZipHeatFiles);
- Set<String> filesDataStructureFiles = getFlatFileNames(filesDataStructure);
- filesDataStructure.getUnassigned().addAll(zipFileList.stream()
- .filter(fileName -> (!filesDataStructureFiles.contains(fileName) &&
- !filesDataStructure.getNested().contains(fileName) &&
- !fileName.equals(SdcCommon.MANIFEST_NAME)))
- .collect(Collectors.toList()));
- dataStructureJson = JsonUtil.object2Json(filesDataStructure);
- } else {
- // create data structure from based on naming convention
- dataStructureJson =
- heatStructureTreeToFileDataStructure(candidateDataEntityTo.getTree(), zipContentMap,
- candidateDataEntityTo.getErrors(), analyzedZipHeatFiles);
+ for (FileData fileData : data) {
+ if (fileData.getType().equals(FileData.Type.HEAT_ENV)) {
+ module.setEnv(fileData.getFile());
+ } else if (fileData.getType().equals(FileData.Type.HEAT_VOL))// must be volume
+ {
+ module.setVol(fileData.getFile());
+ if (!CollectionUtils.isEmpty(fileData.getData())) {
+ FileData volEnv = fileData.getData().get(0);
+ if (volEnv.getType().equals(FileData.Type.HEAT_ENV)) {
+ module.setVolEnv(volEnv.getFile());
+ } else {
+ throw new CoreException((new ErrorCode.ErrorCodeBuilder())
+ .withMessage(Messages.ILLEGAL_MANIFEST.getErrorMessage())
+ .withId(Messages.ILLEGAL_MANIFEST.getErrorMessage())
+ .withCategory(ErrorCategory.APPLICATION).build());
+ }
}
-
- mdcDataDebugMessage.debugExitMessage(null);
- return new OrchestrationTemplateCandidateData(
- ByteBuffer.wrap(candidateDataEntityTo.getUploadedFileData()), dataStructureJson);
+ } else {
+ throw new CoreException((new ErrorCode.ErrorCodeBuilder())
+ .withMessage(Messages.FILE_TYPE_NOT_LEGAL.getErrorMessage())
+ .withId(Messages.FILE_TYPE_NOT_LEGAL.getErrorMessage())
+ .withCategory(ErrorCategory.APPLICATION).build());
+ }
}
+ }
- private void balanceManifestFilesWithZipFiles(
- FilesDataStructure filesDataStructure,
- FileContentHandler fileContentHandler, AnalyzedZipHeatFiles analyzedZipHeatFiles)
- throws Exception {
- Set<String> zipFileList = fileContentHandler.getFileList();
- filesDataStructure.getNested().addAll(analyzedZipHeatFiles.getNestedFiles());
- List<Module> modules = filesDataStructure.getModules();
- if (CollectionUtils.isEmpty(modules)) {
- return;
- }
+ @Override
+ public void updateCandidateUploadData(String vspId, Version version,
+ OrchestrationTemplateCandidateData uploadData) {
+ mdcDataDebugMessage.debugEntryMessage(null);
- for (int i = 0; i < modules.size(); i++) {
- Module module = modules.get(i);
- if (!isFileExistInZipContains(zipFileList, module.getYaml())) {
- addFileToUnassigned(filesDataStructure, zipFileList, module.getEnv());
- addFileToUnassigned(filesDataStructure, zipFileList, module.getVol());
- addFileToUnassigned(filesDataStructure, zipFileList, module.getVolEnv());
- modules.remove(i--);
- } else if (Objects.nonNull(module.getVol()) && !zipFileList.contains(module.getVol())) {
- module.setVol(null);
- CollectionUtils
- .addIgnoreNull(filesDataStructure.getUnassigned(), module.getVolEnv());
- } else {
- if (filesDataStructure.getNested().contains(module.getYaml())) {
- moveModuleFileToNested(filesDataStructure, i--, module);
- }
- }
- }
+ orchestrationTemplateCandidateDao.update(vspId, version, uploadData);
+
+ mdcDataDebugMessage.debugExitMessage(null);
+ }
+
+ @Override
+ public Optional<FilesDataStructure> getOrchestrationTemplateCandidateFileDataStructure(
+ String vspId, Version version) {
+
+ mdcDataDebugMessage.debugEntryMessage("VSP Id", vspId);
+
+ Optional<String> jsonFileDataStructure =
+ orchestrationTemplateCandidateDao.getStructure(vspId, version);
+
+ if (jsonFileDataStructure.isPresent() && JsonUtil.isValidJson(jsonFileDataStructure.get())) {
+ mdcDataDebugMessage.debugExitMessage("VSP Id", vspId);
+ return Optional
+ .of(JsonUtil.json2Object(jsonFileDataStructure.get(), FilesDataStructure.class));
+ } else {
+ mdcDataDebugMessage.debugExitMessage("VSP Id", vspId);
+ return Optional.empty();
}
+ }
- private void addFileToUnassigned(FilesDataStructure filesDataStructure, Set<String> zipFileList,
- String fileName) {
- if (isFileExistInZipContains(zipFileList, fileName)) {
- filesDataStructure.getUnassigned().add(fileName);
- }
- }
+ @Override
+ public void updateOrchestrationTemplateCandidateFileDataStructure(String vspId, Version version,
+ FilesDataStructure fileDataStructure) {
+ OrchestrationTemplateCandidateDaoFactory.getInstance().createInterface()
+ .updateStructure(vspId, version, fileDataStructure);
+ }
- private boolean isFileExistInZipContains(Set<String> zipFileList, String fileName) {
- return Objects.nonNull(fileName) && zipFileList.contains(fileName);
- }
+ @Override
+ public OrchestrationTemplateCandidateData getOrchestrationTemplateCandidate(String vspId,
+ Version version) {
+ mdcDataDebugMessage.debugEntryMessage("VSP Id", vspId);
+ mdcDataDebugMessage.debugExitMessage("VSP Id", vspId);
- private void moveModuleFileToNested(FilesDataStructure filesDataStructure, int i,
- Module module) {
- if (!filesDataStructure.getNested().contains(module.getYaml())) {
- filesDataStructure.getNested().add(module.getYaml());
- }
- if (Objects.nonNull(module.getEnv())) {
- filesDataStructure.getNested().add(module.getEnv());
- }
- if (Objects.nonNull(module.getVol())) {
- filesDataStructure.getNested().add(module.getVol());
- }
- if (Objects.nonNull(module.getVolEnv())) {
- filesDataStructure.getNested().add(module.getVolEnv());
- }
- filesDataStructure.getModules().remove(i);
- }
+ return orchestrationTemplateCandidateDao.get(vspId, version);
+ }
- private Set<String> getFlatFileNames(FilesDataStructure filesDataStructure) {
- Set<String> fileNames = new HashSet<>();
- if (!CollectionUtils.isEmpty(filesDataStructure.getModules())) {
- for (Module module : filesDataStructure.getModules()) {
- CollectionUtils.addIgnoreNull(fileNames, module.getEnv());
- CollectionUtils.addIgnoreNull(fileNames, module.getVol());
- CollectionUtils.addIgnoreNull(fileNames, module.getVolEnv());
- CollectionUtils.addIgnoreNull(fileNames, module.getYaml());
- }
- }
- fileNames.addAll(filesDataStructure.getArtifacts().stream().collect(Collectors.toSet()));
- fileNames.addAll(filesDataStructure.getNested().stream().collect(Collectors.toSet()));
- fileNames.addAll(filesDataStructure.getUnassigned().stream().collect(Collectors.toSet()));
+ @Override
+ public OrchestrationTemplateCandidateData getOrchestrationTemplateCandidateInfo(String vspId,
+ Version version) {
+ mdcDataDebugMessage.debugEntryMessage("VSP Id", vspId);
+ mdcDataDebugMessage.debugExitMessage("VSP Id", vspId);
- return fileNames;
- }
-
- private FilesDataStructure createFileDataStructureFromManifest(InputStream isManifestContent) {
-
-
- mdcDataDebugMessage.debugEntryMessage(null);
-
- ManifestContent manifestContent =
- JsonUtil.json2Object(isManifestContent, ManifestContent.class);
- FilesDataStructure structure = new FilesDataStructure();
- for (FileData fileData : manifestContent.getData()) {
- if (Objects.nonNull(fileData.getType()) &&
- fileData.getType().equals(FileData.Type.HEAT)) {
- Module module = new Module();
- module.setYaml(fileData.getFile());
- module.setIsBase(fileData.getBase());
- addHeatDependenciesToModule(module, fileData.getData());
- structure.getModules().add(module);
- } else if (HeatFileAnalyzer.isYamlOrEnvFile(fileData.getFile()) &&
- !FileData.Type.isArtifact(fileData.getType())) {
- structure.getUnassigned().add(fileData.getFile());
- } else {
- structure.getArtifacts().add(fileData.getFile());
- }
- }
-
- mdcDataDebugMessage.debugExitMessage(null);
- return structure;
- }
-
- private void addHeatDependenciesToModule(Module module, List<FileData> data) {
- if (CollectionUtils.isEmpty(data)) {
- return;
- }
-
- for (FileData fileData : data) {
- if (fileData.getType().equals(FileData.Type.HEAT_ENV)) {
- module.setEnv(fileData.getFile());
- } else if (fileData.getType().equals(FileData.Type.HEAT_VOL))// must be volume
- {
- module.setVol(fileData.getFile());
- if (!CollectionUtils.isEmpty(fileData.getData())) {
- FileData volEnv = fileData.getData().get(0);
- if (volEnv.getType().equals(FileData.Type.HEAT_ENV)) {
- module.setVolEnv(volEnv.getFile());
- } else {
- throw new CoreException((new ErrorCode.ErrorCodeBuilder())
- .withMessage(Messages.ILLEGAL_MANIFEST.getErrorMessage())
- .withId(Messages.ILLEGAL_MANIFEST.getErrorMessage())
- .withCategory(ErrorCategory.APPLICATION).build());
- }
- }
- } else {
- throw new CoreException((new ErrorCode.ErrorCodeBuilder())
- .withMessage(Messages.FILE_TYPE_NOT_LEGAL.getErrorMessage())
- .withId(Messages.FILE_TYPE_NOT_LEGAL.getErrorMessage())
- .withCategory(ErrorCategory.APPLICATION).build());
- }
- }
- }
-
- @Override
- public void updateCandidateUploadData(OrchestrationTemplateCandidateData uploadData,
- String itemId) {
- mdcDataDebugMessage.debugEntryMessage(null);
- orchestrationTemplateCandidateDataDao.update(itemId, uploadData);
- mdcDataDebugMessage.debugExitMessage(null);
- }
-
- @Override
- public Optional<FilesDataStructure> getOrchestrationTemplateCandidateFileDataStructure(
- String vspId, Version version) {
-
- mdcDataDebugMessage.debugEntryMessage("VSP Id", vspId);
-
- Optional<String> jsonFileDataStructure =
- orchestrationTemplateCandidateDataDao.getStructure(vspId, version);
-
- if (jsonFileDataStructure.isPresent()
- && JsonUtil.isValidJson(jsonFileDataStructure.get())) {
- mdcDataDebugMessage.debugExitMessage("VSP Id", vspId);
- return Optional
- .of(JsonUtil.json2Object(jsonFileDataStructure.get(), FilesDataStructure.class));
- } else {
- mdcDataDebugMessage.debugExitMessage("VSP Id", vspId);
- return Optional.empty();
- }
- }
-
- @Override
- public void updateOrchestrationTemplateCandidateFileDataStructure(String vspId, Version version,
- FilesDataStructure fileDataStructure) {
- OrchestrationTemplateCandidateDaoFactory.getInstance().createInterface()
- .updateStructure(vspId, version, fileDataStructure);
- }
-
- @Override
- public OrchestrationTemplateCandidateData getOrchestrationTemplateCandidate(String vspId,
- Version version) {
- mdcDataDebugMessage.debugEntryMessage("VSP Id", vspId);
- mdcDataDebugMessage.debugExitMessage("VSP Id", vspId);
-
- return orchestrationTemplateCandidateDataDao.get(vspId, version);
- }
+ return orchestrationTemplateCandidateDao.getInfo(vspId, version);
+ }
@Override
public String createManifest(VspDetails vspDetails, FilesDataStructure structure) {
- mdcDataDebugMessage.debugEntryMessage("VSP Id", vspDetails.getId());
+ mdcDataDebugMessage.debugEntryMessage("VSP Id", vspDetails.getId());
- Optional<ManifestContent> manifest = manifestCreator.createManifest(vspDetails, structure);
- if (!manifest.isPresent()) {
- throw new RuntimeException(Messages.CREATE_MANIFEST_FROM_ZIP.getErrorMessage());
+ Optional<ManifestContent> manifest = manifestCreator.createManifest(vspDetails, structure);
+ if (!manifest.isPresent()) {
+ throw new RuntimeException(Messages.CREATE_MANIFEST_FROM_ZIP.getErrorMessage());
+ }
+
+ mdcDataDebugMessage.debugExitMessage("VSP Id", vspDetails.getId());
+ return JsonUtil.object2Json(manifest.get());
+ }
+
+ @Override
+ public Optional<ManifestContent> createManifest(VspDetails vspDetails,
+ FileContentHandler fileContentHandler,
+ AnalyzedZipHeatFiles analyzedZipHeatFiles) {
+
+
+ mdcDataDebugMessage.debugEntryMessage("VSP Id", vspDetails.getId());
+
+ mdcDataDebugMessage.debugExitMessage("VSP Id", vspDetails.getId());
+ return manifestCreator.createManifest(vspDetails, fileContentHandler, analyzedZipHeatFiles);
+ }
+
+ @Override
+ public Optional<ByteArrayInputStream> fetchZipFileByteArrayInputStream(String vspId,
+ OrchestrationTemplateCandidateData candidateDataEntity,
+ String manifest,
+ OnboardingTypesEnum type,
+ Map<String, List<ErrorMessage>> uploadErrors) {
+ byte[] file;
+ ByteArrayInputStream byteArrayInputStream = null;
+ try {
+ file = replaceManifestInZip(candidateDataEntity.getContentData(), manifest, vspId, type);
+ byteArrayInputStream = new ByteArrayInputStream(
+ Objects.isNull(file) ? candidateDataEntity.getContentData().array()
+ : file);
+ } catch (IOException e) {
+ ErrorMessage errorMessage =
+ new ErrorMessage(ErrorLevel.ERROR,
+ Messages.CANDIDATE_PROCESS_FAILED.getErrorMessage());
+ logger.error(errorMessage.getMessage(), e);
+ ErrorsUtil
+ .addStructureErrorToErrorMap(SdcCommon.UPLOAD_FILE, errorMessage, uploadErrors);
+ }
+ return Optional.ofNullable(byteArrayInputStream);
+ }
+
+ @Override
+ public byte[] replaceManifestInZip(ByteBuffer contentData, String manifest, String vspId,
+ OnboardingTypesEnum type)
+ throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ try (final ZipOutputStream zos = new ZipOutputStream(baos);
+ ZipInputStream zipStream = new ZipInputStream(
+ new ByteArrayInputStream(contentData.array()))) {
+ ZipEntry zipEntry;
+ boolean manifestWritten = false;
+ while ((zipEntry = zipStream.getNextEntry()) != null) {
+ if (!zipEntry.getName().equalsIgnoreCase(SdcCommon.MANIFEST_NAME)) {
+ ZipEntry loc_ze = new ZipEntry(zipEntry.getName());
+ zos.putNextEntry(loc_ze);
+ byte[] buf = new byte[1024];
+ int len;
+ while ((len = zipStream.read(buf)) > 0) {
+ zos.write(buf, 0, (len < buf.length) ? len : buf.length);
+ }
+ } else {
+ manifestWritten = true;
+ writeManifest(manifest, type, zos);
}
+ zos.closeEntry();
+ }
+ if (!manifestWritten) {
+ writeManifest(manifest, type, zos);
+ zos.closeEntry();
+ }
+ }
+ return baos.toByteArray();
+ }
- mdcDataDebugMessage.debugExitMessage("VSP Id", vspDetails.getId());
- return JsonUtil.object2Json(manifest.get());
+ @Override
+ public Optional<List<ErrorMessage>> validateFileDataStructure(
+ FilesDataStructure filesDataStructure) {
+ return candidateServiceValidator.validateFileDataStructure(filesDataStructure);
+ }
+
+ private void writeManifest(String manifest,
+ OnboardingTypesEnum type,
+ ZipOutputStream zos) throws IOException {
+
+ if (isManifestNeedsToGetWritten(type)) {
+ return;
}
- @Override
- public Optional<ManifestContent> createManifest(VspDetails vspDetails,
- FileContentHandler fileContentHandler,
- AnalyzedZipHeatFiles analyzedZipHeatFiles) {
+ zos.putNextEntry(new ZipEntry(SdcCommon.MANIFEST_NAME));
+ try (InputStream manifestStream = new ByteArrayInputStream(
+ manifest.getBytes(StandardCharsets.UTF_8))) {
+ byte[] buf = new byte[1024];
+ int len;
+ while ((len = (manifestStream.read(buf))) > 0) {
+ zos.write(buf, 0, (len < buf.length) ? len : buf.length);
+ }
+ }
+ }
+ private boolean isManifestNeedsToGetWritten(OnboardingTypesEnum type) {
+ return type.equals(OnboardingTypesEnum.CSAR);
+ }
- mdcDataDebugMessage.debugEntryMessage("VSP Id", vspDetails.getId());
+ private void handleArtifactsFromTree(HeatStructureTree tree, FilesDataStructure structure) {
- mdcDataDebugMessage.debugExitMessage("VSP Id", vspDetails.getId());
- return manifestCreator.createManifest(vspDetails, fileContentHandler, analyzedZipHeatFiles);
+ if (Objects.isNull(tree) || Objects.isNull(tree.getArtifacts())) {
+ return;
}
- @Override
- public Optional<ByteArrayInputStream> fetchZipFileByteArrayInputStream(String vspId,
- OrchestrationTemplateCandidateData candidateDataEntity,
- String manifest,
- OnboardingTypesEnum type,
- Map<String, List<ErrorMessage>> uploadErrors) {
- byte[] file;
- ByteArrayInputStream byteArrayInputStream = null;
- try {
- file = replaceManifestInZip(candidateDataEntity.getContentData(), manifest, vspId, type);
- byteArrayInputStream = new ByteArrayInputStream(
- Objects.isNull(file) ? candidateDataEntity.getContentData().array()
- : file);
- } catch (IOException e) {
- ErrorMessage errorMessage =
- new ErrorMessage(ErrorLevel.ERROR,
- Messages.CANDIDATE_PROCESS_FAILED.getErrorMessage());
- logger.error(errorMessage.getMessage(), e);
- ErrorsUtil
- .addStructureErrorToErrorMap(SdcCommon.UPLOAD_FILE, errorMessage, uploadErrors);
+ if (CollectionUtils.isNotEmpty(tree.getArtifacts())) {
+ structure.getArtifacts().addAll(
+ tree.getArtifacts()
+ .stream()
+ .map(Artifact::getFileName)
+ .filter(fileName -> !structure.getArtifacts().contains(fileName))
+ .collect(Collectors.toList()));
+ }
+ }
+
+ private void handleOtherResources(HeatStructureTree tree, Set<String> usedEnvFiles,
+ FilesDataStructure structure) {
+ Set<HeatStructureTree> others = tree.getOther();
+ if (Objects.isNull(others)) {
+ return;
+ }
+
+ List<String> artifacts = new ArrayList<>();
+ List<String> unassigned = new ArrayList<>();
+ for (HeatStructureTree other : others) {
+ if (HeatFileAnalyzer.isYamlOrEnvFile(other.getFileName())) {
+ if (isEnvFileUsedByHeatFile(usedEnvFiles, other)) {
+ continue;
}
- return Optional.ofNullable(byteArrayInputStream);
+ unassigned.add(other.getFileName());
+ } else {
+ artifacts.add(other.getFileName());
+ }
+ handleArtifactsFromTree(other, structure);
}
+ structure.getArtifacts().addAll(artifacts);
+ structure.getUnassigned().addAll(unassigned);
+ }
- @Override
- public byte[] replaceManifestInZip(ByteBuffer contentData, String manifest, String vspId,
- OnboardingTypesEnum type)
- throws IOException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- try (final ZipOutputStream zos = new ZipOutputStream(baos);
- ZipInputStream zipStream = new ZipInputStream(
- new ByteArrayInputStream(contentData.array()))) {
- ZipEntry zipEntry;
- boolean manifestWritten = false;
- while ((zipEntry = zipStream.getNextEntry()) != null) {
- if (!zipEntry.getName().equalsIgnoreCase(SdcCommon.MANIFEST_NAME)) {
- ZipEntry loc_ze = new ZipEntry(zipEntry.getName());
- zos.putNextEntry(loc_ze);
- byte[] buf = new byte[1024];
- int len;
- while ((len = zipStream.read(buf)) > 0) {
- zos.write(buf, 0, (len < buf.length) ? len : buf.length);
- }
- } else {
- manifestWritten = true;
- writeManifest(manifest, type, zos);
- }
- zos.closeEntry();
- }
- if (!manifestWritten) {
- writeManifest(manifest, type, zos);
- zos.closeEntry();
- }
- }
- return baos.toByteArray();
+ private boolean isEnvFileUsedByHeatFile(Set<String> usedEnvFiles, HeatStructureTree other) {
+ if (HeatFileAnalyzer.isEnvFile(other.getFileName())) {
+ if (usedEnvFiles.contains(other.getFileName())) {
+ return true;
+ }
}
+ return false;
+ }
- @Override
- public Optional<List<ErrorMessage>> validateFileDataStructure(
- FilesDataStructure filesDataStructure) {
- return candidateServiceValidator.validateFileDataStructure(filesDataStructure);
+ private void addHeatsToFileDataStructure(HeatStructureTree tree, Set<String> usedEnvFiles,
+ FilesDataStructure structure,
+ Map<String, List<ErrorMessage>> uploadErrors,
+ AnalyzedZipHeatFiles analyzedZipHeatFiles)
+ throws Exception {
+ List<Module> modules = new ArrayList<>();
+ Set<HeatStructureTree> heatsSet = tree.getHeat();
+ if (Objects.isNull(heatsSet)) {
+ return;
}
-
- private void writeManifest(String manifest,
- OnboardingTypesEnum type,
- ZipOutputStream zos) throws IOException {
-
- if(isManifestNeedsToGetWritten(type)){
- return;
- }
-
- zos.putNextEntry(new ZipEntry(SdcCommon.MANIFEST_NAME));
- try (InputStream manifestStream = new ByteArrayInputStream(
- manifest.getBytes(StandardCharsets.UTF_8))) {
- byte[] buf = new byte[1024];
- int len;
- while ((len = (manifestStream.read(buf))) > 0) {
- zos.write(buf, 0, (len < buf.length) ? len : buf.length);
- }
- }
- }
-
- private boolean isManifestNeedsToGetWritten(OnboardingTypesEnum type) {
- return type.equals(OnboardingTypesEnum.CSAR);
- }
-
- private void handleArtifactsFromTree(HeatStructureTree tree, FilesDataStructure structure) {
-
- if (Objects.isNull(tree) || Objects.isNull(tree.getArtifacts())) {
- return;
- }
-
- if (CollectionUtils.isNotEmpty(tree.getArtifacts())) {
- structure.getArtifacts().addAll(
- tree.getArtifacts()
- .stream()
- .map(Artifact::getFileName)
- .filter(fileName -> !structure.getArtifacts().contains(fileName))
- .collect(Collectors.toList()));
- }
- }
-
- private void handleOtherResources(HeatStructureTree tree, Set<String> usedEnvFiles,
- FilesDataStructure structure) {
- Set<HeatStructureTree> others = tree.getOther();
- if (Objects.isNull(others)) {
- return;
- }
-
- List<String> artifacts = new ArrayList<>();
- List<String> unassigned = new ArrayList<>();
- for (HeatStructureTree other : others) {
- if (HeatFileAnalyzer.isYamlOrEnvFile(other.getFileName())) {
- if (isEnvFileUsedByHeatFile(usedEnvFiles, other)) {
- continue;
- }
- unassigned.add(other.getFileName());
- } else {
- artifacts.add(other.getFileName());
- }
- handleArtifactsFromTree(other, structure);
- }
- structure.getArtifacts().addAll(artifacts);
- structure.getUnassigned().addAll(unassigned);
- }
-
- private boolean isEnvFileUsedByHeatFile(Set<String> usedEnvFiles, HeatStructureTree other) {
- if (HeatFileAnalyzer.isEnvFile(other.getFileName())) {
- if (usedEnvFiles.contains(other.getFileName())) {
- return true;
- }
- }
- return false;
- }
-
- private void addHeatsToFileDataStructure(HeatStructureTree tree, Set<String> usedEnvFiles,
- FilesDataStructure structure,
- Map<String, List<ErrorMessage>> uploadErrors,
- AnalyzedZipHeatFiles analyzedZipHeatFiles)
- throws Exception {
- List<Module> modules = new ArrayList<>();
- Set<HeatStructureTree> heatsSet = tree.getHeat();
- if (Objects.isNull(heatsSet)) {
- return;
- }
- for (HeatStructureTree heat : heatsSet) {
- if (isFileBaseFile(heat.getFileName())) {
- handleSingleHeat(structure, modules, heat, uploadErrors);
- } else if (isFileModuleFile(heat.getFileName(),
- analyzedZipHeatFiles.getModuleFiles())) {
- handleSingleHeat(structure, modules, heat, uploadErrors);
- } else {
- structure.getUnassigned().add(heat.getFileName());
- addNestedToFileDataStructure(heat, structure);
- }
- if (!Objects.isNull(heat.getEnv())) {
- usedEnvFiles.add(heat.getEnv() == null ? null : heat.getEnv().getFileName());
- }
- }
- structure.setModules(modules);
-
- }
-
- private boolean isFileModuleFile(String fileName, Set<String> modulesFileNames) {
- return modulesFileNames.contains(fileName);
- }
-
- private boolean isFileBaseFile(String fileName) {
- return manifestCreator.isFileBaseFile(fileName);
- }
-
- private void handleSingleHeat(FilesDataStructure structure, List<Module> modules,
- HeatStructureTree heat,
- Map<String, List<ErrorMessage>> uploadErrors) {
-
-
- mdcDataDebugMessage.debugEntryMessage(null);
-
- Module module = new Module();
- module.setYaml(heat.getFileName());
- module.setIsBase(heat.getBase());
+ for (HeatStructureTree heat : heatsSet) {
+ if (isFileBaseFile(heat.getFileName())) {
+ handleSingleHeat(structure, modules, heat, uploadErrors);
+ } else if (isFileModuleFile(heat.getFileName(),
+ analyzedZipHeatFiles.getModuleFiles())) {
+ handleSingleHeat(structure, modules, heat, uploadErrors);
+ } else {
+ structure.getUnassigned().add(heat.getFileName());
addNestedToFileDataStructure(heat, structure);
- Set<HeatStructureTree> volumeSet = heat.getVolume();
- int inx = 0;
- if (Objects.nonNull(volumeSet)) {
- handleVolumes(module, volumeSet, structure, inx, uploadErrors);
- }
- handleEnv(module, heat, false, structure);
- modules.add(module);
+ }
+ if (!Objects.isNull(heat.getEnv())) {
+ usedEnvFiles.add(heat.getEnv() == null ? null : heat.getEnv().getFileName());
+ }
+ }
+ structure.setModules(modules);
- mdcDataDebugMessage.debugExitMessage(null);
+ }
+
+ private boolean isFileModuleFile(String fileName, Set<String> modulesFileNames) {
+ return modulesFileNames.contains(fileName);
+ }
+
+ private boolean isFileBaseFile(String fileName) {
+ return manifestCreator.isFileBaseFile(fileName);
+ }
+
+ private void handleSingleHeat(FilesDataStructure structure, List<Module> modules,
+ HeatStructureTree heat,
+ Map<String, List<ErrorMessage>> uploadErrors) {
+
+
+ mdcDataDebugMessage.debugEntryMessage(null);
+
+ Module module = new Module();
+ module.setYaml(heat.getFileName());
+ module.setIsBase(heat.getBase());
+ addNestedToFileDataStructure(heat, structure);
+ Set<HeatStructureTree> volumeSet = heat.getVolume();
+ int inx = 0;
+ if (Objects.nonNull(volumeSet)) {
+ handleVolumes(module, volumeSet, structure, inx, uploadErrors);
+ }
+ handleEnv(module, heat, false, structure);
+ modules.add(module);
+
+ mdcDataDebugMessage.debugExitMessage(null);
+ }
+
+ private void handleVolumes(Module module, Set<HeatStructureTree> volumeSet,
+ FilesDataStructure structure, int inx,
+ Map<String, List<ErrorMessage>> uploadErrors) {
+
+
+ mdcDataDebugMessage.debugEntryMessage(null);
+
+ for (HeatStructureTree volume : volumeSet) {
+ if (inx++ > 0) {
+ ErrorsUtil.addStructureErrorToErrorMap(SdcCommon.UPLOAD_FILE,
+ new ErrorMessage(ErrorLevel.WARNING,
+ Messages.MORE_THEN_ONE_VOL_FOR_HEAT.getErrorMessage()), uploadErrors);
+ break;
+ }
+ handleArtifactsFromTree(volume, structure);
+ module.setVol(volume.getFileName());
+ handleEnv(module, volume, true, structure);
+ addNestedToFileDataStructure(volume, structure);
}
- private void handleVolumes(Module module, Set<HeatStructureTree> volumeSet,
- FilesDataStructure structure, int inx,
- Map<String, List<ErrorMessage>> uploadErrors) {
+ mdcDataDebugMessage.debugExitMessage(null);
+ }
+
+ private void handleEnv(Module module, HeatStructureTree tree, boolean isVolEnv,
+ FilesDataStructure structure) {
- mdcDataDebugMessage.debugEntryMessage(null);
+ mdcDataDebugMessage.debugEntryMessage(null);
- for (HeatStructureTree volume : volumeSet) {
- if (inx++ > 0) {
- ErrorsUtil.addStructureErrorToErrorMap(SdcCommon.UPLOAD_FILE,
- new ErrorMessage(ErrorLevel.WARNING,
- Messages.MORE_THEN_ONE_VOL_FOR_HEAT.getErrorMessage()), uploadErrors);
- break;
- }
- handleArtifactsFromTree(volume, structure);
- module.setVol(volume.getFileName());
- handleEnv(module, volume, true, structure);
- addNestedToFileDataStructure(volume, structure);
- }
-
- mdcDataDebugMessage.debugExitMessage(null);
+ if (Objects.nonNull(tree.getEnv())) {
+ if (isVolEnv) {
+ module.setVolEnv(tree.getEnv().getFileName());
+ } else {
+ module.setEnv(tree.getEnv().getFileName());
+ }
+ handleArtifactsFromTree(tree.getEnv(), structure);
}
- private void handleEnv(Module module, HeatStructureTree tree, boolean isVolEnv,
- FilesDataStructure structure) {
+ mdcDataDebugMessage.debugExitMessage(null);
+ }
-
- mdcDataDebugMessage.debugEntryMessage(null);
-
- if (Objects.nonNull(tree.getEnv())) {
- if (isVolEnv) {
- module.setVolEnv(tree.getEnv().getFileName());
- } else {
- module.setEnv(tree.getEnv().getFileName());
- }
- handleArtifactsFromTree(tree.getEnv(), structure);
- }
-
- mdcDataDebugMessage.debugExitMessage(null);
+ private void addNestedToFileDataStructure(HeatStructureTree heat,
+ FilesDataStructure structure) {
+ Set<HeatStructureTree> nestedSet = heat.getNested();
+ if (Objects.isNull(nestedSet)) {
+ return;
}
-
- private void addNestedToFileDataStructure(HeatStructureTree heat,
- FilesDataStructure structure) {
- Set<HeatStructureTree> nestedSet = heat.getNested();
- if (Objects.isNull(nestedSet)) {
- return;
- }
- for (HeatStructureTree nested : nestedSet) {
- if (structure.getNested().contains(nested.getFileName())) {
- continue;
- }
- structure.getNested().add(nested.getFileName());
- if (CollectionUtils.isNotEmpty(nested.getArtifacts())) {
- handleArtifactsFromTree(nested, structure);
- }
- addNestedToFileDataStructure(nested, structure);
- }
+ for (HeatStructureTree nested : nestedSet) {
+ if (structure.getNested().contains(nested.getFileName())) {
+ continue;
+ }
+ structure.getNested().add(nested.getFileName());
+ if (CollectionUtils.isNotEmpty(nested.getArtifacts())) {
+ handleArtifactsFromTree(nested, structure);
+ }
+ addNestedToFileDataStructure(nested, structure);
}
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImpl.java
index eed575f..ce18097 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImpl.java
@@ -68,7 +68,7 @@
addArtifactsToManifestFileDataList(filesDataStructure, fileDataList);
ManifestContent manifestContent = createManifest(vspDetails, fileDataList);
- mdcDataDebugMessage.debugExitMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null);
return Optional.of(manifestContent);
}
@@ -76,7 +76,7 @@
FilesDataStructure filesDataStructure, List<FileData> fileDataList) {
- mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugEntryMessage(null);
if (CollectionUtils.isNotEmpty(filesDataStructure.getNested())) {
for (String nested : filesDataStructure.getNested()) {
@@ -84,7 +84,7 @@
}
}
- mdcDataDebugMessage.debugExitMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null);
}
@Override
@@ -168,7 +168,7 @@
FilesDataStructure filesDataStructure, List<FileData> fileDataList) {
- mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugEntryMessage(null);
Collection<String> forArtifacts = CollectionUtils
.union(filesDataStructure.getArtifacts(), filesDataStructure.getUnassigned());
@@ -178,14 +178,14 @@
}
}
- mdcDataDebugMessage.debugExitMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null);
}
private void addModulesToManifestFileDataList(
FilesDataStructure filesDataStructure, List<FileData> fileDataList) {
- mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugEntryMessage(null);
if (CollectionUtils.isNotEmpty(filesDataStructure.getModules())) {
for (Module module : filesDataStructure.getModules()) {
@@ -197,7 +197,7 @@
}
}
- mdcDataDebugMessage.debugExitMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null);
}
private void addEnv(Module module, FileData fileData) {
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/resources/factoryConfiguration.json b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/resources/factoryConfiguration.json
new file mode 100644
index 0000000..982277d
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/resources/factoryConfiguration.json
@@ -0,0 +1,3 @@
+{
+ "org.openecomp.sdc.vendorsoftwareproduct.dao.VspMergeDaoFactory": "org.openecomp.sdc.vendorsoftwareproduct.dao.impl.VspMergeDaoFactoryImpl"
+}
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java
index 39c14e6..4690d75 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java
@@ -21,7 +21,9 @@
package org.openecomp.sdc.vendorsoftwareproduct.dao;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementConflict;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ItemVersionConflict;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
import com.amdocs.zusammen.commons.health.data.HealthInfo;
import com.amdocs.zusammen.datatypes.Id;
@@ -32,15 +34,19 @@
import com.amdocs.zusammen.datatypes.item.Item;
import com.amdocs.zusammen.datatypes.item.ItemVersion;
import com.amdocs.zusammen.datatypes.item.ItemVersionData;
+import com.amdocs.zusammen.datatypes.item.ItemVersionStatus;
+import com.amdocs.zusammen.datatypes.item.Resolution;
import com.amdocs.zusammen.datatypes.itemversion.Tag;
import org.openecomp.core.utilities.CommonMethods;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
+import org.openecomp.sdc.common.session.SessionContextProviderFactory;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.model.impl.zusammen.ServiceModelDaoZusammenImpl;
-import org.openecomp.sdc.model.impl.zusammen.StructureElement;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
import org.openecomp.sdc.tosca.services.YamlUtil;
+import org.openecomp.sdc.versioning.dao.types.Revision;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -49,6 +55,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -59,6 +66,10 @@
private static final String baseServiceTemplateName = "baseYaml.yaml";
private static String artifact001;
+ static {
+ SessionContextProviderFactory.getInstance().createInterface().create("test");
+ }
+
@Test
public void storeServiceModelTest() {
@@ -91,14 +102,19 @@
ElementInfo elementInfo = new ElementInfo();
Info info = new Info();
- info.addProperty("base","baseElement");
+ info.addProperty("base", "baseElement");
elementInfo.setInfo(info);
ElementInfo artifactElementInfo = new ElementInfo();
- artifactElementInfo.setInfo(info);
+ artifactElementInfo.setInfo(new Info());
+ artifactElementInfo.getInfo().setName(ElementType.Artifacts.name());
ElementInfo templateElementInfo = new ElementInfo();
- artifactElementInfo.setInfo(info);
+ templateElementInfo.setInfo(new Info());
+ templateElementInfo.getInfo().setName(ElementType.Templates.name());
+ ElementInfo serviceModelElementInfo = new ElementInfo();
+ serviceModelElementInfo.setInfo(new Info());
+ serviceModelElementInfo.getInfo().setName(ElementType.ServiceModel.name());
ZusammenElement element = new ZusammenElement();
ServiceTemplate serviceTemplate = new ServiceTemplate();
YamlUtil yamlUtil = new YamlUtil();
@@ -111,9 +127,11 @@
zusammenAdaptor);
zusammenAdaptor.setItemVersion(itemVersionmock);
- zusammenAdaptor.addElementInfo("null"+StructureElement.ServiceModel.name(),elementInfo);
- zusammenAdaptor.addElementInfo("null"+StructureElement.Artifacts.name(),artifactElementInfo);
- zusammenAdaptor.addElementInfo("null"+StructureElement.Templates.name(),templateElementInfo);
+ zusammenAdaptor.addElementInfo("null" + ElementType.ServiceModel.name(), elementInfo);
+ zusammenAdaptor.addElementInfo("null" + ElementType.Artifacts.name(), artifactElementInfo);
+ zusammenAdaptor.addElementInfo("null" + ElementType.Templates.name(), templateElementInfo);
+ zusammenAdaptor.addElementInfo("null" + ElementType.ServiceModel.name(),
+ serviceModelElementInfo);
zusammenAdaptor.addElement(element);
Object model =
@@ -126,11 +144,11 @@
}
}
- private static void setArtifact(ToscaServiceModel model)
- {
+ private static void setArtifact(ToscaServiceModel model) {
artifact001 =
- (String) (model).getArtifactFiles().getFileList().toArray()[0];
+ (String) (model).getArtifactFiles().getFileList().toArray()[0];
}
+
private ToscaServiceModel getToscaServiceModel() {
Map<String, ServiceTemplate> serviceTemplates = getServiceTemplates(baseServiceTemplateName);
@@ -171,128 +189,225 @@
return serviceTemplate;
}
- private class ZusammenAdaptorMock implements ZusammenAdaptor
- {
+ private class ZusammenAdaptorMock implements ZusammenAdaptor {
private ItemVersion itemVersion;
- private Map<String,ElementInfo> elementInfoMap = new HashMap();
- private Collection<Element> elements = new ArrayList<>();
+ private Map<String, ElementInfo> elementInfoMap = new HashMap();
+ private Collection<Element> elements = new ArrayList<>();
- public void setItemVersion(ItemVersion itemVersion){
+ public void setItemVersion(ItemVersion itemVersion) {
this.itemVersion = itemVersion;
}
- public void addElementInfo(String key,ElementInfo elementInfo){
- elementInfoMap.put(key,elementInfo);
+ public void addElementInfo(String key, ElementInfo elementInfo) {
+ elementInfoMap.put(key, elementInfo);
}
- public void addElement(Element element){
- elements.add(element);
+
+ public void addElement(Element element) {
+ elements.add(element);
}
+
@Override
public Optional<ItemVersion> getFirstVersion(SessionContext context, Id itemId) {
return Optional.ofNullable(itemVersion);
}
- @Override
- public Optional<Element> getElement(SessionContext context, ElementContext elementContext,
- String elementId) {
- return null;
- }
-
- @Override
- public Optional<Element> getElementByName(SessionContext context,
- ElementContext elementContext,
- Id parentElementId, String elementName) {
- return null;
- }
-
- @Override
- public Collection<ElementInfo> listElements(SessionContext context,
- ElementContext elementContext,
- Id parentElementId) {
- return null;
- }
-
- @Override
- public Collection<Element> listElementData(SessionContext context,
- ElementContext elementContext,
- Id parentElementId) {
- return elements;
- }
-
- @Override
- public Collection<ElementInfo> listElementsByName(SessionContext context,
- ElementContext elementContext,
- Id parentElementId, String elementName) {
- return null;
- }
-
- @Override
- public Optional<ElementInfo> getElementInfoByName(SessionContext context,
- ElementContext elementContext,
- Id parentElementId, String elementName) {
- return Optional.ofNullable(elementInfoMap.get(parentElementId+elementName));
- }
-
- @Override
- public Optional<Element> saveElement(SessionContext context, ElementContext elementContext,
- ZusammenElement element, String message) {
- return null;
- }
-
- @Override
- public Collection<HealthInfo> checkHealth(SessionContext context) {
- return null;
- }
-
- @Override
- public Id createItem(SessionContext context, Info info) {
- return null;
- }
-
- @Override
- public void updateItem(SessionContext context, Id itemId, Info info) {
-
- }
-
- @Override
- public Id createVersion(SessionContext context, Id itemId, Id baseVersionId,
- ItemVersionData itemVersionData) {
- return null;
- }
-
- @Override
- public void updateVersion(SessionContext context, Id itemId, Id versionId,
- ItemVersionData itemVersionData) {
-
- }
-
- @Override
- public void tagVersion(SessionContext context, Id itemId, Id versionId, Tag tag) {
-
- }
-
- @Override
- public void resetVersionHistory(SessionContext context, Id itemId, Id versionId, String changeRef) {
-
- }
-
- @Override
- public Optional<ElementInfo> getElementInfo(SessionContext context,
- ElementContext elementContext,
- Id elementId) {
- return null;
- }
-
- @Override
- public String getVersion(SessionContext sessionContext) {
- return null;
- }
-
- @Override
- public Collection<Item> listItems(SessionContext context) {
- return null;
- }
+ @Override
+ public Collection<ItemVersion> listPublicVersions(SessionContext context, Id itemId) {
+ return null;
}
+
+ @Override
+ public ItemVersion getPublicVersion(SessionContext context, Id itemId, Id versionId) {
+ return null;
+ }
+
+ @Override
+ public Optional<Element> getElement(SessionContext context, ElementContext elementContext,
+ String elementId) {
+ return null;
+ }
+
+ @Override
+ public Optional<Element> getElementByName(SessionContext context,
+ ElementContext elementContext,
+ Id parentElementId, String elementName) {
+ return null;
+ }
+
+ @Override
+ public Collection<ElementInfo> listElements(SessionContext context,
+ ElementContext elementContext,
+ Id parentElementId) {
+ return null;
+ }
+
+ @Override
+ public Collection<Element> listElementData(SessionContext context,
+ ElementContext elementContext,
+ Id parentElementId) {
+ return elements;
+ }
+
+ @Override
+ public Collection<ElementInfo> listElementsByName(SessionContext context,
+ ElementContext elementContext,
+ Id parentElementId, String elementName) {
+
+ if(elementName.equals(ElementType.VspModel.name())){
+ return elementInfoMap.values();
+ }
+
+ return null;
+ }
+
+ @Override
+ public Optional<ElementInfo> getElementInfoByName(SessionContext context,
+ ElementContext elementContext,
+ Id parentElementId, String elementName) {
+
+ if(elementName.equals(ElementType.Templates.name())){
+ return Optional.ofNullable(elementInfoMap.get("null" + elementName));
+ }else if(elementName.equals(ElementType.Artifacts.name())) {
+ return Optional.ofNullable(elementInfoMap.get("null" + elementName));
+ }
+
+ return Optional.empty();
+ }
+
+ @Override
+ public Element saveElement(SessionContext context, ElementContext elementContext,
+ ZusammenElement element, String message) {
+ return null;
+ }
+
+ @Override
+ public void resolveElementConflict(SessionContext context, ElementContext elementContext,
+ ZusammenElement element, Resolution resolution) {
+
+ }
+
+ @Override
+ public Collection<HealthInfo> checkHealth(SessionContext context) {
+ return null;
+ }
+
+ @Override
+ public Id createItem(SessionContext context, Info info) {
+ return null;
+ }
+
+ @Override
+ public void updateItem(SessionContext context, Id itemId, Info info) {
+
+ }
+
+ @Override
+ public Id createVersion(SessionContext context, Id itemId, Id baseVersionId,
+ ItemVersionData itemVersionData) {
+ return null;
+ }
+
+ @Override
+ public void updateVersion(SessionContext context, Id itemId, Id versionId,
+ ItemVersionData itemVersionData) {
+
+ }
+
+ @Override
+ public ItemVersion getVersion(SessionContext context, Id itemId, Id versionId) {
+ return null;
+ }
+
+ @Override
+ public ItemVersionStatus getVersionStatus(SessionContext context, Id itemId, Id versionId) {
+ return null;
+ }
+
+ @Override
+ public ItemVersionConflict getVersionConflict(SessionContext context, Id itemId, Id versionId) {
+ return null;
+ }
+
+ @Override
+ public void tagVersion(SessionContext context, Id itemId, Id versionId, Tag tag) {
+
+ }
+
+ @Override
+ public void resetVersionHistory(SessionContext context, Id itemId, Id versionId,
+ String changeRef) {
+
+
+ }
+
+ /*@Override
+ public void revertVersionToRevision(SessionContext context, Id itemId, Id versionId,
+ Id revisionId) {
+
+ }
+
+ @Override
+ public ItemVersionRevisions listVersionRevisions(SessionContext context, Id itemId,
+ Id versionId) {
+ return null;
+ }*/
+
+ @Override
+ public void publishVersion(SessionContext context, Id itemId, Id versionId, String message) {
+
+ }
+
+ @Override
+ public void syncVersion(SessionContext sessionContext, Id itemId, Id versionId) {
+
+ }
+
+ @Override
+ public void forceSyncVersion(SessionContext context, Id itemId, Id versionId) {
+
+ }
+
+ @Override
+ public Optional<ElementInfo> getElementInfo(SessionContext context,
+ ElementContext elementContext,
+ Id elementId) {
+ return null;
+ }
+
+ @Override
+ public String getVersion(SessionContext sessionContext) {
+ return null;
+ }
+
+ @Override
+ public void revert(SessionContext sessionContext, String itemId, String versionId,
+ String revisionId) {
+
+ }
+
+ @Override
+ public List<Revision> listRevisions(SessionContext sessionContext, String itemId,
+ String versionId) {
+ return null;
+ }
+
+ @Override
+ public Optional<ElementConflict> getElementConflict(SessionContext context,
+ ElementContext elementContext,
+ Id id) {
+ return null;
+ }
+
+ @Override
+ public Collection<Item> listItems(SessionContext context) {
+ return null;
+ }
+
+ @Override
+ public Item getItem(SessionContext context, Id itemId) {
+ return null;
+ }
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/impl/TxtInformationArtifactGeneratorImplTest.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/impl/TxtInformationArtifactGeneratorImplTest.java
index 9f2f733..dde8d83 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/impl/TxtInformationArtifactGeneratorImplTest.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/informationArtifact/impl/TxtInformationArtifactGeneratorImplTest.java
@@ -21,41 +21,9 @@
package org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.anyString;
-import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.HEADER;
-import static org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.impl.TxtInformationArtifactConstants.VFC_COMPUTE_CPU_OVER_SUBSCRIPTION;
-
-import org.junit.Assert;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
-import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactData;
import org.openecomp.sdc.vendorsoftwareproduct.questionnaire.QuestionnaireDataService;
-import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.ComponentQuestionnaire;
-import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.compute.Compute;
-import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.compute.GuestOS;
-import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.compute.NumOfVMs;
-import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.general.Hypervisor;
-import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.general.Recovery;
-import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.network.NetworkCapacity;
-import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic.IpConfiguration;
-import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic.Network;
-import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic.NicQuestionnaire;
-import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.nic.Protocols;
-import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.VspQuestionnaire;
-import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.general.Availability;
-import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.general.General;
-import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.vsp.general.StorageDataReplication;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
public class TxtInformationArtifactGeneratorImplTest {
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/pom.xml b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/pom.xml
index d11362c..dcf2c6a 100644
--- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/pom.xml
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/pom.xml
@@ -15,6 +15,21 @@
<dependencies>
<dependency>
<groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-session-lib</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-item-permissions-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-item-permissions-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
<artifactId>openecomp-facade-core</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/ItemManager.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/ItemManager.java
new file mode 100644
index 0000000..ee58902
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/ItemManager.java
@@ -0,0 +1,20 @@
+package org.openecomp.sdc.versioning;
+
+import org.openecomp.sdc.versioning.dao.types.VersionStatus;
+import org.openecomp.sdc.versioning.types.Item;
+
+import java.util.Collection;
+import java.util.function.Predicate;
+
+public interface ItemManager {
+
+ Collection<Item> list(Predicate<Item> predicate);
+
+ Item get(String itemId);
+
+ Item create(Item item);
+
+ void updateVersionStatus(String itemId, VersionStatus addedVersionStatus,
+ VersionStatus removedVersionStatus);
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDaoFactory.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/ItemManagerFactory.java
similarity index 79%
copy from openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDaoFactory.java
copy to openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/ItemManagerFactory.java
index 9654551..314ffce 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDaoFactory.java
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/ItemManagerFactory.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,14 +18,14 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.vendorsoftwareproduct.dao;
+package org.openecomp.sdc.versioning;
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
-public abstract class UploadDataDaoFactory extends AbstractComponentFactory<UploadDataDao> {
+public abstract class ItemManagerFactory extends AbstractComponentFactory<ItemManager> {
- public static UploadDataDaoFactory getInstance() {
- return AbstractFactory.getInstance(UploadDataDaoFactory.class);
+ public static ItemManagerFactory getInstance() {
+ return AbstractFactory.getInstance(ItemManagerFactory.class);
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/VersioningManager.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/VersioningManager.java
index 7fab254..c037694 100644
--- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/VersioningManager.java
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/VersioningManager.java
@@ -20,11 +20,14 @@
package org.openecomp.sdc.versioning;
+import org.openecomp.sdc.versioning.dao.types.Revision;
import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.types.VersionCreationMethod;
import org.openecomp.sdc.versioning.types.VersionInfo;
import org.openecomp.sdc.versioning.types.VersionableEntityAction;
import org.openecomp.sdc.versioning.types.VersionableEntityMetadata;
+import java.util.List;
import java.util.Map;
public interface VersioningManager {
@@ -54,4 +57,24 @@
Map<String, VersionInfo> listDeletedEntitiesVersionInfo(String entityType, String user,
VersionableEntityAction action);
+
+ List<Version> list(String itemId); // TODO: 5/24/2017 filter (by status for example)
+
+ Version get(String itemId, Version version);
+
+ Version create(String itemId, Version version,
+ VersionCreationMethod creationMethod);
+
+ void submit(String itemId, Version version, String submitDescription);
+
+ void publish(String itemId, Version version, String message);
+
+ void sync(String itemId, Version version);
+
+ void forceSync(String itemId, Version version);
+
+ void revert(String itemId, Version version, String revisionId);
+
+ List<Revision> listRevisions(String itemId, Version version);
+
}
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/VersioningNotificationConstansts.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/VersioningNotificationConstansts.java
new file mode 100644
index 0000000..42161df
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/VersioningNotificationConstansts.java
@@ -0,0 +1,13 @@
+package org.openecomp.sdc.versioning;
+
+/**
+ * @author avrahamg
+ * @since July 10, 2017
+ */
+public class VersioningNotificationConstansts {
+ public static final String ITEM_NAME = "itemName";
+ public static final String ITEM_ID = "itemId";
+ public static final String SUBMIT_DESCRIPTION = "description";
+ public static final String VERSION_NAME = "versionName";
+ public static final String VERSION_ID = "versionId";
+}
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/ItemDao.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/ItemDao.java
new file mode 100644
index 0000000..f1edc1e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/ItemDao.java
@@ -0,0 +1,15 @@
+package org.openecomp.sdc.versioning.dao;
+
+import org.openecomp.sdc.versioning.types.Item;
+
+import java.util.Collection;
+
+public interface ItemDao {
+ Collection<Item> list();
+
+ Item get(Item item);
+
+ Item create(Item item);
+
+ void update(Item item);
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDaoFactory.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/ItemDaoFactory.java
similarity index 79%
rename from openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDaoFactory.java
rename to openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/ItemDaoFactory.java
index 9654551..36edaa9 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDaoFactory.java
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/ItemDaoFactory.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,14 +18,13 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.vendorsoftwareproduct.dao;
+package org.openecomp.sdc.versioning.dao;
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
-public abstract class UploadDataDaoFactory extends AbstractComponentFactory<UploadDataDao> {
-
- public static UploadDataDaoFactory getInstance() {
- return AbstractFactory.getInstance(UploadDataDaoFactory.class);
+public abstract class ItemDaoFactory extends AbstractComponentFactory<ItemDao> {
+ public static ItemDaoFactory getInstance() {
+ return AbstractFactory.getInstance(ItemDaoFactory.class);
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/VersionDao.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/VersionDao.java
new file mode 100644
index 0000000..f557e4d
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/VersionDao.java
@@ -0,0 +1,29 @@
+package org.openecomp.sdc.versioning.dao;
+
+import org.openecomp.sdc.versioning.dao.types.Revision;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.List;
+import java.util.Optional;
+
+public interface VersionDao {
+ List<Version> list(String itemId);
+
+ void create(String itemId, Version version);
+
+ void update(String itemId, Version version);
+
+ Optional<Version> get(String itemId, Version version);
+
+ void delete(String itemId, Version version);
+
+ void publish(String itemId, Version version, String message);
+
+ void sync(String itemId, Version version);
+
+ void forceSync(String itemId, Version version);
+
+ void revert(String itemId, Version version, String revisionId);
+
+ List<Revision> listRevisions(String itemId, Version version);
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDaoFactory.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/VersionDaoFactory.java
similarity index 79%
copy from openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDaoFactory.java
copy to openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/VersionDaoFactory.java
index 9654551..845b248 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDaoFactory.java
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/VersionDaoFactory.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,14 +18,13 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.vendorsoftwareproduct.dao;
+package org.openecomp.sdc.versioning.dao;
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
-public abstract class UploadDataDaoFactory extends AbstractComponentFactory<UploadDataDao> {
-
- public static UploadDataDaoFactory getInstance() {
- return AbstractFactory.getInstance(UploadDataDaoFactory.class);
+public abstract class VersionDaoFactory extends AbstractComponentFactory<VersionDao> {
+ public static VersionDaoFactory getInstance() {
+ return AbstractFactory.getInstance(VersionDaoFactory.class);
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/types/Revision.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/types/Revision.java
new file mode 100644
index 0000000..492e75f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/types/Revision.java
@@ -0,0 +1,42 @@
+package org.openecomp.sdc.versioning.dao.types;
+
+import java.util.Date;
+
+public class Revision {
+ private String id;
+ private String message;
+ private Date time;
+ private String user;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public void setTime(Date time) {
+ this.time = time;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public Date getTime() {
+ return time;
+ }
+
+ public String getUser() {
+ return user;
+ }
+
+ public void setUser(String user) {
+ this.user = user;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/types/SynchronizationState.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/types/SynchronizationState.java
new file mode 100644
index 0000000..f0142d3
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/types/SynchronizationState.java
@@ -0,0 +1,17 @@
+package org.openecomp.sdc.versioning.dao.types;
+
+public enum SynchronizationState {
+ UpToDate("Up to date"),
+ OutOfSync("Out of sync"),
+ Merging("Merging");
+
+ private String displayName;
+
+ SynchronizationState(String displayName) {
+ this.displayName = displayName;
+ }
+
+ public String toString() {
+ return this.displayName;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/types/Version.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/types/Version.java
index 82b79c6..b1f0b71 100644
--- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/types/Version.java
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/types/Version.java
@@ -22,23 +22,44 @@
import com.datastax.driver.mapping.annotations.Transient;
import com.datastax.driver.mapping.annotations.UDT;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
+
+import java.util.Date;
+import java.util.Map;
@UDT(name = "version", keyspace = "dox")
public class Version {
- private static final Logger logger = LoggerFactory.getLogger(Version.class);
public static final String VERSION_STRING_VIOLATION_MSG =
"Version string must be in the format of: {integer}.{integer}";
- private int major;
- private int minor;
@Transient
- private VersionStatus status = VersionStatus.Available;
+ private String id;
+ private int major; // TODO: 6/7/2017 remove!
+ private int minor; // TODO: 6/7/2017 remove!
+ @Transient
+ private String name;
+ @Transient
+ private String description;
+ @Transient
+ private String baseId;
+ @Transient
+ private Date creationTime;
+ @Transient
+ private Date modificationTime;
+ @Transient
+ private VersionStatus status = VersionStatus.Draft;
+ @Transient
+ private VersionState state;
+ @Transient
+ private Map<String, Object> additionalInfo;
public Version() {
}
+ public Version(String id) {
+ this.id = id;
+ }
+
+ @Deprecated
public Version(int major, int minor) {
this.major = major;
this.minor = minor;
@@ -62,7 +83,6 @@
try {
version = new Version(Integer.parseInt(versionLevels[0]), Integer.parseInt(versionLevels[1]));
} catch (Exception ex) {
- logger.debug(ex.getMessage(), ex);
throw new IllegalArgumentException(VERSION_STRING_VIOLATION_MSG);
}
@@ -85,6 +105,54 @@
this.minor = minor;
}
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getBaseId() {
+ return baseId;
+ }
+
+ public void setBaseId(String baseId) {
+ this.baseId = baseId;
+ }
+
+ public Date getCreationTime() {
+ return creationTime;
+ }
+
+ public void setCreationTime(Date creationTime) {
+ this.creationTime = creationTime;
+ }
+
+ public Date getModificationTime() {
+ return modificationTime;
+ }
+
+ public void setModificationTime(Date modificationTime) {
+ this.modificationTime = modificationTime;
+ }
+
public VersionStatus getStatus() {
return status;
}
@@ -93,6 +161,14 @@
this.status = status;
}
+ public VersionState getState() {
+ return state;
+ }
+
+ public void setState(VersionState state) {
+ this.state = state;
+ }
+
public Version calculateNextCandidate() {
return new Version(major, minor + 1);
}
@@ -105,6 +181,14 @@
return major != 0 && minor == 0;
}
+ public Map<String, Object> getAdditionalInfo() {
+ return additionalInfo;
+ }
+
+ public void setAdditionalInfo(Map<String, Object> additionalInfo) {
+ this.additionalInfo = additionalInfo;
+ }
+
@Override
public int hashCode() {
int result = major;
@@ -138,6 +222,21 @@
@Override
public String toString() {
- return major + "." + minor;
+ return name != null ? name : major + "." + minor;
}
-}
+
+ @Override
+ public Version clone() {
+ Version version = new Version();
+ version.setStatus(this.getStatus());
+ version.setCreationTime(this.getCreationTime());
+ version.setName(this.getName());
+ version.setBaseId(this.getBaseId());
+ version.setMajor(this.major);
+ version.setMinor(this.minor);
+ version.setModificationTime(this.getModificationTime());
+ version.setDescription(this.description);
+ version.setId(this.getId());
+ return version;
+ }
+}
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/types/VersionState.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/types/VersionState.java
new file mode 100644
index 0000000..8d48980
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/types/VersionState.java
@@ -0,0 +1,23 @@
+package org.openecomp.sdc.versioning.dao.types;
+
+public class VersionState {
+ private SynchronizationState synchronizationState;
+ private boolean dirty;
+
+ public SynchronizationState getSynchronizationState() {
+ return synchronizationState;
+ }
+
+ public void setSynchronizationState(
+ SynchronizationState synchronizationState) {
+ this.synchronizationState = synchronizationState;
+ }
+
+ public boolean isDirty() {
+ return dirty;
+ }
+
+ public void setDirty(boolean dirty) {
+ this.dirty = dirty;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/types/VersionStatus.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/types/VersionStatus.java
index cf980d6..e330b95 100644
--- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/types/VersionStatus.java
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/types/VersionStatus.java
@@ -21,7 +21,7 @@
package org.openecomp.sdc.versioning.dao.types;
public enum VersionStatus {
- Available,
- Locked,
- Final
+ Draft,
+ Locked, /* todo remove!!*/
+ Certified
}
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/errors/EditOnUnlockedEntityErrorBuilder.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/errors/EditOnUnlockedEntityErrorBuilder.java
index 4de5618..367a93b 100644
--- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/errors/EditOnUnlockedEntityErrorBuilder.java
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/errors/EditOnUnlockedEntityErrorBuilder.java
@@ -20,11 +20,11 @@
package org.openecomp.sdc.versioning.errors;
-import static org.openecomp.sdc.versioning.errors.VersioningErrorCodes.EDIT_ON_UNLOCKED_ENTITY;
-
import org.openecomp.sdc.common.errors.BaseErrorBuilder;
import org.openecomp.sdc.common.errors.ErrorCategory;
+import static org.openecomp.sdc.versioning.errors.VersioningErrorCodes.EDIT_ON_UNLOCKED_ENTITY;
+
/**
* The type Edit on unlocked entity error builder.
*/
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/errors/RevisionIdNotFoundErrorBuilder.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/errors/RevisionIdNotFoundErrorBuilder.java
new file mode 100644
index 0000000..0075403
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/errors/RevisionIdNotFoundErrorBuilder.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.versioning.errors;
+
+import org.openecomp.sdc.common.errors.BaseErrorBuilder;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+
+/**
+ * The mandatory field revision id not found error builder.
+ */
+public class RevisionIdNotFoundErrorBuilder extends BaseErrorBuilder {
+
+ private static final String REVISION_ID_NOT_FOUND_MSG =
+ "Mandatory field revision id missing";
+
+ /**
+ * Instantiates a new Versionable sub entity not found error builder.
+ */
+ public RevisionIdNotFoundErrorBuilder() {
+ getErrorCodeBuilder().withId(VersioningErrorCodes.MANDATORY_FIELD_REVISION_ID_MISSING);
+ getErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION);
+ getErrorCodeBuilder().withMessage(REVISION_ID_NOT_FOUND_MSG);
+ }
+
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/errors/VersionableSubEntityNotFoundErrorBuilder.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/errors/VersionableSubEntityNotFoundErrorBuilder.java
index 77be83f..f717e5d 100644
--- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/errors/VersionableSubEntityNotFoundErrorBuilder.java
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/errors/VersionableSubEntityNotFoundErrorBuilder.java
@@ -53,7 +53,7 @@
getErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION);
getErrorCodeBuilder().withMessage(String
.format(SUB_ENTITY_NOT_FOUND_MSG, entityType, entityId, containingEntityType,
- containingEntityId, version.toString()));
+ containingEntityId, version.getId()));
}
/**
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/errors/VersioningErrorCodes.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/errors/VersioningErrorCodes.java
index c1c6b96..3dd87d5 100644
--- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/errors/VersioningErrorCodes.java
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/errors/VersioningErrorCodes.java
@@ -40,4 +40,10 @@
public static final String UNDO_CHECKOUT_ON_ENTITY_LOCKED_BY_OTHER_USER =
"UNDO_CHECKOUT_ON_ENTITY_LOCKED_BY_OTHER_USER";
public static final String UNDO_CHECKOUT_ON_UNLOCKED_ENTITY = "UNDO_CHECKOUT_ON_UNLOCKED_ENTITY";
+ public static final String MANDATORY_FIELD_REVISION_ID_MISSING =
+ "MANDATORY_FIELD_REVISION_ID_MISSING";
+
+
+
+
}
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/types/Item.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/types/Item.java
new file mode 100644
index 0000000..329ac52
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/types/Item.java
@@ -0,0 +1,103 @@
+package org.openecomp.sdc.versioning.types;
+
+import org.openecomp.sdc.versioning.dao.types.VersionStatus;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+public class Item {
+ private String id;
+ private String type;
+ private String name;
+ private String description;
+ private Map<String, Object> properties = new HashMap<>();
+ private Map<VersionStatus, Integer> versionStatusCounters = new HashMap<>();
+ private Date creationTime;
+ private Date modificationTime;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Map<String, Object> getProperties() {
+ return properties;
+ }
+
+ public void addProperty(String key, Object value) {
+ properties.put(key, value);
+ }
+
+ public void setProperties(Map<String, Object> properties) {
+ this.properties = properties;
+ }
+
+ public Map<VersionStatus, Integer> getVersionStatusCounters() {
+ return versionStatusCounters;
+ }
+
+ public void setVersionStatusCounters(Map<VersionStatus, Integer> versionStatusCounters) {
+ this.versionStatusCounters = versionStatusCounters;
+ }
+
+ public void addVersionStatus(VersionStatus versionStatus) {
+ Integer counter = versionStatusCounters.get(versionStatus);
+ versionStatusCounters
+ .put(versionStatus, counter == null ? 1 : counter + 1);
+ }
+
+ public void removeVersionStatus(VersionStatus versionStatus) {
+ Integer counter = versionStatusCounters.get(versionStatus);
+ if (counter != null) {
+ if (counter == 1) {
+ versionStatusCounters.remove(versionStatus);
+ } else {
+ versionStatusCounters.put(versionStatus, counter - 1);
+ }
+ }
+ }
+
+ public Date getCreationTime() {
+ return creationTime;
+ }
+
+ public void setCreationTime(Date creationTime) {
+ this.creationTime = creationTime;
+ }
+
+ public Date getModificationTime() {
+ return modificationTime;
+ }
+
+ public void setModificationTime(Date modificationTime) {
+ this.modificationTime = modificationTime;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/types/NotificationEventTypes.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/types/NotificationEventTypes.java
new file mode 100644
index 0000000..b62f7b5
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/types/NotificationEventTypes.java
@@ -0,0 +1,20 @@
+package org.openecomp.sdc.versioning.types;
+
+/**
+ * @author avrahamg
+ * @since July 10, 2017
+ */
+public enum NotificationEventTypes {
+ SUBMIT("submit"),
+ COMMIT("commit");
+
+ private String eventName;
+
+ NotificationEventTypes(String eventName) {
+ this.eventName = eventName;
+ }
+
+ public String getEventName() {
+ return eventName;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/types/VersionCreationMethod.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/types/VersionCreationMethod.java
new file mode 100644
index 0000000..6404b6b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/types/VersionCreationMethod.java
@@ -0,0 +1,8 @@
+package org.openecomp.sdc.versioning.types;
+
+public enum VersionCreationMethod {
+ /*parent_level,
+ same_level,
+ sub_level*/
+ major,minor
+}
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/resources/factoryConfiguration.json b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/resources/factoryConfiguration.json
index e38ad1a..90d11f1 100644
--- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/resources/factoryConfiguration.json
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/resources/factoryConfiguration.json
@@ -1,6 +1,10 @@
{
+ "org.openecomp.sdc.versioning.ItemManagerFactory": "org.openecomp.sdc.versioning.impl.ItemManagerFactoryImpl",
"org.openecomp.sdc.versioning.VersioningManagerFactory": "org.openecomp.sdc.versioning.impl.VersioningManagerFactoryImpl",
"org.openecomp.sdc.versioning.dao.VersionableEntityDaoFactory": "org.openecomp.sdc.versioning.dao.impl.VersionableEntityDaoFactoryImpl",
"org.openecomp.sdc.versioning.dao.VersionInfoDaoFactory": "org.openecomp.sdc.versioning.dao.impl.VersionInfoDaoFactoryImpl",
- "org.openecomp.sdc.versioning.dao.VersionInfoDeletedDaoFactory": "org.openecomp.sdc.versioning.dao.impl.VersionInfoDeletedDaoFactoryImpl"
+ "org.openecomp.sdc.versioning.dao.VersionInfoDeletedDaoFactory": "org.openecomp.sdc.versioning.dao.impl.VersionInfoDeletedDaoFactoryImpl",
+ "org.openecomp.sdc.versioning.dao.ItemDaoFactory": "org.openecomp.sdc.versioning.dao.impl.ItemDaoFactoryImpl",
+ "org.openecomp.sdc.versioning.dao.VersionDaoFactory": "org.openecomp.sdc.versioning.dao.impl.VersionDaoFactoryImpl",
+ "org.openecomp.sdc.versioning.dao.HealthCheckDaoFactory": "org.openecomp.sdc.model.impl.HealthCheckDaoFactoryImpl"
}
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/VersionCalculator.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/VersionCalculator.java
new file mode 100644
index 0000000..dc9ac7b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/VersionCalculator.java
@@ -0,0 +1,12 @@
+package org.openecomp.sdc.versioning;
+
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.types.VersionCreationMethod;
+
+import java.util.Set;
+
+public interface VersionCalculator {
+ String calculate(String baseVersion, VersionCreationMethod creationMethod);
+
+ void injectAdditionalInfo(Version version, Set<String> existingVersions);
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDaoFactory.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/VersionCalculatorFactory.java
similarity index 79%
copy from openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDaoFactory.java
copy to openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/VersionCalculatorFactory.java
index 9654551..85f02cd 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/UploadDataDaoFactory.java
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/VersionCalculatorFactory.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,14 +18,14 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.vendorsoftwareproduct.dao;
+package org.openecomp.sdc.versioning;
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
-public abstract class UploadDataDaoFactory extends AbstractComponentFactory<UploadDataDao> {
+public abstract class VersionCalculatorFactory extends AbstractComponentFactory<VersionCalculator> {
- public static UploadDataDaoFactory getInstance() {
- return AbstractFactory.getInstance(UploadDataDaoFactory.class);
+ public static VersionCalculatorFactory getInstance() {
+ return AbstractFactory.getInstance(VersionCalculatorFactory.class);
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/ItemDaoFactoryImpl.java
similarity index 66%
copy from openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductDaoFactoryImpl.java
copy to openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/ItemDaoFactoryImpl.java
index 0a80b2a..0f9c906 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductDaoFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/ItemDaoFactoryImpl.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,17 +18,19 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.vendorsoftwareproduct.dao.impl;
+package org.openecomp.sdc.versioning.dao.impl;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
+import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
+import org.openecomp.sdc.versioning.dao.ItemDao;
+import org.openecomp.sdc.versioning.dao.ItemDaoFactory;
+import org.openecomp.sdc.versioning.dao.impl.zusammen.ItemZusammenDaoImpl;
-
-public class VendorSoftwareProductDaoFactoryImpl extends VendorSoftwareProductDaoFactory {
- private static final VendorSoftwareProductDao INSTANCE = new VendorSoftwareProductDaoImpl();
+public class ItemDaoFactoryImpl extends ItemDaoFactory {
+ private static ItemDao INSTANCE =
+ new ItemZusammenDaoImpl(ZusammenAdaptorFactory.getInstance().createInterface());
@Override
- public VendorSoftwareProductDao createInterface() {
+ public ItemDao createInterface() {
return INSTANCE;
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/VersionDaoFactoryImpl.java
similarity index 65%
copy from openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductDaoFactoryImpl.java
copy to openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/VersionDaoFactoryImpl.java
index 0a80b2a..f8b0d71 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VendorSoftwareProductDaoFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/VersionDaoFactoryImpl.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,17 +18,19 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.vendorsoftwareproduct.dao.impl;
+package org.openecomp.sdc.versioning.dao.impl;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
+import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
+import org.openecomp.sdc.versioning.dao.VersionDao;
+import org.openecomp.sdc.versioning.dao.VersionDaoFactory;
+import org.openecomp.sdc.versioning.dao.impl.zusammen.VersionZusammenDaoImpl;
-
-public class VendorSoftwareProductDaoFactoryImpl extends VendorSoftwareProductDaoFactory {
- private static final VendorSoftwareProductDao INSTANCE = new VendorSoftwareProductDaoImpl();
+public class VersionDaoFactoryImpl extends VersionDaoFactory {
+ private static VersionDao INSTANCE =
+ new VersionZusammenDaoImpl(ZusammenAdaptorFactory.getInstance().createInterface());
@Override
- public VendorSoftwareProductDao createInterface() {
+ public VersionDao createInterface() {
return INSTANCE;
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/VersionableEntityDaoCassandraImpl.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/VersionableEntityDaoCassandraImpl.java
index 5673da7..0845bea 100644
--- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/VersionableEntityDaoCassandraImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/VersionableEntityDaoCassandraImpl.java
@@ -24,12 +24,12 @@
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.Row;
import com.datastax.driver.mapping.UDTMapper;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.core.nosqldb.api.NoSqlDb;
import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
import org.openecomp.core.util.UniqueValueUtil;
import org.openecomp.core.utilities.CommonMethods;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.versioning.dao.VersionableEntityDao;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdc.versioning.types.UniqueValueMetadata;
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/zusammen/ItemZusammenDaoImpl.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/zusammen/ItemZusammenDaoImpl.java
new file mode 100644
index 0000000..8fdcf71
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/zusammen/ItemZusammenDaoImpl.java
@@ -0,0 +1,104 @@
+package org.openecomp.sdc.versioning.dao.impl.zusammen;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.item.Info;
+import org.openecomp.core.zusammen.api.ZusammenAdaptor;
+import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.versioning.dao.ItemDao;
+import org.openecomp.sdc.versioning.dao.types.VersionStatus;
+import org.openecomp.sdc.versioning.types.Item;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+public class ItemZusammenDaoImpl implements ItemDao {
+
+ private ZusammenAdaptor zusammenAdaptor;
+
+ public ItemZusammenDaoImpl(ZusammenAdaptor zusammenAdaptor) {
+ this.zusammenAdaptor = zusammenAdaptor;
+ }
+
+ @Override
+ public Collection<Item> list() {
+ return zusammenAdaptor.listItems(ZusammenUtil.createSessionContext())
+ .stream().map(this::mapFromZusammenItem)
+ .collect(Collectors.toList());
+ }
+
+ @Override
+ public Item get(Item item) {
+ return mapFromZusammenItem(
+ zusammenAdaptor.getItem(ZusammenUtil.createSessionContext(), new Id(item.getId())));
+ }
+
+ @Override
+ public Item create(Item item) {
+ Id itemId = zusammenAdaptor
+ .createItem(ZusammenUtil.createSessionContext(), mapToZusammenItemInfo(item));
+ item.setId(itemId.getValue());
+ return item;
+ }
+
+ @Override
+ public void update(Item item) {
+ zusammenAdaptor
+ .updateItem(ZusammenUtil.createSessionContext(), new Id(item.getId()),
+ mapToZusammenItemInfo(item));
+ }
+
+ private Item mapFromZusammenItem(com.amdocs.zusammen.datatypes.item.Item zusammenItem) {
+ if (zusammenItem == null) {
+ return null;
+ }
+ Item item = new Item();
+ item.setId(zusammenItem.getId().getValue());
+ item.setName(zusammenItem.getInfo().getName());
+ item.setDescription(zusammenItem.getInfo().getDescription());
+
+ zusammenItem.getInfo().getProperties().entrySet()
+ .forEach(property -> addPropertyToItem(property.getKey(), property.getValue(), item));
+
+ item.setCreationTime(zusammenItem.getCreationTime());
+ item.setModificationTime(zusammenItem.getModificationTime());
+ return item;
+ }
+
+ private void addPropertyToItem(String propertyKey, Object propertyValue, Item item) {
+ switch (propertyKey) {
+ case InfoPropertyName.ITEM_TYPE:
+ item.setType((String) propertyValue);
+ break;
+ case InfoPropertyName.ITEM_VERSIONS_STATUSES:
+ for (Map.Entry<String, Number> statusCounter :
+ ((Map<String, Number>) propertyValue).entrySet()) {
+ item.getVersionStatusCounters().put(VersionStatus.valueOf(statusCounter.getKey()),
+ statusCounter.getValue().intValue());
+ }
+ break;
+ default:
+ item.addProperty(propertyKey, propertyValue);
+ }
+ }
+
+ private Info mapToZusammenItemInfo(Item item) {
+ Info info = new Info();
+ info.setName(item.getName());
+ info.setDescription(item.getDescription());
+ info.addProperty(InfoPropertyName.ITEM_TYPE, item.getType());
+ info.addProperty(InfoPropertyName.ITEM_VERSIONS_STATUSES, item.getVersionStatusCounters());
+ item.getProperties().entrySet()
+ .forEach(property -> info.addProperty(property.getKey(), property.getValue()));
+ return info;
+ }
+
+ private static final class InfoPropertyName {
+ private static final String ITEM_TYPE = "item_type";
+ private static final String ITEM_VERSIONS_STATUSES = "item_versions_statuses";
+
+ private InfoPropertyName() {
+ throw new IllegalStateException("Constants class");
+ }
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/zusammen/VersionZusammenDaoImpl.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/zusammen/VersionZusammenDaoImpl.java
new file mode 100644
index 0000000..195973b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/zusammen/VersionZusammenDaoImpl.java
@@ -0,0 +1,165 @@
+package org.openecomp.sdc.versioning.dao.impl.zusammen;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.Info;
+import com.amdocs.zusammen.datatypes.item.ItemVersion;
+import com.amdocs.zusammen.datatypes.item.ItemVersionData;
+import com.amdocs.zusammen.datatypes.item.ItemVersionStatus;
+import com.amdocs.zusammen.datatypes.item.SynchronizationStatus;
+import org.openecomp.core.zusammen.api.ZusammenAdaptor;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdc.versioning.dao.VersionDao;
+import org.openecomp.sdc.versioning.dao.impl.zusammen.convertor.ItemVersionToVersionConvertor;
+import org.openecomp.sdc.versioning.dao.types.Revision;
+import org.openecomp.sdc.versioning.dao.types.SynchronizationState;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.dao.types.VersionState;
+
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
+public class VersionZusammenDaoImpl implements VersionDao {
+
+ public static final class ZusammenProperty {
+ public static final String LABEL = "label";
+ public static final String STATUS = "status";
+
+ private ZusammenProperty() {
+ throw new IllegalStateException("Constants class");
+ }
+ }
+
+ private ZusammenAdaptor zusammenAdaptor;
+
+ public VersionZusammenDaoImpl(ZusammenAdaptor zusammenAdaptor) {
+ this.zusammenAdaptor = zusammenAdaptor;
+ }
+
+ @Override
+ public List<Version> list(String itemId) {
+ ItemVersionToVersionConvertor convertor = new ItemVersionToVersionConvertor();
+ return zusammenAdaptor.listPublicVersions(createSessionContext(), new Id(itemId)).stream()
+ .map(convertor::convert)
+ .collect(Collectors.toList());
+ }
+
+ @Override
+ public void create(String itemId, Version version) {
+ Id versionId =
+ zusammenAdaptor.createVersion(createSessionContext(), new Id(itemId),
+ version.getBaseId() == null ? null : new Id(version.getBaseId()),
+ mapToZusammenVersion(version));
+
+ version.setId(versionId.getValue());
+ }
+
+ @Override
+ public void update(String itemId, Version version) {
+ zusammenAdaptor.updateVersion(createSessionContext(), new Id(itemId), new Id(version.getId()),
+ mapToZusammenVersion(version));
+ }
+
+ @Override
+ public Optional<Version> get(String itemId, Version version) {
+ SessionContext context = createSessionContext();
+ Id itemIdObj = new Id(itemId);
+ Id versionId = new Id(version.getId());
+ ItemVersion itemVersion = zusammenAdaptor.getVersion(context, itemIdObj, versionId);
+
+ if (itemVersion == null) {
+ return Optional.empty();
+ }
+
+ VersionState versionState =
+ convertState(zusammenAdaptor.getVersionStatus(context, itemIdObj, versionId));
+ updateVersionStatus(context, itemIdObj, versionId, versionState, itemVersion);
+
+ Version result = new ItemVersionToVersionConvertor().convert(itemVersion);
+ result.setState(versionState);
+ return Optional.of(result);
+ }
+
+ @Override
+ public void delete(String itemId, Version version) {
+ throw new UnsupportedOperationException("Delete version operation is not yet supported.");
+ }
+
+ @Override
+ public void publish(String itemId, Version version, String message) {
+ zusammenAdaptor
+ .publishVersion(createSessionContext(), new Id(itemId), new Id(version.getId()), message);
+ }
+
+ @Override
+ public void sync(String itemId, Version version) {
+ zusammenAdaptor
+ .syncVersion(createSessionContext(), new Id(itemId), new Id(version.getId()));
+ }
+
+ @Override
+ public void forceSync(String itemId, Version version) {
+ zusammenAdaptor
+ .forceSyncVersion(createSessionContext(), new Id(itemId), new Id(version.getId()));
+ }
+
+ @Override
+ public void revert(String itemId, Version version, String revisionId) {
+ zusammenAdaptor.revert(createSessionContext(), itemId, version.getId(), revisionId);
+ }
+
+ @Override
+ public List<Revision> listRevisions(String itemId, Version version) {
+ return zusammenAdaptor.listRevisions(createSessionContext(), itemId, version.getId());
+ }
+
+ private void updateVersionStatus(SessionContext context, Id itemId, Id versionId,
+ VersionState versionState, ItemVersion itemVersion) {
+ if (versionState.getSynchronizationState() != SynchronizationState.UpToDate ||
+ versionState.isDirty()) {
+ String versionStatus = zusammenAdaptor.getPublicVersion(context, itemId, versionId)
+ .getData().getInfo().getProperty(ZusammenProperty.STATUS);
+ itemVersion.getData().getInfo().addProperty(ZusammenProperty.STATUS, versionStatus);
+ }
+ }
+
+ private ItemVersionData mapToZusammenVersion(Version version) {
+ Info info = new Info();
+ info.addProperty(ZusammenProperty.LABEL, version.toString());
+ info.addProperty(ZusammenProperty.STATUS, version.getStatus().name());
+ info.setName(version.getName());
+ info.setDescription(version.getDescription());
+
+ ItemVersionData itemVersionData = new ItemVersionData();
+ itemVersionData.setInfo(info);
+ return itemVersionData;
+ }
+
+ private VersionState convertState(ItemVersionStatus versionStatus) {
+ VersionState state = new VersionState();
+ state.setSynchronizationState(getSyncState(versionStatus.getSynchronizationStatus()));
+ state.setDirty(versionStatus.isDirty());
+ return state;
+ }
+
+ private SynchronizationState getSyncState(SynchronizationStatus synchronizationStatus) {
+ switch (synchronizationStatus) {
+ case UP_TO_DATE:
+ return SynchronizationState.UpToDate;
+ case OUT_OF_SYNC:
+ return SynchronizationState.OutOfSync;
+ case MERGING:
+ return SynchronizationState.Merging;
+ default:
+ throw new CoreException(new ErrorCode.ErrorCodeBuilder()
+ .withCategory(ErrorCategory.APPLICATION)
+ .withId("UNKNOWN_VERSION_STATE")
+ .withMessage("Version state is unknown").build());
+ }
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/zusammen/convertor/ItemVersionToVersionConvertor.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/zusammen/convertor/ItemVersionToVersionConvertor.java
new file mode 100644
index 0000000..f47b5aa
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/zusammen/convertor/ItemVersionToVersionConvertor.java
@@ -0,0 +1,49 @@
+package org.openecomp.sdc.versioning.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.item.Item;
+import com.amdocs.zusammen.datatypes.item.ItemVersion;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.sdc.versioning.dao.impl.zusammen.VersionZusammenDaoImpl;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.dao.types.VersionStatus;
+
+public class ItemVersionToVersionConvertor extends ElementConvertor {
+ @Override
+ public Object convert(Element element) {
+ return null;
+ }
+
+ @Override
+ public Object convert(Item item) {
+ return null;
+ }
+
+ @Override
+ public Object convert(ElementInfo elementInfo) {
+ return null;
+ }
+
+ @Override
+ public Version convert(ItemVersion itemVersion) {
+ if (itemVersion == null) {
+ return null;
+ }
+ Version version = Version.valueOf(
+ itemVersion.getData().getInfo().getProperty(VersionZusammenDaoImpl.ZusammenProperty.LABEL));
+ version.setStatus(VersionStatus.valueOf(itemVersion.getData().getInfo()
+ .getProperty(VersionZusammenDaoImpl.ZusammenProperty.STATUS)));
+ version.setName(itemVersion.getData().getInfo().getName());
+ version.setDescription(itemVersion.getData().getInfo().getDescription());
+
+ version.setId(itemVersion.getId().getValue());
+ if (itemVersion.getBaseId() != null) {
+ version.setBaseId(itemVersion.getBaseId().getValue());
+ }
+ version.setCreationTime(itemVersion.getCreationTime());
+ version.setModificationTime(itemVersion.getModificationTime());
+ return version;
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/ItemManagerFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/ItemManagerFactoryImpl.java
new file mode 100644
index 0000000..ba5bd07
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/ItemManagerFactoryImpl.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.versioning.impl;
+
+import org.openecomp.sdc.itempermissions.PermissionsServicesFactory;
+import org.openecomp.sdc.notification.factories.SubscriptionServiceFactory;
+import org.openecomp.sdc.versioning.ItemManager;
+import org.openecomp.sdc.versioning.ItemManagerFactory;
+import org.openecomp.sdc.versioning.dao.ItemDaoFactory;
+
+public class ItemManagerFactoryImpl extends ItemManagerFactory {
+ private static final ItemManager INSTANCE =
+ new ItemManagerImpl(ItemDaoFactory.getInstance().createInterface(),
+ PermissionsServicesFactory.getInstance().createInterface(),
+ SubscriptionServiceFactory.getInstance().createInterface());
+
+ @Override
+ public ItemManager createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/ItemManagerImpl.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/ItemManagerImpl.java
new file mode 100644
index 0000000..7928454
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/ItemManagerImpl.java
@@ -0,0 +1,68 @@
+package org.openecomp.sdc.versioning.impl;
+
+import org.openecomp.sdc.common.session.SessionContextProviderFactory;
+import org.openecomp.sdc.itempermissions.PermissionsServices;
+import org.openecomp.sdc.notification.services.SubscriptionService;
+import org.openecomp.sdc.versioning.ItemManager;
+import org.openecomp.sdc.versioning.dao.ItemDao;
+import org.openecomp.sdc.versioning.dao.types.VersionStatus;
+import org.openecomp.sdc.versioning.types.Item;
+
+import java.util.Collection;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+
+public class ItemManagerImpl implements ItemManager {
+ public static final String CREATE_ITEM = "Create_Item";
+
+ private ItemDao itemDao;
+ private PermissionsServices permissionsServices;
+ private SubscriptionService subscriptionService;
+
+ public ItemManagerImpl(ItemDao itemDao, PermissionsServices permissionsServices,
+ SubscriptionService subscriptionService) {
+ this.itemDao = itemDao;
+ this.permissionsServices = permissionsServices;
+ this.subscriptionService = subscriptionService;
+ }
+
+ @Override
+ public Collection<Item> list(Predicate<Item> predicate) {
+ return itemDao.list().stream().filter(predicate).collect(Collectors.toList());
+ }
+
+ @Override
+ public Item get(String itemId) {
+ Item item = new Item();
+ item.setId(itemId);
+ return itemDao.get(item);
+ }
+
+ @Override
+ public Item create(Item item) {
+ Item createdItem = itemDao.create(item);
+
+ String userId = SessionContextProviderFactory.getInstance()
+ .createInterface().get().getUser().getUserId();
+ String itemId = createdItem.getId();
+ permissionsServices.execute(itemId, userId, CREATE_ITEM);
+ subscriptionService.subscribe(userId, itemId);
+
+ return createdItem;
+ }
+
+ @Override
+ public void updateVersionStatus(String itemId, VersionStatus addedVersionStatus,
+ VersionStatus removedVersionStatus) {
+ Item item = get(itemId);
+ if (item == null) {
+ return;
+ }
+
+ item.addVersionStatus(addedVersionStatus);
+ if (removedVersionStatus != null) {
+ item.removeVersionStatus(removedVersionStatus);
+ }
+ itemDao.update(item);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/MajorVersionCalculatorFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/MajorVersionCalculatorFactoryImpl.java
new file mode 100644
index 0000000..2300f62
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/MajorVersionCalculatorFactoryImpl.java
@@ -0,0 +1,14 @@
+package org.openecomp.sdc.versioning.impl;
+
+import org.openecomp.sdc.versioning.VersionCalculator;
+import org.openecomp.sdc.versioning.VersionCalculatorFactory;
+
+public class MajorVersionCalculatorFactoryImpl extends VersionCalculatorFactory {
+ private static final VersionCalculator INSTANCE =
+ new MajorVersionCalculatorImpl();
+
+ @Override
+ public VersionCalculator createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/MajorVersionCalculatorImpl.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/MajorVersionCalculatorImpl.java
new file mode 100644
index 0000000..91c59e0
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/MajorVersionCalculatorImpl.java
@@ -0,0 +1,53 @@
+package org.openecomp.sdc.versioning.impl;
+
+import org.openecomp.core.utilities.CommonMethods;
+import org.openecomp.sdc.versioning.VersionCalculator;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.dao.types.VersionStatus;
+import org.openecomp.sdc.versioning.types.VersionCreationMethod;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class MajorVersionCalculatorImpl implements VersionCalculator {
+ private static final String INITIAL_VERSION = "1.0";
+ private static final String VERSION_STRING_VIOLATION_MSG =
+ "Version string must be in the format of: {integer}.{integer}";
+
+ @Override
+ public String calculate(String baseVersion, VersionCreationMethod creationMethod) {
+
+ if (baseVersion == null) {
+ return INITIAL_VERSION;
+ }
+
+ String[] versionLevels = baseVersion.split("\\.");
+ if (versionLevels.length != 2) {
+ throw new IllegalArgumentException(VERSION_STRING_VIOLATION_MSG);
+ }
+
+ int index = Integer.parseInt(versionLevels[0]);
+ index++;
+ versionLevels[0] = Integer.toString(index);
+ versionLevels[1] = "0";
+
+ return CommonMethods.arrayToSeparatedString(versionLevels, '.');
+ }
+
+ @Override
+ public void injectAdditionalInfo(Version version, Set<String> existingVersions) {
+ String optionalVersion;
+ Set<VersionCreationMethod> optionalCreationMethods = new HashSet<>();
+ if(version.getStatus().equals(VersionStatus.Certified)) {
+ try {
+ optionalVersion = calculate(version.getName(), VersionCreationMethod.major);
+ if (!existingVersions.contains(optionalVersion)) {
+ optionalCreationMethods.add(VersionCreationMethod.major);
+ }
+ } catch (IllegalArgumentException iae) {
+ //not a valid creation method.
+ }
+ }
+ version.getAdditionalInfo().put("OptionalCreationMethods", optionalCreationMethods);
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activityLog/ActivityLogManager.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/VersionCalculatorFactoryImpl.java
similarity index 70%
copy from openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activityLog/ActivityLogManager.java
copy to openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/VersionCalculatorFactoryImpl.java
index a40e101..155aa9c 100644
--- a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activityLog/ActivityLogManager.java
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/VersionCalculatorFactoryImpl.java
@@ -18,14 +18,17 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.activityLog;
+package org.openecomp.sdc.versioning.impl;
-import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
-import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.VersionCalculator;
+import org.openecomp.sdc.versioning.VersionCalculatorFactory;
-import java.util.Collection;
+public class VersionCalculatorFactoryImpl extends VersionCalculatorFactory {
+ private static final VersionCalculator INSTANCE =
+ new VersionCalculatorImpl();
-public interface ActivityLogManager {
- void addActionLog(ActivityLogEntity activityLogEntity, String user);
- Collection<ActivityLogEntity> listActivityLogs(String itemId, Version versionId, String user);
+ @Override
+ public VersionCalculator createInterface() {
+ return INSTANCE;
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/VersionCalculatorImpl.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/VersionCalculatorImpl.java
new file mode 100644
index 0000000..b7008de
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/VersionCalculatorImpl.java
@@ -0,0 +1,155 @@
+package org.openecomp.sdc.versioning.impl;
+
+import org.openecomp.core.utilities.CommonMethods;
+import org.openecomp.sdc.versioning.VersionCalculator;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.dao.types.VersionStatus;
+import org.openecomp.sdc.versioning.types.VersionCreationMethod;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class VersionCalculatorImpl implements VersionCalculator {
+
+ private static final String INITIAL_VERSION = "1.0";
+ private static final String VERSION_STRING_VIOLATION_MSG =
+ "Version string must be in the format of: {integer}.{integer}";
+ private static final String PARENT_LEVEL_VERSION_CANNOT_BE_CREATED_FROM_TOP_LEVEL =
+ "Creation of parent level version on top level version is invalid.";
+ private static final String SUB_LEVEL_VERSION_CANNOT_BE_CREATED_FROM_LOWEST_LEVEL =
+ "Creation of parent level version on top level version is invalid.";
+
+ private static final String VERSION_CALCULATION_ERROR_MSG =
+ "Version calculation error.";
+
+ private static final String INVALID_CREATION_METHOD_MSG = "Invalid creation method-";
+
+
+ @Override
+ public String calculate(String baseVersion, VersionCreationMethod creationMethod) {
+
+ if (baseVersion == null) {
+ return INITIAL_VERSION;
+ }
+
+ String[] versionLevels = baseVersion.split("\\.");
+ if (versionLevels.length != 2) {
+ throw new IllegalArgumentException(VERSION_STRING_VIOLATION_MSG);
+ }
+
+ int index;
+ switch (creationMethod) {
+ case major:
+ index = Integer.parseInt(versionLevels[0]);
+ index++;
+ versionLevels[0] = Integer.toString(index);
+ versionLevels[1] = "0";
+ break;
+ case minor:
+ index = Integer.parseInt(versionLevels[1]);
+ index++;
+ versionLevels[1] = Integer.toString(index);
+ break;
+ }
+ return CommonMethods.arrayToSeparatedString(versionLevels, '.');
+ }
+
+
+ // version calculator when there are no version restrictions
+ /* @Override
+ public String calculate(String baseVersion, VersionCreationMethod creationMethod) {
+
+ return calculate(baseVersion,creationMethod,2);
+ }
+
+ private String calculate(String baseVersion, VersionCreationMethod creationMethod,int
+ maxVersionLevels) {
+ if (baseVersion == null) {
+ return INITIAL_VERSION;
+ }
+
+ String[] versionLevels = baseVersion.split("\\.");
+ if (versionLevels.length > maxVersionLevels) {
+ throw new IllegalArgumentException(VERSION_STRING_VIOLATION_MSG);
+ }
+
+ int index;
+ int versionLevel = calcVersionLevel(versionLevels);
+ if (versionLevel == -1) {
+ throw new IllegalArgumentException(
+ VERSION_STRING_VIOLATION_MSG + " given version:" + baseVersion);
+ }
+ int requiredVersionLevelIncrease;
+ switch (creationMethod) {
+ case parent_level:
+ if (versionLevel == 0) {
+ throw new IllegalArgumentException(
+ PARENT_LEVEL_VERSION_CANNOT_BE_CREATED_FROM_TOP_LEVEL + " version:" + baseVersion);
+
+ }
+ requiredVersionLevelIncrease = versionLevel - 1;
+ versionLevels[versionLevel] = "0";
+ index = Integer.getInteger(versionLevels[requiredVersionLevelIncrease]);
+ index++;
+ versionLevels[requiredVersionLevelIncrease] = Integer.toString(index);
+ break;
+ case same_level:
+ requiredVersionLevelIncrease = versionLevel;
+ index = Integer.valueOf(versionLevels[requiredVersionLevelIncrease]);
+ index++;
+ versionLevels[requiredVersionLevelIncrease] = Integer.toString(index);
+ break;
+ case sub_level:
+ if (versionLevel == versionLevels.length - 1) {
+ throw new IllegalArgumentException(
+ SUB_LEVEL_VERSION_CANNOT_BE_CREATED_FROM_LOWEST_LEVEL + " version:" + baseVersion);
+ }
+ requiredVersionLevelIncrease = versionLevel + 1;
+ if(requiredVersionLevelIncrease>maxVersionLevels){
+ throw new IllegalArgumentException(INVALID_CREATION_METHOD_MSG+" max " +
+ "levels:"+maxVersionLevels + "requested level:"+requiredVersionLevelIncrease);
+ }
+ String newVersion = baseVersion + ".1";
+ versionLevels = newVersion.split("\\.");
+
+ break;
+ default:
+ throw new IllegalArgumentException(VERSION_CALCULATION_ERROR_MSG + " base " +
+ "version:" + baseVersion + " creation method:" + creationMethod);
+
+ }
+
+ return CommonMethods.arrayToSeparatedString(versionLevels, '.');
+ }*/
+
+
+ @Override
+ public void injectAdditionalInfo(Version version, Set<String> existingVersions) {
+ String optionalVersion;
+ Set<VersionCreationMethod> optionalCreationMethods = new HashSet<>();
+ if(version.getStatus().equals(VersionStatus.Certified)) {
+ for (VersionCreationMethod versionCreationMethod : VersionCreationMethod.values()) {
+ try {
+ optionalVersion = calculate(version.getName(), versionCreationMethod);
+ if (!existingVersions.contains(optionalVersion)) {
+ optionalCreationMethods.add(versionCreationMethod);
+ }
+ } catch (IllegalArgumentException iae) {
+ //not a valid creation method.
+ }
+ }
+ }
+ version.getAdditionalInfo().put("OptionalCreationMethods", optionalCreationMethods);
+
+ }
+
+
+ private int calcVersionLevel(String[] versionLevels) {
+ for (int i = versionLevels.length - 1; i >= 0; i--) {
+ if (!versionLevels[i].equals("0")) {
+ return i;
+ }
+ }
+ return -1;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/VersioningManagerFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/VersioningManagerFactoryImpl.java
index 8ab5c60..b4dbcf3 100644
--- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/VersioningManagerFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/VersioningManagerFactoryImpl.java
@@ -20,16 +20,21 @@
package org.openecomp.sdc.versioning.impl;
+import org.openecomp.sdc.versioning.ItemManagerFactory;
+import org.openecomp.sdc.versioning.VersionCalculatorFactory;
import org.openecomp.sdc.versioning.VersioningManager;
import org.openecomp.sdc.versioning.VersioningManagerFactory;
+import org.openecomp.sdc.versioning.dao.VersionDaoFactory;
import org.openecomp.sdc.versioning.dao.VersionInfoDaoFactory;
import org.openecomp.sdc.versioning.dao.VersionInfoDeletedDaoFactory;
public class VersioningManagerFactoryImpl extends VersioningManagerFactory {
private static final VersioningManager INSTANCE = new VersioningManagerImpl(
VersionInfoDaoFactory.getInstance().createInterface(),
- VersionInfoDeletedDaoFactory.getInstance().createInterface()
- );
+ VersionInfoDeletedDaoFactory.getInstance().createInterface(),
+ VersionDaoFactory.getInstance().createInterface(),
+ VersionCalculatorFactory.getInstance().createInterface(),
+ ItemManagerFactory.getInstance().createInterface());
@Override
public VersioningManager createInterface() {
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/VersioningManagerImpl.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/VersioningManagerImpl.java
index 4a49d53..7f98347 100644
--- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/VersioningManagerImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/VersioningManagerImpl.java
@@ -21,25 +21,31 @@
package org.openecomp.sdc.versioning.impl;
import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
import org.openecomp.sdc.logging.types.LoggerConstants;
import org.openecomp.sdc.logging.types.LoggerErrorCode;
import org.openecomp.sdc.logging.types.LoggerErrorDescription;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+import org.openecomp.sdc.versioning.ItemManager;
+import org.openecomp.sdc.versioning.VersionCalculator;
import org.openecomp.sdc.versioning.VersioningManager;
+import org.openecomp.sdc.versioning.dao.VersionDao;
import org.openecomp.sdc.versioning.dao.VersionInfoDao;
import org.openecomp.sdc.versioning.dao.VersionInfoDeletedDao;
import org.openecomp.sdc.versioning.dao.VersionableEntityDaoFactory;
+import org.openecomp.sdc.versioning.dao.types.Revision;
+import org.openecomp.sdc.versioning.dao.types.SynchronizationState;
import org.openecomp.sdc.versioning.dao.types.UserCandidateVersion;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.dao.types.VersionHistoryEntity;
import org.openecomp.sdc.versioning.dao.types.VersionInfoDeletedEntity;
import org.openecomp.sdc.versioning.dao.types.VersionInfoEntity;
import org.openecomp.sdc.versioning.dao.types.VersionStatus;
-import org.openecomp.sdc.versioning.dao.types.VersionType;
-import org.openecomp.sdc.versioning.dao.types.VersionableEntityId;
import org.openecomp.sdc.versioning.errors.CheckinOnEntityLockedByOtherErrorBuilder;
import org.openecomp.sdc.versioning.errors.CheckinOnUnlockedEntityErrorBuilder;
import org.openecomp.sdc.versioning.errors.CheckoutOnLockedEntityErrorBuilder;
@@ -52,6 +58,7 @@
import org.openecomp.sdc.versioning.errors.SubmitLockedEntityNotAllowedErrorBuilder;
import org.openecomp.sdc.versioning.errors.UndoCheckoutOnEntityLockedByOtherErrorBuilder;
import org.openecomp.sdc.versioning.errors.UndoCheckoutOnUnlockedEntityErrorBuilder;
+import org.openecomp.sdc.versioning.types.VersionCreationMethod;
import org.openecomp.sdc.versioning.types.VersionInfo;
import org.openecomp.sdc.versioning.types.VersionableEntityAction;
import org.openecomp.sdc.versioning.types.VersionableEntityMetadata;
@@ -66,18 +73,27 @@
import java.util.stream.Collectors;
public class VersioningManagerImpl implements VersioningManager {
-
+ private static final Logger LOGGER = LoggerFactory.getLogger(VersioningManagerImpl.class);
private static final Version INITIAL_ACTIVE_VERSION = new Version(0, 0);
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
private static Map<String, Set<VersionableEntityMetadata>> versionableEntities = new HashMap<>();
- private VersionInfoDao versionInfoDao;
- private VersionInfoDeletedDao versionInfoDeletedDao;
+ private final VersionInfoDao versionInfoDao;
+ private final VersionInfoDeletedDao versionInfoDeletedDao;
+ private VersionDao versionDao;
+ private VersionCalculator versionCalculator;
+ private ItemManager itemManager;
public VersioningManagerImpl(VersionInfoDao versionInfoDao,
- VersionInfoDeletedDao versionInfoDeletedDao) {
+ VersionInfoDeletedDao versionInfoDeletedDao,
+ VersionDao versionDao,
+ VersionCalculator versionCalculator,
+ ItemManager itemManager) {
this.versionInfoDao = versionInfoDao;
this.versionInfoDeletedDao = versionInfoDeletedDao;
+ this.versionDao = versionDao;
+ this.versionCalculator = versionCalculator;
+ this.itemManager = itemManager;
}
private static VersionInfo getVersionInfo(VersionInfoEntity versionInfoEntity, String user,
@@ -146,8 +162,12 @@
VersionInfo versionInfo = new VersionInfo();
versionInfo.setStatus(status);
activeVersion.setStatus(status);
- if(latestFinalVersion!= null) latestFinalVersion.setStatus(status);
- if(viewableVersions != null) viewableVersions.forEach(version->version.setStatus(status));
+ if (latestFinalVersion != null) {
+ latestFinalVersion.setStatus(status);
+ }
+ if (viewableVersions != null) {
+ viewableVersions.forEach(version -> version.setStatus(status));
+ }
versionInfo.setActiveVersion(activeVersion);
versionInfo.setLatestFinalVersion(latestFinalVersion);
versionInfo.setViewableVersions(toSortedList(viewableVersions));
@@ -166,11 +186,9 @@
private static List<Version> toSortedList(
Set<Version> versions) { // changing the Set to List in DB will require migration...
- return versions.stream().sorted((o1, o2) -> {
- return o1.getMajor() > o2.getMajor() ? 1
- : o1.getMajor() == o2.getMajor() ? (o1.getMinor() > o2.getMinor() ? 1
- : o1.getMinor() == o2.getMinor() ? 0 : -1) : -1;
- }).collect(Collectors.toList());
+ return versions.stream().sorted((o1, o2) -> o1.getMajor() > o2.getMajor() ? 1
+ : o1.getMajor() == o2.getMajor() ? (o1.getMinor() > o2.getMinor() ? 1
+ : o1.getMinor() == o2.getMinor() ? 0 : -1) : -1).collect(Collectors.toList());
}
private static List<Version> getFinalVersions(Set<Version> versions) {
@@ -263,8 +281,8 @@
LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Can't checkout versionable entity");
throw new CoreException(new CheckoutOnLockedEntityErrorBuilder(entityType, entityId,
versionInfoEntity.getCandidate().getUser()).build());
- case Final:
- case Available:
+ case Certified:
+ case Draft:
checkoutVersion = doCheckout(versionInfoEntity, user);
break;
default:
@@ -300,8 +318,8 @@
}
activeVersion = undoCheckout(versionInfoEntity);
break;
- case Final:
- case Available:
+ case Certified:
+ case Draft:
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.UNDO_CHECKOUT_ENTITY, ErrorLevel.ERROR.name(),
LoggerErrorCode.PERMISSION_ERROR.getErrorCode(),
@@ -320,8 +338,9 @@
deleteVersionFromEntity(versionInfoEntity.getEntityType(), versionInfoEntity.getEntityId(),
versionInfoEntity.getCandidate().getVersion(), versionInfoEntity.getActiveVersion());
- versionInfoEntity.setStatus(versionInfoEntity.getActiveVersion().isFinal() ? VersionStatus.Final
- : VersionStatus.Available);
+ versionInfoEntity
+ .setStatus(versionInfoEntity.getActiveVersion().isFinal() ? VersionStatus.Certified
+ : VersionStatus.Draft);
versionInfoEntity.setCandidate(null);
versionInfoDao.update(versionInfoEntity);
return versionInfoEntity.getActiveVersion();
@@ -341,8 +360,8 @@
Version checkedInVersion = null;
switch (versionInfoEntity.getStatus()) {
- case Available:
- case Final:
+ case Draft:
+ case Certified:
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.CHECKIN_ENTITY, ErrorLevel.ERROR.name(),
LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Can't checkin versionable entity");
@@ -379,7 +398,7 @@
Version submitVersion = null;
switch (versionInfoEntity.getStatus()) {
- case Final:
+ case Certified:
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.SUBMIT_ENTITY, ErrorLevel.ERROR.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), "Can't submit versionable entity");
@@ -391,7 +410,7 @@
LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Can't submit versionable entity");
throw new CoreException(new SubmitLockedEntityNotAllowedErrorBuilder(entityType, entityId,
versionInfoEntity.getCandidate().getUser()).build());
- case Available:
+ case Draft:
submitVersion = doSubmit(versionInfoEntity, user, submitDescription);
break;
default:
@@ -444,6 +463,143 @@
return activeVersions;
}
+ @Override
+ public List<Version> list(String itemId) {
+
+ List<Version> versions = versionDao.list(itemId);
+ Set<String> versionsNames = versions.stream().map(Version::getName).collect(Collectors.toSet());
+ versions.forEach(version -> {
+ version.setAdditionalInfo(new HashMap<>());
+ versionCalculator.injectAdditionalInfo(version, versionsNames);
+ });
+ return versions;
+ }
+
+ @Override
+ public Version get(String itemId, Version version) {
+ return versionDao.get(itemId, version)
+ .map(retrievedVersion -> getUpdateRetrievedVersion(itemId, retrievedVersion))
+ .orElseGet(() -> getSyncedVersion(itemId, version));
+ }
+
+ private Version getUpdateRetrievedVersion(String itemId, Version version) {
+ if (version.getStatus() == VersionStatus.Certified &&
+ (version.getState().getSynchronizationState() == SynchronizationState.OutOfSync ||
+ version.getState().isDirty())) {
+ forceSync(itemId, version);
+ LOGGER.info("Item Id {}, version Id {}: Force sync is done", itemId, version.getId());
+ version = versionDao.get(itemId, version)
+ .orElseThrow(() -> new IllegalStateException(
+ "Get version after a successful force sync must return the version"));
+ }
+ return version;
+ }
+
+ private Version getSyncedVersion(String itemId, Version version) {
+ sync(itemId, version);
+ LOGGER.info("Item Id {}, version Id {}: First time sync is done", itemId, version.getId());
+ return versionDao.get(itemId, version)
+ .orElseThrow(() -> new IllegalStateException(
+ "Get version after a successful sync must return the version"));
+ }
+
+ @Override
+ public Version create(String itemId, Version version, VersionCreationMethod creationMethod) {
+ String baseVersionName = null;
+ if (version.getBaseId() == null) {
+ version.setDescription("Initial version");
+ } else {
+ baseVersionName = get(itemId, new Version(version.getBaseId())).getName();
+ }
+ String versionName = versionCalculator.calculate(baseVersionName, creationMethod);
+ validateVersionName(itemId, versionName);
+ version.setName(versionName);
+
+ versionDao.create(itemId, version);
+ itemManager.updateVersionStatus(itemId, VersionStatus.Draft, null);
+
+ publish(itemId, version, String.format("Initial version: %s ", version.getName()));
+ return version;
+ }
+
+ private void validateVersionName(String itemId, String versionName) {
+ if (versionDao.list(itemId).stream()
+ .anyMatch(version -> versionName.equals(version.getName()))) {
+ String errorDescription = String
+ .format("Item %s: create version failed, a version with the name %s already exist",
+ itemId, versionName);
+
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY,
+ LoggerTragetServiceName.CREATE_VERSION, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), errorDescription);
+
+ throw new CoreException(new ErrorCode.ErrorCodeBuilder()
+ .withCategory(ErrorCategory.APPLICATION)
+ .withId("VERSION_NAME_ALREADY_EXIST")
+ .withMessage(errorDescription)
+ .build());
+ }
+ }
+
+ @Override
+ public void submit(String itemId, Version version, String submitDescription) {
+ version = get(itemId, version);
+
+ validateSubmit(itemId, version);
+
+ version.setStatus(VersionStatus.Certified);
+ versionDao.update(itemId, version);
+
+ publish(itemId, version, submitDescription);
+
+ itemManager.updateVersionStatus(itemId, VersionStatus.Certified, VersionStatus.Draft);
+ }
+
+ private void validateSubmit(String itemId, Version version) {
+ if (version.getStatus() == VersionStatus.Certified) {
+ String errorDescription = String
+ .format("Item %s: submit version failed, version %s is already Certified", itemId,
+ version.getId());
+
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.SUBMIT_ENTITY, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), errorDescription);
+
+ throw new CoreException(new ErrorCode.ErrorCodeBuilder()
+ .withCategory(ErrorCategory.APPLICATION)
+ .withId("VERSION_ALREADY_CERTIFIED")
+ .withMessage(errorDescription)
+ .build());
+ }
+ }
+
+ @Override
+ public void publish(String itemId, Version version, String message) {
+ versionDao.publish(itemId, version, message);
+ }
+
+
+ @Override
+ public void sync(String itemId, Version version) {
+ versionDao.sync(itemId, version);
+ }
+
+ @Override
+ public void forceSync(String itemId, Version version) {
+ versionDao.forceSync(itemId, version);
+ }
+
+ @Override
+ public void revert(String itemId, Version version, String revisionId) {
+ versionDao.revert(itemId, version, revisionId);
+ }
+
+ @Override
+ public List<Revision> listRevisions(String itemId, Version version) {
+ return versionDao.listRevisions(itemId, version);
+
+ }
+
private void markAsCheckedOut(VersionInfoEntity versionInfoEntity, String checkingOutUser) {
versionInfoEntity.setStatus(VersionStatus.Locked);
versionInfoEntity.setCandidate(new UserCandidateVersion(checkingOutUser,
@@ -491,7 +647,7 @@
versionInfoEntity.setCandidate(null);
versionInfoEntity.setActiveVersion(userCandidateVersion.getVersion());
versionInfoEntity.getViewableVersions().add(versionInfoEntity.getActiveVersion());
- versionInfoEntity.setStatus(VersionStatus.Available);
+ versionInfoEntity.setStatus(VersionStatus.Draft);
closeVersionOnEntity(versionInfoEntity.getEntityType(), versionInfoEntity.getEntityId(),
versionInfoEntity.getActiveVersion());
@@ -519,22 +675,12 @@
versionInfoEntity.setViewableVersions(viewableVersions);
versionInfoEntity.setActiveVersion(finalVersion);
versionInfoEntity.setLatestFinalVersion(finalVersion);
- versionInfoEntity.setStatus(VersionStatus.Final);
+ versionInfoEntity.setStatus(VersionStatus.Certified);
versionInfoDao.update(versionInfoEntity);
return finalVersion;
}
- private void createVersionHistory(VersionableEntityId entityId, Version version, String user,
- String description, VersionType type) {
- VersionHistoryEntity versionHistory = new VersionHistoryEntity(entityId);
- versionHistory.setVersion(version);
- versionHistory.setUser(user);
- versionHistory.setDescription(description);
- versionHistory.setType(type);
- //versionHistoryDao.create(versionHistory);
- }
-
private void initVersionOnEntity(String entityType, String entityId, Version baseVersion,
Version newVersion) {
Set<VersionableEntityMetadata> entityMetadatas = versionableEntities.get(entityType);
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/resources/factoryConfiguration.json b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/resources/factoryConfiguration.json
new file mode 100644
index 0000000..d2d16ef
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/resources/factoryConfiguration.json
@@ -0,0 +1,3 @@
+{
+ "org.openecomp.sdc.versioning.VersionCalculatorFactory": "org.openecomp.sdc.versioning.impl.MajorVersionCalculatorFactoryImpl"
+}
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/dao/impl/zusammen/VersionZusammenDaoImplTest.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/dao/impl/zusammen/VersionZusammenDaoImplTest.java
new file mode 100644
index 0000000..1f1efdf
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/dao/impl/zusammen/VersionZusammenDaoImplTest.java
@@ -0,0 +1,265 @@
+package org.openecomp.sdc.versioning.dao.impl.zusammen;
+
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.UserInfo;
+import com.amdocs.zusammen.datatypes.item.Info;
+import com.amdocs.zusammen.datatypes.item.ItemVersion;
+import com.amdocs.zusammen.datatypes.item.ItemVersionData;
+import com.amdocs.zusammen.datatypes.item.ItemVersionStatus;
+import com.amdocs.zusammen.datatypes.item.SynchronizationStatus;
+import org.mockito.ArgumentCaptor;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.core.zusammen.api.ZusammenAdaptor;
+import org.openecomp.sdc.common.session.SessionContextProviderFactory;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.dao.types.VersionStatus;
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Matchers.isNull;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
+
+public class VersionZusammenDaoImplTest {
+
+ private static final String USER = "user1";
+ @Mock
+ private ZusammenAdaptor zusammenAdaptorMock;
+ @InjectMocks
+ private VersionZusammenDaoImpl versionDao;
+
+ @BeforeMethod
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ SessionContextProviderFactory.getInstance().createInterface().create(USER);
+ }
+
+ @Test
+ public void testList() throws Exception {
+ String itemId = "itemId";
+ Id versionId1 = new Id("v1_id");
+ Id versionId2 = new Id("v2_id");
+ Id versionId3 = new Id("v3_id");
+
+ List<ItemVersion> zusammenVersions = Stream.of(
+ createZusammenVersion(versionId1, null, "version desc", "1.0", VersionStatus.Certified),
+ createZusammenVersion(versionId2, versionId1, "version desc", "2.0", VersionStatus.Certified
+ ),
+ createZusammenVersion(versionId3, versionId2, "version desc", "3.0", VersionStatus.Draft))
+ .collect(Collectors.toList());
+ doReturn(zusammenVersions).when(zusammenAdaptorMock)
+ .listPublicVersions(eq(createZusammenContext()), eq(new Id(itemId)));
+
+ List<Version> versions = versionDao.list(itemId);
+ Assert.assertEquals(versions.size(), 3);
+
+ int zusammenVersionIndex;
+ for (Version version : versions) {
+ zusammenVersionIndex = versionId1.getValue().equals(version.getId())
+ ? 0
+ : versionId2.getValue().equals(version.getId())
+ ? 1
+ : 2;
+ assetVersionEquals(version, zusammenVersions.get(zusammenVersionIndex));
+ }
+ }
+
+ @Test
+ public void testCreate() throws Exception {
+ testCreate(null);
+ }
+
+ @Test
+ public void testCreateBasedOn() throws Exception {
+ testCreate("baseId");
+ }
+
+ private void testCreate(String baseId) {
+ String itemId = "itemId";
+ Version version = new Version(1, 0);
+ version.setBaseId(baseId);
+ version.setName("version name");
+ version.setDescription("version description");
+ version.setStatus(VersionStatus.Draft);
+
+ doReturn(new Id("versionId")).when(zusammenAdaptorMock)
+ .createVersion(eq(createZusammenContext()), eq(new Id(itemId)),
+ baseId == null ? isNull(Id.class) : eq(new Id(baseId)), any(ItemVersionData.class));
+
+ ArgumentCaptor<ItemVersionData> capturedZusammenVersion =
+ ArgumentCaptor.forClass(ItemVersionData.class);
+
+ versionDao.create(itemId, version);
+
+ verify(zusammenAdaptorMock)
+ .createVersion(eq(createZusammenContext()), eq(new Id(itemId)),
+ baseId == null ? isNull(Id.class) : eq(new Id(baseId)),
+ capturedZusammenVersion.capture());
+
+ Info capturedInfo = capturedZusammenVersion.getValue().getInfo();
+ Assert.assertEquals(capturedInfo.getName(), version.getName());
+ Assert.assertEquals(capturedInfo.getDescription(), version.getDescription());
+ Assert.assertEquals(VersionStatus
+ .valueOf(capturedInfo.getProperty(VersionZusammenDaoImpl.ZusammenProperty.STATUS)),
+ version.getStatus());
+ Assert.assertEquals(capturedInfo.getProperty(VersionZusammenDaoImpl.ZusammenProperty.LABEL),
+ version.toString());
+ }
+
+ @Test
+ public void testUpdate() throws Exception {
+ String itemId = "itemId";
+ Version version = new Version(1, 0);
+ version.setId("versionId");
+ version.setBaseId("baseId");
+ version.setName("version name");
+ version.setDescription("version description");
+ version.setStatus(VersionStatus.Certified);
+
+ ArgumentCaptor<ItemVersionData> capturedZusammenVersion =
+ ArgumentCaptor.forClass(ItemVersionData.class);
+
+ versionDao.update(itemId, version);
+
+ verify(zusammenAdaptorMock)
+ .updateVersion(eq(createZusammenContext()), eq(new Id(itemId)), eq(new Id(version.getId())),
+ capturedZusammenVersion.capture());
+
+ Info capturedInfo = capturedZusammenVersion.getValue().getInfo();
+ Assert.assertEquals(capturedInfo.getName(), version.getName());
+ Assert.assertEquals(capturedInfo.getDescription(), version.getDescription());
+ Assert.assertEquals(VersionStatus
+ .valueOf(capturedInfo.getProperty(VersionZusammenDaoImpl.ZusammenProperty.STATUS)),
+ version.getStatus());
+ Assert.assertEquals(capturedInfo.getProperty(VersionZusammenDaoImpl.ZusammenProperty.LABEL),
+ version.toString());
+ }
+
+ @Test
+ public void testGetNonExisting() throws Exception {
+ Optional<Version> version = versionDao.get("itemId", new Version("versionId"));
+
+ Assert.assertEquals(version, Optional.empty());
+ }
+
+ @Test
+ public void testGet() throws Exception {
+ String itemId = "itemId";
+ String versionId = "versionId";
+
+ SessionContext zusammenContext = createZusammenContext();
+ Id itemIdObj = new Id(itemId);
+ Id versionIdObj = new Id(versionId);
+
+ ItemVersion zusammenPrivateVersion =
+ createZusammenVersion(versionIdObj, new Id("baseId"), "version desc updated", "2.0",
+ VersionStatus.Draft);
+ doReturn(zusammenPrivateVersion).when(zusammenAdaptorMock)
+ .getVersion(eq(zusammenContext), eq(itemIdObj), eq(versionIdObj));
+
+ doReturn(new ItemVersionStatus(SynchronizationStatus.UP_TO_DATE, true))
+ .when(zusammenAdaptorMock)
+ .getVersionStatus(eq(zusammenContext), eq(itemIdObj), eq(versionIdObj));
+
+ ItemVersion zusammenPublicVersion =
+ createZusammenVersion(versionIdObj, new Id("baseId"), "version desc", "2.0",
+ VersionStatus.Certified);
+ doReturn(zusammenPublicVersion).when(zusammenAdaptorMock)
+ .getPublicVersion(eq(zusammenContext), eq(itemIdObj), eq(versionIdObj));
+
+ Optional<Version> version = versionDao.get(itemId, new Version(versionId));
+
+ Assert.assertTrue(version.isPresent());
+ zusammenPrivateVersion.getData().getInfo()
+ .addProperty(VersionZusammenDaoImpl.ZusammenProperty.STATUS,
+ VersionStatus.Certified.name());
+ assetVersionEquals(version.get(), zusammenPrivateVersion);
+ }
+
+ // TODO: 12/20/2017 complete tests
+ /* @Test
+ public void testDelete() throws Exception {
+
+ }
+
+ @Test
+ public void testPublish() throws Exception {
+
+ }
+
+ @Test
+ public void testSync() throws Exception {
+
+ }
+
+ @Test
+ public void testForceSync() throws Exception {
+
+ }
+
+ @Test
+ public void testRevert() throws Exception {
+
+ }
+
+ @Test
+ public void testListRevisions() throws Exception {
+
+ }*/
+
+ private void assetVersionEquals(Version version, ItemVersion zusammenVersion) {
+ Assert.assertEquals(version.getId(), zusammenVersion.getId().getValue());
+ Assert.assertEquals(version.getBaseId(),
+ zusammenVersion.getBaseId() == null ? null : zusammenVersion.getBaseId().getValue());
+ Info info = zusammenVersion.getData().getInfo();
+ Assert.assertEquals(version.getName(), info.getName());
+ Assert.assertEquals(version.getDescription(), info.getDescription());
+ Assert.assertEquals(version.getStatus(),
+ VersionStatus.valueOf(info.getProperty(VersionZusammenDaoImpl.ZusammenProperty.STATUS)));
+ String label = info.getProperty(VersionZusammenDaoImpl.ZusammenProperty.LABEL).toString();
+ Assert
+ .assertEquals(version.getMajor(), Integer.parseInt(label.substring(0, label.indexOf('.'))));
+ Assert.assertEquals(version.getMinor(),
+ Integer.parseInt(label.substring(label.indexOf('.') + 1, label.length())));
+ Assert.assertEquals(version.getCreationTime(), zusammenVersion.getCreationTime());
+ Assert.assertEquals(version.getModificationTime(), zusammenVersion.getModificationTime());
+ }
+
+ private ItemVersion createZusammenVersion(Id id, Id baseId, String description, String label,
+ VersionStatus status) {
+ ItemVersion version = new ItemVersion();
+ version.setId(id);
+ version.setBaseId(baseId);
+ Info info = new Info();
+ info.setName(id + "_name");
+ info.setDescription(description);
+ info.addProperty(VersionZusammenDaoImpl.ZusammenProperty.LABEL, label);
+ info.addProperty(VersionZusammenDaoImpl.ZusammenProperty.STATUS, status.name());
+ ItemVersionData data = new ItemVersionData();
+ data.setInfo(info);
+ version.setData(data);
+ version.setCreationTime(new Date());
+ version.setModificationTime(new Date());
+ return version;
+ }
+
+ private SessionContext createZusammenContext() {
+ SessionContext sessionContext = new SessionContext();
+ sessionContext.setUser(new UserInfo(USER));
+ sessionContext.setTenant("dox");
+ return sessionContext;
+ }
+
+}
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/impl/ItemManagerImplTest.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/impl/ItemManagerImplTest.java
new file mode 100644
index 0000000..755bfb4
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/impl/ItemManagerImplTest.java
@@ -0,0 +1,124 @@
+package org.openecomp.sdc.versioning.impl;
+
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.common.session.SessionContextProviderFactory;
+import org.openecomp.sdc.itempermissions.PermissionsServices;
+import org.openecomp.sdc.notification.services.SubscriptionService;
+import org.openecomp.sdc.versioning.dao.ItemDao;
+import org.openecomp.sdc.versioning.dao.types.VersionStatus;
+import org.openecomp.sdc.versioning.types.Item;
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.Collection;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+
+public class ItemManagerImplTest {
+
+ @Mock
+ private ItemDao itemDao;
+ @Mock
+ private PermissionsServices permissionsServices;
+ @Mock
+ private SubscriptionService subscriptionService;
+ @InjectMocks
+ private ItemManagerImpl itemManager;
+
+ @BeforeMethod
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testList() throws Exception {
+ doReturn(Stream.of(
+ createItem("item1", "A"),
+ createItem("item2", "B"),
+ createItem("item3", "B"),
+ createItem("item4", "A"))
+ .collect(Collectors.toList())).when(itemDao).list();
+
+ Collection<Item> items = itemManager.list(item -> "B".equals(item.getType()));
+ Assert.assertEquals(items.size(), 2);
+ Assert.assertTrue(items.stream().anyMatch(item -> "item2".equals(item.getName())));
+ Assert.assertTrue(items.stream().anyMatch(item -> "item3".equals(item.getName())));
+ }
+
+ @Test
+ public void testGetNotExisting() throws Exception {
+ Item item = itemManager.get("item1");
+ Assert.assertNull(item);
+ }
+
+ @Test
+ public void testGet() throws Exception {
+ Item toBeReturned = new Item();
+ toBeReturned.setId("itemId");
+ doReturn(toBeReturned).when(itemDao).get(any(Item.class));
+
+ Item item = itemManager.get("itemId");
+ Assert.assertEquals(item.getId(), "itemId");
+ }
+
+ @Test
+ public void testCreate() throws Exception {
+ SessionContextProviderFactory.getInstance().createInterface().create("user1");
+
+ Item toBeReturned = new Item();
+ toBeReturned.setId("itemId");
+ doReturn(toBeReturned).when(itemDao).create(any(Item.class));
+
+ Item item = itemManager.create(createItem("item1", "A"));
+ Assert.assertEquals(item.getId(), "itemId");
+ }
+
+ @Test
+ public void testUpdateNotExistingVersionStatus() throws Exception {
+ itemManager.updateVersionStatus("itemId", VersionStatus.Certified, VersionStatus.Draft);
+ verify(itemDao, never()).update(any(Item.class));
+ }
+
+ @Test
+ public void testUpdateVersionStatusWhenNone() throws Exception {
+ Item item = new Item();
+ item.setId("itemId");
+ doReturn(item).when(itemDao).get(any(Item.class));
+
+ itemManager.updateVersionStatus("itemId", VersionStatus.Certified, VersionStatus.Draft);
+ verify(itemDao).update(item);
+ Assert.assertEquals(item.getVersionStatusCounters().get(VersionStatus.Certified).intValue(), 1);
+ Assert.assertNull(item.getVersionStatusCounters().get(VersionStatus.Draft));
+ }
+
+ @Test
+ public void testUpdateVersionStatus() throws Exception {
+ Item item = new Item();
+ item.setId("itemId");
+ item.getVersionStatusCounters().put(VersionStatus.Certified, 2);
+ item.getVersionStatusCounters().put(VersionStatus.Draft, 5);
+ doReturn(item).when(itemDao).get(any(Item.class));
+
+ itemManager.updateVersionStatus("itemId", VersionStatus.Certified, VersionStatus.Draft);
+ verify(itemDao).update(item);
+ Assert.assertEquals(item.getVersionStatusCounters().get(VersionStatus.Certified).intValue(), 3);
+ Assert.assertEquals(item.getVersionStatusCounters().get(VersionStatus.Draft).intValue(), 4);
+ }
+
+ private Item createItem(String name, String type) {
+ Item item = new Item();
+ item.setId(name);
+ item.setName(name);
+ item.setType(type);
+ return item;
+ }
+
+}
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/impl/VersioningManagerImplTest.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/impl/VersioningManagerImplTest.java
index d35de4f..2d1109a 100644
--- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/impl/VersioningManagerImplTest.java
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/impl/VersioningManagerImplTest.java
@@ -21,39 +21,326 @@
package org.openecomp.sdc.versioning.impl;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.verify;
-
import org.mockito.ArgumentCaptor;
-import org.mockito.Captor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.versioning.dao.VersionInfoDao;
-import org.openecomp.sdc.versioning.dao.VersionInfoDeletedDao;
-import org.openecomp.sdc.versioning.dao.types.UserCandidateVersion;
+import org.openecomp.sdc.versioning.ItemManager;
+import org.openecomp.sdc.versioning.VersionCalculator;
+import org.openecomp.sdc.versioning.dao.VersionDao;
+import org.openecomp.sdc.versioning.dao.types.Revision;
+import org.openecomp.sdc.versioning.dao.types.SynchronizationState;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.dao.types.VersionInfoDeletedEntity;
-import org.openecomp.sdc.versioning.dao.types.VersionInfoEntity;
+import org.openecomp.sdc.versioning.dao.types.VersionState;
import org.openecomp.sdc.versioning.dao.types.VersionStatus;
-import org.openecomp.sdc.versioning.types.VersionInfo;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
+import org.openecomp.sdc.versioning.types.VersionCreationMethod;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.openecomp.sdc.versioning.dao.types.SynchronizationState.OutOfSync;
+import static org.openecomp.sdc.versioning.dao.types.SynchronizationState.UpToDate;
+import static org.openecomp.sdc.versioning.dao.types.VersionStatus.Certified;
+import static org.openecomp.sdc.versioning.dao.types.VersionStatus.Draft;
public class VersioningManagerImplTest {
+ @Mock
+ private VersionDao versionDaoMock;
+ @Mock
+ private VersionCalculator versionCalculatorMock;
+ @Mock
+ private ItemManager itemManagerMock;
+ @InjectMocks
+ private VersioningManagerImpl versioningManager;
+
+ @BeforeMethod
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testList() throws Exception {
+ String itemId = "itemId";
+
+ List<Version> returnedVersions = Stream.of(createVersion("1", null, null, false),
+ createVersion("2", null, null, false),
+ createVersion("3", null, null, false)).collect(Collectors.toList());
+ doReturn(returnedVersions).when(versionDaoMock).list(itemId);
+
+ List<Version> versions = versioningManager.list(itemId);
+ Assert.assertEquals(versions, returnedVersions);
+ }
+
+ @Test(expectedExceptions = Exception.class)
+ public void testGetNonExisting() throws Exception {
+ String itemId = "itemId";
+ String versionId = "versionId";
+ Version version = new Version(versionId);
+
+ doReturn(Optional.empty()).when(versionDaoMock).get(itemId, version);
+ doThrow(new Exception()).when(versionDaoMock).sync(itemId, version);
+
+ versioningManager.get(itemId, version);
+ }
+
+ @Test
+ public void testGetNonExistingForUser() throws Exception {
+ String itemId = "itemId";
+ String versionId = "versionId";
+ Version requestedVersion = new Version(versionId);
+
+ Version returnedVersion = createVersion(versionId, Draft, UpToDate, false);
+ doReturn(Optional.empty()).doReturn(Optional.of(returnedVersion))
+ .when(versionDaoMock).get(itemId, requestedVersion);
+
+ Version version = versioningManager.get(itemId, requestedVersion);
+ Assert.assertEquals(version, returnedVersion);
+
+ verify(versionDaoMock, times(2)).get(itemId, requestedVersion);
+ verify(versionDaoMock).sync(itemId, requestedVersion);
+ }
+
+ @Test
+ public void testGetOutOfSyncCertified() throws Exception {
+ String itemId = "itemId";
+ String versionId = "versionId";
+ Version requestedVersion = new Version(versionId);
+
+ Version returnedVersion = createVersion(versionId, Certified, UpToDate, false);
+ doReturn(Optional.of(createVersion(versionId, Certified, OutOfSync, false)))
+ .doReturn(Optional.of(returnedVersion))
+ .when(versionDaoMock).get(itemId, requestedVersion);
+
+ Version version = versioningManager.get(itemId, requestedVersion);
+ Assert.assertEquals(version, returnedVersion);
+
+ verify(versionDaoMock, times(2)).get(itemId, requestedVersion);
+ verify(versionDaoMock).forceSync(itemId, requestedVersion);
+ }
+
+ @Test
+ public void testGet() throws Exception {
+ String itemId = "itemId";
+ String versionId = "versionId";
+ Version requestedVersion = new Version(versionId);
+
+ Version returnedVersion = createVersion(versionId, Draft, OutOfSync, true);
+ doReturn(Optional.of(returnedVersion)).when(versionDaoMock).get(itemId, requestedVersion);
+
+ Version version = versioningManager.get(itemId, requestedVersion);
+ Assert.assertEquals(version, returnedVersion);
+
+ verify(versionDaoMock).get(itemId, requestedVersion);
+ verify(versionDaoMock, never()).sync(any(), any());
+ verify(versionDaoMock, never()).forceSync(any(), any());
+ }
+
+ @Test
+ public void testCreate() throws Exception {
+ String itemId = "itemId";
+ Version requestedVersion = new Version();
+
+ String versionName = "versionName";
+ doReturn(versionName).when(versionCalculatorMock).calculate(null, VersionCreationMethod.major);
+
+ doReturn(Stream.of(createVersion("1", null, null, false),
+ createVersion("2", null, null, false),
+ createVersion("3", null, null, false)).collect(Collectors.toList()))
+ .when(versionDaoMock).list(itemId);
+
+ Version version =
+ versioningManager.create(itemId, requestedVersion, VersionCreationMethod.major);
+ Assert.assertNotNull(version);
+ Assert.assertEquals(version.getName(), versionName);
+
+ verify(versionDaoMock).create(itemId, requestedVersion);
+ verify(itemManagerMock).updateVersionStatus(itemId, Draft, null);
+ verify(versionDaoMock).publish(eq(itemId), eq(requestedVersion), anyString());
+ }
+
+ @Test
+ public void testCreateBasedOn() throws Exception {
+ String itemId = "itemId";
+ Version requestedVersion = new Version();
+ requestedVersion.setBaseId("baseVersionId");
+
+ Version baseVersion = createVersion(requestedVersion.getBaseId(), Certified, UpToDate, false);
+ // TODO: 12/13/2017 fix to eq(new Version("baseVersionId")) when version.equals will be fixed
+ doReturn(Optional.of(baseVersion)).when(versionDaoMock).get(eq(itemId), any(Version.class));
+
+ String versionName = "4.0";
+ doReturn(versionName)
+ .when(versionCalculatorMock).calculate(baseVersion.getName(), VersionCreationMethod.major);
+
+ doReturn(Stream.of(createVersion("1", null, null, false),
+ createVersion("2", null, null, false),
+ createVersion("3", null, null, false)).collect(Collectors.toList()))
+ .when(versionDaoMock).list(itemId);
+
+ Version version =
+ versioningManager.create(itemId, requestedVersion, VersionCreationMethod.major);
+ Assert.assertNotNull(version);
+ Assert.assertEquals(version.getName(), versionName);
+
+ verify(versionDaoMock).create(itemId, requestedVersion);
+ verify(itemManagerMock).updateVersionStatus(itemId, Draft, null);
+ verify(versionDaoMock).publish(eq(itemId), eq(requestedVersion), anyString());
+ }
+
+ @Test(expectedExceptions = CoreException.class, expectedExceptionsMessageRegExp =
+ "Item itemId: create version failed, a version with the name 2.0 already exist")
+ public void testCreateWithExistingName() throws Exception {
+ String itemId = "itemId";
+ Version version = new Version();
+ version.setBaseId("baseVersionId");
+
+ Version baseVersion = createVersion(version.getBaseId(), Certified, UpToDate, false);
+ // TODO: 12/13/2017 fix to eq(new Version("baseVersionId")) when version.equals will be fixed
+ doReturn(Optional.of(baseVersion)).when(versionDaoMock).get(eq(itemId), any(Version.class));
+
+ String versionName = "2.0";
+ doReturn(versionName)
+ .when(versionCalculatorMock).calculate(baseVersion.getName(), VersionCreationMethod.major);
+
+ doReturn(Stream.of(createVersion("1", null, null, false),
+ createVersion("2", null, null, false),
+ createVersion("3", null, null, false)).collect(Collectors.toList()))
+ .when(versionDaoMock).list(itemId);
+
+ versioningManager.create(itemId, version, VersionCreationMethod.major);
+ }
+
+ @Test(expectedExceptions = CoreException.class, expectedExceptionsMessageRegExp =
+ "Item itemId: submit version failed, version versionId is already Certified")
+ public void testSubmitCertified() throws Exception {
+ String itemId = "itemId";
+ String versionId = "versionId";
+ Version version = new Version(versionId);
+
+ Version returnedVersion = createVersion(versionId, Certified, UpToDate, false);
+ doReturn(Optional.of(returnedVersion)).when(versionDaoMock).get(itemId, version);
+
+ versioningManager.submit(itemId, version, "Submit message");
+ }
+
+ @Test
+ public void testSubmit() throws Exception {
+ String itemId = "itemId";
+ String versionId = "versionId";
+ Version version = new Version(versionId);
+
+ ArgumentCaptor<Version> versionArgumentCaptor = ArgumentCaptor.forClass(Version.class);
+
+ Version returnedVersion = createVersion(versionId, Draft, UpToDate, false);
+ doReturn(Optional.of(returnedVersion)).when(versionDaoMock).get(itemId, version);
+
+ String submitDescription = "Submit message";
+ versioningManager.submit(itemId, version, submitDescription);
+
+ verify(versionDaoMock).update(eq(itemId), versionArgumentCaptor.capture());
+ Assert.assertEquals(Certified, versionArgumentCaptor.getValue().getStatus());
+ verify(versionDaoMock).publish(itemId, version, submitDescription);
+ verify(itemManagerMock).updateVersionStatus(itemId, Certified, Draft);
+ }
+
+ @Test
+ public void testPublish() throws Exception {
+ String itemId = "itemId";
+ String versionId = "versionId";
+ Version version = new Version(versionId);
+ String publishDescription = "Publish message";
+
+ versioningManager.publish(itemId, version, publishDescription);
+
+ verify(versionDaoMock).publish(itemId, version, publishDescription);
+ }
+
+ @Test
+ public void testSync() throws Exception {
+ String itemId = "itemId";
+ String versionId = "versionId";
+ Version version = new Version(versionId);
+
+ versioningManager.sync(itemId, version);
+
+ verify(versionDaoMock).sync(itemId, version);
+ }
+
+ @Test
+ public void testForceSync() throws Exception {
+ String itemId = "itemId";
+ String versionId = "versionId";
+ Version version = new Version(versionId);
+
+ versioningManager.forceSync(itemId, version);
+
+ verify(versionDaoMock).forceSync(itemId, version);
+ }
+
+ @Test
+ public void testRevert() throws Exception {
+ String itemId = "itemId";
+ String versionId = "versionId";
+ Version version = new Version(versionId);
+ String revisionId = "revisionId";
+
+ versioningManager.revert(itemId, version, revisionId);
+
+ verify(versionDaoMock).revert(itemId, version, revisionId);
+ }
+
+ @Test
+ public void testListRevisions() throws Exception {
+ String itemId = "itemId";
+ String versionId = "versionId";
+ Version version = new Version(versionId);
+
+ List<Revision> returnedRevisions =
+ Stream.of(new Revision(), new Revision()).collect(Collectors.toList());
+ doReturn(returnedRevisions)
+ .when(versionDaoMock).listRevisions(itemId, version);
+
+ List<Revision> revisions = versioningManager.listRevisions(itemId, version);
+ Assert.assertEquals(revisions, returnedRevisions);
+ }
+
+ private Version createVersion(String id, VersionStatus status,
+ SynchronizationState syncState, boolean dirty) {
+ Version version = new Version(id);
+ version.setName(id + ".0");
+ version.setDescription(id + " desc");
+ version.setStatus(status);
+
+ VersionState state = new VersionState();
+ state.setSynchronizationState(syncState);
+ state.setDirty(dirty);
+ version.setState(state);
+ return version;
+ }
+
+/*
private static final String USR1 = "usr1";
private static final String USR2 = "usr2";
private static final String TYPE1 = "Type1";
-/* private static final String TYPE2 = "Type2";*/
+*/
+/* private static final String TYPE2 = "Type2";*//*
+
private static final String ID1 = "Id1";
+*/
/* private static final String ID2 = "Id2";
private static final String ID3 = "Id3";
private static final String TYPE1_TABLE_NAME = "vendor_license_model";
@@ -61,17 +348,20 @@
private static final String TYPE1_VERSION_NAME = "version";
private static final String TYPE2_TABLE_NAME = "feature_group";
private static final String TYPE2_ID_NAME = "vlm_id";
- private static final String TYPE2_VERSION_NAME = "version";*/
+ private static final String TYPE2_VERSION_NAME = "version";*//*
+
private static final Version VERSION0 = new Version(0, 0);
private static final Version VERSION01 = new Version(0, 1);
private static final Version VERSION02 = new Version(0, 2);
private static final Version VERSION10 = new Version(1, 0);
private static final Version VERSION11 = new Version(1, 1);
- /* private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
+ */
+/* private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
private static UDTMapper<Version> versionMapper =
- noSqlDb.getMappingManager().udtMapper(Version.class);*/
+ noSqlDb.getMappingManager().udtMapper(Version.class);*//*
+
@Mock
private VersionInfoDao versionInfoDaoMock;
@Mock
@@ -87,7 +377,8 @@
MockitoAnnotations.initMocks(this);
}
- /* @BeforeClass
+ */
+/* @BeforeClass
private void init() {
versionInfoDaoMock.delete(new VersionInfoEntity(TYPE1, ID1));
versionInfoDaoMock.delete(new VersionInfoEntity(TYPE1, ID2));
@@ -103,8 +394,10 @@
new VersionableEntityMetadata(TYPE1_TABLE_NAME, TYPE1_ID_NAME, TYPE1_VERSION_NAME));
versioningManager.register(TYPE2,
new VersionableEntityMetadata(TYPE2_TABLE_NAME, TYPE2_ID_NAME, TYPE2_VERSION_NAME));
- }*/
+ }*//*
+
+*/
/* @Test
public void testRegister() throws Exception {
VersionableEntityMetadata entityMetadata =
@@ -116,7 +409,8 @@
Set<VersionableEntityMetadata> type1Entities = versionableEntities.get(TYPE1);
Assert.assertNotNull(type1Entities);
Assert.assertTrue(type1Entities.contains(entityMetadata));
- }*/
+ }*//*
+
@Test(expectedExceptions = CoreException.class)
public void testCreateAlreadyExisting() {
@@ -129,8 +423,10 @@
Version version = versioningManager.create(TYPE1, ID1, USR1);
Assert.assertEquals(version, VERSION01);
+*/
/* createVersionableEntityRecord(TYPE1_TABLE_NAME, TYPE1_ID_NAME, TYPE1_VERSION_NAME, ID1,
- version);*/
+ version);*//*
+
verify(versionInfoDaoMock).create(versionInfoEntityArg.capture());
VersionInfoEntity versionInfoEntity = versionInfoEntityArg.getValue();
assretVersionInfoEntity(versionInfoEntity, TYPE1, ID1, new Version(0, 0), VERSION01, USR1,
@@ -152,7 +448,7 @@
@Test
public void testDelete() {
VersionInfoEntity versionInfoEntity = new VersionInfoEntity();
- versionInfoEntity.setStatus(VersionStatus.Available);
+ versionInfoEntity.setStatus(VersionStatus.Draft);
doReturn(versionInfoEntity).when(versionInfoDaoMock).get(anyObject());
versioningManager.delete(TYPE1, ID1, USR1);
@@ -171,13 +467,14 @@
@Test
public void testUndoDelete() {
VersionInfoDeletedEntity versionInfoDeletedEntity = new VersionInfoDeletedEntity();
- versionInfoDeletedEntity.setStatus(VersionStatus.Available);
+ versionInfoDeletedEntity.setStatus(VersionStatus.Draft);
doReturn(versionInfoDeletedEntity).when(versionInfoDeletedDaoMock).get(anyObject());
versioningManager.undoDelete(TYPE1, ID1, USR1);
verify(versionInfoDeletedDaoMock).delete(versionInfoDeletedEntity);
verify(versionInfoDaoMock).create(versionInfoEntityArg.capture());
+*/
/*
VersionInfoDeletedEntity versionInfoDeletedEntity =
versionInfoDeletedDaoMock.get(new VersionInfoDeletedEntity(TYPE1, ID1));
@@ -190,7 +487,8 @@
Assert.assertNull(versionInfoEntity);
versioningManager.undoDelete(TYPE1, ID1, USR1);
versionInfoEntity = versionInfoDaoMock.get(new VersionInfoEntity(TYPE1, ID1));
- Assert.assertNotNull(versionInfoEntity);*/
+ Assert.assertNotNull(versionInfoEntity);*//*
+
}
@Test(expectedExceptions = CoreException.class)
@@ -216,7 +514,7 @@
public void testCheckoutOnFinalized() {
Set<Version> viewableVersions = new HashSet<>();
viewableVersions.add(VERSION10);
- mockVersionInfoEntity(TYPE1, ID1, VersionStatus.Final, VERSION10, null, viewableVersions,
+ mockVersionInfoEntity(TYPE1, ID1, VersionStatus.Certified, VERSION10, null, viewableVersions,
VERSION10);
Version version = versioningManager.checkout(TYPE1, ID1, USR1);
@@ -225,18 +523,20 @@
VersionInfoEntity versionInfoEntity = versionInfoDaoMock.get(new VersionInfoEntity(TYPE1, ID1));
assretVersionInfoEntity(versionInfoEntity, TYPE1, ID1, VERSION10, VERSION11, USR1,
VersionStatus.Locked, viewableVersions, VERSION10);
+*/
/*
ResultSet results =
loadVersionableEntityRecord(TYPE1_TABLE_NAME, TYPE1_ID_NAME, TYPE1_VERSION_NAME, ID1,
VERSION11);
- Assert.assertTrue(results.iterator().hasNext());*/
+ Assert.assertTrue(results.iterator().hasNext());*//*
+
}
@Test
public void testCheckout() {
Set<Version> viewableVersions = new HashSet<>();
viewableVersions.add(VERSION01);
- mockVersionInfoEntity(TYPE1, ID1, VersionStatus.Available, VERSION01, null, viewableVersions,
+ mockVersionInfoEntity(TYPE1, ID1, VersionStatus.Draft, VERSION01, null, viewableVersions,
null);
Version version = versioningManager.checkout(TYPE1, ID1, USR1);
@@ -248,10 +548,12 @@
assretVersionInfoEntity(versionInfoEntity, TYPE1, ID1, VERSION01, VERSION02, USR1,
VersionStatus.Locked, viewableVersions, null);
+*/
/* ResultSet results =
loadVersionableEntityRecord(TYPE1_TABLE_NAME, TYPE1_ID_NAME, TYPE1_VERSION_NAME, ID1,
VERSION02);
- Assert.assertTrue(results.iterator().hasNext());*/
+ Assert.assertTrue(results.iterator().hasNext());*//*
+
}
@Test(expectedExceptions = CoreException.class)
@@ -263,7 +565,7 @@
public void testUndoCheckoutOnAvailable() {
Set<Version> viewableVersions = new HashSet<>();
viewableVersions.add(VERSION01);
- mockVersionInfoEntity(TYPE1, ID1, VersionStatus.Available, VERSION01, null, viewableVersions,
+ mockVersionInfoEntity(TYPE1, ID1, VersionStatus.Draft, VERSION01, null, viewableVersions,
null);
versioningManager.undoCheckout(TYPE1, ID1, USR1);
@@ -273,7 +575,7 @@
public void testUndoCheckouOnFinalized() {
Set<Version> viewableVersions = new HashSet<>();
viewableVersions.add(VERSION10);
- mockVersionInfoEntity(TYPE1, ID1, VersionStatus.Final, VERSION10, null, viewableVersions,
+ mockVersionInfoEntity(TYPE1, ID1, VersionStatus.Certified, VERSION10, null, viewableVersions,
VERSION10);
versioningManager.undoCheckout(TYPE1, ID1, USR2);
}
@@ -298,12 +600,14 @@
VersionInfoEntity versionInfoEntity = versionInfoDaoMock.get(new VersionInfoEntity(TYPE1, ID1));
assretVersionInfoEntity(versionInfoEntity, TYPE1, ID1, VERSION01, null, null,
- VersionStatus.Available, viewableVersions, null);
+ VersionStatus.Draft, viewableVersions, null);
+*/
/* ResultSet results =
loadVersionableEntityRecord(TYPE1_TABLE_NAME, TYPE1_ID_NAME, TYPE1_VERSION_NAME, ID1,
VERSION02);
- Assert.assertFalse(results.iterator().hasNext());*/
+ Assert.assertFalse(results.iterator().hasNext());*//*
+
}
@Test(expectedExceptions = CoreException.class)
@@ -315,7 +619,7 @@
public void testCheckinOnAvailable() {
Set<Version> viewableVersions = new HashSet<>();
viewableVersions.add(VERSION01);
- mockVersionInfoEntity(TYPE1, ID1, VersionStatus.Available, VERSION01, null, viewableVersions,
+ mockVersionInfoEntity(TYPE1, ID1, VersionStatus.Draft, VERSION01, null, viewableVersions,
null);
versioningManager.checkin(TYPE1, ID1, USR1, "fail checkin");
@@ -326,7 +630,7 @@
public void testCheckinOnFinalized() {
Set<Version> viewableVersions = new HashSet<>();
viewableVersions.add(VERSION10);
- mockVersionInfoEntity(TYPE1, ID1, VersionStatus.Final, VERSION10, null, viewableVersions,
+ mockVersionInfoEntity(TYPE1, ID1, VersionStatus.Certified, VERSION10, null, viewableVersions,
VERSION10);
versioningManager.checkin(TYPE1, ID1, USR1, "failed checkin");
@@ -354,7 +658,7 @@
viewableVersions.add(VERSION01);
assretVersionInfoEntity(versionInfoEntity, TYPE1, ID1, VERSION01, null, null,
- VersionStatus.Available, viewableVersions, null);
+ VersionStatus.Draft, viewableVersions, null);
}
@Test(expectedExceptions = CoreException.class)
@@ -374,7 +678,7 @@
public void testSubmitOnFinalized() {
Set<Version> viewableVersions = new HashSet<>();
viewableVersions.add(VERSION10);
- mockVersionInfoEntity(TYPE1, ID1, VersionStatus.Final, VERSION10, null, viewableVersions,
+ mockVersionInfoEntity(TYPE1, ID1, VersionStatus.Certified, VERSION10, null, viewableVersions,
VERSION10);
versioningManager.submit(TYPE1, ID1, USR2, "failed submit");
}
@@ -390,7 +694,7 @@
viewableVersions.add(new Version(3, 0));
viewableVersions.add(new Version(3, 1));
viewableVersions.add(version32);
- mockVersionInfoEntity(TYPE1, ID1, VersionStatus.Available, version32, null, viewableVersions,
+ mockVersionInfoEntity(TYPE1, ID1, VersionStatus.Draft, version32, null, viewableVersions,
new Version(3, 0));
Version version = versioningManager.submit(TYPE1, ID1, USR1, "submit msg");
@@ -403,12 +707,14 @@
VersionInfoEntity versionInfoEntity = versionInfoEntityArg.getValue();
assretVersionInfoEntity(versionInfoEntity, TYPE1, ID1, version40, null, null,
- VersionStatus.Final, viewableVersions, version40);
+ VersionStatus.Certified, viewableVersions, version40);
+*/
/* ResultSet results =
loadVersionableEntityRecord(TYPE1_TABLE_NAME, TYPE1_ID_NAME, TYPE1_VERSION_NAME, ID1,
VERSION10);
- Assert.assertTrue(results.iterator().hasNext());*/
+ Assert.assertTrue(results.iterator().hasNext());*//*
+
}
@Test(expectedExceptions = CoreException.class)
@@ -420,12 +726,12 @@
public void testGetVersionInfoForReadOnAvailable() {
Set<Version> viewableVersions = new HashSet<>();
viewableVersions.add(VERSION01);
- mockVersionInfoEntity(TYPE1, ID1, VersionStatus.Available, VERSION01, null, viewableVersions,
+ mockVersionInfoEntity(TYPE1, ID1, VersionStatus.Draft, VERSION01, null, viewableVersions,
null);
VersionInfo versionInfo =
versioningManager.getEntityVersionInfo(TYPE1, ID1, USR1, VersionableEntityAction.Read);
- assertVersionInfo(versionInfo, VERSION01, VersionStatus.Available, null,
+ assertVersionInfo(versionInfo, VERSION01, VersionStatus.Draft, null,
viewableVersions, null);
}
@@ -433,7 +739,7 @@
public void testGetVersionInfoForWriteOnAvailable() {
Set<Version> viewableVersions = new HashSet<>();
viewableVersions.add(VERSION01);
- mockVersionInfoEntity(TYPE1, ID1, VersionStatus.Available, VERSION01, null, viewableVersions,
+ mockVersionInfoEntity(TYPE1, ID1, VersionStatus.Draft, VERSION01, null, viewableVersions,
null);
versioningManager.getEntityVersionInfo(TYPE1, ID1, USR1, VersionableEntityAction.Write);
@@ -488,6 +794,7 @@
assertVersionInfo(versionInfo, VERSION02, VersionStatus.Locked, USR1, viewableVersions, null);
}
+*/
/* private void createVersionableEntityRecord(String tableName, String idName, String versionName,
String id, Version version) {
noSqlDb.execute(
@@ -500,7 +807,8 @@
return noSqlDb.execute(
String.format("select * from %s where %s=? and %s=?", tableName, idName, versionName), id,
versionMapper.toUDT(version));
- }*/
+ }*//*
+
private static void assretVersionInfoEntity(VersionInfoEntity actual, String entityType,
@@ -553,4 +861,5 @@
doReturn(mock).when(versionInfoDaoMock).get(anyObject());
return mock;
}
+*/
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/errors/CreateToscaObjectErrorBuilder.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/errors/CreateToscaObjectErrorBuilder.java
index f9a3da2..daeb570 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/errors/CreateToscaObjectErrorBuilder.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-api/src/main/java/org/openecomp/core/converter/errors/CreateToscaObjectErrorBuilder.java
@@ -5,15 +5,14 @@
public class CreateToscaObjectErrorBuilder extends BaseErrorBuilder {
private static final String CANT_CREATE_OBJECT_FROM_CLASS =
- "Can't create %s from %s. Reason - %s";
+ "Can't create %s from %s.";
private static final String IMPORT_TOSCA = "IMPORT_TOSCA";
public CreateToscaObjectErrorBuilder(String className,
- String objectId,
- String reason) {
+ String objectId) {
getErrorCodeBuilder()
.withId(IMPORT_TOSCA)
.withCategory(ErrorCategory.APPLICATION)
- .withMessage(String.format(CANT_CREATE_OBJECT_FROM_CLASS, className, objectId, reason));
+ .withMessage(String.format(CANT_CREATE_OBJECT_FROM_CLASS, className, objectId));
}
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java
index e7ff3aa..39a53b4 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterImpl.java
@@ -12,7 +12,17 @@
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
-import org.openecomp.sdc.tosca.datatypes.model.*;
+import org.openecomp.sdc.tosca.datatypes.model.ArtifactDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.CapabilityAssignment;
+import org.openecomp.sdc.tosca.datatypes.model.Import;
+import org.openecomp.sdc.tosca.datatypes.model.InterfaceDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.NodeFilter;
+import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate;
+import org.openecomp.sdc.tosca.datatypes.model.NodeType;
+import org.openecomp.sdc.tosca.datatypes.model.ParameterDefinition;
+import org.openecomp.sdc.tosca.datatypes.model.RequirementAssignment;
+import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.sdc.tosca.datatypes.model.SubstitutionMapping;
import org.openecomp.sdc.tosca.services.DataModelUtil;
import org.openecomp.sdc.tosca.services.ToscaUtil;
import org.openecomp.sdc.translator.services.heattotosca.globaltypes.GlobalTypesGenerator;
@@ -21,11 +31,28 @@
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
import java.util.jar.Manifest;
import java.util.regex.Pattern;
-import static org.openecomp.core.converter.datatypes.Constants.*;
+import static org.openecomp.core.converter.datatypes.Constants.capabilities;
+import static org.openecomp.core.converter.datatypes.Constants.definitionsDir;
+import static org.openecomp.core.converter.datatypes.Constants.globalStName;
+import static org.openecomp.core.converter.datatypes.Constants.globalSubstitution;
+import static org.openecomp.core.converter.datatypes.Constants.inputs;
+import static org.openecomp.core.converter.datatypes.Constants.mainStName;
+import static org.openecomp.core.converter.datatypes.Constants.manifestFileName;
+import static org.openecomp.core.converter.datatypes.Constants.metadataFile;
+import static org.openecomp.core.converter.datatypes.Constants.nodeType;
+import static org.openecomp.core.converter.datatypes.Constants.openecompHeatIndex;
+import static org.openecomp.core.converter.datatypes.Constants.outputs;
+import static org.openecomp.core.converter.datatypes.Constants.requirements;
import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME;
public class ToscaConverterImpl implements ToscaConverter {
@@ -89,9 +116,8 @@
}
} catch (YAMLException ye) {
throw new CoreException(new ErrorCode.ErrorCodeBuilder()
- .withMessage("Invalid YAML content in file " + key + ". reason - "
- + ye.getMessage())
- .withCategory(ErrorCategory.APPLICATION).build());
+ .withMessage("Invalid YAML content in file " + key)
+ .withCategory(ErrorCategory.APPLICATION).build(), ye);
}
}
@@ -181,9 +207,8 @@
} catch (YAMLException ye) {
throw new CoreException(new ErrorCode.ErrorCodeBuilder()
- .withMessage("Invalid YAML content in file" + serviceTemplateName + ". reason - "
- + ye.getMessage())
- .withCategory(ErrorCategory.APPLICATION).build());
+ .withMessage("Invalid YAML content in file" + serviceTemplateName)
+ .withCategory(ErrorCategory.APPLICATION).build(), ye);
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterManagerImpl.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterManagerImpl.java
index 520e418..4917533 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterManagerImpl.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterManagerImpl.java
@@ -5,6 +5,8 @@
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import java.lang.reflect.Constructor;
@@ -14,8 +16,10 @@
public class ToscaConverterManagerImpl implements ToscaConverterManager {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ToscaConverterManagerImpl.class.getName());
private static List<ToscaConverter> toscaConverters;
private static final String toscaConverterFileName = "ToscaConverters.json";
+ private static final String TOSCA_CONVERTER_IMPL_FORMAT_ERROR = "Failed to construct TOSCA converter for '%s' implementation.";
static {
toscaConverters = getConvertersList();
@@ -40,7 +44,8 @@
Class<?> clazz = Class.forName(implClassName);
Constructor<?> constructor = clazz.getConstructor();
toscaConvertersList.add((ToscaConverter) constructor.newInstance());
- }catch (Exception e){
+ }catch (Exception ex){
+ LOGGER.debug(String.format(TOSCA_CONVERTER_IMPL_FORMAT_ERROR, implClassName), ex);
continue;
}
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterUtil.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterUtil.java
index 20ac641..d34d467 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterUtil.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterUtil.java
@@ -4,6 +4,8 @@
import org.apache.commons.lang.StringUtils;
import org.openecomp.core.converter.errors.CreateToscaObjectErrorBuilder;
import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
import java.lang.reflect.Field;
import java.util.HashSet;
@@ -20,6 +22,8 @@
private static final String DEFAULT_CAPITAL = "Default";
private static Set<String> defaultValueKeys;
+ private static Logger LOGGER = LoggerFactory.getLogger(ToscaConverterUtil.class.getName());
+
static {
defaultValueKeys =
Stream.of(DEFAULT, DEFAULT_CAPITAL).collect(Collectors.toSet());
@@ -30,10 +34,10 @@
Class<T> classToCreate) {
try {
return createObjectUsingSetters(objectCandidate, classToCreate);
- } catch (Exception e) {
+ } catch (Exception ex) {
throw new CoreException(
- new CreateToscaObjectErrorBuilder(classToCreate.getSimpleName(), objectId, e.getMessage())
- .build());
+ new CreateToscaObjectErrorBuilder(classToCreate.getSimpleName(), objectId)
+ .build(), ex);
}
}
@@ -68,6 +72,8 @@
return Objects.nonNull(fieldValueToAssign)
&& Objects.nonNull(classToCreate.getMethod(methodName, field.getType()));
} catch (NoSuchMethodException e) {
+ LOGGER.debug(String.format("Could not extract method '%s' from class '%s'. returning false " +
+ "with filedType '%s'.", methodName, classToCreate, field.getType()), e);
return false;
}
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/services/ServiceTemplateReaderServiceImpl.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/services/ServiceTemplateReaderServiceImpl.java
index 22780af..ee39af9 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/services/ServiceTemplateReaderServiceImpl.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/services/ServiceTemplateReaderServiceImpl.java
@@ -7,7 +7,14 @@
import java.util.Map;
import java.util.Objects;
-import static org.openecomp.core.converter.datatypes.Constants.*;
+import static org.openecomp.core.converter.datatypes.Constants.definitionVersion;
+import static org.openecomp.core.converter.datatypes.Constants.inputs;
+import static org.openecomp.core.converter.datatypes.Constants.metadata;
+import static org.openecomp.core.converter.datatypes.Constants.nodeTemplates;
+import static org.openecomp.core.converter.datatypes.Constants.nodeTypes;
+import static org.openecomp.core.converter.datatypes.Constants.outputs;
+import static org.openecomp.core.converter.datatypes.Constants.substitutionMappings;
+import static org.openecomp.core.converter.datatypes.Constants.topologyTemplate;
public class ServiceTemplateReaderServiceImpl implements ServiceTemplateReaderService {
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java
index 5ee96ab..df34b89 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java
@@ -2,7 +2,6 @@
import org.apache.commons.collections.CollectionUtils;
import org.junit.Assert;
-import org.junit.Ignore;
import org.junit.Test;
import org.openecomp.core.converter.ToscaConverter;
import org.openecomp.core.impl.ToscaConverterImpl;
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConvertorDefinitionsTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConvertorDefinitionsTest.java
index 1ee8f6c..82a3695 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConvertorDefinitionsTest.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConvertorDefinitionsTest.java
@@ -13,9 +13,15 @@
import java.util.Map;
import java.util.Set;
-import static org.openecomp.sdc.common.utils.CommonUtil.*;
-import static org.junit.Assert.*;
-import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.DEFININTION_VERSION;
+import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME;
+import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.HEAT_INDEX;
+import static org.openecomp.core.impl.GlobalSubstitutionServiceTemplate.TEMPLATE_NAME_PROPERTY;
+import static org.openecomp.sdc.common.utils.CommonUtil.validateAndUploadFileContent;
public class ToscaConvertorDefinitionsTest {
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java
index 45e6c3d..30e767b 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java
@@ -53,8 +53,8 @@
import org.openecomp.sdc.tosca.services.DataModelUtil;
import org.openecomp.sdc.tosca.services.ToscaAnalyzerService;
import org.openecomp.sdc.tosca.services.ToscaConstants;
-import org.openecomp.sdc.tosca.services.ToscaUtil;
import org.openecomp.sdc.tosca.services.ToscaExtensionYamlUtil;
+import org.openecomp.sdc.tosca.services.ToscaUtil;
import java.util.ArrayList;
import java.util.Collection;
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java
index aad2163..d082d2f 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java
@@ -20,12 +20,6 @@
package org.openecomp.sdc.tosca.services.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.when;
-
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
@@ -58,6 +52,12 @@
import java.util.Map;
import java.util.Optional;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
/**
* @author Avrahamg
diff --git a/openecomp-be/lib/pom.xml b/openecomp-be/lib/pom.xml
index ea1faae..d031dd4 100644
--- a/openecomp-be/lib/pom.xml
+++ b/openecomp-be/lib/pom.xml
@@ -10,7 +10,7 @@
<artifactId>openecomp-sdc</artifactId>
<groupId>org.openecomp.sdc</groupId>
<version>1.2.0-SNAPSHOT</version>
- <relativePath>..</relativePath>
+ <relativePath>..</relativePath>
</parent>
<modules>
@@ -33,5 +33,8 @@
<module>openecomp-sdc-activity-log-lib</module>
<module>openecomp-tosca-converter-lib</module>
<module>openecomp-sdc-orchestration-lib</module>
+ <module>openecomp-sdc-notification-lib</module>
+ <module>openecomp-item-permissions-lib</module>
+ <module>openecomp-conflict-lib</module>
</modules>
</project>
diff --git a/openecomp-be/pom.xml b/openecomp-be/pom.xml
index 02da3b9..dba8d0f 100644
--- a/openecomp-be/pom.xml
+++ b/openecomp-be/pom.xml
@@ -21,7 +21,7 @@
<module>/lib</module>
<module>/configuration</module>
<module>/tools/swagger-ui</module>
- <module>/tools/migration/1702_to_1707_zusammen</module>
+ <!--<module>/tools/migration/1702_to_1707_zusammen</module>-->
<module>/tools/zusammen-tools</module>
<module>/backend</module>
</modules>
@@ -159,7 +159,7 @@
</executions>
</plugin>
<!-- Jacoco consolidation Report -->
- <plugin>
+ <!--<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>${mvn.antrun.version}</version>
@@ -171,7 +171,7 @@
</goals>
<configuration>
<target>
- <!-- Execute an ant task within maven -->
+ <!– Execute an ant task within maven –>
<echo message="Generating JaCoCo Reports" />
<taskdef name="report" classname="org.jacoco.ant.ReportTask">
<classpath path="${basedir}/target/jacoco-jars/org.jacoco.ant.jar" />
@@ -212,7 +212,7 @@
<version>${jacoco.version}</version>
</dependency>
</dependencies>
- </plugin>
+ </plugin>-->
</plugins>
</build>
@@ -262,7 +262,7 @@
<artifactId>classmate</artifactId>
<version>${classmate.version}</version>
</dependency>
- <!--1702 -->
+ <!--1702 -->
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<dependency>
<groupId>org.slf4j</groupId>
@@ -274,7 +274,7 @@
<artifactId>groovy-all</artifactId>
<version>${groovy.version}</version>
</dependency>
- <dependency>
+ <dependency>
<groupId>org.codehaus.janino</groupId>
<artifactId>janino</artifactId>
<version>${janino.version}</version>
diff --git a/openecomp-be/tools/build/scripts/cassandra-commands.json b/openecomp-be/tools/build/scripts/cassandra-commands.json
index 2935aca..34916fe 100644
--- a/openecomp-be/tools/build/scripts/cassandra-commands.json
+++ b/openecomp-be/tools/build/scripts/cassandra-commands.json
@@ -5,22 +5,7 @@
"version_info": "CREATE TABLE IF NOT EXISTS version_info (entity_type text, entity_id text, active_version frozen<version>, status text, candidate frozen<user_candidate_version>, viewable_versions set<frozen<version>>, latest_final_version frozen<version>, PRIMARY KEY (entity_type, entity_id))",
"version_info_deleted": "CREATE TABLE IF NOT EXISTS version_info_deleted (entity_type text, entity_id text, active_version frozen<version>, status text, candidate frozen<user_candidate_version>, viewable_versions set<frozen<version>>, latest_final_version frozen<version>, PRIMARY KEY (entity_type, entity_id))",
"unique_value" : "CREATE TABLE IF NOT EXISTS unique_value (type text, value text, PRIMARY KEY ((type, value)))",
- "choice_or_other": "CREATE TYPE IF NOT EXISTS choice_or_other (result text)",
- "multi_choice_or_other": "CREATE TYPE IF NOT EXISTS multi_choice_or_other (results set<text>)",
- "vendor_license_model": "CREATE TABLE IF NOT EXISTS vendor_license_model (vlm_id text, version frozen<version>, vendor_name text, description text, icon text, PRIMARY KEY ((vlm_id, version)))",
- "license_agreement": "CREATE TABLE IF NOT EXISTS license_agreement (vlm_id text, version frozen<version>, la_id text, name text, description text, lic_term frozen<choice_or_other>, req_const text, fg_ids set<text>, PRIMARY KEY ((vlm_id, version), la_id))",
- "feature_group": "CREATE TABLE IF NOT EXISTS feature_group (vlm_id text, version frozen<version>, fg_id text, name text, description text, part_num text, ep_ids set<text>, lkg_ids set<text>, ref_la_ids set<text>, PRIMARY KEY ((vlm_id, version), fg_id))",
- "license_key_group": "CREATE TABLE IF NOT EXISTS license_key_group (vlm_id text, version frozen<version>, lkg_id text,name text,description text, type text, operational_scope frozen<multi_choice_or_other>, ref_fg_ids set<text>, version_uuid text, PRIMARY KEY ((vlm_id, version), lkg_id))",
- "entitlement_pool": "CREATE TABLE IF NOT EXISTS entitlement_pool (vlm_id text, version frozen<version>, ep_id text,name text,description text,threshold float,threshold_unit text,entitlement_metric frozen<choice_or_other>,increments text,aggregation_func frozen<choice_or_other>, operational_scope frozen<multi_choice_or_other>, time frozen<choice_or_other>,manufacturer_ref_num text,ref_fg_ids set<text>, version_uuid text, PRIMARY KEY ((vlm_id, version), ep_id))",
- "vsp_information": "CREATE TABLE IF NOT EXISTS vsp_information (VSP_ID text, version frozen<version>, NAME text,DESCRIPTION text,CATEGORY text,SUB_CATEGORY text,ICON text,PACKAGE_NAME text,PACKAGE_VERSION text,vendor_name text, vendor_id text,LICENSE_AGREEMENT text,FEATURE_GROUPS list<text>,VALIDATION_DATA text,CONTENT_DATA blob, questionnaire_data text, vlm_version frozen<version>, is_old_version text, onboarding_method text, PRIMARY KEY ((VSP_ID, version)))",
- "package_details": "CREATE TABLE IF NOT EXISTS package_details (VSP_ID text, version frozen<version>,DISPLAY_NAME text,vsp_name text,vsp_description text,VENDOR_NAME text,CATEGORY text,SUB_CATEGORY text,VENDOR_RELEASE text,PACKAGE_CHECKSUM text,PACKAGE_TYPE text,TRANSLATE_CONTENT blob,PRIMARY KEY ((VSP_ID, version)))",
- "vsp_network": "CREATE TABLE IF NOT EXISTS vsp_network (vsp_id text, version frozen<version>, network_id text, composition_data text, questionnaire_data text, PRIMARY KEY ((vsp_id, version), network_id))",
- "vsp_component": "CREATE TABLE IF NOT EXISTS vsp_component (vsp_id text, version frozen<version>, component_id text, composition_data text, questionnaire_data text, PRIMARY KEY ((vsp_id, version), component_id))",
- "vsp_component_nic": "CREATE TABLE IF NOT EXISTS vsp_component_nic (vsp_id text, version frozen<version>, component_id text, nic_id text, composition_data text, questionnaire_data text, PRIMARY KEY ((vsp_id, version), component_id, nic_id))",
- "vsp_component_image": "CREATE TABLE IF NOT EXISTS vsp_component_image (vsp_id text, version frozen<version>, component_id text, image_id text, composition_data text, questionnaire_data text, PRIMARY KEY ((vsp_id, version), component_id, image_id))",
- "vsp_process" : "CREATE TABLE IF NOT EXISTS vsp_process (vsp_id text, version frozen<version>, component_id text, process_id text, name text, description text, type text, artifact_name text, artifact blob, PRIMARY KEY ((vsp_id, version), component_id, process_id))",
- "vsp_service_artifact" : "CREATE TABLE IF NOT EXISTS vsp_service_artifact (vsp_id text, version frozen<version>, name text, content_data blob, PRIMARY KEY ((vsp_id, version), name))",
- "vsp_service_template" : "CREATE TABLE IF NOT EXISTS vsp_service_template (vsp_id text, version frozen<version>, base_name text static, name text, content_data blob, PRIMARY KEY ((vsp_id, version), name))",
+ "package_details": "CREATE TABLE IF NOT EXISTS package_details (VSP_ID text, version text,DISPLAY_NAME text,vsp_name text,vsp_description text,VENDOR_NAME text,CATEGORY text,SUB_CATEGORY text,VENDOR_RELEASE text,PACKAGE_CHECKSUM text,PACKAGE_TYPE text,TRANSLATE_CONTENT blob,PRIMARY KEY ((VSP_ID, version)))",
"vsp_enriched_service_template" : "CREATE TABLE IF NOT EXISTS vsp_enriched_service_template (vsp_id text, version frozen<version>, base_name text static, name text, content_data blob, PRIMARY KEY ((vsp_id, version), name))",
"vsp_enriched_service_artifact" : "CREATE TABLE IF NOT EXISTS vsp_enriched_service_artifact (vsp_id text, version frozen<version>, name text, content_data blob, PRIMARY KEY ((vsp_id, version), name))",
"application_config" : "CREATE TABLE IF NOT EXISTS application_config (namespace text, key text, value text, PRIMARY KEY (namespace, key))",
@@ -31,37 +16,22 @@
"vendor_list_index" : "CREATE INDEX IF NOT EXISTS action_vendor_list ON dox.Action (vendor_list)",
"actionUUID_index" : "CREATE INDEX IF NOT EXISTS action_actionUUID ON dox.Action (actionUUID)",
"ecomp_component": "CREATE TABLE IF NOT EXISTS dox.ecompcomponent(id text PRIMARY KEY, name text)",
- "vsp_component_artifact": "CREATE TABLE IF NOT EXISTS vsp_component_artifact (vsp_id text, version frozen<version>, component_id text, artifact_type text, artifact_id text, name text, description text, artifact blob, PRIMARY KEY ((vsp_id, version), component_id, artifact_type, artifact_id))",
"name_index": "CREATE INDEX IF NOT EXISTS action_name ON dox.Action (name)",
"action_artifact":"CREATE TABLE IF NOT EXISTS action_artifact(artifactuuid text, effective_version int, artifact blob, PRIMARY KEY(artifactuuid, effective_version)) WITH CLUSTERING ORDER BY (effective_version DESC)",
- "vsp_orchestration_template_candidate" : "CREATE TABLE IF NOT EXISTS vsp_orchestration_template_candidate (vsp_id text, version frozen<version>, files_data_structure text, content_data blob, PRIMARY KEY ((vsp_id, version)))",
- "vsp_deployment_flavor" : "CREATE TABLE IF NOT EXISTS vsp_deployment_flavor (vsp_id text, version frozen<version>, deployment_flavor_id text, composition_data text, questionnaire_data text, PRIMARY KEY ((vsp_id, version), deployment_flavor_id))",
- "vsp_component_compute": "CREATE TABLE IF NOT EXISTS vsp_component_compute (vsp_id text, version frozen<version>, component_id text, compute_id text, composition_data text, questionnaire_data text, PRIMARY KEY ((vsp_id, version), component_id, compute_id))",
- "vsp_component_dependency_model" : "CREATE TABLE IF NOT EXISTS vsp_component_dependency_model (vsp_id text, version frozen<version>, dependency_id text, sourcecomponent_id text, targetcomponent_id text, relation text, PRIMARY KEY ((vsp_id, version), dependency_id))",
"activity_log" : "CREATE TABLE IF NOT EXISTS activity_log (item_id text, version_id text, activity_id text, type text, user text, timestamp timestamp, success boolean, message text, comment text, PRIMARY KEY (item_id, version_id, activity_id))",
- "migration": "CREATE TABLE IF NOT EXISTS migration (id text, ismigrated boolean, primary key(id))"
+ "healing" : "CREATE TABLE IF NOT EXISTS healing (space text,item_id text,version_id text, healing_needed boolean,old_version text, PRIMARY KEY((space,item_id),version_id))",
+ "migration": "CREATE TABLE IF NOT EXISTS migration (id text, ismigrated boolean, primary key (id))",
+ "item_permissions" : "CREATE TABLE IF NOT EXISTS item_permissions (item_id text,user_id text, permission text, PRIMARY KEY(item_id,user_id)) WITH CLUSTERING ORDER BY (user_id DESC)",
+ "notification_subscribers": "CREATE TABLE IF NOT EXISTS NOTIFICATION_SUBSCRIBERS (entity_id text PRIMARY KEY, subscribers set<text>)",
+ "last_notification": "CREATE TABLE IF NOT EXISTS last_notification (owner_id text PRIMARY KEY, event_id timeuuid)",
+ "notifications": "CREATE TABLE IF NOT EXISTS notifications (owner_id text, event_id timeuuid, read boolean, originator_id text, event_type text, event_attributes text, PRIMARY KEY (owner_id, event_id)) WITH CLUSTERING ORDER BY (event_id DESC)",
+ "vsp_merge_hint": "CREATE TABLE IF NOT EXISTS vsp_merge_hint (space text, item_id text, version_id text, model_id text, model_resolution text, PRIMARY KEY ((space, item_id, version_id)))"
},
"drop": {
- "version_info": "DROP TABLE IF EXISTS version_info",
"version_info_deleted": "DROP TABLE IF EXISTS version_info_deleted",
"unique_value": "DROP TABLE IF EXISTS unique_value",
- "entitlement_pool": "DROP TABLE IF EXISTS entitlement_pool",
- "vendor_license_model": "DROP TABLE IF EXISTS vendor_license_model",
- "license_agreement": "DROP TABLE IF EXISTS license_agreement",
- "feature_group": "DROP TABLE IF EXISTS feature_group",
- "license_key_group": "DROP TABLE IF EXISTS license_key_group",
- "vsp_information": "DROP TABLE IF EXISTS vsp_information",
"package_details": "DROP TABLE IF EXISTS package_details",
- "vsp_network": "DROP TABLE IF EXISTS vsp_network",
- "vsp_component_image": "DROP TABLE IF EXISTS vsp_component_image",
- "vsp_component": "DROP TABLE IF EXISTS vsp_component",
- "vsp_component_nic": "DROP TABLE IF EXISTS vsp_component_nic",
- "vsp_process":"DROP TABLE IF EXISTS vsp_process",
- "choice_or_other": "DROP TYPE IF EXISTS choice_or_other",
- "multi_choice_or_other": "DROP TYPE IF EXISTS multi_choice_or_other",
"application_config" : "DROP TABLE IF EXISTS application_config",
- "vsp_service_artifact" :"DROP TABLE IF EXISTS vsp_service_artifact",
- "vsp_service_template" :"DROP TABLE IF EXISTS vsp_service_template",
"vsp_enriched_service_artifact" :"DROP TABLE IF EXISTS vsp_enriched_service_artifact",
"vsp_enriched_service_template" :"DROP TABLE IF EXISTS vsp_enriched_service_template",
"action" : "DROP TABLE IF EXISTS action",
@@ -72,22 +42,16 @@
"actionUUID_index" : "DROP INDEX IF EXISTS dox.action_actionUUID",
"name_index" : "DROP INDEX IF EXISTS dox.action_name",
"ecomp_component": "DROP TABLE IF EXISTS dox.ecompcomponent",
- "vsp_component_artifact": "DROP TABLE IF EXISTS dox.vsp_component_artifact",
"action_artifact":"DROP TABLE IF EXISTS action_artifact",
- "vsp_orchestration_template_candidate":"DROP TABLE IF EXISTS vsp_orchestration_template_candidate",
- "vsp_deployment_flavor":"DROP TABLE IF EXISTS vsp_deployment_flavor",
- "vsp_component_dependency_model":"DROP TABLE IF EXISTS vsp_component_dependency_model",
"activity_log": "DROP TABLE IF EXISTS activity_log",
- "migration": "DROP TABLE IF EXISTS migration"
+ "migration": "DROP TABLE IF EXISTS migration",
+ "item_permissions": "DROP TABLE IF EXISTS item_permissions",
+ "notification_subscribers": "DROP TABLE IF EXISTS notification_subscribers",
+ "last_notification": "DROP TABLE IF EXISTS last_notification",
+ "notifications": "DROP TABLE IF EXISTS notifications",
+ "vsp_merge_hint": "DROP TABLE IF EXISTS vsp_merge_hint"
},
"alter": {
- "vsp_information": "ALTER TABLE vsp_information ADD questionnaire_data text",
- "vsp_information_1": "ALTER TABLE vsp_information ADD vlm_version frozen<version>",
- "vsp_information_2": "ALTER TABLE vsp_information ADD onboarding_method text",
- "vsp_process": "ALTER TABLE vsp_process ADD type text",
- "entitlement_pool": "alter table entitlement_pool ADD version_uuid text",
- "license_key_group": "alter table license_key_group ADD version_uuid text",
- "application_config": "delete from application_config where namespace='vsp.monitoring' and key = 'component.ceilometer'"
},
"actions": {
"truncate_configuration": "truncate configuration"
diff --git a/openecomp-be/tools/build/scripts/zusammen-cassandra-commands.json b/openecomp-be/tools/build/scripts/zusammen-cassandra-commands.json
index 1395fec..5ddb1d7 100644
--- a/openecomp-be/tools/build/scripts/zusammen-cassandra-commands.json
+++ b/openecomp-be/tools/build/scripts/zusammen-cassandra-commands.json
@@ -1,19 +1,26 @@
{
"create": {
"item": "CREATE TABLE IF NOT EXISTS item (item_id text primary key, item_info text, creation_time timestamp, modification_time timestamp)",
- "version": "CREATE TABLE IF NOT EXISTS version (space text, item_id text, version_id text,base_version_id text,info text,relations text,creation_time timestamp,modification_time timestamp,PRIMARY KEY (( space, item_id ), version_id))",
- "version_elements": "CREATE TABLE IF NOT EXISTS version_elements (space text,item_id text,version_id text,element_ids set<text>,PRIMARY KEY (( space, item_id, version_id )))",
- "element_namespace": "CREATE TABLE IF NOT EXISTS element_namespace (space text, item_id text, element_id text, namespace text, PRIMARY KEY ((space, item_id, element_id)))",
- "element": "CREATE TABLE IF NOT EXISTS element (space text,item_id text,version_id text,element_id text,parent_id text,namespace text,info text,relations text,data blob,searchable_data blob,visualization blob,sub_element_ids set<text>,PRIMARY KEY (( space, item_id, version_id, element_id )))"
+ "version": "CREATE TABLE IF NOT EXISTS version (space text, item_id text, version_id text,base_version_id text,info text,relations text,creation_time timestamp,modification_time timestamp ,PRIMARY KEY (( space, item_id ), version_id))",
+ "version_elements": "CREATE TABLE IF NOT EXISTS version_elements (space text,item_id text,version_id text,revision_id text,element_ids Map<text,text>, dirty_element_ids set<text>,stage_element_ids set<text>, conflict_element_ids set<text>, publish_time timestamp,user text,message text, PRIMARY KEY (( space, item_id, version_id ),revision_id))",
+ "element_namespace": "CREATE TABLE IF NOT EXISTS element_namespace (item_id text, element_id text, namespace text, PRIMARY KEY ((item_id, element_id)))",
+ "element": "CREATE TABLE IF NOT EXISTS element (space text,item_id text,version_id text,element_id text,revision_id text,parent_id text,namespace text,info text,relations text,data blob,searchable_data blob,visualization blob,sub_element_ids set<text> ,element_hash text,PRIMARY KEY (( space, item_id, version_id, element_id ),revision_id))",
+ "element_synchronization_state": "CREATE TABLE IF NOT EXISTS element_synchronization_state (space text, item_id text, version_id text, element_id text,revision_id text, publish_time timestamp, dirty boolean, PRIMARY KEY (( space, item_id, version_id ), element_id,revision_id))",
+ "element_stage": "CREATE TABLE IF NOT EXISTS element_stage (space text, item_id text,version_id text, element_id text, parent_id text, namespace text, info text, relations text,data blob, searchable_data blob, visualization blob, sub_element_ids set<text>,element_hash text, publish_time timestamp, action text, conflicted boolean,conflict_dependent_ids set<text>, PRIMARY KEY (( space, item_id, version_id, element_id )))",
+ "version_stage": "CREATE TABLE IF NOT EXISTS version_stage (space text, item_id text, version_id text, base_version_id text, creation_time timestamp,modification_time timestamp, publish_time timestamp, action text, PRIMARY KEY (( space, item_id ), version_id))"
},
"drop": {
"item": "DROP TABLE IF EXISTS item",
"version": "DROP TABLE IF EXISTS version",
"version_elements": "DROP TABLE IF EXISTS version_elements",
"element_namespace": "DROP TABLE IF EXISTS element_namespace",
- "element": "DROP TABLE IF EXISTS element"
+ "element": "DROP TABLE IF EXISTS element",
+ "element_synchronization_state": "DROP TABLE IF EXISTS element_synchronization_state",
+ "element_stage": "DROP TABLE IF EXISTS element_stage",
+ "version_stage": "DROP TABLE IF EXISTS version_stage"
},
"alter": {
+
},
"actions": {
}
diff --git a/openecomp-be/tools/install/database/schemaTemplates/questionnaire/vsp.ftl b/openecomp-be/tools/install/database/schemaTemplates/questionnaire/vsp.ftl
index 96f77b7..0f9be1c 100644
--- a/openecomp-be/tools/install/database/schemaTemplates/questionnaire/vsp.ftl
+++ b/openecomp-be/tools/install/database/schemaTemplates/questionnaire/vsp.ftl
@@ -63,6 +63,7 @@
},
"storageReplicationSize": {
"type": "number",
+ "minimum": 0,
"maximum": 100,
"exclusiveMaximum": true
},
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/pom.xml b/openecomp-be/tools/migration/1702_to_1707_zusammen/pom.xml
deleted file mode 100644
index c2dbc94..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/pom.xml
+++ /dev/null
@@ -1,241 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <properties>
-
- <groovy.version>2.4.7</groovy.version>
- <janino.version>2.7.7</janino.version>
-
- </properties>
-
-
-
- <name>openecomp-zusammen-migration</name>
- <dependencies>
- <dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-vendor-software-product-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <artifactId>openecomp-zusammen-plugin</artifactId>
- <groupId>org.openecomp.sdc.core</groupId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-vendor-software-product-core</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-vendor-license-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-model-impl</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.sdc.core</groupId>
- <artifactId>openecomp-zusammen-core</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>com.amdocs.zusammen.plugin</groupId>
- <artifactId>zusammen-state-store-cassandra-plugin</artifactId>
- <version>${zusammen-state-store.version}</version>
- </dependency>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-validator</artifactId>
- <version>${hibernate.validator.version}</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-vendor-license-core</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- <artifactId>openecomp-zusammen-migration</artifactId>
- <groupId>org.openecomp.sdc.core.migration</groupId>
- <version>1.2.0-SNAPSHOT</version>
- <parent>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-lib</artifactId>
- <relativePath>../../../lib</relativePath>
- <version>1.2.0-SNAPSHOT</version>
- </parent>
- <build>
- <plugins>
-
- <!-- ================================================== -->
- <!-- Set the JDK compiler version. -->
- <!-- ================================================== -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.5.1</version>
- <inherited>true</inherited>
- <configuration>
- <source>1.8</source>
- <target>1.8</target>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>license-maven-plugin</artifactId>
- <version>1.10</version>
- <configuration>
- <addJavaLicenseAfterPackage>false</addJavaLicenseAfterPackage>
- <processStartTag>
- ============LICENSE_START=======================================================
- </processStartTag>
- <processEndTag>
- ============LICENSE_END=========================================================
- </processEndTag>
- <sectionDelimiter>
- ================================================================================
- </sectionDelimiter>
- <licenseName>apache_v2</licenseName>
- <inceptionYear>2017</inceptionYear>
- <organizationName>AT&T Intellectual Property. All rights reserved.
- </organizationName>
- <projectName>SDC</projectName>
- <canUpdateCopyright>true</canUpdateCopyright>
- <canUpdateDescription>true</canUpdateDescription>
- <canUpdateLicense>true</canUpdateLicense>
- <emptyLineAfterHeader>true</emptyLineAfterHeader>
- <verbose>false</verbose>
- <includes>
- <include>**/*.java</include>
- <include>**/*.js</include>
- <include>**/*.ts</include>
- </includes>
- <roots>
- <root>src</root>
- <root>app</root>
- <root>server-mock</root>
- <root>typings</root>
- </roots>
- </configuration>
- <executions>
- <execution>
- <id>first</id>
- <goals>
- <goal>update-file-header</goal>
- </goals>
- <!--phase>process-sources</phase-->
- </execution>
- </executions>
- </plugin>
-
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <version>2.8</version>
- <executions>
- <execution>
- <id>copy-dependencies</id>
- <phase>install</phase>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- <configuration>
- <outputDirectory>${project.build.directory}/lib</outputDirectory>
- <overWriteReleases>false</overWriteReleases>
- <overWriteSnapshots>false</overWriteSnapshots>
- <overWriteIfNewer>true</overWriteIfNewer>
- <!--includeScope>runtime</includeScope-->
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.4</version>
- <executions>
- <execution>
- <phase>package</phase>
- </execution>
- </executions>
- <configuration>
- <archive>
- <manifest>
- <addClasspath>true</addClasspath>
- <classpathLayoutType>custom</classpathLayoutType>
- <customClasspathLayout>
- lib/${artifact.artifactId}-${baseVersion}.${artifact.extension}
- </customClasspathLayout>
- <mainClass>org.openecomp.core.migration.MigrationMain
- </mainClass>
- </manifest>
- <manifestEntries>
- <Class-Path>lib/</Class-Path>
- </manifestEntries>
- </archive>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.19.1</version>
- <configuration>
- <useSystemClassLoader>false</useSystemClassLoader>
- <redirectTestOutputToFile>true</redirectTestOutputToFile>
- </configuration>
- </plugin>
-
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>ant-test</id>
- <phase>package</phase>
- <configuration>
- <tasks>
- <fixcrlf srcdir="./" eol="unix"
- includes="cassandra2zusammen.sh"/>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>${mvn.assembly.version}</version>
- <executions>
- <execution>
- <id>Generate assembly</id>
- <phase>install</phase>
- <goals>
- <goal>single</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <descriptors>
- <descriptor>${basedir}/src/main/assembly/migration-lib-assembly.xml
- </descriptor>
- </descriptors>
- <finalName>openecomp-zusammen-migration-lib</finalName>
- </configuration>
- </plugin>
-
- </plugins>
- </build>
-
-</project>
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/assembly/migration-lib-assembly.xml b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/assembly/migration-lib-assembly.xml
deleted file mode 100644
index 42296ba..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/assembly/migration-lib-assembly.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
-
- <formats>
- <format>zip</format>
- </formats>
-
- <includeBaseDirectory>false</includeBaseDirectory>
-
- <!--files>
- <file>
- <source>../cassandra2zusammen.sh</source>
- </file>
- </files-->
-
- <fileSets>
- <fileSet>
- <directory>${basedir}/..</directory>
- <includes>
- <include>cassandra2zusammen.sh</include>
- </includes>
- <outputDirectory>/</outputDirectory>
- <fileMode>0755</fileMode>
- </fileSet>
- <fileSet>
- <directory>${basedir}/target</directory>
- <includes>
- <include>
- openecomp-zusammen*.jar
- </include>
- </includes>
- <outputDirectory>/</outputDirectory>
- </fileSet>
- <fileSet>
- <directory>${basedir}/target/lib</directory>
- <outputDirectory>/lib</outputDirectory>
- </fileSet>
- </fileSets>
-</assembly>
-
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/MigrationMain.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/MigrationMain.java
deleted file mode 100644
index 1711e41..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/MigrationMain.java
+++ /dev/null
@@ -1,469 +0,0 @@
-package org.openecomp.core.migration;
-
-import com.amdocs.zusammen.datatypes.SessionContext;
-import com.amdocs.zusammen.datatypes.UserInfo;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.impl.ItemCassandraDao;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.impl.VersionCassandraDao;
-import org.openecomp.core.migration.convertors.ComponentConvertor;
-import org.openecomp.core.migration.convertors.EntitlementPoolConvertor;
-import org.openecomp.core.migration.convertors.FeatureGroupConvertor;
-import org.openecomp.core.migration.convertors.LKGConvertor;
-import org.openecomp.core.migration.convertors.LicenseAgreementConvertor;
-import org.openecomp.core.migration.convertors.MibConvertor;
-import org.openecomp.core.migration.convertors.NetworkConvertor;
-import org.openecomp.core.migration.convertors.NicConvertor;
-import org.openecomp.core.migration.convertors.OrchestrationTemplateCandidateConvertor;
-import org.openecomp.core.migration.convertors.ProcessConvertor;
-import org.openecomp.core.migration.convertors.VlmConvertor;
-import org.openecomp.core.migration.convertors.VspInformationConvertor;
-import org.openecomp.core.migration.convertors.VspServiceArtifactConvertor;
-import org.openecomp.core.migration.convertors.VspServiceTemplateConvertor;
-import org.openecomp.core.migration.loaders.ComponentCassandraLoader;
-import org.openecomp.core.migration.loaders.EntitlementPoolCassandraLoader;
-import org.openecomp.core.migration.loaders.FeatureGroupCassandraLoader;
-import org.openecomp.core.migration.loaders.LKGCassandraLoader;
-import org.openecomp.core.migration.loaders.LicenseAgreementCassandraLoader;
-import org.openecomp.core.migration.loaders.MibCassandraLoader;
-import org.openecomp.core.migration.loaders.NetworkCassandraLoader;
-import org.openecomp.core.migration.loaders.NicCassandraLoader;
-import org.openecomp.core.migration.loaders.OrchestrationTemplateCandidateCassandraLoader;
-import org.openecomp.core.migration.loaders.ProcessCassandraLoader;
-import org.openecomp.core.migration.loaders.ServiceArtifactCassandraLoader;
-import org.openecomp.core.migration.loaders.ServiceTemplateCassandraLoader;
-import org.openecomp.core.migration.loaders.VendorLicenseModelCassandraLoader;
-import org.openecomp.core.migration.loaders.VendorSoftwareProductInfoLoader;
-import org.openecomp.core.migration.loaders.VersionInfoCassandraLoader;
-import org.openecomp.core.migration.loaders.VspInformation;
-import org.openecomp.core.migration.store.ElementHandler;
-import org.openecomp.core.migration.store.ItemHandler;
-import org.openecomp.core.migration.util.marker.MigrationMarker;
-import org.openecomp.core.model.types.ServiceArtifact;
-import org.openecomp.core.model.types.ServiceTemplate;
-import org.openecomp.core.zusammen.impl.CassandraConnectionInitializer;
-import org.openecomp.core.zusammen.plugin.dao.impl.CassandraElementRepository;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.dao.types.VersionInfoEntity;
-
-import java.time.Duration;
-import java.time.Instant;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.openecomp.core.migration.util.Utils.printMessage;
-
-public class MigrationMain {
- private static final String GLOBAL_USER = "GLOBAL_USER";
- private static Logger logger = LoggerFactory.getLogger(MigrationMain.class);
- private static int status = 0;
-
- private static Map<String, VersionInfoEntity> versionInfoMap = new HashMap<>();
-
- public static void main(String[] args) {
- CassandraElementRepository cassandraElementRepository = new CassandraElementRepository();
- CassandraConnectionInitializer.setCassandraConnectionPropertiesToSystem();
- printMessage(logger, "Checking whether a migration has already been run.");
- if (MigrationMarker.isMigrated()) {
- printMessage(logger, "The DB has already been migrated, this script will now exit.");
- System.exit(status);
- }
- ItemCassandraDao itemCassandraDao = new ItemCassandraDao();
- VersionCassandraDao versionCassandraDao = new VersionCassandraDao();
- SessionContext context = new SessionContext();
- context.setUser(new UserInfo(GLOBAL_USER));
- context.setTenant("dox");
- printMessage(logger, "Starting migration.\n");
- Instant startTime = Instant.now();
-
- migrateToZusammen(cassandraElementRepository, itemCassandraDao, versionCassandraDao, context);
-
- Instant stopTime = Instant.now();
- Duration duration = Duration.between(startTime, stopTime);
- long minutesPart = duration.toMinutes();
- long secondsPart = duration.minusMinutes(minutesPart).getSeconds();
-
- if (status == 0) {
- MigrationMarker.markMigrated();
- }
- printMessage(logger,
- "Migration finished . Total run time was : " + minutesPart + ":" + secondsPart
- + " minutes");
- System.exit(status);
- }
-
-
- private static void migrateToZusammen(CassandraElementRepository cassandraElementRepository,
- ItemCassandraDao itemCassandraDao,
- VersionCassandraDao versionCassandraDao,
- SessionContext context) {
- loadVersionInfo();
-
-
- try {
- convertVsp(context, itemCassandraDao, versionCassandraDao, cassandraElementRepository);
- printMessage(logger, "Converted VSPs\n");
- } catch (Exception e) {
- logger.debug(e.getMessage(), e);
- status = -1;
- }
-
- try {
- convertOrchestrationTemplateCandidate(context, cassandraElementRepository);
- printMessage(logger, "Converted OrchestrationTemplateCandidates\n");
- } catch (Exception e) {
- logger.debug(e.getMessage(), e);
- status = -1;
- }
-
-
- try {
- convertComponent(context, cassandraElementRepository);
- printMessage(logger, "Converted Components\n");
- } catch (Exception e) {
- logger.debug(e.getMessage(), e);
- status = -1;
- }
- try {
- convertNic(context, cassandraElementRepository);
- printMessage(logger, "Converted Nics\n");
- } catch (Exception e) {
- logger.debug(e.getMessage(), e);
- status = -1;
- }
- try {
- convertNetwork(context, cassandraElementRepository);
- printMessage(logger, "Converted Networks\n");
- } catch (Exception e) {
- logger.debug(e.getMessage(), e);
- status = -1;
- }
- try {
- convertMibs(context, cassandraElementRepository);
- printMessage(logger, "Converted MIBs\n");
- } catch (Exception e) {
- logger.debug(e.getMessage(), e);
- status = -1;
- }
- try {
- convertServiceArtifact(context, cassandraElementRepository);
- printMessage(logger, "Converted Service Artifacts\n");
- } catch (Exception e) {
- logger.debug(e.getMessage(), e);
- status = -1;
- }
- try {
- convertServiceTemplate(context, cassandraElementRepository);
- printMessage(logger, "Converted Service Templates\n");
- } catch (Exception e) {
- logger.debug(e.getMessage(), e);
- status = -1;
- }
- try {
- convertProcesses(context, cassandraElementRepository);
- printMessage(logger, "Converted Processes\n");
- } catch (Exception e) {
- logger.debug(e.getMessage(), e);
- status = -1;
- }
-
-
- try {
- convertVlm(context, itemCassandraDao, versionCassandraDao, cassandraElementRepository);
- printMessage(logger, "Converted VLMs\n");
- } catch (Exception e) {
- logger.debug(e.getMessage(), e);
- status = -1;
- }
- try {
- convertLKG(context, cassandraElementRepository);
- printMessage(logger, "Converted LKGs\n");
- } catch (Exception e) {
- logger.debug(e.getMessage(), e);
- status = -1;
- }
- try {
- convertFeatureGroup(context, cassandraElementRepository);
- printMessage(logger, "Converted Feature Groups\n");
- } catch (Exception e) {
- logger.debug(e.getMessage(), e);
- status = -1;
- }
- try {
- convertEP(context, cassandraElementRepository);
- printMessage(logger, "Converted EPs\n");
- } catch (Exception e) {
- logger.debug(e.getMessage(), e);
- status = -1;
- }
- try {
- convertLicenseAgreement(context, cassandraElementRepository);
- printMessage(logger, "Converted License Agreements\n");
- } catch (Exception e) {
- logger.debug(e.getMessage(), e);
- status = -1;
- }
- }
-
- private static void convertOrchestrationTemplateCandidate(SessionContext context,
- CassandraElementRepository cassandraElementRepository) {
- OrchestrationTemplateCandidateCassandraLoader orchestrationTemplateCandidateCassandraLoader =
- new OrchestrationTemplateCandidateCassandraLoader();
-
- orchestrationTemplateCandidateCassandraLoader.list().stream()
- .filter(entity -> needMigration(entity.getId(), entity.getVersion()) &&
- entity.getContentData()!=null && entity.getFilesDataStructure()!=null)
- .forEach(entity -> ElementHandler
- .save(context, cassandraElementRepository, entity.getId(), entity.getVersion(),
- OrchestrationTemplateCandidateConvertor
- .convertOrchestrationTemplateCandidateToElement(entity)));
- }
-
- private static void loadVersionInfo() {
-
- VersionInfoCassandraLoader versionInfoCassandraLoader = new VersionInfoCassandraLoader();
- Collection<VersionInfoEntity> versions =
- versionInfoCassandraLoader.list();
-
- versions.forEach(versionInfoEntity -> versionInfoMap.put(versionInfoEntity.getEntityId
- (), versionInfoEntity));
-
-
- }
-
- private static void convertMibs(SessionContext context,
- CassandraElementRepository cassandraElementRepository) {
- MibCassandraLoader cassandraLoader = new MibCassandraLoader();
- Collection<ComponentMonitoringUploadEntity> mibs = cassandraLoader.list();
- mibs.stream().filter(mibEntity -> needMigration(mibEntity.getVspId(), mibEntity.getVersion()))
- .forEach
- (mibEntity -> {
- ElementHandler.save(context, cassandraElementRepository,
- mibEntity
- .getVspId(), mibEntity.getVersion(),
- MibConvertor.convertMibToElement
- (mibEntity));
- });
- }
-
- private static void convertProcesses(SessionContext context,
- CassandraElementRepository cassandraElementRepository) {
- ProcessCassandraLoader cassandraLoader = new ProcessCassandraLoader();
- Collection<ProcessEntity> processes = cassandraLoader.list();
- processes.stream()
- .filter(processEntity -> needMigration(processEntity.getVspId(), processEntity.getVersion
- ())).forEach(processEntity -> {
- ElementHandler.save(
- context,
- cassandraElementRepository,
- processEntity
- .getId(), processEntity.getVersion(),
- ProcessConvertor.convertProcessToElement(processEntity));
- });
- }
-
- private static void convertVsp(SessionContext context, ItemCassandraDao itemCassandraDao,
- VersionCassandraDao versionCassandraDao,
- CassandraElementRepository cassandraElementRepository) {
- VendorSoftwareProductInfoLoader vendorSoftwareProductInfoLoader = new
- VendorSoftwareProductInfoLoader();
- Collection<VspInformation> vsps =
- vendorSoftwareProductInfoLoader.list();
- vsps.stream().filter(vspInformation -> needMigration(vspInformation.getId(),
- vspInformation.getVersion())).forEach
- (vspInformation
- ->
- ItemHandler.save(context,
- itemCassandraDao,
- versionCassandraDao,
- vspInformation.getId(), vspInformation
- .getVersion(),
- VspInformationConvertor
- .getVspInfo
- (vspInformation),
- VspInformationConvertor.getItemVersionData(vspInformation),
- vspInformation.getWritetimeMicroSeconds()));
-
- vsps.stream().filter(vspInformation -> needMigration(vspInformation.getId(),
- vspInformation.getVersion()))
- .forEach(vspInformation -> ElementHandler.save(context, cassandraElementRepository,
- vspInformation.getId(), vspInformation.getVersion(),
- VspInformationConvertor.convertVspToElement
- (vspInformation)));
- }
-
- private static void convertVlm(SessionContext context, ItemCassandraDao itemCassandraDao,
- VersionCassandraDao versionCassandraDao,
- CassandraElementRepository cassandraElementRepository) {
- VendorLicenseModelCassandraLoader
- vendorLicenseModelCassandraDao = new VendorLicenseModelCassandraLoader();
- Collection<VendorLicenseModelEntity> vlms =
- vendorLicenseModelCassandraDao.list();
- vlms.stream().filter(vlm -> needMigration(vlm.getId(), vlm.getVersion())).forEach(vlmEntity ->
- ItemHandler.save
- (context, itemCassandraDao,
- versionCassandraDao,
- vlmEntity.getId(), vlmEntity.getVersion(),
- VlmConvertor.getVlmInfo
- (vlmEntity),
- VlmConvertor.getItemVersionData(vlmEntity), new Date().getTime()));
- vlms.stream().filter(vlm -> needMigration(vlm.getId(), vlm.getVersion()))
- .forEach(vlmEntity -> ElementHandler.save(context, cassandraElementRepository,
- vlmEntity.getId(), vlmEntity.getVersion(),
- VlmConvertor.convertVlmToElement
- (vlmEntity)));
-
- }
-
- private static void convertNic(SessionContext context,
- CassandraElementRepository cassandraElementRepository) {
- NicCassandraLoader nicCassandraLoader = new NicCassandraLoader();
- Collection<NicEntity> nics = nicCassandraLoader.list();
- nics.stream().filter(entity -> needMigration(entity.getVspId(), entity.getVersion
- ())).forEach(nicEntity -> ElementHandler.save(context, cassandraElementRepository,
- nicEntity.getVspId(), nicEntity.getVersion(), NicConvertor.convertNicToElement
- (nicEntity)));
-
- }
-
- private static void convertNetwork(SessionContext context,
- CassandraElementRepository cassandraElementRepository) {
- NetworkCassandraLoader networkCassandraLoader = new NetworkCassandraLoader();
- Collection<NetworkEntity> networks = networkCassandraLoader.list();
- networks.stream().filter(entity -> needMigration(entity.getVspId(), entity.getVersion
- ())).forEach(networkEntity -> ElementHandler.save(context, cassandraElementRepository,
- networkEntity.getVspId(), networkEntity.getVersion(), NetworkConvertor
- .convertNetworkToElement(networkEntity)));
-
- }
-
- private static void convertComponent(SessionContext context,
- CassandraElementRepository cassandraElementRepository) {
- ComponentCassandraLoader componentCassandraLoader = new ComponentCassandraLoader();
- Collection<ComponentEntity> components = componentCassandraLoader.list();
- components.stream().filter(entity -> needMigration(entity.getVspId(), entity.getVersion
- ())).forEach(componentEntity -> ElementHandler.save(context, cassandraElementRepository,
- componentEntity
- .getVspId(), componentEntity.getVersion(), ComponentConvertor
- .convertComponentToElement(componentEntity)));
-
- }
-
- private static void convertServiceArtifact(SessionContext context,
- CassandraElementRepository cassandraElementRepository) {
- ServiceArtifactCassandraLoader serviceArtifactCassandraLoader =
- new ServiceArtifactCassandraLoader();
- Collection<ServiceArtifact> serviceArtifacts = serviceArtifactCassandraLoader.list();
- serviceArtifacts.stream().filter(entity -> needMigration(entity.getVspId(), entity.getVersion
- ())).forEach(serviceArtifact -> ElementHandler.save(context,
- cassandraElementRepository,
- serviceArtifact
- .getVspId(), serviceArtifact.getVersion(),
- VspServiceArtifactConvertor
- .convertServiceArtifactToElement(serviceArtifact)));
-
- }
-
- private static void convertServiceTemplate(SessionContext context,
- CassandraElementRepository cassandraElementRepository) {
- ServiceTemplateCassandraLoader serviceTemplateCassandraLoader =
- new ServiceTemplateCassandraLoader();
- Collection<ServiceTemplate> serviceTemplates = serviceTemplateCassandraLoader.list();
- serviceTemplates.stream().filter(entity -> needMigration(entity.getVspId(), entity.getVersion
- ())).forEach(serviceTemplate -> ElementHandler.save(context,
- cassandraElementRepository,
- serviceTemplate
- .getVspId(), serviceTemplate.getVersion(),
- VspServiceTemplateConvertor
- .convertServiceTemplateToElement(serviceTemplate)));
-
- }
-
- private static void convertLKG(SessionContext context,
- CassandraElementRepository cassandraElementRepository) {
- LKGCassandraLoader LKGCassandraLoader = new LKGCassandraLoader();
- Collection<LicenseKeyGroupEntity> lkgs = LKGCassandraLoader.list();
- lkgs.stream().filter(entity -> needMigration(entity.getVendorLicenseModelId(), entity.getVersion
- ()))
- .forEach(licenseKeyGroupEntity -> ElementHandler.save(context, cassandraElementRepository,
- licenseKeyGroupEntity
- .getVendorLicenseModelId(), licenseKeyGroupEntity.getVersion(),
- LKGConvertor.convertLKGToElement
- (licenseKeyGroupEntity)));
- }
-
- private static void convertEP(SessionContext context,
- CassandraElementRepository cassandraElementRepository) {
- EntitlementPoolCassandraLoader entitlementPoolCassandraLoader =
- new EntitlementPoolCassandraLoader();
- Collection<EntitlementPoolEntity> entitlementPools = entitlementPoolCassandraLoader.list();
- entitlementPools.stream()
- .filter(entity -> needMigration(entity.getVendorLicenseModelId(), entity.getVersion
- ()))
- .forEach(entitlementPoolEntity -> ElementHandler.save(context, cassandraElementRepository,
- entitlementPoolEntity
- .getVendorLicenseModelId(), entitlementPoolEntity.getVersion(),
- EntitlementPoolConvertor.convertEntitlementPoolToElement(entitlementPoolEntity)));
- }
-
- private static void convertFeatureGroup(SessionContext context,
- CassandraElementRepository cassandraElementRepository) {
- FeatureGroupCassandraLoader featureGroupCassandraLoader = new FeatureGroupCassandraLoader();
- Collection<FeatureGroupEntity> featureGroupEntities = featureGroupCassandraLoader.list();
- featureGroupEntities.stream()
- .filter(entity -> needMigration(entity.getVendorLicenseModelId(), entity.getVersion
- ()))
- .forEach(featureGroupEntity -> ElementHandler.save(context, cassandraElementRepository,
- featureGroupEntity
- .getVendorLicenseModelId(), featureGroupEntity.getVersion(),
- FeatureGroupConvertor.convertFeatureGroupToElement(featureGroupEntity)));
- }
-
- private static void convertLicenseAgreement(SessionContext context,
- CassandraElementRepository cassandraElementRepository) {
- LicenseAgreementCassandraLoader licenseAgreementCassandraLoader =
- new LicenseAgreementCassandraLoader();
- Collection<LicenseAgreementEntity> licenseAgreementEntities =
- licenseAgreementCassandraLoader.list();
- licenseAgreementEntities.stream()
- .filter(entity -> needMigration(entity.getVendorLicenseModelId(), entity.getVersion
- ()))
- .forEach(licenseAgreementEntity -> ElementHandler.save(context, cassandraElementRepository,
- licenseAgreementEntity
- .getVendorLicenseModelId(), licenseAgreementEntity.getVersion(),
- LicenseAgreementConvertor.convertLicenseAgreementToElement(licenseAgreementEntity)));
- }
-
-
- private static boolean needMigration(String itemId, Version versionId) {
-
- VersionInfoEntity versionInfo =
- MigrationMain.versionInfoMap.get(itemId);
- if (versionInfo == null) {
- printMessage(logger, "ItemId: " + itemId + " is not in version_info table.");
- return false;
- }
- return (versionInfo.getCandidate() != null && versionId.equals(versionInfo.getCandidate()
- .getVersion()))
- || (versionInfo
- .getViewableVersions() != null && versionInfo
- .getViewableVersions().contains(versionId));
- }
-
- public static Map<String, VersionInfoEntity> getVersionInfoMap()
- {
- return versionInfoMap;
- }
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/ComponentConvertor.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/ComponentConvertor.java
deleted file mode 100644
index fb597d5..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/ComponentConvertor.java
+++ /dev/null
@@ -1,102 +0,0 @@
-package org.openecomp.core.migration.convertors;
-
-import com.amdocs.zusammen.datatypes.item.ElementContext;
-import com.amdocs.zusammen.datatypes.item.Info;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
-import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElement;
-import org.openecomp.core.migration.MigrationMain;
-import org.openecomp.core.migration.store.ElementHandler;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ElementPropertyName;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ElementType;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.StructureElement;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author katyr
- * @since April 23, 2017
- */
-
-public class ComponentConvertor {
-
- private static Set<String> componentsLoaded = new HashSet<>();
- private static Logger logger = LoggerFactory.getLogger(MigrationMain.class);
-
- public static CollaborationElement[] convertComponentToElement(ComponentEntity componentEntity) {
-
- CollaborationElement[] componentElements;
- List<String> componentNamespace = getComponentNamespace();
-
- int index = 0;
- String componentsEntityId = StructureElement.Components.name();
- String uniqueId = componentEntity.getVspId()+"_"+componentEntity.getVersion().toString();
- if (componentsLoaded.contains(uniqueId)) {
-// printMessage(logger, "Components structural elements exist for component " +
-// componentEntity.getId());
- componentElements = new CollaborationElement[2];
- } else {
- componentsLoaded.add(uniqueId);
-// printMessage(logger, "Creating Components structural elements for component " +
-// componentEntity.getId());
- componentElements = new CollaborationElement[3];
- componentElements[index] = ElementHandler.getElementEntity(
- componentEntity.getVspId(), componentEntity.getVersion().toString(), componentsEntityId,
- componentNamespace,
- ElementHandler.getStructuralElementInfo(StructureElement.Components.name()),
- null,
- null,
- null);
- index++;
- }
-
- componentNamespace.add(componentsEntityId);
- componentElements[index] = ElementHandler.getElementEntity(
- componentEntity.getVspId(), componentEntity.getVersion().toString(),
- componentEntity.getId(),
- componentNamespace,
- getComponentInfo(componentEntity),
- null,
- null,
- (componentEntity.getCompositionData() != null) ? componentEntity.getCompositionData().getBytes()
- : null);
- index++;
-
- componentNamespace.add(componentEntity.getId());
- componentElements[index] = ElementHandler.getElementEntity(
- componentEntity.getVspId(), componentEntity.getVersion().toString(),StructureElement.Questionnaire.name() + "_" + componentEntity.getId(),
- componentNamespace,
- ElementHandler.getStructuralElementInfo(StructureElement.Questionnaire.name()),
- null,
- null,
- (componentEntity.getQuestionnaireData() != null) ? componentEntity.getQuestionnaireData().getBytes()
- : null);
-
- return componentElements;
- }
-
- private static Info getComponentInfo(ComponentEntity componentEntity) {
- Info info = new Info();
- info.addProperty(ElementPropertyName.type.name(), ElementType.Component);
- info.addProperty(ElementPropertyName.compositionData.name(),
- componentEntity.getCompositionData());
-
- return info;
- }
-
- private static List<String> getComponentNamespace() {
- return ElementHandler.getElementPath();
- }
-
- public static ElementEntityContext convertComponentToElementContext(
- ComponentEntity componentEntity) {
-
- return new ElementEntityContext("GLOBAL_USER", new
- ElementContext(componentEntity.getVspId(), componentEntity.getVersion().toString()));
- }
-
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/EntitlementPoolConvertor.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/EntitlementPoolConvertor.java
deleted file mode 100644
index 86faf15..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/EntitlementPoolConvertor.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package org.openecomp.core.migration.convertors;
-
-import com.amdocs.zusammen.datatypes.item.ElementContext;
-import com.amdocs.zusammen.datatypes.item.Info;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
-import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElement;
-import org.openecomp.core.migration.store.ElementHandler;
-import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.RelationType;
-import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.StructureElement;
-import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.VlmZusammenUtil;
-import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-/**
- * Created by ayalaben on 4/24/2017
- */
-public class EntitlementPoolConvertor {
-
- private static Set<String> EntitlementPoolsLoaded = new HashSet<>();
-
- public static ElementEntityContext convertEntitlementPoolToElementContext(
- EntitlementPoolEntity entitlementPoolEntity) {
-
- return new ElementEntityContext("GLOBAL_USER", new
- ElementContext(entitlementPoolEntity.getVendorLicenseModelId(),
- entitlementPoolEntity.getVersion().toString()));
- }
-
- public static CollaborationElement[] convertEntitlementPoolToElement(
- EntitlementPoolEntity entitlementPoolEntity) {
-// printMessage(logger, "source EntitlementPoolEntity -> " + entitlementPoolEntity.toString());
- CollaborationElement[] elements;
- List<String> entitlementPoolNamespace = getEntitlementPoolNamespace(entitlementPoolEntity);
-
- int index = 0;
- String entitlememtPoolsEntityId = StructureElement.EntitlementPools.name();
- String uniqueId = entitlementPoolEntity.getVendorLicenseModelId() + "_" +
- entitlementPoolEntity.getVersion().toString();
-
- if (EntitlementPoolsLoaded.contains(uniqueId)) {
- elements = new CollaborationElement[1];
- } else {
- EntitlementPoolsLoaded.add(uniqueId);
- elements = new CollaborationElement[2];
- elements[index] = ElementHandler.getElementEntity(
- entitlementPoolEntity.getVendorLicenseModelId(),
- entitlementPoolEntity.getVersion().toString(),
- entitlememtPoolsEntityId, entitlementPoolNamespace,
- ElementHandler.getStructuralElementInfo(StructureElement.EntitlementPools.name()),
- null, null, null);
- index++;
- }
-
- entitlementPoolNamespace.add(entitlememtPoolsEntityId);
-
- elements[index] = ElementHandler.getElementEntity(
- entitlementPoolEntity.getVendorLicenseModelId(),
- entitlementPoolEntity.getVersion().toString(),
- entitlementPoolEntity.getId(), entitlementPoolNamespace,
- getEntitelementPoolInfo(entitlementPoolEntity),
- entitlementPoolEntity.getReferencingFeatureGroups().stream().map(rel ->
- VlmZusammenUtil
- .createRelation( RelationType.EntitlmentPoolToReferencingFeatureGroup, rel))
- .collect(Collectors.toList()), null, null);
-
- return elements;
- }
-
- private static Info getEntitelementPoolInfo(EntitlementPoolEntity entitlementPool) {
-
- Info info = new Info();
- info.setName(entitlementPool.getName());
- info.setDescription(entitlementPool.getDescription());
- info.addProperty("thresholdValue", entitlementPool.getThresholdValue());
- info.addProperty("threshold_unit", entitlementPool.getThresholdUnit());
- //info.addProperty("entitlement_metric", entitlementPool.getEntitlementMetric());
- info.addProperty("increments", entitlementPool.getIncrements());
- info.addProperty("operational_scope", entitlementPool.getOperationalScope());
-
- return info;
- }
-
- private static List<String> getEntitlementPoolNamespace(
- EntitlementPoolEntity entitlementPoolEntity) {
- return ElementHandler.getElementPath("");
- }
-
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/FeatureGroupConvertor.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/FeatureGroupConvertor.java
deleted file mode 100644
index eac5ce6..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/FeatureGroupConvertor.java
+++ /dev/null
@@ -1,102 +0,0 @@
-package org.openecomp.core.migration.convertors;
-
-import com.amdocs.zusammen.datatypes.item.ElementContext;
-import com.amdocs.zusammen.datatypes.item.Info;
-import com.amdocs.zusammen.datatypes.item.Relation;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
-import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElement;
-import org.openecomp.core.migration.store.ElementHandler;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.RelationType;
-import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.StructureElement;
-import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.VlmZusammenUtil;
-import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-/**
- * Created by ayalaben on 4/25/2017
- */
-public class FeatureGroupConvertor {
-
- private static Logger logger = LoggerFactory.getLogger(FeatureGroupConvertor.class);
- private static Set<String> FeatureGroupsLoaded = new HashSet<>();
-
- public static ElementEntityContext convertFeatureGroupToElementContext(FeatureGroupEntity featureGroupEntity) {
-
- return new ElementEntityContext("GLOBAL_USER", new
- ElementContext(featureGroupEntity.getVendorLicenseModelId(), featureGroupEntity.getVersion().toString()));
- }
-
- public static CollaborationElement[] convertFeatureGroupToElement(FeatureGroupEntity featureGroupEntity) {
-// printMessage(logger, "source FeatureGroupEntity -> " + featureGroupEntity.toString());
- CollaborationElement[] elements;
- List<String> featureGroupNamespace = getFeatureGroupNamespace(featureGroupEntity);
-
- int index = 0;
- String featureGroupsEntityId = StructureElement.FeatureGroups.name();
- String uniqueId = featureGroupEntity.getVendorLicenseModelId() + "_" + featureGroupEntity.getVersion().toString();
-
- if (FeatureGroupsLoaded.contains(uniqueId)) {
- elements = new CollaborationElement[1];
- } else {
- FeatureGroupsLoaded.add(uniqueId);
- elements = new CollaborationElement[2];
- elements[index] = ElementHandler.getElementEntity(
- featureGroupEntity.getVendorLicenseModelId(), featureGroupEntity.getVersion().toString(),
- featureGroupsEntityId, featureGroupNamespace,
- ElementHandler.getStructuralElementInfo(StructureElement.FeatureGroups.name()),
- null, null, null);
- index++;
- }
-
- featureGroupNamespace.add(featureGroupsEntityId);
-
- elements[index] = ElementHandler.getElementEntity(
- featureGroupEntity.getVendorLicenseModelId(), featureGroupEntity.getVersion().toString(),
- featureGroupEntity.getId(), featureGroupNamespace, getFeatureGroupInfo(featureGroupEntity),
- getAllFeatureGroupRelations(featureGroupEntity), null, null);
-
- return elements;
- }
-
- private static Collection<Relation> getAllFeatureGroupRelations(FeatureGroupEntity featureGroup) {
- Collection<Relation> relations = new ArrayList<>();
-
- relations.addAll(featureGroup.getEntitlementPoolIds().stream().map(rel ->
- VlmZusammenUtil.createRelation( RelationType.FeatureGroupToEntitlmentPool, rel))
- .collect(Collectors.toList()));
-
- relations.addAll(featureGroup.getLicenseKeyGroupIds().stream().map(rel ->
- VlmZusammenUtil.createRelation( RelationType.FeatureGroupToLicenseKeyGroup, rel))
- .collect(Collectors.toList()));
-
- relations.addAll(featureGroup.getReferencingLicenseAgreements().stream().map(rel ->
- VlmZusammenUtil.createRelation( RelationType.FeatureGroupToReferencingLicenseAgreement,
- rel)).collect(Collectors.toList()));
-
- return relations;
- }
-
- private static Info getFeatureGroupInfo(FeatureGroupEntity featureGroup) {
-
- Info info = new Info();
- info.setName(featureGroup.getName());
- info.setDescription(featureGroup.getDescription());
- info.addProperty("partNumber", featureGroup.getPartNumber());
- info.addProperty("manufacturerReferenceNumber", featureGroup.getManufacturerReferenceNumber());
-
- return info;
- }
-
-
- private static List<String> getFeatureGroupNamespace(FeatureGroupEntity featureGroupEntity) {
- return ElementHandler.getElementPath("");
- }
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/LKGConvertor.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/LKGConvertor.java
deleted file mode 100644
index 7fd640b..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/LKGConvertor.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package org.openecomp.core.migration.convertors;
-
-import com.amdocs.zusammen.datatypes.item.ElementContext;
-import com.amdocs.zusammen.datatypes.item.Info;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
-import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElement;
-import org.openecomp.core.migration.store.ElementHandler;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.RelationType;
-import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.StructureElement;
-import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.VlmZusammenUtil;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-/**
- * Created by ayalaben on 4/24/2017
- */
-public class LKGConvertor {
-
- private static Logger logger = LoggerFactory.getLogger(LKGConvertor.class);
- private static Set<String> compLKGLoaded = new HashSet<>();
-
- public static CollaborationElement[] convertLKGToElement(LicenseKeyGroupEntity licenseKeyGroupEntity) {
- CollaborationElement[] elements;
- List<String> lkgNamespace = getLKGNamespace(licenseKeyGroupEntity);
-
- int index = 0;
- String lkgsEntityId = StructureElement.LicenseKeyGroups.name();
- String uniqueId = licenseKeyGroupEntity.getVendorLicenseModelId() + "_" + licenseKeyGroupEntity.getVersion().toString();
-
- if (compLKGLoaded.contains(uniqueId)) {
- elements = new CollaborationElement[1];
- } else {
- compLKGLoaded.add(uniqueId);
- elements = new CollaborationElement[2];
- elements[index] = ElementHandler.getElementEntity(
- licenseKeyGroupEntity.getVendorLicenseModelId(), licenseKeyGroupEntity.getVersion().toString(), lkgsEntityId, lkgNamespace,
- ElementHandler.getStructuralElementInfo(StructureElement.LicenseKeyGroups.name()), null, null, null);
- index++;
- }
-
- lkgNamespace.add(lkgsEntityId);
-
- elements[index] = ElementHandler.getElementEntity(
- licenseKeyGroupEntity.getVendorLicenseModelId(), licenseKeyGroupEntity.getVersion().toString(), licenseKeyGroupEntity.getId(), lkgNamespace,
- getLKGInfo(licenseKeyGroupEntity), licenseKeyGroupEntity.getReferencingFeatureGroups().stream().map(rel ->
- VlmZusammenUtil.createRelation( RelationType.LicenseKeyGroupToReferencingFeatureGroup, rel))
- .collect(Collectors.toList()), null, null);
-
- return elements;
- }
-
- private static Info getLKGInfo(LicenseKeyGroupEntity licenseKeyGroupEntity) {
-
- Info info = new Info();
- info.setName(licenseKeyGroupEntity.getName());
- info.setDescription(licenseKeyGroupEntity.getDescription());
- info.addProperty("LicenseKeyType", licenseKeyGroupEntity.getType());
- info.addProperty("operational_scope", licenseKeyGroupEntity.getOperationalScope());
-
- return info;
- }
-
- private static List<String> getLKGNamespace(LicenseKeyGroupEntity LKGEntity) {
- return ElementHandler.getElementPath("");
- }
-
- public static ElementEntityContext convertLKGToElementContext(LicenseKeyGroupEntity licenseKeyGroupEntity) {
-
- return new ElementEntityContext("GLOBAL_USER", new
- ElementContext(licenseKeyGroupEntity.getVendorLicenseModelId(), licenseKeyGroupEntity.getVersion().toString()));
- }
-
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/LicenseAgreementConvertor.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/LicenseAgreementConvertor.java
deleted file mode 100644
index 25564c3..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/LicenseAgreementConvertor.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package org.openecomp.core.migration.convertors;
-
-import com.amdocs.zusammen.datatypes.item.ElementContext;
-import com.amdocs.zusammen.datatypes.item.Info;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
-import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElement;
-import org.openecomp.core.migration.store.ElementHandler;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.RelationType;
-import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.StructureElement;
-import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.VlmZusammenUtil;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-/**
- * Created by ayalaben on 4/25/2017
- */
-public class LicenseAgreementConvertor {
-
- private static Logger logger = LoggerFactory.getLogger(LicenseAgreementConvertor.class);
- private static Set<String> LicenseAgreementsLoaded = new HashSet<>();
-
- public static ElementEntityContext convertLicenseAgreementToElementContext(LicenseAgreementEntity licenseAgreementEntity) {
-
- return new ElementEntityContext("GLOBAL_USER", new
- ElementContext(licenseAgreementEntity.getVendorLicenseModelId(), licenseAgreementEntity.getVersion().toString()));
- }
-
-
- public static CollaborationElement[] convertLicenseAgreementToElement(LicenseAgreementEntity licenseAgreementEntity) {
-// printMessage(logger, "source LicenseAgreementEntity -> " + licenseAgreementEntity.toString());
- CollaborationElement[] elements;
- List<String> featureGroupNamespace = getLicenseAgreementNamespace(licenseAgreementEntity);
-
- int index = 0;
- String featureGroupsEntityId = StructureElement.LicenseAgreements.name();
- String uniqueId = licenseAgreementEntity.getVendorLicenseModelId() + "_" + licenseAgreementEntity.getVersion().toString();
-
- if (LicenseAgreementsLoaded.contains(uniqueId)) {
- elements = new CollaborationElement[1];
- } else {
- LicenseAgreementsLoaded.add(uniqueId);
- elements = new CollaborationElement[2];
- elements[index] = ElementHandler.getElementEntity(
- licenseAgreementEntity.getVendorLicenseModelId(), licenseAgreementEntity.getVersion().toString(),
- featureGroupsEntityId, featureGroupNamespace,
- ElementHandler.getStructuralElementInfo(StructureElement.LicenseAgreements.name()),
- null, null, null);
- index++;
- }
-
- featureGroupNamespace.add(featureGroupsEntityId);
-
- elements[index] = ElementHandler.getElementEntity(
- licenseAgreementEntity.getVendorLicenseModelId(), licenseAgreementEntity.getVersion().toString(),
- licenseAgreementEntity.getId(), featureGroupNamespace, getLicenseAgreementInfo(licenseAgreementEntity),
- licenseAgreementEntity.getFeatureGroupIds().stream().map(rel ->
- VlmZusammenUtil.createRelation( RelationType.LicenseAgreementToFeatureGroup, rel))
- .collect(Collectors.toList()), null, null);
-
- return elements;
- }
-
- private static Info getLicenseAgreementInfo(LicenseAgreementEntity licenseAgreement) {
-
- Info info = new Info();
- info.setName(licenseAgreement.getName());
- info.setDescription(licenseAgreement.getDescription());
- info.addProperty("licenseTerm", licenseAgreement.getLicenseTerm());
- info.addProperty("requirementsAndConstrains", licenseAgreement.getRequirementsAndConstrains());
-
- return info;
- }
-
- private static List<String> getLicenseAgreementNamespace(LicenseAgreementEntity licenseAgreement) {
- return ElementHandler.getElementPath("");
- }
-
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/MibConvertor.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/MibConvertor.java
deleted file mode 100644
index f145e51..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/MibConvertor.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package org.openecomp.core.migration.convertors;
-
-import com.amdocs.zusammen.datatypes.item.ElementContext;
-import com.amdocs.zusammen.datatypes.item.Info;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
-import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElement;
-import org.openecomp.core.migration.MigrationMain;
-import org.openecomp.core.migration.store.ElementHandler;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.StructureElement;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-public class MibConvertor {
- private static Logger logger = LoggerFactory.getLogger(MigrationMain.class);
-
- private static Set<String> compMibLoaded = new HashSet<>();
-
-
- public static CollaborationElement[] convertMibToElement(
- ComponentMonitoringUploadEntity componentMonitoringUploadEntity) {
- CollaborationElement[] elements;
- List<String> mibNamespace = getMibNamespace(componentMonitoringUploadEntity);
-
- int index = 0;
- String mibsEntityId =
- StructureElement.Mibs.name() + "_" + componentMonitoringUploadEntity.getComponentId();
- if (compMibLoaded.contains(mibsEntityId)) {
- elements = new CollaborationElement[1];
- } else {
- compMibLoaded.add(mibsEntityId);
- elements = new CollaborationElement[2];
- elements[index++] = ElementHandler.getElementEntity(
- componentMonitoringUploadEntity.getVspId(),
- componentMonitoringUploadEntity.getVersion().toString(), mibsEntityId, mibNamespace,
- ElementHandler.getStructuralElementInfo(StructureElement.Mibs.name()), null, null, null);
- }
-
- mibNamespace.add(mibsEntityId);
- elements[index] = ElementHandler.getElementEntity(
- componentMonitoringUploadEntity.getVspId(),
- componentMonitoringUploadEntity.getVersion().toString(), componentMonitoringUploadEntity
- .getId(), mibNamespace,
- getMibInfo(componentMonitoringUploadEntity), null, null, componentMonitoringUploadEntity
- .getArtifact().array());
-
- return elements;
- }
-
- private static Info getMibInfo(
- ComponentMonitoringUploadEntity componentMonitoringUploadEntity) {
- Info info = new Info();
- info.setName(componentMonitoringUploadEntity.getType().toString());
- info.getProperties().put("name", componentMonitoringUploadEntity.getArtifactName());
- return info;
- }
-
- private static List<String> getMibNamespace(
- ComponentMonitoringUploadEntity componentMonitoringUploadEntity) {
- return ElementHandler
- .getElementPath(StructureElement.Components.name(), componentMonitoringUploadEntity
- .getComponentId());
- }
-
- public static ElementEntityContext convertMibToElementContext(
- ComponentMonitoringUploadEntity componentMonitoringUploadEntity) {
-
- return new ElementEntityContext("GLOBAL_USER", new
- ElementContext(componentMonitoringUploadEntity.getVspId(),
- componentMonitoringUploadEntity
- .getVersion().toString()));
- }
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/NetworkConvertor.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/NetworkConvertor.java
deleted file mode 100644
index 3d4f157..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/NetworkConvertor.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package org.openecomp.core.migration.convertors;
-
-import com.amdocs.zusammen.datatypes.item.ElementContext;
-import com.amdocs.zusammen.datatypes.item.Info;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
-import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElement;
-import org.openecomp.core.migration.MigrationMain;
-import org.openecomp.core.migration.store.ElementHandler;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ElementPropertyName;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ElementType;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.StructureElement;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author katyr
- * @since April 23, 2017
- */
-
-public class NetworkConvertor {
-
- private static Set<String> networksLoaded = new HashSet<>();
- private static Logger logger = LoggerFactory.getLogger(MigrationMain.class);
-
-
-
- public static CollaborationElement[] convertNetworkToElement(NetworkEntity networkEntity) {
-
- CollaborationElement[] networkElements;
- List<String> networkNamespace = getNetworkNamespace();
-
- int index = 0;
- String networksEntityId = StructureElement.Networks.name();
- String uniqueId = networkEntity.getVspId()+"_"+networkEntity.getVersion().toString();
- if (networksLoaded.contains(uniqueId)) {
-// printMessage(logger, "Networks structural elements exist for network " +
-// networkEntity.getId());
- networkElements = new CollaborationElement[1];
- } else {
-// printMessage(logger, "Creating Networks structural element for network " +
-// networkEntity.getId());
- networksLoaded.add(uniqueId);
- networkElements = new CollaborationElement[2];
- networkElements[index] = ElementHandler.getElementEntity(
- networkEntity.getVspId(), networkEntity.getVersion().toString(), networksEntityId,
- networkNamespace,
- ElementHandler.getStructuralElementInfo(StructureElement.Networks.name()),
- null,
- null,
- null);
- index++;
- }
-
- networkNamespace.add(networksEntityId);
-
- networkElements[index] = ElementHandler.getElementEntity(
- networkEntity.getVspId(), networkEntity.getVersion().toString(), networkEntity.getId(),
- networkNamespace,
- getNetworkInfo(networkEntity),
- null,
- null,
- networkEntity.getCompositionData().getBytes());
-
-
- return networkElements;
- }
-
- private static Info getNetworkInfo(NetworkEntity networkEntity) {
- Info info = new Info();
- info.addProperty(ElementPropertyName.type.name(), ElementType.Network);
- info.addProperty(ElementPropertyName.compositionData.name(), networkEntity.getCompositionData());
-
- return info;
- }
-
- private static List<String> getNetworkNamespace() {
- return ElementHandler.getElementPath();
- }
-
- public static ElementEntityContext convertNetworkToElementContext(NetworkEntity networkEntity) {
-
- return new ElementEntityContext("GLOBAL_USER", new
- ElementContext(networkEntity.getVspId(), networkEntity.getVersion().toString()));
- }
-
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/NicConvertor.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/NicConvertor.java
deleted file mode 100644
index b17e68c..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/NicConvertor.java
+++ /dev/null
@@ -1,95 +0,0 @@
-package org.openecomp.core.migration.convertors;
-
-import com.amdocs.zusammen.datatypes.item.ElementContext;
-import com.amdocs.zusammen.datatypes.item.Info;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
-import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElement;
-import org.openecomp.core.migration.MigrationMain;
-import org.openecomp.core.migration.store.ElementHandler;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ElementPropertyName;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ElementType;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.StructureElement;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-public class NicConvertor {
-
-
- private static Set<String> compNicLoaded = new HashSet<>();
- private static Logger logger = LoggerFactory.getLogger(MigrationMain.class);
-
-
-
- public static CollaborationElement[] convertNicToElement(NicEntity nicEntity) {
-
- CollaborationElement[] nicElements;
- List<String> nicNamespace = getNicNamespace(nicEntity);
-
- int index = 0;
- String nicsEntityId = StructureElement.Nics.name() + "_" + nicEntity.getComponentId();
- if (compNicLoaded.contains(nicsEntityId)) {
-// printMessage(logger, "Nics structural element exists for nic " +
-// nicEntity.getId());
- nicElements = new CollaborationElement[2];
- } else {
-// printMessage(logger, "Creating Nics structural element for nic " +
-// nicEntity.getId());
- compNicLoaded.add(nicsEntityId);
- nicElements = new CollaborationElement[3];
- nicElements[index] = ElementHandler.getElementEntity(
- nicEntity.getVspId(), nicEntity.getVersion().toString(), nicsEntityId,
- nicNamespace,
- ElementHandler.getStructuralElementInfo(StructureElement.Nics.name()),
- null,
- null,
- null);
- index++;
- }
-
- nicNamespace.add(nicsEntityId);
- nicElements[index] = ElementHandler.getElementEntity(
- nicEntity.getVspId(), nicEntity.getVersion().toString(), nicEntity.getId(),
- nicNamespace,
- getNicInfo(nicEntity),
- null,
- null,
- nicEntity.getCompositionData().getBytes());
- index++;
-
- nicNamespace.add(nicEntity.getId());
- nicElements[index] = ElementHandler.getElementEntity(
- nicEntity.getVspId(), nicEntity.getVersion().toString(),StructureElement.Questionnaire.name() + "_" + nicEntity.getId(),
- nicNamespace,
- ElementHandler.getStructuralElementInfo(StructureElement.Questionnaire.name()),
- null,
- null,
- (nicEntity.getQuestionnaireData() != null) ? nicEntity.getQuestionnaireData().getBytes()
- : null);
- return nicElements;
- }
-
- private static Info getNicInfo(NicEntity nicEntity) {
- Info info = new Info();
- info.addProperty(ElementPropertyName.type.name(), ElementType.Nic);
- info.addProperty(ElementPropertyName.compositionData.name(), nicEntity.getCompositionData());
- return info;
- }
-
- private static List<String> getNicNamespace(NicEntity nicEntity) {
- return ElementHandler.getElementPath(StructureElement.Components.name(), nicEntity
- .getComponentId());
- }
-
- public static ElementEntityContext convertNicToElementContext(NicEntity nicEntity) {
-
- return new ElementEntityContext("GLOBAL_USER", new
- ElementContext(nicEntity.getVspId(), nicEntity.getVersion().toString()));
- }
-
-
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/OrchestrationTemplateCandidateConvertor.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/OrchestrationTemplateCandidateConvertor.java
deleted file mode 100644
index e6ceb36..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/OrchestrationTemplateCandidateConvertor.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package org.openecomp.core.migration.convertors;
-
-import com.amdocs.zusammen.datatypes.item.ElementContext;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
-import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElement;
-import org.openecomp.core.migration.MigrationMain;
-import org.openecomp.core.migration.store.ElementHandler;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.StructureElement;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateDataEntity;
-
-import java.util.List;
-
-public class OrchestrationTemplateCandidateConvertor {
-
-
-
-
- private static Logger logger = LoggerFactory.getLogger(MigrationMain.class);
-
- public static CollaborationElement[] convertOrchestrationTemplateCandidateToElement(
- OrchestrationTemplateCandidateDataEntity entity) {
-
-
- CollaborationElement[] orchestrationTemplateCandidateElements = new CollaborationElement[2];
- List<String> orchestrationTemplateCandidateNamespace =
- getOrchestrationTemplateCandidateNamespace();
-
-
-
- orchestrationTemplateCandidateElements[0] = ElementHandler.getElementEntity(
- entity.getId(), entity.getVersion().toString(), StructureElement.OrchestrationTemplateCandidate.name(),
- orchestrationTemplateCandidateNamespace,
- ElementHandler.getStructuralElementInfo(StructureElement.OrchestrationTemplateCandidate.name()),
- null,
- null,
- entity.getFilesDataStructure().getBytes());
-
- orchestrationTemplateCandidateNamespace.add(StructureElement.OrchestrationTemplateCandidate.name());
- orchestrationTemplateCandidateElements[1] = ElementHandler.getElementEntity(
- entity.getId(), entity.getVersion().toString(), StructureElement.OrchestrationTemplateCandidateContent.name(),
- orchestrationTemplateCandidateNamespace,
- ElementHandler.getStructuralElementInfo(StructureElement.OrchestrationTemplateCandidateContent.name()),
- null,
- null,
- entity.getContentData().array());
-
-
-
- return orchestrationTemplateCandidateElements;
- }
-
-
- private static List<String> getOrchestrationTemplateCandidateNamespace() {
- return ElementHandler.getElementPath();
- }
-
- public static ElementEntityContext convertComponentToElementContext(
- ComponentEntity componentEntity) {
-
- return new ElementEntityContext("GLOBAL_USER", new
- ElementContext(componentEntity.getVspId(), componentEntity.getVersion().toString()));
- }
-
-
-
-
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/ProcessConvertor.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/ProcessConvertor.java
deleted file mode 100644
index 0a145c4..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/ProcessConvertor.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package org.openecomp.core.migration.convertors;
-
-import com.amdocs.zusammen.datatypes.item.ElementContext;
-import com.amdocs.zusammen.datatypes.item.Info;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
-import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElement;
-import org.openecomp.core.migration.MigrationMain;
-import org.openecomp.core.migration.store.ElementHandler;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.ElementType;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.StructureElement;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-public class ProcessConvertor {
- private static final String NAME = "name";
- private static final String ELEMENT_TYPE = "type";
- private static final String ARTIFACT_NAME = "artifactName";
- private static final String DESCRIPTION = "description";
- private static final String PROCESS_TYPE = "processType";
- private static Set<String> compProcessesLoaded = new HashSet<>();
-
- private static Logger logger = LoggerFactory.getLogger(MigrationMain.class);
-
-
- public static CollaborationElement[] convertProcessToElement(ProcessEntity processEntity) {
- CollaborationElement[] elements;
- boolean isGeneralComponentId = isGeneralComponentId(processEntity);
- List<String> processNamespace = getProcessNamespace(processEntity);
- int index = 0;
- String uniqueId = getUniqueId(processEntity, isGeneralComponentId);
- String processesEntityId = isGeneralComponentId ? StructureElement.Processes.name() :
- (StructureElement.Processes.name() + "_" +processEntity.getComponentId());
- if (compProcessesLoaded.contains(uniqueId)) {
- elements = new CollaborationElement[1];
- } else {
- compProcessesLoaded.add(uniqueId);
- elements = new CollaborationElement[2];
- elements[index++] = ElementHandler.getElementEntity(
- processEntity.getVspId(), processEntity.getVersion().toString(), processesEntityId,
- processNamespace,
- ElementHandler.getStructuralElementInfo(StructureElement.Processes.name()), null, null, null);
- }
-
- processNamespace.add(processesEntityId);
- elements[index] = ElementHandler.getElementEntity(
- processEntity.getVspId(), processEntity.getVersion().toString(), processEntity.getId(),
- processNamespace,
- getProcessInfo(processEntity), null, null, processEntity.getArtifact() ==
- null ? null : processEntity.getArtifact().array());
-
- return elements;
- }
-
- private static String getUniqueId(ProcessEntity processEntity, boolean isGeneralComponentId) {
- if (isGeneralComponentId) {
- return processEntity.getVspId() + "_" + processEntity.getVersion().toString();
- } else {
- return StructureElement.Processes.name() + "_" + processEntity
- .getComponentId();
- }
- }
-
- private static Info getProcessInfo(ProcessEntity processEntity) {
- Info info = new Info();
- info.setName(processEntity.getName());
- info.addProperty(NAME, processEntity.getName());
- info.addProperty(ELEMENT_TYPE, ElementType.Process);
- info.addProperty(ARTIFACT_NAME, processEntity.getArtifactName());
- info.addProperty(DESCRIPTION, processEntity.getDescription());
- info.addProperty(PROCESS_TYPE,
- processEntity.getType() != null ? processEntity.getType().name() : null);
- return info;
- }
-
- private static List<String> getProcessNamespace(ProcessEntity processEntity) {
- if (isGeneralComponentId(processEntity)) {
- return ElementHandler.getElementPath();
- } else {
- return ElementHandler
- .getElementPath(StructureElement.Components.name(), processEntity.getComponentId());
- }
- }
-
- private static boolean isGeneralComponentId(ProcessEntity processEntity) {
- return processEntity.getComponentId().equals("General");
- }
-
- public static ElementEntityContext convertProcessToElementContext(ProcessEntity processEntity) {
-
- return new ElementEntityContext("GLOBAL_USER", new
- ElementContext(processEntity.getVspId(), processEntity.getVersion().toString()));
- }
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VlmConvertor.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VlmConvertor.java
deleted file mode 100644
index 2e48374..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VlmConvertor.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package org.openecomp.core.migration.convertors;
-
-import com.amdocs.zusammen.datatypes.item.ElementContext;
-import com.amdocs.zusammen.datatypes.item.Info;
-import com.amdocs.zusammen.datatypes.item.ItemVersionData;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
-import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElement;
-import org.openecomp.core.migration.store.ElementHandler;
-import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.StructureElement;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-public class VlmConvertor {
-
- private static Set<String> compNicLoaded = new HashSet<>();
-
- public static CollaborationElement[] convertVlmToElement(VendorLicenseModelEntity vendorLicenseModel) {
-
- CollaborationElement[] vspElements = new CollaborationElement[1];
- List<String> vspNamespace = getVlmNamespace(vendorLicenseModel);
-
-
- String vspEntityId = StructureElement.General.name();
-
- vspElements[0] = ElementHandler.getElementEntity(
- vendorLicenseModel.getId(), vendorLicenseModel.getVersion().toString(),
- vspEntityId,
- vspNamespace,
- getVlmGeneralInfo(vendorLicenseModel),
- null,
- null,
- null);
- return vspElements;
- }
-
-
- public static ItemVersionData getItemVersionData(
- VendorLicenseModelEntity vendorLicenseModel) {
- ItemVersionData itemVersionData = new ItemVersionData();
- Info info = new Info();
- info.setName("main version");
- itemVersionData.setInfo(info);
- return itemVersionData;
- }
-
- public static Info getVlmInfo(VendorLicenseModelEntity vendorLicenseModel) {
-
- Info info = new Info();
- info.setName(vendorLicenseModel.getVendorName());
- info.setDescription(vendorLicenseModel.getDescription());
- info.addProperty("type", "vlm");
- info.addProperty("version", vendorLicenseModel.getVersion());
- info.addProperty("iconRef", vendorLicenseModel.getIconRef());
- return info;
- }
-
- private static List<String> getVlmNamespace(VendorLicenseModelEntity vlmEntity) {
- return ElementHandler.getElementPath("");
- }
-
- private static Info getVlmGeneralInfo(VendorLicenseModelEntity vendorLicenseModel) {
-
-
- Info info = new Info();
- info.setName(StructureElement.General.name());
- info.addProperty(InfoPropertyName.type.name(), InfoPropertyName.vlm.name());
- info.addProperty(InfoPropertyName.iconRef.name(), vendorLicenseModel.getIconRef());
- info.addProperty(InfoPropertyName.name.name(), vendorLicenseModel.getVendorName());
- info.addProperty(InfoPropertyName.description.name(), vendorLicenseModel.getDescription());
- return info;
- }
-
- public static ElementEntityContext convertVlmToElementContext(VendorLicenseModelEntity
- vendorLicenseModel) {
-
- return new ElementEntityContext("GLOBAL_USER", new
- ElementContext(vendorLicenseModel.getId(), vendorLicenseModel.getVersion().toString()));
- }
-
-
- private enum InfoPropertyName {
- name,
- description,
- iconRef,
- type,
- vlm
- }
-
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VspInformationConvertor.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VspInformationConvertor.java
deleted file mode 100644
index 59fba5f..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VspInformationConvertor.java
+++ /dev/null
@@ -1,162 +0,0 @@
-package org.openecomp.core.migration.convertors;
-
-import com.amdocs.zusammen.datatypes.item.ElementContext;
-import com.amdocs.zusammen.datatypes.item.Info;
-import com.amdocs.zusammen.datatypes.item.ItemVersionData;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
-import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElement;
-import org.openecomp.core.migration.loaders.VspInformation;
-import org.openecomp.core.migration.store.ElementHandler;
-import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.StructureElement;
-
-import java.util.List;
-
-public class VspInformationConvertor {
-
- public static ItemVersionData getItemVersionData(
- VspInformation vspInformation) {
- Info info = new Info();
- info.setName("main version");
- ItemVersionData itemVersionData = new ItemVersionData();
- itemVersionData.setInfo(info);
- return itemVersionData;
- }
-
- public static Info getVspInfo(VspInformation vspInformation) {
-
- Info info = new Info();
- info.setName(vspInformation.getName());
- info.setDescription(vspInformation.getDescription());
- info.addProperty("type", "vsp");
- addVspDetailsToInfo(info, vspInformation);
- return info;
- }
-
- private static List<String> getVspNamespace(VendorLicenseModelEntity vlmEntity) {
- return ElementHandler.getElementPath("");
- }
-
- private static void addVspDetailsToInfo(Info info, VspInformation vspInformation) {
- info.addProperty("name", vspInformation.getName());
- info.addProperty("description", vspInformation.getDescription());
- info.addProperty("category", vspInformation.getCategory());
- info.addProperty("subCategory", vspInformation.getSubCategory());
- info.addProperty("vendorId", vspInformation.getVendorId());
- info.addProperty("vendorName", vspInformation.getVendorName());
- if (vspInformation.getVlmVersion() != null) {
- info.addProperty("vendorVersion", vspInformation.getVlmVersion().toString());
- }
- info.addProperty("featureGroups", vspInformation.getFeatureGroups());
- info.addProperty("licenseAgreement", vspInformation.getLicenseAgreement());
- String oldVersion = vspInformation.getIsOldVersion() == null? "1702":"1610";
- info.addProperty("oldVersion", oldVersion);
- }
-
- public static CollaborationElement[] convertVspToElement(VspInformation vspInformation) {
-
- CollaborationElement[] vspElements;
- if(vspInformation.getQuestionnaireData() == null){
- vspElements = new CollaborationElement[4];
- }else{
- vspElements = new CollaborationElement[5];
- }
-
- int index=0;
-
- List<String> vspNamespace = getVspNamespace(vspInformation);
-
-
- String vspEntityId = StructureElement.General.name();
-
- vspElements[index] = ElementHandler.getElementEntity(
- vspInformation.getId(), vspInformation.getVersion().toString(),
- vspEntityId,
- vspNamespace,
- getVspGeneralInfo(vspInformation),
- null,
- null,
- null);
-
- index++;
- String vspOrchestrationTemplateEntityId = StructureElement.OrchestrationTemplate.name();
- vspElements[index] = ElementHandler.getElementEntity(
- vspInformation.getId(), vspInformation.getVersion().toString(),
- vspOrchestrationTemplateEntityId,
- vspNamespace,
- ElementHandler.getStructuralElementInfo(vspOrchestrationTemplateEntityId),
- null,
- null,
- null);
-
- if(vspInformation.getQuestionnaireData()!= null) {
- index++;
- String vspQuestionnaireEntityId = StructureElement.Questionnaire.name();
- vspElements[index] = ElementHandler.getElementEntity(
- vspInformation.getId(), vspInformation.getVersion().toString(),
- vspQuestionnaireEntityId,
- vspNamespace,
- ElementHandler.getStructuralElementInfo(vspQuestionnaireEntityId),
- null,
- null,
- vspInformation.getQuestionnaireData().getBytes() != null ? vspInformation
- .getQuestionnaireData().getBytes() : null);
- }
- vspNamespace.add(vspOrchestrationTemplateEntityId);
- index++;
- String vspOrchestrationTemplateValidationDataEntityId = StructureElement.OrchestrationTemplateValidationData.name();
- vspElements[index] = ElementHandler.getElementEntity(
- vspInformation.getId(), vspInformation.getVersion().toString(),
- vspOrchestrationTemplateValidationDataEntityId,
- vspNamespace,
- ElementHandler.getStructuralElementInfo(vspOrchestrationTemplateValidationDataEntityId),
- null,
- null,
- vspInformation.getValidationData()!= null?vspInformation.getValidationData().getBytes()
- :null);
- index++;
- String vspOrchestrationTemplateContentEntityId = StructureElement.OrchestrationTemplateContent.name();
- vspElements[index] = ElementHandler.getElementEntity(
- vspInformation.getId(), vspInformation.getVersion().toString(),
- vspOrchestrationTemplateContentEntityId,
- vspNamespace,
- ElementHandler.getStructuralElementInfo(vspOrchestrationTemplateContentEntityId),
- null,
- null,
- vspInformation.getContentData()!= null?vspInformation.getContentData().array()
- :null);
-
- return vspElements;
- }
-
- private static Info getVspGeneralInfo(VspInformation vspInformation) {
-
-
- Info info = new Info();
- info.setName(StructureElement.General.name());
- info.addProperty("name", vspInformation.getName());
- info.addProperty("description", vspInformation.getDescription());
- info.addProperty("category", vspInformation.getCategory());
- info.addProperty("subCategory", vspInformation.getSubCategory());
- info.addProperty("vendorId", vspInformation.getVendorId());
- info.addProperty("vendorName", vspInformation.getVendorName());
- if (vspInformation.getVlmVersion() != null) {
- info.addProperty("vendorVersion", vspInformation.getVlmVersion().toString());
- }
- info.addProperty("featureGroups", vspInformation.getFeatureGroups());
- info.addProperty("licenseAgreement", vspInformation.getLicenseAgreement());
- String oldVersion = vspInformation.getIsOldVersion() == null? "1702":"1610";
- info.addProperty("oldVersion", oldVersion);
- return info;
- }
-
- private static List<String> getVspNamespace(VspInformation vspEntity) {
- return ElementHandler.getElementPath("");
- }
-
- public static ElementEntityContext convertVspToElementContext(VspInformation vspEntity) {
-
- return new ElementEntityContext("GLOBAL_USER", new
- ElementContext(vspEntity.getId(), vspEntity.getVersion().toString()));
- }
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VspServiceArtifactConvertor.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VspServiceArtifactConvertor.java
deleted file mode 100644
index 15b8ad7..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VspServiceArtifactConvertor.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package org.openecomp.core.migration.convertors;
-
-import com.amdocs.zusammen.datatypes.item.ElementContext;
-import com.amdocs.zusammen.datatypes.item.Info;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
-import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElement;
-import org.openecomp.core.migration.store.ElementHandler;
-import org.openecomp.core.model.types.ServiceArtifact;
-import org.openecomp.core.utilities.file.FileUtils;
-import org.openecomp.sdc.model.impl.zusammen.StructureElement;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author katyr
- * @since April 23, 2017
- */
-
-public class VspServiceArtifactConvertor
-{
- private static Set<String> serviceArtifactsLoaded = new HashSet<>();
-
-
-
- public static CollaborationElement[] convertServiceArtifactToElement(ServiceArtifact serviceArtifact) {
-
- CollaborationElement[] serviceArtifactElements;
- List<String> serviceArtifactNamespace = getServiceArtifactNamespace();
-
- int index = 0;
- String serviceArtifactsEntityId = StructureElement.Artifacts.name();
- String uniqueId = serviceArtifact.getVspId()+"_"+serviceArtifact.getVersion().toString();
- if (serviceArtifactsLoaded.contains(uniqueId)) {
- serviceArtifactElements = new CollaborationElement[1];
- } else {
- serviceArtifactsLoaded.add(uniqueId);
- serviceArtifactElements = new CollaborationElement[2];
- serviceArtifactElements[index] = ElementHandler.getElementEntity(
- serviceArtifact.getVspId(), serviceArtifact.getVersion().toString(), serviceArtifactsEntityId,
- serviceArtifactNamespace,
- ElementHandler.getStructuralElementInfo(StructureElement.Artifacts.name()),
- null,
- null,
- null);
- index++;
- }
-
- serviceArtifactNamespace.add(serviceArtifactsEntityId);
- String elementId = serviceArtifact.getVspId()+"_"+serviceArtifact.getVersion().toString()
- +"_"+serviceArtifact.getName();
- serviceArtifactElements[index] = ElementHandler.getElementEntity(
- serviceArtifact.getVspId(), serviceArtifact.getVersion().toString(), elementId,
- serviceArtifactNamespace,
- getServiceArtifactInfo(serviceArtifact),
- null,
- null,
- FileUtils.toByteArray(serviceArtifact.getContent()));
-
- return serviceArtifactElements;
- }
-
- private static Info getServiceArtifactInfo(ServiceArtifact serviceArtifactEntity) {
- Info info = new Info();
- info.setName(serviceArtifactEntity.getName());
- info.addProperty("type", org.openecomp.sdc.model.impl.zusammen.ElementType.Artifact.name());
-
- return info;
- }
-
- private static List<String> getServiceArtifactNamespace() {
- return ElementHandler.getElementPath(StructureElement.ServiceModel.name());
- }
-
- public static ElementEntityContext convertServiceArtifactToElementContext(ServiceArtifact
- serviceArtifactEntity) {
-
- return new ElementEntityContext("GLOBAL_USER", new
- ElementContext(serviceArtifactEntity.getVspId(), serviceArtifactEntity.getVersion().toString()));
- }
-
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VspServiceTemplateConvertor.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VspServiceTemplateConvertor.java
deleted file mode 100644
index a767246..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/convertors/VspServiceTemplateConvertor.java
+++ /dev/null
@@ -1,100 +0,0 @@
-package org.openecomp.core.migration.convertors;
-
-import com.amdocs.zusammen.datatypes.item.ElementContext;
-import com.amdocs.zusammen.datatypes.item.Info;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
-import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElement;
-import org.openecomp.core.migration.store.ElementHandler;
-import org.openecomp.core.model.types.ServiceTemplate;
-import org.openecomp.core.utilities.file.FileUtils;
-import org.openecomp.sdc.model.impl.zusammen.ElementType;
-import org.openecomp.sdc.model.impl.zusammen.StructureElement;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author katyr
- * @since April 23, 2017
- */
-
-public class VspServiceTemplateConvertor
-{
- private static Set<String> serviceTemplatesLoaded = new HashSet<>();
-
-
-
- public static CollaborationElement[] convertServiceTemplateToElement(ServiceTemplate serviceTemplate) {
-
- CollaborationElement[] serviceTemplateElements;
- List<String> serviceTemplateNamespace = getServiceTemplateNamespace();
-
- int index = 0;
- String serviceTemplatesEntityId = StructureElement.Templates.name();
- String uniqueId = serviceTemplate.getVspId()+"_"+serviceTemplate.getVersion().toString();
- if (serviceTemplatesLoaded.contains(uniqueId)) {
- serviceTemplateElements = new CollaborationElement[1];
- } else {
- serviceTemplatesLoaded.add(uniqueId);
- String vspServiceModelEntityId = StructureElement.ServiceModel.name();
-
- serviceTemplateElements = new CollaborationElement[3];
- serviceTemplateElements[index] = ElementHandler.getElementEntity(
- serviceTemplate.getVspId(),
- serviceTemplate.getVersion().toString(),
- vspServiceModelEntityId,
- serviceTemplateNamespace,
- ElementHandler.getServiceModelElementInfo(vspServiceModelEntityId,serviceTemplate),
- null,
- null,
- null);
- index++;
- serviceTemplateNamespace.add(vspServiceModelEntityId);
- serviceTemplateElements[index] = ElementHandler.getElementEntity(
- serviceTemplate.getVspId(), serviceTemplate.getVersion().toString(), serviceTemplatesEntityId,
- serviceTemplateNamespace,
- ElementHandler.getStructuralElementInfo(StructureElement.Templates.name()),
- null,
- null,
- null);
- index++;
- }
-
- serviceTemplateNamespace.add(serviceTemplatesEntityId);
- String elementId = serviceTemplate.getVspId()+"_"+serviceTemplate.getVersion().toString()
- +"_"+serviceTemplate.getName();
- serviceTemplateElements[index] = ElementHandler.getElementEntity(
- serviceTemplate.getVspId(), serviceTemplate.getVersion().toString(), elementId,
- serviceTemplateNamespace,
- getServiceTemplateInfo(serviceTemplate),
- null,
- null,
- FileUtils.toByteArray(serviceTemplate.getContent()));
-
- return serviceTemplateElements;
- }
-
- private static Info getServiceTemplateInfo(ServiceTemplate serviceTemplateEntity) {
- Info info = new Info();
- info.setName(serviceTemplateEntity.getName());
- info.addProperty("type", ElementType.Servicetemplate.name());
- info.addProperty("base", serviceTemplateEntity.getBaseName());
-
-
-
- return info;
- }
-
- private static List<String> getServiceTemplateNamespace() {
- return ElementHandler.getElementPath();
- }
-
- public static ElementEntityContext convertServiceTemplateToElementContext(ServiceTemplate
- serviceTemplateEntity) {
-
- return new ElementEntityContext("GLOBAL_USER", new
- ElementContext(serviceTemplateEntity.getVspId(), serviceTemplateEntity.getVersion().toString()));
- }
-
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/ComponentCassandraLoader.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/ComponentCassandraLoader.java
deleted file mode 100644
index 3e00f9d..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/ComponentCassandraLoader.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.core.migration.loaders;
-
-import com.datastax.driver.mapping.Result;
-import com.datastax.driver.mapping.annotations.Accessor;
-import com.datastax.driver.mapping.annotations.Query;
-import org.openecomp.core.nosqldb.api.NoSqlDb;
-import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
-
-import java.util.Collection;
-
-public class ComponentCassandraLoader {
-
- private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
- private static final ComponentAccessor accessor =
- noSqlDb.getMappingManager().createAccessor(ComponentAccessor.class);
-
-
- public Collection<ComponentEntity> list() {
- return accessor.list().all();
- }
-
- @Accessor
- interface ComponentAccessor {
-
- @Query(
- "select * from vsp_component ")
- Result<ComponentEntity> list();
-
-
- }
-
-
-
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/EntitlementPoolCassandraLoader.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/EntitlementPoolCassandraLoader.java
deleted file mode 100644
index c307bfc..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/EntitlementPoolCassandraLoader.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.openecomp.core.migration.loaders;
-
-import com.datastax.driver.mapping.Result;
-import com.datastax.driver.mapping.annotations.Accessor;
-import com.datastax.driver.mapping.annotations.Query;
-import org.openecomp.core.nosqldb.api.NoSqlDb;
-import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
-import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
-
-import java.util.Collection;
-
-/**
- * Created by ayalaben on 4/24/2017
- */
-public class EntitlementPoolCassandraLoader {
-
- private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
-
- private static final EntitlementPoolCassandraLoader.EntitlementPoolAccessor accessor =
- noSqlDb.getMappingManager().createAccessor(EntitlementPoolCassandraLoader.EntitlementPoolAccessor.class);
-
- public Collection<EntitlementPoolEntity> list() {
- return accessor.list().all();
- }
-
- @Accessor
- interface EntitlementPoolAccessor {
- @Query("select * from entitlement_pool ")
- Result<EntitlementPoolEntity> list();
- }
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/FeatureGroupCassandraLoader.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/FeatureGroupCassandraLoader.java
deleted file mode 100644
index 0c7627f..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/FeatureGroupCassandraLoader.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.openecomp.core.migration.loaders;
-
-import com.datastax.driver.mapping.Result;
-import com.datastax.driver.mapping.annotations.Accessor;
-import com.datastax.driver.mapping.annotations.Query;
-import org.openecomp.core.nosqldb.api.NoSqlDb;
-import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
-import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
-
-import java.util.Collection;
-
-/**
- * Created by ayalaben on 4/25/2017.
- */
-public class FeatureGroupCassandraLoader {
-
- private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
- private static final FeatureGroupCassandraLoader.FGAccessor accessor =
- noSqlDb.getMappingManager().createAccessor(FeatureGroupCassandraLoader.FGAccessor.class);
-
- public Collection<FeatureGroupEntity> list() {
- return accessor.getAll().all();
- }
-
- @Accessor
- interface FGAccessor {
- @Query("SELECT * FROM feature_group")
- Result<FeatureGroupEntity> getAll();
- }
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/LKGCassandraLoader.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/LKGCassandraLoader.java
deleted file mode 100644
index 891a69e..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/LKGCassandraLoader.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.openecomp.core.migration.loaders;
-
-import com.datastax.driver.mapping.Result;
-import com.datastax.driver.mapping.annotations.Accessor;
-import com.datastax.driver.mapping.annotations.Query;
-import org.openecomp.core.nosqldb.api.NoSqlDb;
-import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
-
-import java.util.Collection;
-
-/**
- * Created by ayalaben on 4/24/2017
- */
-public class LKGCassandraLoader {
-
- private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
- private static final LKGCassandraLoader.LKGAccessor accessor =
- noSqlDb.getMappingManager().createAccessor(LKGCassandraLoader.LKGAccessor.class);
-
- public Collection<LicenseKeyGroupEntity> list() {
- return accessor.getAll().all();
- }
-
- @Accessor
- interface LKGAccessor {
- @Query("SELECT * FROM license_key_group")
- Result<LicenseKeyGroupEntity> getAll();
-
- }
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/LicenseAgreementCassandraLoader.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/LicenseAgreementCassandraLoader.java
deleted file mode 100644
index ca44209..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/LicenseAgreementCassandraLoader.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.openecomp.core.migration.loaders;
-
-import com.datastax.driver.mapping.Result;
-import com.datastax.driver.mapping.annotations.Accessor;
-import com.datastax.driver.mapping.annotations.Query;
-import org.openecomp.core.nosqldb.api.NoSqlDb;
-import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity;
-
-import java.util.Collection;
-
-/**
- * Created by ayalaben on 4/25/2017.
- */
-public class LicenseAgreementCassandraLoader {
-
- private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
- private static final LicenseAgreementCassandraLoader.LicenseAgreementAccessor accessor =
- noSqlDb.getMappingManager().createAccessor(LicenseAgreementCassandraLoader.LicenseAgreementAccessor.class);
-
- public Collection<LicenseAgreementEntity> list() {
- return accessor.getAll().all();
- }
-
- @Accessor
- interface LicenseAgreementAccessor {
- @Query("SELECT * FROM license_agreement")
- Result<LicenseAgreementEntity> getAll();
-
- }
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/MibCassandraLoader.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/MibCassandraLoader.java
deleted file mode 100644
index b93033c..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/MibCassandraLoader.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.core.migration.loaders;
-
-import com.datastax.driver.mapping.Result;
-import com.datastax.driver.mapping.annotations.Accessor;
-import com.datastax.driver.mapping.annotations.Query;
-import org.openecomp.core.nosqldb.api.NoSqlDb;
-import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity;
-
-import java.util.Collection;
-
-public class MibCassandraLoader {
-
- private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
- private static final MibAccessor accessor =
- noSqlDb.getMappingManager().createAccessor(MibAccessor.class);
-
-
- public Collection<ComponentMonitoringUploadEntity> list() {
- return accessor.list().all();
- }
-
- @Accessor
- interface MibAccessor {
-
- @Query(
- "select * from vsp_component_artifact")
- Result<ComponentMonitoringUploadEntity> list();
-
-
- }
-
-
-
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/NetworkCassandraLoader.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/NetworkCassandraLoader.java
deleted file mode 100644
index 7ce93bc..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/NetworkCassandraLoader.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.openecomp.core.migration.loaders;
-
-import com.datastax.driver.mapping.Result;
-import com.datastax.driver.mapping.annotations.Accessor;
-import com.datastax.driver.mapping.annotations.Query;
-import org.openecomp.core.nosqldb.api.NoSqlDb;
-import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity;
-
-import java.util.Collection;
-
-/**
- * @author katyr
- * @since April 23, 2017
- */
-
-public class NetworkCassandraLoader {
-
- private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
- private static final NetworkCassandraLoader.NetworkAccessor accessor =
- noSqlDb.getMappingManager().createAccessor(NetworkCassandraLoader.NetworkAccessor.class);
-
-
- public Collection<NetworkEntity> list() {
- return accessor.list().all();
- }
-
- @Accessor
- interface NetworkAccessor {
-
- @Query(
- "select * from vsp_network ")
- Result<NetworkEntity> list();
- }
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/NicCassandraLoader.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/NicCassandraLoader.java
deleted file mode 100644
index fea9c08..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/NicCassandraLoader.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.core.migration.loaders;
-
-import com.datastax.driver.mapping.Mapper;
-import com.datastax.driver.mapping.Result;
-import com.datastax.driver.mapping.UDTMapper;
-import com.datastax.driver.mapping.annotations.Accessor;
-import com.datastax.driver.mapping.annotations.Query;
-import org.openecomp.core.nosqldb.api.NoSqlDb;
-import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
-import org.openecomp.sdc.versioning.dao.types.Version;
-
-import java.util.Collection;
-
-public class NicCassandraLoader {
-
- private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
- private static final Mapper<NicEntity> mapper =
- noSqlDb.getMappingManager().mapper(NicEntity.class);
- private static final NicAccessor accessor =
- noSqlDb.getMappingManager().createAccessor(NicAccessor.class);
- private static final UDTMapper<Version> versionMapper =
- noSqlDb.getMappingManager().udtMapper(Version.class);
-
-
- public Collection<NicEntity> list() {
- return accessor.list().all();
- }
-
- @Accessor
- interface NicAccessor {
-
- @Query(
- "select vsp_id, version, component_id, nic_id, composition_data,questionnaire_data "
- + " from vsp_component_nic ")
- Result<NicEntity> list();
-
-
- }
-
-
-
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/OrchestrationTemplateCandidateCassandraLoader.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/OrchestrationTemplateCandidateCassandraLoader.java
deleted file mode 100644
index 09da455..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/OrchestrationTemplateCandidateCassandraLoader.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.core.migration.loaders;
-
-import com.datastax.driver.mapping.Result;
-import com.datastax.driver.mapping.annotations.Accessor;
-import com.datastax.driver.mapping.annotations.Query;
-import org.openecomp.core.nosqldb.api.NoSqlDb;
-import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateDataEntity;
-
-import java.util.Collection;
-
-public class OrchestrationTemplateCandidateCassandraLoader {
-
- private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
- private static final OrchestrationTemplateCandidateAccessor accessor =
- noSqlDb.getMappingManager().createAccessor(OrchestrationTemplateCandidateAccessor.class);
-
-
- public Collection<OrchestrationTemplateCandidateDataEntity> list() {
- return accessor.list().all();
- }
-
- @Accessor
- interface OrchestrationTemplateCandidateAccessor {
-
- @Query(
- "select * from vsp_orchestration_template_candidate ")
- Result<OrchestrationTemplateCandidateDataEntity> list();
-
-
- }
-
-
-
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/ProcessCassandraLoader.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/ProcessCassandraLoader.java
deleted file mode 100644
index 6672af5..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/ProcessCassandraLoader.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.core.migration.loaders;
-
-import com.datastax.driver.mapping.Result;
-import com.datastax.driver.mapping.annotations.Accessor;
-import com.datastax.driver.mapping.annotations.Query;
-import org.openecomp.core.nosqldb.api.NoSqlDb;
-import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
-
-import java.util.Collection;
-
-public class ProcessCassandraLoader {
-
- private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
- private static final ProcessAccessor accessor =
- noSqlDb.getMappingManager().createAccessor(ProcessAccessor.class);
-
-
- public Collection<ProcessEntity> list() {
- return accessor.list().all();
- }
-
- @Accessor
- interface ProcessAccessor {
-
- @Query(
- "select * from vsp_process")
- Result<ProcessEntity> list();
-
-
- }
-
-
-
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/ServiceArtifactCassandraLoader.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/ServiceArtifactCassandraLoader.java
deleted file mode 100644
index 5231662..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/ServiceArtifactCassandraLoader.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.core.migration.loaders;
-
-import com.datastax.driver.mapping.Result;
-import com.datastax.driver.mapping.annotations.Accessor;
-import com.datastax.driver.mapping.annotations.Query;
-import org.openecomp.core.model.types.ServiceArtifact;
-import org.openecomp.core.model.types.ServiceArtifactEntity;
-import org.openecomp.core.nosqldb.api.NoSqlDb;
-import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.stream.Collectors;
-
-public class ServiceArtifactCassandraLoader {
-
- private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
- private static final VspServiceArtifactAccessor accessor =
- noSqlDb.getMappingManager().createAccessor(
- VspServiceArtifactAccessor.class);
-
-
- public Collection<ServiceArtifact> list() {
-
-
- List<ServiceArtifactEntity> entityList = accessor.listAll().all();
-
- return entityList.stream().map(entity -> entity.getServiceArtifact())
- .collect(Collectors.toList());
- }
-
- @Accessor
- interface VspServiceArtifactAccessor {
-
- @Query("SELECT * FROM vsp_service_artifact")
- Result<ServiceArtifactEntity> listAll();
-
-
- }
-
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/ServiceTemplateCassandraLoader.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/ServiceTemplateCassandraLoader.java
deleted file mode 100644
index f7e5853..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/ServiceTemplateCassandraLoader.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.core.migration.loaders;
-
-import com.datastax.driver.mapping.Result;
-import com.datastax.driver.mapping.annotations.Accessor;
-import com.datastax.driver.mapping.annotations.Query;
-import org.openecomp.core.model.types.ServiceTemplate;
-import org.openecomp.core.model.types.ServiceTemplateEntity;
-import org.openecomp.core.nosqldb.api.NoSqlDb;
-import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.stream.Collectors;
-
-public class ServiceTemplateCassandraLoader {
-
- private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
- private static final VspServiceTemplateAccessor accessor =
- noSqlDb.getMappingManager().createAccessor(
- VspServiceTemplateAccessor.class);
-
-
- public Collection<ServiceTemplate> list() {
-
-
- List<ServiceTemplateEntity> entityList = accessor.listAll().all();
-
- return entityList.stream().map(entity -> entity.getServiceTemplate())
- .collect(Collectors.toList());
- }
-
- @Accessor
- interface VspServiceTemplateAccessor {
-
- @Query("SELECT * FROM vsp_service_template")
- Result<ServiceTemplateEntity> listAll();
-
-
- }
-
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/VendorLicenseModelCassandraLoader.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/VendorLicenseModelCassandraLoader.java
deleted file mode 100644
index c02cc1e..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/VendorLicenseModelCassandraLoader.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.core.migration.loaders;
-
-import com.datastax.driver.mapping.Result;
-import com.datastax.driver.mapping.annotations.Accessor;
-import com.datastax.driver.mapping.annotations.Query;
-import org.openecomp.core.nosqldb.api.NoSqlDb;
-import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
-import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
-
-import java.util.Collection;
-
-public class VendorLicenseModelCassandraLoader {
-
- private static NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
- private static VendorLicenseModelAccessor accessor =
- noSqlDb.getMappingManager().createAccessor(VendorLicenseModelAccessor.class);
-
-
- public Collection<VendorLicenseModelEntity> list() {
- return accessor.getAll().all();
- }
-
- @Accessor
- interface VendorLicenseModelAccessor {
-
- @Query("SELECT * FROM vendor_license_model")
- Result<VendorLicenseModelEntity> getAll();
-
- }
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/VendorSoftwareProductInfoLoader.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/VendorSoftwareProductInfoLoader.java
deleted file mode 100644
index 26fc23c..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/VendorSoftwareProductInfoLoader.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.core.migration.loaders;
-
-import com.datastax.driver.mapping.Mapper;
-import com.datastax.driver.mapping.Result;
-import com.datastax.driver.mapping.UDTMapper;
-import com.datastax.driver.mapping.annotations.Accessor;
-import com.datastax.driver.mapping.annotations.Query;
-import org.openecomp.core.nosqldb.api.NoSqlDb;
-import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
-import org.openecomp.sdc.versioning.dao.types.Version;
-
-import java.util.Collection;
-
-public class VendorSoftwareProductInfoLoader {
-
- private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
- private static final Mapper<VspInformation> mapper =
- noSqlDb.getMappingManager().mapper(VspInformation.class);
- private static final VendorSoftwareProductInfoAccessor accessor =
- noSqlDb.getMappingManager().createAccessor(VendorSoftwareProductInfoAccessor.class);
- private static final UDTMapper<Version> versionMapper =
- noSqlDb.getMappingManager().udtMapper(Version.class);
-
-
- public Collection<VspInformation> list() {
- return accessor.listAll().all();
- }
-
-
- @Accessor
- interface VendorSoftwareProductInfoAccessor {
-
- @Query(
- "SELECT * " +
- "FROM " +
- "vsp_information")
- Result<VspInformation> listAll();
-
-
- }
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/VersionInfoCassandraLoader.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/VersionInfoCassandraLoader.java
deleted file mode 100644
index 725298b..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/VersionInfoCassandraLoader.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.core.migration.loaders;
-
-import com.datastax.driver.mapping.Mapper;
-import com.datastax.driver.mapping.Result;
-import com.datastax.driver.mapping.annotations.Accessor;
-import com.datastax.driver.mapping.annotations.Query;
-import org.openecomp.core.nosqldb.api.NoSqlDb;
-import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
-import org.openecomp.sdc.versioning.dao.types.VersionInfoEntity;
-
-import java.util.Collection;
-
-public class VersionInfoCassandraLoader {
-
- private static NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
- private static Mapper<VersionInfoEntity> mapper =
- noSqlDb.getMappingManager().mapper(VersionInfoEntity.class);
- private static VersionInfoAccessor accessor =
- noSqlDb.getMappingManager().createAccessor(VersionInfoAccessor.class);
-
-
-
-
- public Collection<VersionInfoEntity> list() {
- return accessor.getAll().all();
- }
-
- @Accessor
- interface VersionInfoAccessor {
- @Query("select * from version_info ")
- Result<VersionInfoEntity> getAll();
- }
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/VspInformation.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/VspInformation.java
deleted file mode 100644
index 2db1b09..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/loaders/VspInformation.java
+++ /dev/null
@@ -1,276 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.core.migration.loaders;
-
-import com.datastax.driver.mapping.annotations.Column;
-import com.datastax.driver.mapping.annotations.Computed;
-import com.datastax.driver.mapping.annotations.Frozen;
-import com.datastax.driver.mapping.annotations.PartitionKey;
-import com.datastax.driver.mapping.annotations.Table;
-import org.openecomp.core.utilities.json.JsonUtil;
-import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList;
-import org.openecomp.sdc.versioning.dao.types.Version;
-
-import java.nio.ByteBuffer;
-import java.util.List;
-
-@Table(keyspace = "dox", name = "vsp_information")
-public class VspInformation {
- public static final String ENTITY_TYPE = "Vendor Software Product";
-
- @PartitionKey
- @Column(name = "vsp_id")
- private String id;
-
- @PartitionKey(value = 1)
- @Frozen
- private Version version;
-
- private String name;
- private String description;
-
- private String category;
-
- @Column(name = "sub_category")
- private String subCategory;
-
- private String icon;
-
- @Column(name = "vendor_name")
- private String vendorName;
-
- @Column(name = "vendor_id")
- private String vendorId;
-
- @Column(name = "vlm_version")
- @Frozen
- private Version vlmVersion;
-
- @Column(name = "license_agreement")
- private String licenseAgreement;
-
- @Column(name = "feature_groups")
- private List<String> featureGroups;
-
- @Column(name = "package_name")
- private String packageName;
-
- @Column(name = "package_version")
- private String packageVersion;
-
- @Column(name = "validation_data")
- private String validationData;
-
- @Column(name = "is_old_version")
- private String isOldVersion;
-
- @Column(name = "questionnaire_data")
- private String questionnaireData;
-
- @Column(name = "content_data")
- private ByteBuffer contentData;
-
-
- @Computed("writetime(name)")
- private Long writetimeMicroSeconds;
-
-
- public VspInformation() {
- }
-
- public VspInformation(String id, Version version) {
- this.id = id;
- this.version = version;
- }
-
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getCategory() {
- return category;
- }
-
- public void setCategory(String category) {
- this.category = category;
- }
-
- public String getSubCategory() {
- return subCategory;
- }
-
- public void setSubCategory(String subCategory) {
- this.subCategory = subCategory;
- }
-
- public String getIcon() {
- return icon;
- }
-
- public void setIcon(String icon) {
- this.icon = icon;
- }
-
- public String getVendorName() {
- return vendorName;
- }
-
- public void setVendorName(String vendorName) {
- this.vendorName = vendorName;
- }
-
- public String getVendorId() {
- return vendorId;
- }
-
- public void setVendorId(String vendorId) {
- this.vendorId = vendorId;
- }
-
- public Version getVlmVersion() {
- return vlmVersion;
- }
-
- public void setVlmVersion(Version vlmVersion) {
- this.vlmVersion = vlmVersion;
- }
-
- public String getLicenseAgreement() {
- return licenseAgreement;
- }
-
- public void setLicenseAgreement(String licenseAgreement) {
- this.licenseAgreement = licenseAgreement;
- }
-
- public List<String> getFeatureGroups() {
- return featureGroups;
- }
-
- public void setFeatureGroups(List<String> featureGroups) {
- this.featureGroups = featureGroups;
- }
-
- public String getPackageName() {
- return packageName;
- }
-
- public void setPackageName(String packageName) {
- this.packageName = packageName;
- }
-
- public String getPackageVersion() {
- return packageVersion;
- }
-
- public void setPackageVersion(String packageVersion) {
- this.packageVersion = packageVersion;
- }
-
- public String getValidationData() {
- return validationData;
- }
-
- public void setValidationData(String validationData) {
- this.validationData = validationData;
- }
-
- public ValidationStructureList getValidationDataStructure() {
- return validationData == null ? null
- : JsonUtil.json2Object(validationData, ValidationStructureList.class);
- }
-
- public void setValidationDataStructure(ValidationStructureList validationData) {
- this.validationData = validationData == null ? null
- : JsonUtil.object2Json(validationData);
- }
-
- public Long getWritetimeMicroSeconds() {
- return this.writetimeMicroSeconds;
- }
-
- public void setWritetimeMicroSeconds(Long writetimeMicroSeconds) {
- this.writetimeMicroSeconds = writetimeMicroSeconds;
- }
-
- public String getIsOldVersion() {
- return this.isOldVersion;
- }
-
- public void setIsOldVersion(String oldVersion) {
- this.isOldVersion = oldVersion;
- }
-
- public void setVersion(Version version) {
- this.version = version;
- }
-
- public Version getVersion() {
- return version;
- }
-
- public String getQuestionnaireData() {
- return questionnaireData;
- }
-
- public void setQuestionnaireData(String questionnaireData) {
- this.questionnaireData = questionnaireData;
- }
-
- public ByteBuffer getContentData() {
- return contentData;
- }
-
- public void setContentData(ByteBuffer contentData) {
- this.contentData = contentData;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("Vsp id = ").append(this.id);
- sb.append("Version = ").append(this.version);
-
- return sb.toString();
- }
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/store/ElementHandler.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/store/ElementHandler.java
deleted file mode 100644
index 548a8d9..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/store/ElementHandler.java
+++ /dev/null
@@ -1,136 +0,0 @@
-package org.openecomp.core.migration.store;
-
-import com.amdocs.zusammen.datatypes.Id;
-import com.amdocs.zusammen.datatypes.Namespace;
-import com.amdocs.zusammen.datatypes.SessionContext;
-import com.amdocs.zusammen.datatypes.item.Info;
-import com.amdocs.zusammen.datatypes.item.Relation;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
-import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElement;
-import org.openecomp.core.migration.MigrationMain;
-import org.openecomp.core.model.types.ServiceTemplate;
-import org.openecomp.core.zusammen.plugin.ZusammenPluginUtil;
-import org.openecomp.core.zusammen.plugin.dao.impl.CassandraElementRepository;
-import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.dao.types.VersionInfoEntity;
-
-import java.io.ByteArrayInputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-public class ElementHandler {
-
- private static final String GLOBAL_USER = "GLOBAL_USER";
-
- public static void save(SessionContext context,
- CassandraElementRepository cassandraElementRepository,
- String itemId, Version versionId,
- CollaborationElement[] elements) {
-
- ElementEntityContext elementContext;
- for (CollaborationElement element : elements) {
-
- elementContext = new ElementEntityContext(GLOBAL_USER, new Id(itemId), getVersionId(itemId,
- versionId));
- ElementEntity elementEntity = ZusammenPluginUtil.getElementEntity(element);
-
- cassandraElementRepository.createNamespace(context, elementContext, elementEntity);
-
- cassandraElementRepository.create(context, elementContext, elementEntity);
-
- if (isActiveVersion(itemId, versionId)) {
- elementContext =
- new ElementEntityContext(GLOBAL_USER, new Id(itemId), new Id(versionId.toString()));
- cassandraElementRepository.create(context, elementContext, elementEntity);
-
- }
- }
- }
-
- public static CollaborationElement getElementEntity(String itemId,
- String versionId,
- String elementId,
- List<String> elementPath,
- Info info,
- Collection<Relation> relations,
- List<String> subElements,
- byte[] data) {
- Namespace namespace = new Namespace();
- for (String pathElementId : elementPath) {
- namespace = new Namespace(namespace, new Id(pathElementId));
- }
- if (namespace.getValue() == null || namespace.getValue().equals("")) {
- namespace = Namespace.ROOT_NAMESPACE;
- }
- CollaborationElement elementEntity = new CollaborationElement(new Id(itemId), new Id(versionId),
- namespace, new Id(elementId));
-
- Id parentId = namespace.getParentElementId() != null ? namespace.getParentElementId() : Id.ZERO;
- elementEntity.setParentId(parentId);
- elementEntity.setInfo(info);
- elementEntity.setRelations(relations);
- if (subElements != null) {
- Set<Id> subElementSet = new HashSet<>();
-
- subElements.forEach(subElement -> subElementSet.add(new Id(subElement)));
-
- }
- if (data != null) {
- elementEntity.setData(new ByteArrayInputStream(data));
- }
-
- return elementEntity;
- }
-
- public static List<String> getElementPath(String... paths) {
- List<String> pathList = new ArrayList<>();
- if (paths != null) {
- Collections.addAll(pathList, paths);
- }
- return pathList;
- }
-
- public static Info getStructuralElementInfo(String elementName) {
- Info info = new Info();
- info.setName(elementName);
- return info;
- }
-
-
- private static Id getVersionId(String itemId, Version versionId) {
- VersionInfoEntity versionInfo =
- MigrationMain.getVersionInfoMap().get(itemId);
- if (versionInfo == null) {
- return new Id(versionId.toString());
- }
- Version lastVersion = versionInfo.getCandidate() != null ? versionInfo.getCandidate()
- .getVersion()
- : versionInfo.getActiveVersion();
-
- if (lastVersion.equals(versionId)) {
- return new Id(itemId);
- } else {
- return new Id(versionId.toString());
- }
- }
-
- private static boolean isActiveVersion(String itemId, Version versionId) {
- VersionInfoEntity versionInfo =
- MigrationMain.getVersionInfoMap().get(itemId);
- return versionInfo != null && versionInfo.getActiveVersion().equals(versionId);
- }
-
-
- public static Info getServiceModelElementInfo(String vspServiceModelEntityId,
- ServiceTemplate serviceTemplate) {
- Info info = ElementHandler.getStructuralElementInfo(vspServiceModelEntityId);
- info.addProperty("base", serviceTemplate.getBaseName());
- return info;
-
- }
-}
\ No newline at end of file
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/store/ItemHandler.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/store/ItemHandler.java
deleted file mode 100644
index 801984a..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/store/ItemHandler.java
+++ /dev/null
@@ -1,122 +0,0 @@
-package org.openecomp.core.migration.store;
-
-import com.amdocs.zusammen.datatypes.Id;
-import com.amdocs.zusammen.datatypes.Namespace;
-import com.amdocs.zusammen.datatypes.SessionContext;
-import com.amdocs.zusammen.datatypes.item.Info;
-import com.amdocs.zusammen.datatypes.item.ItemVersionData;
-import com.amdocs.zusammen.datatypes.item.Relation;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.impl.ItemCassandraDao;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.impl.VersionCassandraDao;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntity;
-
-import org.openecomp.core.migration.MigrationMain;
-import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.dao.types.VersionInfoEntity;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-public class ItemHandler {
-
- public static ElementEntity getElementEntity(String id, List<String>
- elementPath, Info info, Collection<Relation> relations, List<String> subElements,
- byte[] data) {
- ElementEntity elementEntity = new ElementEntity(new Id(id));
-
- Namespace namespace = new Namespace();
- for (String elementId : elementPath) {
- namespace = new Namespace(namespace, new Id(elementId));
- }
- elementEntity.setNamespace(namespace);
- elementEntity.setParentId(namespace.getParentElementId());
- elementEntity.setInfo(info);
- elementEntity.setRelations(relations);
- if(subElements!=null) {
- Set<Id> subElementSet = new HashSet<>();
-
- subElements.forEach(subElement -> subElementSet.add(new Id(subElement)));
-
- elementEntity.setSubElementIds(subElementSet);
- }
-
- //elementEntity.setData(new ByteArrayInputStream(data));
- return elementEntity;
- }
-
- public static List<String> getElementPath(String... paths) {
- List<String> pathList = new ArrayList<>();
- for (String path : paths) {
- pathList.add(path);
- }
- return pathList;
- }
-
- public static Info getStractualElementInfo(String elementName) {
- Info info = new Info();
- info.setName(elementName);
- return info;
- }
-
- public static void save(SessionContext context, ItemCassandraDao itemCassandraDao,
- VersionCassandraDao versionCassandraDao,
- String itemId, Version versionId, Info info,
- ItemVersionData itemVersionData, Long writetimeMicroSeconds) {
-
- Date date = writetimeMicroSeconds==null?new Date():new Date(writetimeMicroSeconds);
- itemCassandraDao.create(context,new Id(itemId),info,date);
-
- versionCassandraDao.create(context, context.getUser().getUserName(),new Id(itemId),
- null,getVersionId(itemId,versionId),itemVersionData,date);
-
- if(isActiveVersion(itemId,versionId)){
- versionCassandraDao.create(context, context.getUser().getUserName(),new Id(itemId),
- null,new Id(versionId.toString()),itemVersionData,date);
- }
- }
-
-
-
- private static Info getInfo(VendorLicenseModelEntity vlmEntity) {
- Info info = new Info();
-
- info.setName(vlmEntity.getVendorName());
- info.setDescription(vlmEntity.getDescription());
- info.addProperty("iconRef",vlmEntity.getIconRef());
- info.addProperty("type",vlmEntity.getIconRef());
- return info;
- }
-
- private static Id getVersionId(String itemId, Version versionId) {
- VersionInfoEntity versionInfo =
- MigrationMain.getVersionInfoMap().get(itemId);
- if (versionInfo == null) {
- return new Id(versionId.toString());
- }
- Version lastVersion = versionInfo.getCandidate() != null ? versionInfo.getCandidate()
- .getVersion()
- : versionInfo.getActiveVersion();
-
- if (lastVersion.equals(versionId)) {
- return new Id(itemId);
- } else {
- return new Id(versionId.toString());
- }
- }
- private static boolean isActiveVersion(String itemId, Version versionId) {
- VersionInfoEntity versionInfo =
- MigrationMain.getVersionInfoMap().get(itemId);
- if (versionInfo == null) {
- return false;
- }
-
- return versionInfo.getActiveVersion().equals(versionId);
- }
-
-
-}
\ No newline at end of file
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/util/Utils.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/util/Utils.java
deleted file mode 100644
index ea026e5..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/util/Utils.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.openecomp.core.migration.util;
-
-import org.openecomp.sdc.logging.api.Logger;
-
-/**
- * @author Avrahamg
- * @since April 24, 2017
- */
-public class Utils {
- public static void printMessage(Logger logger, String message) {
- System.out.println(message);
- logger.debug(message);
- }
-}
-
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/util/marker/MigrationMarker.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/util/marker/MigrationMarker.java
deleted file mode 100644
index 4481b43..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/util/marker/MigrationMarker.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.openecomp.core.migration.util.marker;
-
-import com.datastax.driver.mapping.annotations.Accessor;
-import com.datastax.driver.mapping.annotations.Query;
-import org.openecomp.core.migration.MigrationMain;
-import org.openecomp.core.nosqldb.api.NoSqlDb;
-import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-
-/**
- * @author katyr
- * @since May 01, 2017
- */
-
-public class MigrationMarker {
-
- private static Logger logger = LoggerFactory.getLogger(MigrationMain.class);
-
- private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
- private static final MigrationTableAccessor accessor =
- noSqlDb.getMappingManager().createAccessor(MigrationMarker.MigrationTableAccessor.class);
-
- public static Boolean isMigrated() {
-
- MigrationMarkerEntity result = accessor.isMigrated();
- if (result == null) {
- return false;
- } else {
- return result.getMigrated();
- }
- }
-
- public static void markMigrated() {
- accessor.markMigrated();
- }
-
- @Accessor
- interface MigrationTableAccessor {
- @Query("SELECT * FROM migration where id='1'")
- MigrationMarkerEntity isMigrated();
-
-
- @Query("insert into migration (id,isMigrated) values('1',true)")
- void markMigrated();
-
- }
-
-}
diff --git a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/util/marker/MigrationMarkerEntity.java b/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/util/marker/MigrationMarkerEntity.java
deleted file mode 100644
index 47bb91d..0000000
--- a/openecomp-be/tools/migration/1702_to_1707_zusammen/src/main/java/org/openecomp/core/migration/util/marker/MigrationMarkerEntity.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package org.openecomp.core.migration.util.marker;
-
-import com.datastax.driver.mapping.annotations.ClusteringColumn;
-import com.datastax.driver.mapping.annotations.Column;
-import com.datastax.driver.mapping.annotations.Table;
-
-/**
- * @author katyr
- * @since May 03, 2017
- */
-
-@Table(keyspace = "dox", name = "migration")
-public class MigrationMarkerEntity {
-
- @ClusteringColumn
- private String id;
-
- @Column(name = "ismigrated")
- private Boolean migrated;
-
- public Boolean getMigrated() {
- return migrated;
- }
-
- public void setMigrated(Boolean migrated) {
- this.migrated = migrated;
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder("MigrationMarkerEntity{");
- sb.append("id='").append(id).append('\'');
- sb.append(", migrated=").append(migrated);
- sb.append('}');
- return sb.toString();
- }
-}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/ExportDataCommand.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/ExportDataCommand.java
deleted file mode 100644
index 487b413..0000000
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/ExportDataCommand.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package org.openecomp.core.tools.Commands;
-
-import static java.nio.file.Files.createDirectories;
-
-import com.amdocs.zusammen.datatypes.SessionContext;
-import org.apache.commons.io.FileUtils;
-import org.openecomp.core.tools.Commands.exportdata.ElementHandler;
-import org.openecomp.core.tools.Commands.exportdata.ImportProperties;
-import org.openecomp.core.tools.Commands.exportdata.ItemHandler;
-import org.openecomp.core.tools.Commands.exportdata.VersionHandler;
-import org.openecomp.core.tools.util.ZipUtils;
-import org.openecomp.core.zusammen.impl.CassandraConnectionInitializer;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.HashSet;
-import java.util.Set;
-public class ExportDataCommand {
- private static final Logger logger = LoggerFactory.getLogger(ExportDataCommand.class);
-
- public static void exportData(SessionContext context, String filterItem) {
- try {
- Set<String> filteredItem = new HashSet<>();
- filteredItem.add(filterItem);
- ImportProperties.initParams();
- CassandraConnectionInitializer.setCassandraConnectionPropertiesToSystem();
- Path rootDir = Paths.get(ImportProperties.ROOT_DIRECTORY);
- initDir(rootDir);
- if (filterItem != null) {
- filterItem = filterItem.replaceAll("\\r", "");
- }
- new ItemHandler().createItemsData(context, filteredItem);
- new VersionHandler().loadVersions(filteredItem);
- new ElementHandler().loadElements(filteredItem);
- zipPath(rootDir,filteredItem);
- FileUtils.forceDelete(rootDir.toFile());
- } catch (Exception ex) {
- logger.error(ex.getMessage(), ex);
- }
-
- }
- private static void zipPath(Path rootDir,Set<String> filterItem ) throws Exception{
- LocalDateTime date = LocalDateTime.now();
- DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME;
- String dateStr = date.format(formatter);
- String zipFile = System.getProperty("user.home")+ File.separatorChar+"onboarding_import"+ dateStr + ".zip";
- ZipUtils.createZip(zipFile, rootDir,filterItem);
- logger.info("Exported file :" + zipFile);
- System.out.println("Exported file :" + zipFile);
- }
-
-
- public static void initDir(Path rootDir ) throws IOException{
- if (Files.exists(rootDir)) {
- FileUtils.forceDelete(rootDir.toFile());
- }
- createDirectories(rootDir);
- }
-
-}
\ No newline at end of file
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/HealAll.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/HealAll.java
index 2bc48bd..40a56ed 100644
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/HealAll.java
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/HealAll.java
@@ -3,6 +3,8 @@
import org.apache.commons.collections.CollectionUtils;
import org.openecomp.core.tools.concurrent.ItemHealingTask;
import org.openecomp.core.tools.loaders.VersionInfoCassandraLoader;
+import org.openecomp.sdc.healing.api.HealingManager;
+import org.openecomp.sdc.healing.factory.HealingManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
import org.openecomp.sdc.vendorsoftwareproduct.VspManagerFactory;
@@ -31,18 +33,20 @@
public class HealAll {
private static final String HEALING_USER = "healing_user";
- private static final int defaulThreadNumber =100;
+ private static final int defaulThreadNumber = 100;
private static BufferedWriter log;
private static List<ItemHealingTask> tasks = new ArrayList<>();
private static VendorSoftwareProductManager vspManager = VspManagerFactory
.getInstance().createInterface();
+ private static HealingManager healingManager = HealingManagerFactory.getInstance()
+ .createInterface();
private static VersioningManager versioningManager = VersioningManagerFactory.getInstance()
.createInterface();
static {
try {
log =
- new BufferedWriter(new FileWriter("healing.log",true));
+ new BufferedWriter(new FileWriter("healing.log", true));
} catch (IOException e) {
if (log != null) {
try {
@@ -64,13 +68,13 @@
defaulThreadNumber;
ExecutorService executor = Executors.newFixedThreadPool(numberOfThreads);
- filterByEntityType(VersionInfoCassandraLoader.list(),
+ filterByEntityType(VersionInfoCassandraLoader.list(),
VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE).forEach
- (HealAll::addTaskToTasks);
+ (HealAll::addTaskToTasks);
executeAllTasks(executor);
- writeToLog("----finished healing------" );
+ writeToLog("----finished healing------");
Instant endTime = Instant.now();
writeToLog("Total runtime was: " + Duration.between(startTime, endTime));
@@ -112,7 +116,7 @@
if (Objects.nonNull(versionInfoEntity.getCandidate())) {
return versionInfoEntity.getCandidate().getVersion();
} else if (!CollectionUtils.isEmpty(versionInfoEntity.getViewableVersions())) {
- return versionInfoEntity.getViewableVersions().stream().max(Version::compateTo).get();
+ return versionInfoEntity.getViewableVersions().stream().max(Version::compateTo).get();
}
return versionInfoEntity.getActiveVersion();
}
@@ -126,17 +130,16 @@
}
}
- private static Stream<VersionInfoEntity> filterByEntityType(Collection<VersionInfoEntity>
- versionInfoEntities,
- String entityType){
+ private static Stream<VersionInfoEntity> filterByEntityType(
+ Collection<VersionInfoEntity> versionInfoEntities, String entityType) {
return versionInfoEntities.stream().filter(versionInfoEntity -> versionInfoEntity
.getEntityType().equals(entityType));
}
- private static void addTaskToTasks(VersionInfoEntity versionInfoEntity){
+
+ private static void addTaskToTasks(VersionInfoEntity versionInfoEntity) {
tasks.add(new ItemHealingTask(versionInfoEntity.getEntityId(), resolveVersion
- (versionInfoEntity).toString(), versionInfoEntity.getCandidate() == null ?
- HEALING_USER : versionInfoEntity.getCandidate().getUser(),
- vspManager, versioningManager));
+ (versionInfoEntity).toString(),
+ vspManager, healingManager));
}
}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/ImportCommand.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/ImportCommand.java
deleted file mode 100644
index cebff91..0000000
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/ImportCommand.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package org.openecomp.core.tools.Commands;
-
-import com.amdocs.zusammen.datatypes.SessionContext;
-import org.apache.commons.io.FileUtils;
-import org.openecomp.core.tools.Commands.importdata.TreeWalker;
-import org.openecomp.core.tools.Commands.exportdata.ImportProperties;
-import org.openecomp.core.tools.util.ZipUtils;
-import org.openecomp.core.zusammen.impl.CassandraConnectionInitializer;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-public class ImportCommand {
-
- private static final Logger logger = LoggerFactory.getLogger(ImportCommand.class);
-
-
- public static void importData(SessionContext context, String zippedFile, String filterItem) {
- try {
- ImportProperties.initParams();
- CassandraConnectionInitializer.setCassandraConnectionPropertiesToSystem();
- if (zippedFile == null){
- logger.error("Import must have a valid file as an input.");
- }
- if (zippedFile != null) {
- zippedFile = zippedFile.replaceAll("\\r", "");
- if (filterItem != null) {
- filterItem = filterItem.replaceAll("\\r", "");
- }
- Path rootDir = Paths.get(ImportProperties.ROOT_DIRECTORY);
- ExportDataCommand.initDir(rootDir);
- ZipUtils.unzip(Paths.get(zippedFile), rootDir);
- TreeWalker.walkFiles(context, rootDir, filterItem);
- FileUtils.forceDelete(rootDir.toFile()); // clear all unzip data at the end.
- }
-
-
- } catch (Exception ex) {
- logger.error(ex.getMessage(), ex);
- }
- }
-
-}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/SetHealingFlag.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/SetHealingFlag.java
new file mode 100644
index 0000000..b885ac5
--- /dev/null
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/SetHealingFlag.java
@@ -0,0 +1,31 @@
+package org.openecomp.core.tools.Commands;
+
+import com.datastax.driver.core.ResultSet;
+import org.openecomp.core.tools.store.HealingHandler;
+import org.openecomp.core.tools.store.VersionCassandraLoader;
+import org.openecomp.core.tools.store.zusammen.datatypes.HealingEntity;
+
+import java.util.ArrayList;
+
+
+/**
+ * Created by ayalaben on 10/15/2017
+ */
+public class SetHealingFlag {
+
+
+ public static void populateHealingTable(String oldVersion) {
+
+ VersionCassandraLoader versionCassandraLoader = new VersionCassandraLoader();
+ ResultSet listItemVersion = versionCassandraLoader.listItemVersion();
+
+ ArrayList<HealingEntity> healingEntities = new ArrayList<HealingEntity>();
+
+ listItemVersion.iterator().forEachRemaining(entry -> healingEntities.add(new HealingEntity
+ (entry.getString(0),entry.getString(1),entry.getString(2),true,oldVersion)));
+
+ HealingHandler healingHandler = new HealingHandler();
+ healingHandler.populateHealingTable(healingEntities);
+
+ }
+}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/exportdata/ElementHandler.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/exportdata/ElementHandler.java
deleted file mode 100644
index e03b7ff..0000000
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/exportdata/ElementHandler.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package org.openecomp.core.tools.Commands.exportdata;
-
-
-import org.openecomp.core.tools.store.ElementCassandraLoader;
-import org.openecomp.core.tools.store.zusammen.datatypes.ElementEntity;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-
-import java.nio.ByteBuffer;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Objects;
-import java.util.Set;
-
-import static java.io.File.separator;
-import static java.nio.file.Files.*;
-import static org.openecomp.core.tools.Commands.exportdata.ImportProperties.*;
-
-public class ElementHandler {
-
- private static final Logger logger = LoggerFactory.getLogger(ElementHandler.class);
-
- public ElementHandler() {
- }
-
- public void loadElements(Set<String> filteredItem) {
- ElementCassandraLoader elementCassandraLoader = new ElementCassandraLoader();
- elementCassandraLoader.list().forEach(elementEntity -> handleElementEntity(elementEntity,filteredItem));
- }
-
- private void handleElementEntity(ElementEntity elementEntity, Set<String> filteredItem) {
- try {
- String itemId = elementEntity.getItemId();
-
- if (!filteredItem.isEmpty() && !filteredItem.contains(itemId)){
- return;
- }
- String versionId = elementEntity.getVersionId();
- String space = elementEntity.getSpace();
- String namespace = elementEntity.getNamespace();
- String elementId = elementEntity.getElement_id();
-
- String namespacePath = separator;
- if (!isNull(namespace)){
- namespacePath = namespace.replace(ELEMENT_NAMESPACE_SPLITTER,separator)+separator;
- }
- Path elementDirectoryPath;
- if (!isNull(namespace)){
- elementDirectoryPath = Paths.get( ROOT_DIRECTORY + separator + itemId
- + separator + versionId + separator + space + separator + namespacePath+ separator + elementId);
- } else {
- elementDirectoryPath = Paths.get( ROOT_DIRECTORY + separator + itemId
- + separator + versionId + separator + space + separator + elementId);
- }
-
- if (notExists(elementDirectoryPath)) {
- Path created = createDirectories(elementDirectoryPath);
- }
-
- String info = elementEntity.getInfo();
- if (!isNull(info)) {
- Path infoFilePath = Paths.get(elementDirectoryPath.toString() + separator + ELEMENT_INFO_PREFIX
- + elementId + JSON_POSTFIX);
- write(infoFilePath, info.getBytes());
- }
-
- String relations = elementEntity.getRelations();
- if (!isNull(relations)) {
- Path realtionsFilePath = Paths.get(elementDirectoryPath.toString() + separator
- + ELEMENT_RELATION_PREFIX + elementId + JSON_POSTFIX);
- write(realtionsFilePath, relations.getBytes());
- }
-
- ByteBuffer data = elementEntity.getData();
- if (!Objects.isNull(data)) {
- Path dataFilePath = Paths.get(elementDirectoryPath.toString() + separator
- + ELEMENT_DATA_PREFIX + elementId + JSON_POSTFIX);
- write(dataFilePath, data.array());
- }
-
- ByteBuffer visualization = elementEntity.getVisualization();
- if (!Objects.isNull(visualization)) {
- Path visualFilePath = Paths.get(elementDirectoryPath.toString() + separator
- + ELEMENT_VISUALIZATION_PREFIX + elementId );
- write(visualFilePath, visualization.array());
- }
-
- ByteBuffer searchableData = elementEntity.getSearchableData();
- if (!Objects.isNull(searchableData)) {
- Path searchableFilePath = Paths.get(elementDirectoryPath.toString() + separator
- + ELEMENT_SEARCHABLE_PREFIX + elementId);
- write(searchableFilePath, searchableData.array());
- }
-
- } catch (Exception ex) {
- logger.error(ex.getMessage(), ex);
- }
-
- }
-
- private boolean isNull(String inStr){
- if (Objects.isNull(inStr)){
- return true;
- }
- return inStr.trim().equalsIgnoreCase("null");
- }
-
-}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/exportdata/ImportProperties.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/exportdata/ImportProperties.java
deleted file mode 100644
index 3b7566f..0000000
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/exportdata/ImportProperties.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.openecomp.core.tools.Commands.exportdata;
-
-import java.io.File;
-
-public class ImportProperties {
- public static final String VERSION_FILE_PREFIX = "version_";
- public static final String VERSION_INFO_FILE_PREFIX = "version_info_";
- public static final String JSON_POSTFIX = ".json";
-
- public static final String ELEMENT_INFO_PREFIX = "elem_info";
- public static final String ELEMENT_RELATION_PREFIX = "elem_relations";
- public static final String ELEMENT_DATA_PREFIX = "elem_data";
- public static final String ELEMENT_VISUALIZATION_PREFIX = "elem_visualization";
- public static final String ELEMENT_SEARCHABLE_PREFIX = "elem_searchableData";
- public static final String ELEMENT_NAMESPACE_SPLITTER = "/";
- public static String ROOT_DIRECTORY;
- public static final void initParams(){
- ROOT_DIRECTORY = System.getProperty("user.home")+File.separator+ "onboarding_import";
- }
-}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/exportdata/ItemHandler.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/exportdata/ItemHandler.java
deleted file mode 100644
index ebbfb56..0000000
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/exportdata/ItemHandler.java
+++ /dev/null
@@ -1,87 +0,0 @@
-package org.openecomp.core.tools.Commands.exportdata;
-
-import com.amdocs.zusammen.datatypes.Id;
-import com.amdocs.zusammen.datatypes.SessionContext;
-import com.amdocs.zusammen.datatypes.item.Item;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.ItemDao;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.ItemDaoFactory;
-import com.google.common.base.Strings;
-import org.openecomp.core.tools.Commands.ExportDataCommand;
-import org.openecomp.core.utilities.json.JsonUtil;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-import java.util.Set;
-
-import static java.io.File.separator;
-import static java.nio.file.Files.*;
-import static org.openecomp.core.tools.Commands.exportdata.ImportProperties.JSON_POSTFIX;
-
-public class ItemHandler {
- private static final Logger logger = LoggerFactory.getLogger(ExportDataCommand.class);
-
-
- public ItemHandler() {
- ImportProperties.initParams();
- }
-
- public void createItemsData(SessionContext context, Set<String> filteredItem) throws URISyntaxException, IOException {
- final List<Item> items = new ArrayList<>();
- if (filteredItem.isEmpty()) {
- items.addAll(getItemDao(context).list(context));
- } else {
- Optional<Item> item = addItem(context, filteredItem.iterator().next(), items);
- item.ifPresent(foundedItem -> {
- Object vendorId = foundedItem.getInfo().getProperty("vendorId");
- if (vendorId != null) {
- String vendorIdStr = vendorId.toString();
- addItem(context, vendorIdStr, items);
- filteredItem.add(vendorIdStr);
- }
- });
- }
-
- items.parallelStream().forEach(item -> createItemDirectoryAndFiles(item, filteredItem));
-
- }
-
-
-
- private Optional<Item> addItem(SessionContext context, String filteredItem, List<Item> items) {
- Optional<Item> item = getItemDao(context).get(context, new Id(filteredItem));
- item.ifPresent(itemData -> items.add(itemData));
- return item;
- }
-
- private final void createItemDirectoryAndFiles(Item item, Set<String> filteredItem) {
- try {
- String itemId = item.getId().getValue();
- if (!filteredItem.isEmpty() && !filteredItem.contains(itemId)) {
- return;
- }
- Path itemPath = Paths.get(ImportProperties.ROOT_DIRECTORY + separator + itemId);
- Path itemFilePath = Paths.get(ImportProperties.ROOT_DIRECTORY + separator +
- itemId + separator + itemId + JSON_POSTFIX);
- if (notExists(itemPath)) {
- createDirectories(itemPath);
- }
- String itemJson = JsonUtil.object2Json(item);
- write(itemFilePath, itemJson.getBytes());
- } catch (Exception ex) {
- logger.error(ex.getMessage(), ex);
- }
-
- }
-
-
- private ItemDao getItemDao(SessionContext context) {
- return ItemDaoFactory.getInstance().createInterface(context);
- }
-}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/exportdata/VersionHandler.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/exportdata/VersionHandler.java
deleted file mode 100644
index 4ff5624..0000000
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/exportdata/VersionHandler.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package org.openecomp.core.tools.Commands.exportdata;
-
-import org.openecomp.core.tools.Commands.ExportDataCommand;
-import org.openecomp.core.tools.store.VersionInfoCassandraLoader;
-import org.openecomp.core.tools.store.VersionCassandraLoader;
-
-import org.openecomp.core.tools.store.zusammen.datatypes.VersionEntity;
-import org.openecomp.core.utilities.json.JsonUtil;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-import org.openecomp.sdc.versioning.dao.types.VersionInfoEntity;
-
-import static java.io.File.separator;
-import static java.nio.file.Files.*;
-import static org.openecomp.core.tools.Commands.exportdata.ImportProperties.*;
-import static org.openecomp.core.tools.Commands.exportdata.ImportProperties.ROOT_DIRECTORY;
-
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Set;
-
-public class VersionHandler {
- private static final Logger logger = LoggerFactory.getLogger(ExportDataCommand.class);
-
- public VersionHandler() {
- }
-
- public void loadVersions(Set<String> filteredItem) {
- VersionCassandraLoader versionCassandraLoader = new VersionCassandraLoader();
- versionCassandraLoader.list().forEach(versionEntity -> handleVersionEntity(versionEntity,filteredItem));
- VersionInfoCassandraLoader versionInfoCassandraLoader = new VersionInfoCassandraLoader();
- versionInfoCassandraLoader.list().forEach(versionInfoEntity -> handleVersionInfo(versionInfoEntity,filteredItem));
- }
-
- private void handleVersionEntity(VersionEntity versionEntity, Set<String> filteredItem) {
- try {
- String itemId = versionEntity.getItemId();
- if (!filteredItem.isEmpty() && !filteredItem.contains(itemId)){
- return;
- }
- String versionId = versionEntity.getVersionId();
- String space = versionEntity.getSpace();
- Path versionDirectoryPath = Paths.get( ROOT_DIRECTORY + separator + itemId
- + separator + versionId + separator + space);
- Path versionFilePath = Paths.get(versionDirectoryPath.toString() + separator + VERSION_FILE_PREFIX
- + versionId + JSON_POSTFIX);
- if (notExists(versionDirectoryPath)) {
- createDirectories(versionDirectoryPath);
- }
- String versionJson = JsonUtil.object2Json(versionEntity);
- write(versionFilePath, versionJson.getBytes());
- } catch (Exception ex) {
- logger.error(ex.getMessage(), ex);
- }
-
- }
-
- private void handleVersionInfo(VersionInfoEntity versionInfoEntity, Set<String> filteredItem) {
- try {
- String itemId = versionInfoEntity.getEntityId();
- Path itemDirectory = Paths.get( ROOT_DIRECTORY + separator + itemId);
- Path versionInfoFilePath = Paths.get(itemDirectory.toString() + separator + VERSION_INFO_FILE_PREFIX
- + itemId + JSON_POSTFIX);
- if (exists(itemDirectory)) {
- String versionJson = JsonUtil.object2Json(versionInfoEntity);
- write(versionInfoFilePath, versionJson.getBytes());
- }
- } catch (Exception ex) {
- logger.error(ex.getMessage(), ex);
- }
-
- }
-}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/importdata/ElementImport.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/importdata/ElementImport.java
deleted file mode 100644
index d439468..0000000
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/importdata/ElementImport.java
+++ /dev/null
@@ -1,135 +0,0 @@
-package org.openecomp.core.tools.Commands.importdata;
-
-import com.amdocs.zusammen.datatypes.Id;
-import com.amdocs.zusammen.datatypes.SessionContext;
-import org.openecomp.core.tools.store.ElementCassandraLoader;
-import org.openecomp.core.tools.store.ElementNamespaceHandler;
-import org.openecomp.core.tools.store.VersionCassandraLoader;
-import org.openecomp.core.tools.store.zusammen.datatypes.ElementEntity;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import static java.io.File.separator;
-import static org.openecomp.core.tools.Commands.exportdata.ImportProperties.*;
-
-public class ElementImport {
- private static final Logger logger = LoggerFactory.getLogger(ElementImport.class);
- public static final String ROOT_ITEM = Id.ZERO.getValue();
-
- private ElementCassandraLoader elementCassandraLoader = new ElementCassandraLoader();
- private ElementNamespaceHandler cassandraElementRepository = new ElementNamespaceHandler();
- private VersionCassandraLoader versionCassandraLoader = new VersionCassandraLoader();
-
- public void loadPath(SessionContext sessionContext, Path elementDir, String elementId, String[]
- pathObjects) {
- try {
- if (!Files.isDirectory(elementDir)){
- return;
- }
- // load info file
- ElementEntity elementEntity = new ElementEntity();
- Path infoFilePath = Paths.get(elementDir.toString() + separator + ELEMENT_INFO_PREFIX
- + elementId + JSON_POSTFIX);
- if (Files.exists(infoFilePath)) {
- String info = new String(Files.readAllBytes(infoFilePath));
- elementEntity.setInfo(info);
- }
- // load relation file
- Path realtionsFilePath = Paths.get(elementDir.toString() + separator
- + ELEMENT_RELATION_PREFIX + elementId + JSON_POSTFIX);
- if (Files.exists(realtionsFilePath)) {
- String relations = new String(Files.readAllBytes(realtionsFilePath));
- elementEntity.setRelations(relations);
- }
-
- //load entity data
- Path dataFilePath = Paths.get(elementDir.toString() + separator
- + ELEMENT_DATA_PREFIX + elementId + JSON_POSTFIX);
- if (Files.exists(dataFilePath)) {
- byte[] bytes = Files.readAllBytes(dataFilePath);
- ByteBuffer data = ByteBuffer.wrap(bytes);
- elementEntity.setData(data);
- }
-
- //load visualization
- Path visualFilePath = Paths.get(elementDir.toString() + separator
- + ELEMENT_VISUALIZATION_PREFIX + elementId);
- if (Files.exists(visualFilePath)) {
- byte[] bytes = Files.readAllBytes(visualFilePath);
- ByteBuffer visualization = ByteBuffer.wrap(bytes);
- elementEntity.setVisualization(visualization);
- }
-
- //load searchable
- Path searchableFilePath = Paths.get(elementDir.toString() + separator
- + ELEMENT_SEARCHABLE_PREFIX + elementId);
- if (Files.exists(searchableFilePath)) {
- byte[] bytes = Files.readAllBytes(searchableFilePath);
- ByteBuffer searchable = ByteBuffer.wrap(bytes);
- elementEntity.setSearchableData(searchable);
- }
- String element_Id = pathObjects[pathObjects.length - 1];
- elementEntity.setSpace(pathObjects[2]);
- elementEntity.setItemId(pathObjects[0]);
- elementEntity.setVersionId(pathObjects[1]);
- elementEntity.setElement_id(element_Id);
- elementEntity.setNamespace(getNameSpace(pathObjects));
- elementEntity.setParentId(getParentId(pathObjects));
- elementEntity.setSubElementIds(getAllSubElementsIds(elementDir, element_Id));
- elementCassandraLoader.createEntity(elementEntity);
- cassandraElementRepository.createElementNamespace(elementEntity);
- versionCassandraLoader.insertElementToVersion(elementEntity);
- } catch (Exception ex) {
- logger.error(ex.getMessage(), ex);
- }
- }
-
- private String getParentId(String[] pathObjects) {
-
- if (pathObjects[pathObjects.length - 1].equals(ROOT_ITEM)) {
- return null;
- }
- if (pathObjects.length == 4) {
- return ROOT_ITEM;
- }
- return pathObjects[pathObjects.length - 2];
- }
-
- private Set<String> getAllSubElementsIds(Path root, String elementId) throws IOException {
- if (elementId.equals(ROOT_ITEM)) {
- root = root.getParent();
- }
- File file = root.toFile();
- Set<String> retVal = new HashSet<>();
- File[] files = file.listFiles();
- for (File f : files){
- if (f.isDirectory()){
- retVal.add(f.getName());
- }
- }
- retVal.remove(ROOT_ITEM);
- return retVal;
-
- }
-
- private String getNameSpace(String[] pathObjects) {
- if (pathObjects.length <= 4) {
- return "";
- }
- if (pathObjects.length == 5) {
- return pathObjects[3];
- }
- return Arrays.stream(pathObjects, 3, pathObjects.length - 1)
- .reduce("", (s1, s2) -> s1 + File.separator + s2);
- }
-}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/importdata/ItemImport.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/importdata/ItemImport.java
deleted file mode 100644
index 4dd4a1f..0000000
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/importdata/ItemImport.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package org.openecomp.core.tools.Commands.importdata;
-
-import com.amdocs.zusammen.datatypes.SessionContext;
-import com.amdocs.zusammen.datatypes.item.Item;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.ItemDao;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.ItemDaoFactory;
-import org.openecomp.core.utilities.json.JsonUtil;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-
-import java.io.File;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-import static org.openecomp.core.tools.Commands.exportdata.ImportProperties.JSON_POSTFIX;
-
-public class ItemImport {
- private static final Logger logger = LoggerFactory.getLogger(ItemImport.class);
-
- public void loadPath(SessionContext sessionContext, Path itemDir, String itemName) {
- try {
- Path itemPath = Paths.get(itemDir.toString() + File.separator + itemName + JSON_POSTFIX);
- if (!Files.exists(itemPath)) {
- return;
- }
- String itemJson = new String(Files.readAllBytes(itemPath));
- if (itemJson.trim().isEmpty()) {
- return;
- }
- Item item = JsonUtil.json2Object(itemJson, Item.class);
- ItemDao itemDao = getItemDao(sessionContext);
- itemDao.create(sessionContext, item.getId(), item.getInfo(), item.getCreationTime());
- logger.info("Item Created :"+item.getInfo().getName()+" , "+item.getId());
- System.out.println("Item Created :"+item.getInfo().getName()+" , "+item.getId());
- } catch (Exception ex) {
- logger.error(ex.getMessage(), ex);
- }
- }
-
- private ItemDao getItemDao(SessionContext context) {
- return ItemDaoFactory.getInstance().createInterface(context);
- }
-}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/importdata/TreeWalker.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/importdata/TreeWalker.java
deleted file mode 100644
index 30c4152..0000000
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/importdata/TreeWalker.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package org.openecomp.core.tools.Commands.importdata;
-
-import com.amdocs.zusammen.datatypes.SessionContext;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.stream.Stream;
-
-public class TreeWalker {
- private static final Logger logger = LoggerFactory.getLogger(TreeWalker.class);
-
- public static final void walkFiles(SessionContext sessionContext,Path rootDir, String filterItem) throws IOException {
- try (Stream<Path> walk = Files.walk(rootDir)) {
- walk.parallel().filter(path -> Files.isDirectory(path)).
- forEach(path -> handlePath(sessionContext,path, rootDir, filterItem));
- }
- }
-
- private static final void handlePath(SessionContext sessionContext, Path path, Path root,String filterItem) {
- String logicalPath = path.toString().replace(root.toString(), "");
- if (logicalPath.startsWith(File.separator)){
- logicalPath = logicalPath.substring(1);
- }
- String[] splitted = logicalPath.split(File.separator);
- if(filterItem != null && splitted.length > 0 && !splitted[0].contains(filterItem)){
- return;
- }
- switch (splitted.length) {
- case 0:
- //root - ignore
- break;
- case 1: // handle Item
- new ItemImport().loadPath(sessionContext,path,splitted[splitted.length -1]);
- new VersionInfoImport().loadPath(sessionContext,path,splitted[splitted.length -1]);
- break;
- case 2:
- //ignore this level
- break;
- case 3: // handle version
- new VersionImport().loadPath(sessionContext,path,splitted[splitted.length -2]);
- break;
- default:
- //handle elements
- new ElementImport().loadPath(sessionContext,path,splitted[splitted.length -1],splitted);
- break;
- }
-
- }
-
-}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/importdata/VersionImport.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/importdata/VersionImport.java
deleted file mode 100644
index 48433d8..0000000
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/importdata/VersionImport.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package org.openecomp.core.tools.Commands.importdata;
-
-import com.amdocs.zusammen.datatypes.SessionContext;
-import org.openecomp.core.tools.store.VersionCassandraLoader;
-import org.openecomp.core.tools.store.zusammen.datatypes.VersionEntity;
-import org.openecomp.core.utilities.json.JsonUtil;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-import static java.io.File.separator;
-import static org.openecomp.core.tools.Commands.exportdata.ImportProperties.JSON_POSTFIX;
-import static org.openecomp.core.tools.Commands.exportdata.ImportProperties.VERSION_FILE_PREFIX;
-
-public class VersionImport {
- private static final Logger logger = LoggerFactory.getLogger(VersionImport.class);
-
- public void loadPath(SessionContext sessionContext, Path versionDir , String versionId){
- try {
- Path versionPath = Paths.get(versionDir.toString() + separator + VERSION_FILE_PREFIX
- + versionId + JSON_POSTFIX);
- if (!Files.exists(versionPath)) {
- return;
- }
- String versionJson = new String(Files.readAllBytes(versionPath));
- if (versionJson.trim().isEmpty()) {
- return;
- }
- VersionEntity versionEntity = JsonUtil.json2Object(versionJson, VersionEntity.class);
- VersionCassandraLoader versionCassandraLoader = new VersionCassandraLoader();
- versionCassandraLoader.insertVersion(versionEntity);
- } catch (Exception ex) {
- logger.error(ex.getMessage(), ex);
- }
- }
-
-
-}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/importdata/VersionInfoImport.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/importdata/VersionInfoImport.java
deleted file mode 100644
index e9d4174..0000000
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/importdata/VersionInfoImport.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package org.openecomp.core.tools.Commands.importdata;
-
-import com.amdocs.zusammen.datatypes.SessionContext;
-import org.openecomp.core.tools.store.VersionInfoCassandraLoader;
-import org.openecomp.core.utilities.json.JsonUtil;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-import org.openecomp.sdc.versioning.dao.types.VersionInfoEntity;
-
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-import static java.io.File.separator;
-import static org.openecomp.core.tools.Commands.exportdata.ImportProperties.JSON_POSTFIX;
-import static org.openecomp.core.tools.Commands.exportdata.ImportProperties.VERSION_INFO_FILE_PREFIX;
-
-public class VersionInfoImport {
- private static final Logger logger = LoggerFactory.getLogger(VersionInfoImport.class);
-
- public void loadPath(SessionContext sessionContext, Path itemPath, String itemId) {
- try {
- Path versionInfoFilePath = Paths.get(itemPath.toString() + separator + VERSION_INFO_FILE_PREFIX
- + itemId + JSON_POSTFIX);
- if (!Files.exists(versionInfoFilePath)) {
- return;
- }
- String versionInfoJson = new String(Files.readAllBytes(versionInfoFilePath));
- if (versionInfoJson.trim().isEmpty()) {
- return;
- }
- VersionInfoEntity versionInfoEntity = JsonUtil.json2Object(versionInfoJson, VersionInfoEntity.class);
- VersionInfoCassandraLoader versionInfoCassandraLoader = new VersionInfoCassandraLoader();
- versionInfoCassandraLoader.insertVersionInfo(versionInfoEntity);
- } catch (Exception ex) {
- logger.error(ex.getMessage(), ex);
- }
- }
-
-
-}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/concurrent/ItemHealingTask.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/concurrent/ItemHealingTask.java
index 39b62d4..878390f 100644
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/concurrent/ItemHealingTask.java
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/concurrent/ItemHealingTask.java
@@ -1,13 +1,8 @@
package org.openecomp.core.tools.concurrent;
-import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
+import org.openecomp.sdc.healing.api.HealingManager;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
-import org.openecomp.sdc.versioning.VersioningManager;
-import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.VersionInfo;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
import java.util.concurrent.Callable;
@@ -17,55 +12,44 @@
public class ItemHealingTask implements Callable<String> {
private String itemId;
- private String versionId;
- private String user;
+ private Version version;
private VendorSoftwareProductManager vspManager;
- private VersioningManager versioningManager;
+ private HealingManager healingManager;
public String getItemId() {
return itemId;
}
public String getVersionId() {
- return versionId;
+// return version.getId();
+ return null;
}
- public ItemHealingTask(String itemId, String versionId, String user,
+ public ItemHealingTask(String itemId, String versionId,
VendorSoftwareProductManager vspManager,
- VersioningManager versioningManager) {
- this.itemId = itemId;
- this.versionId = versionId;
- this.user = user;
- this.versioningManager = versioningManager;
+ HealingManager healingManager) {
+// this.itemId = itemId;
+// this.version = new Version(versionId);
this.vspManager = vspManager;
+ this.healingManager = healingManager;
+
}
@Override
public String call() throws Exception {
-
- VersionInfo versionInfo = getVersionInfo(itemId, VersionableEntityAction.Read, user);
- Version resolvedVersion = VersioningUtil.resolveVersion(Version.valueOf(versionId),
- versionInfo, user);
- VspDetails vspDetails = vspManager.getVsp(itemId, resolvedVersion, user);
-
- try {
- vspManager.callAutoHeal(itemId, versionInfo, vspDetails, user);
-
- } catch (Exception e) {
- return (String.format("healing failed on vsp: %s with id: %s, versionId: %s, resolved " +
- "Version: %s, with message: %s",vspDetails.getName(),itemId,
- versionId,resolvedVersion,e.getMessage()));
- }
-
- return String.format("healed vsp: %s, with id: %s, versionId:%s, resolved version: %s",
- vspDetails.getName(), itemId, versionId,resolvedVersion );
- }
-
- private VersionInfo getVersionInfo(String vendorSoftwareProductId, VersionableEntityAction action,
- String user) {
- return versioningManager.getEntityVersionInfo(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
- vendorSoftwareProductId, user, action);
+// VspDetails vspDetails = vspManager.getVsp(itemId, version);
+//
+// try {
+// healingManager.healItemVersion(itemId, version, ItemType.vsp, true);
+// } catch (Exception e) {
+// return (String
+// .format("healing failed on vsp: %s with id: %s, versionId: %s, with message: %s",
+// vspDetails.getName(), itemId, version.getId(), e.getMessage()));
+// }
+//
+// return String.format("healed vsp: %s, with id: %s, versionId: %s",
+// vspDetails.getName(), itemId, version.getId());
+ return null;
}
}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/exportinfo/ExportDataCommand.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/exportinfo/ExportDataCommand.java
new file mode 100644
index 0000000..5dcc72d
--- /dev/null
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/exportinfo/ExportDataCommand.java
@@ -0,0 +1,125 @@
+/**
+ * Copyright © 2016-2017 European Support Limited.
+ */
+package org.openecomp.core.tools.exportinfo;
+
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.ResultSetFuture;
+import com.datastax.driver.core.Session;
+import com.google.common.collect.Sets;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import org.apache.commons.io.FileUtils;
+import org.openecomp.core.nosqldb.impl.cassandra.CassandraSessionFactory;
+import org.openecomp.core.tools.importinfo.ImportProperties;
+import org.openecomp.core.tools.util.Utils;
+import org.openecomp.core.tools.util.ZipUtils;
+import org.openecomp.core.zusammen.impl.CassandraConnectionInitializer;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+import org.yaml.snakeyaml.Yaml;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CountDownLatch;
+import java.util.stream.Collectors;
+
+import static java.nio.file.Files.createDirectories;
+
+
+public class ExportDataCommand {
+ private static final Logger logger = LoggerFactory.getLogger(ExportDataCommand.class);
+ public static final String JOIN_DELIMITER = "$#";
+ public static final String JOIN_DELIMITER_SPILTTER = "\\$\\#";
+ public static final String MAP_DELIMITER = "!@";
+ public static final String MAP_DELIMITER_SPLITTER = "\\!\\@";
+ public static final String EXPORT_FILE_NAME = "ITEM_EXPORT";
+
+ public static void exportData(SessionContext sessionContext, String filterItem) {
+ try {
+ CassandraConnectionInitializer.setCassandraConnectionPropertiesToSystem();
+ final Set<String> filteredItems = Sets.newHashSet(filterItem);
+ Path rootDir = Paths.get(ImportProperties.ROOT_DIRECTORY);
+ initDir(rootDir);
+ Set<String> fis = filteredItems.stream().map(fi -> fi.replaceAll("\\r", "")).collect(Collectors.toSet());
+
+ Map<String, List<String>> queries;
+ Yaml yaml = new Yaml();
+ try (InputStream is = ExportDataCommand.class.getResourceAsStream("/queries.yaml")) {
+ queries = (Map<String, List<String>>) yaml.load(is);
+ }
+ List<String> queriesList = queries.get("queries");
+ List<String> itempsColumns = queries.get("item_columns");
+ Set<String> vlms = new HashSet<>();
+ CountDownLatch doneQueries = new CountDownLatch(queriesList.size());
+ for (int i = 0; i < queriesList.size(); i++) {
+ executeQuery(queriesList.get(i), fis, itempsColumns.get(i), vlms, doneQueries);
+ }
+ doneQueries.await();
+ if (!vlms.isEmpty()) {
+ CountDownLatch doneVmls = new CountDownLatch(queriesList.size());
+
+ for (int i = 0; i < queriesList.size(); i++) {
+ executeQuery(queriesList.get(i), vlms, itempsColumns.get(i), null, doneVmls);
+ }
+
+ doneVmls.await();
+ }
+ zipPath(rootDir);
+ FileUtils.forceDelete(rootDir.toFile());
+ } catch (Exception ex) {
+ Utils.logError(logger, ex);
+ }
+
+ }
+
+
+ private static boolean executeQuery(final String query, final Set<String> filteredItems, final String filteredColumn,
+ final Set<String> vlms, final CountDownLatch donequerying) {
+ Session session = CassandraSessionFactory.getSession();
+ ResultSetFuture resultSetFuture = session.executeAsync(query);
+ Futures.addCallback(resultSetFuture, new FutureCallback<ResultSet>() {
+ @Override
+ public void onSuccess(ResultSet resultSet) {
+ new ExportSerializer().serializeResult(resultSet, filteredItems, filteredColumn, vlms);
+ donequerying.countDown();
+ }
+
+ @Override
+ public void onFailure(Throwable t) {
+ Utils.logError(logger, "Query failed :" + query, t);
+ donequerying.countDown();
+ }
+ });
+ return true;
+ }
+
+ private static void zipPath(Path rootDir) throws Exception {
+ LocalDateTime date = LocalDateTime.now();
+ DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME;
+ String dateStr = date.format(formatter);
+ dateStr = dateStr.replaceAll(":", "_");
+ String zipFile = System.getProperty("user.home") + File.separatorChar + "onboarding_import" + dateStr + ".zip";
+ ZipUtils.createZip(zipFile, rootDir);
+ Utils.printMessage(logger, "Exported file :" + zipFile);
+ }
+
+
+ public static void initDir(Path rootDir) throws IOException {
+ if (rootDir.toFile().exists()) {
+ FileUtils.forceDelete(rootDir.toFile());
+ }
+ createDirectories(rootDir);
+ }
+
+}
\ No newline at end of file
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/exportinfo/ExportSerializer.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/exportinfo/ExportSerializer.java
new file mode 100644
index 0000000..3c917b1
--- /dev/null
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/exportinfo/ExportSerializer.java
@@ -0,0 +1,152 @@
+/**
+ * Copyright © 2016-2017 European Support Limited.
+ */
+package org.openecomp.core.tools.exportinfo;
+
+import com.datastax.driver.core.DataType.Name;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.openecomp.core.tools.importinfo.ImportProperties;
+import org.openecomp.core.tools.model.ColumnDefinition;
+import org.openecomp.core.tools.model.TableData;
+import org.openecomp.core.tools.util.Utils;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Base64;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import static org.openecomp.core.tools.importinfo.ImportSingleTable.dataTypesMap;
+
+public class ExportSerializer {
+
+ private static final Logger logger = LoggerFactory.getLogger(ExportDataCommand.class);
+ private static final String ELEMENT_TABLE_NAME = "element";
+ private static final String ELEMENT_INFO_COLUMN_NAME = "info";
+
+ public void serializeResult(final ResultSet resultSet, final Set<String> filteredItems, final String filteredColumn, Set<String> vlms) {
+ try {
+ TableData tableData = new TableData();
+ tableData.definitions = resultSet.getColumnDefinitions().asList().stream().map(column -> new ColumnDefinition(column)).collect(Collectors.toList());
+ String table = tableData.definitions.iterator().next().getTable();
+ boolean isElementTable = table.equals(ELEMENT_TABLE_NAME);
+ Iterator<Row> iterator = resultSet.iterator();
+ iterator.forEachRemaining(row -> {
+ if (!filteredItems.contains(row.getString(filteredColumn))) {
+ return;
+ }
+ List<String> rowData = new ArrayList<>();
+ for (int i = 0; i < tableData.definitions.size(); i++) {
+ ColumnDefinition columnDefinition = tableData.definitions.get(i);
+ Name name = dataTypesMap.get(columnDefinition.getType());
+ boolean checkForVLM = isElementTable && columnDefinition.getName().equals(ELEMENT_INFO_COLUMN_NAME);
+ Object data;
+ data = convertByType(vlms, row, i, name, checkForVLM);
+ rowData.add(data.toString());
+ }
+ tableData.rows.add(rowData);
+ });
+ ObjectMapper objectMapper = new ObjectMapper();
+ String fileName = ImportProperties.ROOT_DIRECTORY + File.separator + table + "_" + System.currentTimeMillis() + ".json";
+ objectMapper.writeValue(Paths.get(fileName).toFile(), tableData);
+ Utils.printMessage(logger, "File exported is :" + fileName);
+
+ } catch (IOException e) {
+ Utils.logError(logger, e);
+ System.exit(1);
+ }
+ }
+
+ private Object convertByType(Set<String> vlms, Row row, int i, Name name, boolean checkForVLM) {
+ Object data;
+ switch (name) {
+ case VARCHAR:
+ case TEXT:
+ case ASCII:
+ String string = row.getString(i);
+ if (string == null) {
+ string = "";
+ }
+ if (checkForVLM && vlms != null){
+ String vlm = extractVlm(string);
+ if (vlm!= null) {
+ vlms.add(vlm);
+ }
+ }
+ data = Base64.getEncoder().encodeToString(string.getBytes());
+ break;
+ case BLOB:
+ ByteBuffer bytes = row.getBytes(i);
+ if (bytes == null) {
+ bytes = ByteBuffer.wrap("".getBytes());
+ }
+ data = Base64.getEncoder().encodeToString(bytes.array());
+ break;
+ case TIMESTAMP:
+ data = row.getDate(i).getTime();
+ break;
+ case BOOLEAN:
+ data = row.getBool(i);
+ break;
+ case COUNTER:
+ data = row.getLong(i);
+ break;
+ case INT:
+ data = row.getInt(i);
+ break;
+ case FLOAT:
+ data = row.getFloat(i);
+ break;
+ case SET:
+ Set set = row.getSet(i, Object.class);
+ Object joined = set.stream().map(o -> o.toString()).collect(Collectors.joining(ExportDataCommand.JOIN_DELIMITER));
+ data = Base64.getEncoder().encodeToString(joined.toString().getBytes());
+ break;
+ case MAP:
+ Map<Object,Object> map = row.getMap(i, Object.class, Object.class);
+ Set<Map.Entry<Object,Object>> entrySet = map.entrySet();
+ Object mapAsString = entrySet.parallelStream().map(entry -> entry.getKey().toString() + ExportDataCommand.MAP_DELIMITER +entry.getValue().toString())
+ .collect(Collectors.joining(ExportDataCommand.MAP_DELIMITER));
+ data = Base64.getEncoder().encodeToString(mapAsString.toString().getBytes());
+ break;
+ default:
+ throw new UnsupportedOperationException("Name is not supported :" + name);
+ }
+ return data;
+ }
+
+ protected String extractVlm(String injson) {
+ try {
+ if (injson == null){
+ return null;
+ }
+ JsonElement root = new JsonParser().parse(injson);
+ if (root == null){
+ return null;
+ }
+ JsonElement properties = root.getAsJsonObject().get("properties");
+ if (properties == null){
+ return null;
+ }
+ JsonElement vendorId = properties.getAsJsonObject().get("vendorId");
+ if (vendorId == null){
+ return null;
+ }
+ return vendorId.getAsString();
+ } catch (Exception ex){
+ return null;
+ }
+ }
+}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/importinfo/ImportDataCommand.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/importinfo/ImportDataCommand.java
new file mode 100644
index 0000000..bae6cfa
--- /dev/null
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/importinfo/ImportDataCommand.java
@@ -0,0 +1,37 @@
+package org.openecomp.core.tools.importinfo;
+
+
+import com.amdocs.zusammen.datatypes.SessionContext;
+import org.apache.commons.io.FileUtils;
+import org.openecomp.core.tools.exportinfo.ExportDataCommand;
+import org.openecomp.core.tools.util.Utils;
+import org.openecomp.core.tools.util.ZipUtils;
+import org.openecomp.core.zusammen.impl.CassandraConnectionInitializer;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.stream.Stream;
+
+public class ImportDataCommand {
+
+ private static final Logger logger = LoggerFactory.getLogger(ImportDataCommand.class);
+
+ public static final void execute(SessionContext sessionContext, String uploadFile) {
+ try {
+ CassandraConnectionInitializer.setCassandraConnectionPropertiesToSystem();
+ Path outputFolder = Paths.get(ImportProperties.ROOT_DIRECTORY);
+ ExportDataCommand.initDir(outputFolder); //clear old imports.
+ ZipUtils.unzip(Paths.get(uploadFile), outputFolder);
+ try( Stream<Path> files = Files.list(outputFolder)) {
+ files.forEach(file -> new ImportSingleTable().importFile(file));
+ }
+ FileUtils.forceDelete(outputFolder.toFile()); // leaves directory clean
+ } catch (IOException e) {
+ Utils.logError(logger, e);
+ }
+ }
+}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/importinfo/ImportProperties.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/importinfo/ImportProperties.java
new file mode 100644
index 0000000..b9a27fa
--- /dev/null
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/importinfo/ImportProperties.java
@@ -0,0 +1,7 @@
+package org.openecomp.core.tools.importinfo;
+
+import java.io.File;
+
+public class ImportProperties {
+ public static final String ROOT_DIRECTORY = System.getProperty("user.home")+File.separator+ "onboarding_import";
+}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/importinfo/ImportSingleTable.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/importinfo/ImportSingleTable.java
new file mode 100644
index 0000000..7504ad1
--- /dev/null
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/importinfo/ImportSingleTable.java
@@ -0,0 +1,166 @@
+package org.openecomp.core.tools.importinfo;
+
+import com.datastax.driver.core.BoundStatement;
+import com.datastax.driver.core.DataType.Name;
+import com.datastax.driver.core.PreparedStatement;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.ResultSetFuture;
+import com.datastax.driver.core.Session;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
+import com.google.common.collect.Sets;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import org.apache.commons.lang3.StringUtils;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.openecomp.core.nosqldb.impl.cassandra.CassandraSessionFactory;
+import org.openecomp.core.tools.exportinfo.ExportDataCommand;
+import org.openecomp.core.tools.model.ColumnDefinition;
+import org.openecomp.core.tools.model.TableData;
+import org.openecomp.core.tools.util.Utils;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.file.Path;
+import java.util.Base64;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+public class ImportSingleTable {
+
+ private static final Logger logger = LoggerFactory.getLogger(ImportSingleTable.class);
+
+ public static final String INSERT_INTO = "INSERT INTO ";
+ public static final String VALUES = " VALUES ";
+ private static final Map<String, PreparedStatement> statementsCache = new HashMap<>();
+
+ public void importFile(Path file) {
+ try {
+ ObjectMapper objectMapper = new ObjectMapper();
+ TableData tableData = objectMapper.readValue(file.toFile(), TableData.class);
+ Session session = CassandraSessionFactory.getSession();
+ PreparedStatement ps = getPrepareStatement(tableData, session);
+ tableData.rows.parallelStream().forEach(row -> executeQuery(session, ps, tableData.definitions, row));
+ } catch (IOException e) {
+ Utils.logError(logger, e);
+ }
+
+ }
+
+ private PreparedStatement getPrepareStatement(TableData tableData, Session session) {
+ String query = createQuery(tableData);
+ if (statementsCache.containsKey(query)) {
+ return statementsCache.get(query);
+ }
+ PreparedStatement preparedStatement = session.prepare(query);
+ statementsCache.put(query, preparedStatement);
+ return preparedStatement;
+ }
+
+ private void executeQuery(Session session, PreparedStatement ps, List<ColumnDefinition> definitions, List<String> rows) {
+ BoundStatement bind = ps.bind();
+ for (int i = 0; i < definitions.size(); i++) {
+ ColumnDefinition columnDefinition = definitions.get(i);
+ String rowData = rows.get(i);
+ Name name = dataTypesMap.get(columnDefinition.getType());
+ handleByType(bind, i, rowData, name);
+ }
+ ResultSetFuture resultSetFuture = session.executeAsync(bind);
+ Futures.addCallback(resultSetFuture, new FutureCallback<ResultSet>() {
+ @Override
+ public void onSuccess(ResultSet resultSet) {
+ Utils.printMessage(logger, "successful write ");
+ }
+
+ @Override
+ public void onFailure(Throwable t) {
+ Utils.logError(logger, t);
+ }
+ });
+ }
+
+ private void handleByType(BoundStatement bind, int i, String rowData, Name name) {
+ switch (name) {
+ case VARCHAR:
+ case TEXT:
+ case ASCII:
+ bind.setString(i, new String(Base64.getDecoder().decode(rowData)));
+ break;
+ case BLOB:
+ bind.setBytes(i, ByteBuffer.wrap(Base64.getDecoder().decode(rowData.getBytes())));
+ break;
+ case TIMESTAMP:
+ bind.setDate(i, new Date(Long.parseLong(rowData)));
+ break;
+ case BOOLEAN:
+ bind.setBool(i, Boolean.parseBoolean(rowData));
+ break;
+ case COUNTER:
+ bind.setLong(i, Long.parseLong(rowData));
+ break;
+ case INT:
+ bind.setInt(i, Integer.parseInt(rowData));
+ break;
+ case FLOAT:
+ bind.setFloat(i, Float.parseFloat(rowData));
+ break;
+ case SET:
+ byte[] decoded = Base64.getDecoder().decode(rowData);
+ String decodedStr = new String(decoded);
+ if (!StringUtils.isEmpty(decodedStr)) {
+ String[] splitted = decodedStr.split(ExportDataCommand.JOIN_DELIMITER_SPILTTER);
+ Set set = Sets.newHashSet(splitted);
+ set.remove("");
+ bind.setSet(i, set);
+ } else {
+ bind.setSet(i, null);
+ }
+ break;
+ case MAP:
+ byte[] decodedMap = Base64.getDecoder().decode(rowData);
+ String mapStr = new String(decodedMap);
+ if (!StringUtils.isEmpty(mapStr)) {
+ String[] splittedMap = mapStr.split(ExportDataCommand.JOIN_DELIMITER_SPILTTER);
+ Map<String, String> map = new HashMap<>();
+ for (String keyValue : splittedMap) {
+ String[] split = keyValue.split(ExportDataCommand.MAP_DELIMITER_SPLITTER);
+ map.put(split[0], split[1]);
+ }
+ bind.setMap(i, map);
+ } else {
+ bind.setMap(i, null);
+ }
+ break;
+ default:
+ throw new UnsupportedOperationException("Name is not supported :" + name);
+
+ }
+ }
+
+ private String createQuery(TableData tableData) {
+ ColumnDefinition def = tableData.definitions.iterator().next();
+ StringBuilder sb = new StringBuilder();
+ sb.append(INSERT_INTO).append(def.getKeyspace()).append(".").append(def.getTable());
+ sb.append(tableData.definitions.stream().map(definition -> definition.getName()).collect(Collectors.joining(" , ", " ( ", " ) ")));
+ sb.append(VALUES).append(tableData.definitions.stream().map(definition -> "?").collect(Collectors.joining(" , ", " ( ", " ) "))).append(";");
+ return sb.toString();
+ }
+
+ public static final ImmutableMap<String, Name> dataTypesMap;
+
+ static {
+ Builder<String, Name> builder = ImmutableMap.builder();
+ Name[] values = Name.values();
+ for (Name name : values) {
+ builder.put(name.name().toLowerCase(), name);
+ }
+ dataTypesMap = builder.build();
+ }
+
+}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/loaders/zusammen/VspGeneralLoader.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/loaders/zusammen/VspGeneralLoader.java
deleted file mode 100644
index d92866b..0000000
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/loaders/zusammen/VspGeneralLoader.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.openecomp.core.tools.loaders.zusammen;
-
-import com.amdocs.zusammen.datatypes.Id;
-import com.amdocs.zusammen.datatypes.SessionContext;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
-import org.openecomp.core.zusammen.plugin.dao.impl.CassandraElementRepository;
-import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.StructureElement;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-
-public class VspGeneralLoader {
- public static Map<String, ElementEntity> load(SessionContext context,
- Map<String, List<String>> vspItemVersionsMap) {
- Map<String, ElementEntity> elementEntityMap = new HashMap<>();
- System.setProperty("cassandra.dox.keystore", "zusammen_dox");
- CassandraElementRepository cassandraElementRepository = new CassandraElementRepository();
- for (Map.Entry<String, List<String>> entry : vspItemVersionsMap.entrySet()) {
-
- for (String version : entry.getValue()) {
-
- Optional<ElementEntity> result =
- cassandraElementRepository.get(context, new ElementEntityContext(
- context.getUser().getUserName(),
- new Id(entry.getKey()),
- new Id(version)),
- new ElementEntity(new Id(StructureElement.General.name())));
- if (result.isPresent()) {
- elementEntityMap.put(context.getUser().getUserName() + "_" + entry.getKey()
- + "_" + version, result.get());
- }
- }
- }
-
- return elementEntityMap;
- }
-}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/loaders/zusammen/VspItemLoader.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/loaders/zusammen/VspItemLoader.java
deleted file mode 100644
index 78b915c..0000000
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/loaders/zusammen/VspItemLoader.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package org.openecomp.core.tools.loaders.zusammen;
-
-public class VspItemLoader {
-}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/main/ZusammenMainTool.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/main/ZusammenMainTool.java
index b55d517..1829887 100644
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/main/ZusammenMainTool.java
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/main/ZusammenMainTool.java
@@ -3,9 +3,9 @@
import com.amdocs.zusammen.datatypes.SessionContext;
import com.amdocs.zusammen.datatypes.UserInfo;
import org.openecomp.core.tools.Commands.HealAll;
-import org.openecomp.core.tools.Commands.ImportCommand;
-import org.openecomp.core.tools.Commands.ExportDataCommand;
-import org.openecomp.core.tools.Commands.ResetOldVersion;
+import org.openecomp.core.tools.Commands.SetHealingFlag;
+import org.openecomp.core.tools.exportinfo.ExportDataCommand;
+import org.openecomp.core.tools.importinfo.ImportDataCommand;
import org.openecomp.core.tools.util.ToolsUtil;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
@@ -39,13 +39,13 @@
switch (COMMANDS.valueOf(command)){
case RESET_OLD_VERSION:
- ResetOldVersion.reset(context,ToolsUtil.getParam("v",args),ToolsUtil.getParam("n",args));
+ SetHealingFlag.populateHealingTable(ToolsUtil.getParam("v",args));
break;
case EXPORT:
ExportDataCommand.exportData(context,ToolsUtil.getParam("i",args));
break;
case IMPORT:
- ImportCommand.importData(context, ToolsUtil.getParam("f",args),ToolsUtil.getParam("i",args));
+ ImportDataCommand.execute(context, ToolsUtil.getParam("f",args));
break;
case HEAL_ALL:
HealAll.healAll(ToolsUtil.getParam("t",args));
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/model/ColumnDefinition.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/model/ColumnDefinition.java
new file mode 100644
index 0000000..846392c
--- /dev/null
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/model/ColumnDefinition.java
@@ -0,0 +1,84 @@
+/**
+ * Copyright © 2016-2017 European Support Limited.
+ */
+package org.openecomp.core.tools.model;
+
+import com.datastax.driver.core.ColumnDefinitions.Definition;
+import com.datastax.driver.core.DataType;
+
+import java.util.Arrays;
+
+public class ColumnDefinition {
+
+ private String keyspace;
+ private String table;
+ private String name;
+ private String type;
+
+ public ColumnDefinition() {
+ }
+
+ public ColumnDefinition(String keyspace, String table, String name, DataType type) {
+ this.keyspace = keyspace;
+ this.table = table;
+ this.name = name;
+ this.type = type.getName().toString();
+ }
+
+ public ColumnDefinition(Definition definition) {
+ this(definition.getKeyspace(), definition.getTable(), definition.getName(), definition.getType());
+ }
+
+ /**
+ * The name of the keyspace this column is part of.
+ *
+ * @return the name of the keyspace this column is part of.
+ */
+ public String getKeyspace() {
+ return keyspace;
+ }
+
+ /**
+ * Returns the name of the table this column is part of.
+ *
+ * @return the name of the table this column is part of.
+ */
+ public String getTable() {
+ return table;
+ }
+
+ /**
+ * Returns the name of the column.
+ *
+ * @return the name of the column.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Returns the type of the column.
+ *
+ * @return the type of the column.
+ */
+ public String getType() {
+ return type;
+ }
+
+ @Override
+ public final int hashCode() {
+ return Arrays.hashCode(new Object[]{keyspace, table, name, type});
+ }
+
+ @Override
+ public final boolean equals(Object o) {
+ if (!(o instanceof ColumnDefinition))
+ return false;
+
+ ColumnDefinition other = (ColumnDefinition) o;
+ return keyspace.equals(other.keyspace)
+ && table.equals(other.table)
+ && name.equals(other.name)
+ && type.equals(other.type);
+ }
+}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/model/TableData.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/model/TableData.java
new file mode 100644
index 0000000..155f35c
--- /dev/null
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/model/TableData.java
@@ -0,0 +1,12 @@
+/**
+ * Copyright © 2016-2017 European Support Limited.
+ */
+package org.openecomp.core.tools.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TableData {
+ public List<ColumnDefinition> definitions = new ArrayList<>();
+ public List<List<String>> rows = new ArrayList<>();
+}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/CassandraElementRepository.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/CassandraElementRepository.java
index c41b46e..fcc67e1 100644
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/CassandraElementRepository.java
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/CassandraElementRepository.java
@@ -34,7 +34,12 @@
import java.lang.reflect.Type;
import java.nio.ByteBuffer;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
import java.util.stream.Collectors;
public class CassandraElementRepository {
@@ -61,18 +66,18 @@
ElementEntity element) {
Row row = getElementAccessor(context).get(
elementContext.getSpace(),
- elementContext.getItemId().toString(),
+ elementContext.getItemId().getValue(),
getVersionId(elementContext),
- element.getId().toString()).one();
+ element.getId().getValue()).one();
return row == null ? Optional.empty() : Optional.of(getElementEntity(element, row));
}
private String getVersionId(ElementEntityContext elementContext) {
- return elementContext.getChangeRef() == null
- ? elementContext.getVersionId().toString()
- : elementContext.getChangeRef();
+ return elementContext.getRevisionId() == null
+ ? elementContext.getVersionId().getValue()
+ : elementContext.getRevisionId().getValue();
}
@@ -92,7 +97,7 @@
private void updateElement(SessionContext context, ElementEntityContext elementContext,
ElementEntity element) {
- if (elementContext.getChangeRef() == null) {
+ if (elementContext.getRevisionId() == null) {
getElementAccessor(context).update(
JsonUtil.object2Json(element.getInfo()),
@@ -113,7 +118,7 @@
element.getVisualization(),
elementContext.getSpace(),
elementContext.getItemId().toString(),
- elementContext.getChangeRef(),
+ elementContext.getRevisionId().getValue(),
element.getId().toString());
}
}
@@ -154,7 +159,7 @@
getVersionId(elementContext)).one();
return row == null
? new HashSet<>()
- : row.getSet(CassandraElementRepository.VersionElementsField.ELEMENT_IDS, String.class);
+ : row.getSet(VersionElementsField.ELEMENT_IDS, String.class);
}
/*
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/ElementHandler.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/ElementHandler.java
index 5c72c95..d8929ea 100644
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/ElementHandler.java
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/ElementHandler.java
@@ -2,7 +2,6 @@
import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.SessionContext;
-import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
@@ -11,23 +10,17 @@
private static final String GLOBAL_USER = "GLOBAL_USER";
public static void update(SessionContext context,
- String itemId, String versionId, String changeRef,
+ String itemId, String versionId, String revisionId,
ElementEntity elementEntity) {
ElementEntityContext elementContext;
CassandraElementRepository cassandraElementRepository = new CassandraElementRepository();
- if (changeRef == null) {
+ if (revisionId == null) {
elementContext = new ElementEntityContext(GLOBAL_USER, new Id(itemId),
- new Id(versionId));
+ new Id(versionId));
- } else {
- elementContext = new ElementEntityContext(GLOBAL_USER, new ElementContext(new Id(itemId),
- new Id(versionId),
- changeRef));
}
- cassandraElementRepository.update(context, elementContext, elementEntity);
-
}
}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/HealingHandler.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/HealingHandler.java
new file mode 100644
index 0000000..78bbdf0
--- /dev/null
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/HealingHandler.java
@@ -0,0 +1,54 @@
+package org.openecomp.core.tools.store;
+
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.mapping.annotations.Accessor;
+import com.datastax.driver.mapping.annotations.Query;
+import org.openecomp.core.nosqldb.api.NoSqlDb;
+import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
+import org.openecomp.core.tools.store.zusammen.datatypes.HealingEntity;
+
+import java.util.ArrayList;
+
+/**
+ * Created by ayalaben on 10/15/2017
+ */
+public class HealingHandler {
+
+ private static NoSqlDb nnoSqlDb = NoSqlDbFactory.getInstance().createInterface();
+ private static HealingAccessor accessor =
+ nnoSqlDb.getMappingManager().createAccessor(HealingAccessor.class);
+
+
+ public void populateHealingTable(ArrayList<HealingEntity> healingEntities) {
+ healingEntities.forEach(healingEntity -> {
+ if (isHealingRecordExist(healingEntity)) {
+ accessor.updateFlag(healingEntity.getHealingFlag(), healingEntity.getSpace(),
+ healingEntity.getItemId(), healingEntity.getVersionId());
+ } else {
+ accessor.create(healingEntity.getSpace(), healingEntity.getItemId(),
+ healingEntity.getVersionId(), healingEntity.getHealingFlag(),
+ healingEntity.getOldVersion());
+ }
+ });
+ }
+
+ private boolean isHealingRecordExist(HealingEntity healingEntity) {
+ return accessor.getFlag(healingEntity.getSpace(), healingEntity.getItemId(),
+ healingEntity.getVersionId()).getAvailableWithoutFetching() == 1;
+ }
+
+ @Accessor
+ interface HealingAccessor {
+
+ @Query("SELECT healing_needed FROM healing WHERE space=? AND item_id=? AND version_id=?")
+ ResultSet getFlag(String space, String itemId, String versionId);
+
+ @Query("Insert into healing (space, item_id, version_id, healing_needed, old_version) " +
+ "values (?,?,?,?,?)")
+ void create(String space, String itemId, String versionId, boolean flag, String oldVersion);
+
+ @Query("UPDATE healing SET healing_needed=? WHERE space=? AND item_id=? AND version_id=?")
+ void updateFlag(boolean flag, String space, String itemId, String versionId);
+ }
+
+}
\ No newline at end of file
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/VersionCassandraLoader.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/VersionCassandraLoader.java
index 851e92d..fd9dc25 100644
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/VersionCassandraLoader.java
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/VersionCassandraLoader.java
@@ -20,6 +20,7 @@
package org.openecomp.core.tools.store;
+import com.datastax.driver.core.ResultSet;
import com.datastax.driver.mapping.Mapper;
import com.datastax.driver.mapping.Result;
import com.datastax.driver.mapping.annotations.Accessor;
@@ -60,6 +61,8 @@
return accessor.getAll();
}
+ public ResultSet listItemVersion() { return accessor.getAllItemVersion();}
+
@Accessor
interface VersionAccessor {
@@ -74,5 +77,8 @@
@Query("select * from zusammen_dox.version ")
@QueryParameters(fetchSize = 400)
Result<VersionEntity> getAll();
+
+ @Query("select space,item_id,version_id from zusammen_dox.version ")
+ ResultSet getAllItemVersion();
}
}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/VspGeneralLoader.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/VspGeneralLoader.java
index 1d9d2d9..b8620b8 100644
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/VspGeneralLoader.java
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/VspGeneralLoader.java
@@ -4,14 +4,13 @@
import com.amdocs.zusammen.datatypes.SessionContext;
import com.amdocs.zusammen.datatypes.item.Info;
import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
-import org.openecomp.core.zusammen.plugin.dao.impl.CassandraElementRepository;
import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Optional;
import java.util.Objects;
+import java.util.Optional;
public class VspGeneralLoader {
@@ -56,24 +55,24 @@
for (Map.Entry<String, List<String>> entry : vspItemChangeRefssMap.entrySet()) {
- for (String changeRef : entry.getValue()) {
+ for (String revisionId : entry.getValue()) {
itemId = new Id(entry.getKey());
- entityId = getEntityIdByInfoNameValue(context, itemId, null, changeRef,null, NAME,
+ entityId = getEntityIdByInfoNameValue(context, itemId, null, revisionId,null, NAME,
GENERAL);
if (entityId != null) {
ElementEntityContext elementContext = new ElementEntityContext(
context.getUser().getUserName(),
itemId,
null);
- elementContext.setChangeRef(changeRef);
+ elementContext.setRevisionId(new Id(revisionId));
Optional<ElementEntity> result =
cassandraElementRepository.get(context, elementContext,
new ElementEntity(entityId));
if (result.isPresent()) {
- elementEntityMap.put(buildKey(context, entry, changeRef), result.get());
+ elementEntityMap.put(buildKey(context, entry, revisionId), result.get());
}
}
}
@@ -90,7 +89,7 @@
private static Id getEntityIdByInfoNameValue(SessionContext context,
Id itemId,
Id versionId,
- String changeRef,
+ String revisionId,
Id elementId,
String name,
String value) {
@@ -100,8 +99,8 @@
context.getUser().getUserName(),
itemId,
versionId);
- if (changeRef != null) {
- elementContext.setChangeRef(changeRef);
+ if (revisionId != null) {
+ elementContext.setRevisionId(new Id(revisionId));
}
Optional<ElementEntity> result =
cassandraElementRepository.get(context, elementContext,
@@ -113,8 +112,8 @@
context.getUser().getUserName(),
itemId,
versionId);
- if(changeRef!= null){
- subElementContext.setChangeRef(changeRef);
+ if(revisionId!= null){
+ subElementContext.setRevisionId(new Id(revisionId));
}
Optional<ElementEntity> subElementEntityOptional =
cassandraElementRepository.get(context, subElementContext,
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/zusammen/datatypes/HealingEntity.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/zusammen/datatypes/HealingEntity.java
new file mode 100644
index 0000000..8c95f79
--- /dev/null
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/zusammen/datatypes/HealingEntity.java
@@ -0,0 +1,78 @@
+package org.openecomp.core.tools.store.zusammen.datatypes;
+
+import com.datastax.driver.mapping.annotations.Column;
+import com.datastax.driver.mapping.annotations.PartitionKey;
+import com.datastax.driver.mapping.annotations.Table;
+
+/**
+ * Created by ayalaben on 10/15/2017
+ */
+@Table(keyspace = "dox", name = "healing")
+public class HealingEntity {
+ @Column(name = "space")
+ @PartitionKey(0)
+ private String space;
+
+ @Column(name = "item_id")
+ @PartitionKey(1)
+ private String itemId;
+
+ @Column(name = "version_id")
+ @PartitionKey(2)
+ private String versionId;
+
+ @Column(name = "healing_needed")
+ private boolean healingFlag;
+
+ @Column(name = "old_version")
+ private String old_version;
+
+ public String getSpace() {
+ return space;
+ }
+
+ public void setSpace(String space) {
+ this.space = space;
+ }
+
+ public String getItemId() {
+ return itemId;
+ }
+
+ public void setItemId(String itemId) {
+ this.itemId = itemId;
+ }
+
+ public String getVersionId() {
+ return versionId;
+ }
+
+ public void setVersionId(String versionId) {
+ this.versionId = versionId;
+ }
+
+ public boolean getHealingFlag() {
+ return healingFlag;
+ }
+
+ public void setHealingFlag(boolean healingFlag) {
+ this.healingFlag = healingFlag;
+ }
+
+ public HealingEntity(String space, String itemId, String versionId, boolean healingFlag,String
+ oldVersion) {
+ this.space = space;
+ this.itemId = itemId;
+ this.versionId = versionId;
+ this.healingFlag = healingFlag;
+ this.old_version = oldVersion;
+ }
+
+ public String getOldVersion() {
+ return old_version;
+ }
+
+ public void setOldVersion(String old_version) {
+ this.old_version = old_version;
+ }
+}
\ No newline at end of file
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/zusammen/datatypes/VersionEntity.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/zusammen/datatypes/VersionEntity.java
index c7280c8..946c05e 100644
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/zusammen/datatypes/VersionEntity.java
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/zusammen/datatypes/VersionEntity.java
@@ -1,6 +1,8 @@
package org.openecomp.core.tools.store.zusammen.datatypes;
-import com.datastax.driver.mapping.annotations.*;
+import com.datastax.driver.mapping.annotations.Column;
+import com.datastax.driver.mapping.annotations.PartitionKey;
+import com.datastax.driver.mapping.annotations.Table;
import java.util.Date;
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/util/Utils.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/util/Utils.java
index d1621ad..f48b212 100644
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/util/Utils.java
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/util/Utils.java
@@ -3,13 +3,36 @@
import org.openecomp.sdc.logging.api.Logger;
/**
+ * Copyright © 2016-2017 European Support Limited.
* @author Avrahamg
* @since April 24, 2017
+ * Since it is a command line tools writing to console will be helpful to users.
*/
public class Utils {
public static void printMessage(Logger logger, String message) {
+ /**
+ * Since it is a command line tools writing to console will be helpful to users.
+ */
System.out.println(message);
logger.debug(message);
}
+
+
+ public static void logError(Logger logger, Throwable ex) {
+ /**
+ * Since it is a command line tools writing to console will be helpful to users.
+ */
+ ex.printStackTrace();
+ logger.error(ex.getMessage(),ex);
+ }
+
+ public static void logError(Logger logger, String message, Throwable ex) {
+ /**
+ * Since it is a command line tools writing to console will be helpful to users.
+ */
+ System.out.println(message);
+ ex.printStackTrace();
+ logger.error(message,ex);
+ }
}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/util/ZipUtils.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/util/ZipUtils.java
index 2f6693d..e0fd1a7 100644
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/util/ZipUtils.java
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/util/ZipUtils.java
@@ -1,13 +1,17 @@
package org.openecomp.core.tools.util;
import com.google.common.io.ByteStreams;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.Objects;
import java.util.Scanner;
import java.util.Set;
@@ -17,12 +21,23 @@
import java.util.zip.ZipOutputStream;
public class ZipUtils {
- public static void createZip(String zipFileName, Path dir, Set<String> filterItem) throws Exception {
+
+ private static final Logger logger = LoggerFactory.getLogger(ZipUtils.class);
+
+ public static void createZip(String zipFileName, Path dir) throws IOException {
File dirObj = dir.toFile();
+ Path zippedFile = Files.createFile(Paths.get(zipFileName));
try (
- FileOutputStream fileOutputStream = new FileOutputStream(zipFileName);
- ZipOutputStream out = new ZipOutputStream(fileOutputStream)) {
- addDir(dirObj, out, dir.toString(), filterItem);
+ FileOutputStream fileOutputStream = new FileOutputStream(File.separator + zippedFile.toFile());
+ BufferedOutputStream bos = new BufferedOutputStream(fileOutputStream);
+ ZipOutputStream out = new ZipOutputStream(bos)) {
+ File[] files = dirObj.listFiles();
+ for (File file : files) {
+ out.putNextEntry(new ZipEntry(file.getName()));
+ Files.copy(Paths.get(file.getPath()), out);
+ out.closeEntry();
+ }
+ Utils.printMessage(logger, "Zip file was created " + zipFileName);
}
}
@@ -47,7 +62,7 @@
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory()) {
addDir(files[i], out, root, filterItem);
- String filePath = files[i].getAbsolutePath().replace(root + File.separator, "") + "/";
+ String filePath = files[i].getAbsolutePath().replace(root + File.separator, "") + File.separator;
out.putNextEntry(new ZipEntry(filePath));
continue;
}
@@ -57,7 +72,6 @@
out.putNextEntry(new ZipEntry(filePath));
try {
ByteStreams.copy(in, out);
-
} finally {
out.closeEntry();
}
@@ -71,7 +85,7 @@
if (zipFile == null || outputFolder == null) {
return;
}
- if (!Files.exists(outputFolder)) {
+ if (!outputFolder.toFile().exists()) {
Files.createDirectories(outputFolder);
}
@@ -83,7 +97,7 @@
File newFile = new File(outputFolder.toString() + File.separator + fileName);
if (ze.isDirectory()) {
Path path = newFile.toPath();
- if (!Files.exists(path)) {
+ if (!path.toFile().exists()) {
Files.createDirectories(path);
}
} else {
diff --git a/openecomp-be/tools/zusammen-tools/src/main/resources/logback.xml b/openecomp-be/tools/zusammen-tools/src/main/resources/logback.xml
index a13dc82..2461aed 100644
--- a/openecomp-be/tools/zusammen-tools/src/main/resources/logback.xml
+++ b/openecomp-be/tools/zusammen-tools/src/main/resources/logback.xml
@@ -1,5 +1,6 @@
<configuration>
+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
diff --git a/openecomp-be/tools/zusammen-tools/src/main/resources/queries.yaml b/openecomp-be/tools/zusammen-tools/src/main/resources/queries.yaml
new file mode 100644
index 0000000..a93a5a4
--- /dev/null
+++ b/openecomp-be/tools/zusammen-tools/src/main/resources/queries.yaml
@@ -0,0 +1,16 @@
+queries:
+ - select * from zusammen_dox.element;
+ - select * from zusammen_dox.element_namespace;
+ - select * from zusammen_dox.item;
+ - select * from zusammen_dox.version;
+ - select * from zusammen_dox.version_elements;
+ - select * from dox.item_permissions;
+ - select * from dox.vsp_merge_hint ;
+item_columns:
+ - item_id
+ - item_id
+ - item_id
+ - item_id
+ - item_id
+ - item_id
+ - item_id
\ No newline at end of file
diff --git a/openecomp-be/tools/zusammen-tools/src/test/java/org/openecomp/core/tools/Commands/exportinfo/serialize/VLMExtractTest.java b/openecomp-be/tools/zusammen-tools/src/test/java/org/openecomp/core/tools/Commands/exportinfo/serialize/VLMExtractTest.java
new file mode 100644
index 0000000..7b43c46
--- /dev/null
+++ b/openecomp-be/tools/zusammen-tools/src/test/java/org/openecomp/core/tools/Commands/exportinfo/serialize/VLMExtractTest.java
@@ -0,0 +1,48 @@
+package org.openecomp.core.tools.Commands.exportinfo.serialize;
+
+import org.openecomp.core.tools.exportinfo.ExportSerializer;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+public class VLMExtractTest {
+
+
+
+ @Test
+ public void extractVLM(){
+ String vlmId = "979a56c7b2fa41e6a5742137f53a5c1b";
+ String elemenet_info_string = "{\n" +
+ " \"name\": \"VendorSoftwareProduct\",\n" +
+ " \"properties\": {\n" +
+ " \"subCategory\": \"resourceNewCategory.dcae component.collector\",\n" +
+ " \"name\": \"vsp1\",\n" +
+ " \"icon\": \"icon\",\n" +
+ " \"onboardingMethod\": \"NetworkPackage\",\n" +
+ " \"description\": \"d\",\n" +
+ " \"vendorId\": \""+vlmId+"\",\n" +
+ " \"category\": \"resourceNewCategory.dcae component\",\n" +
+ " \"vendorName\": \"vlm1\",\n" +
+ " \"elementType\": \"VendorSoftwareProduct\"\n" +
+ " }\n" +
+ "}\n" ;
+ String extractedVlmId = new CustomExportSerializer().extractVlm(elemenet_info_string);
+ assertNotNull(extractedVlmId);
+ assertEquals(extractedVlmId,vlmId);
+
+ }
+
+ @Test
+ public void failToExtractVLMBecauseJsonIsCorrupted(){
+ String elemenet_info_string = "gfhhhghgh";
+ String extractedVlmId = new CustomExportSerializer().extractVlm(elemenet_info_string);
+ assertNull(extractedVlmId);
+ }
+
+ private static final class CustomExportSerializer extends ExportSerializer{
+ public String extractVlm(String injson) {
+ return super.extractVlm(injson);
+ }
+ }
+}
diff --git a/openecomp-be/tools/zusammen-tools/src/test/resources/configuration.yaml b/openecomp-be/tools/zusammen-tools/src/test/resources/configuration.yaml
new file mode 100644
index 0000000..6636e20
--- /dev/null
+++ b/openecomp-be/tools/zusammen-tools/src/test/resources/configuration.yaml
@@ -0,0 +1,251 @@
+identificationHeaderFields:
+ - HTTP_IV_USER
+ - HTTP_CSP_FIRSTNAME
+ - HTTP_CSP_LASTNAME
+ - HTTP_IV_REMOTE_ADDRESS
+ - HTTP_CSP_WSTYPE
+
+
+
+# catalog backend http port
+beHttpPort: 8080
+
+# catalog backend http context
+beContext: /sdc/rest/config/get
+
+# catalog backend protocol
+beProtocol: http
+
+# catalog backend ssl port
+beSslPort: 8443
+
+version: 1.0
+released: 2012-11-30
+
+titanCfgFile: /home/vagrant/catalog-be/config/catalog-be/titan.properties
+titanInMemoryGraph: false
+titanLockTimeout: 30
+titanReconnectIntervalInSeconds: 3
+titanHealthCheckReadTimeout: 1
+esReconnectIntervalInSeconds: 3
+uebHealthCheckReconnectIntervalInSeconds: 15
+uebHealthCheckReadTimeout: 4
+
+# Protocols
+protocols:
+ - http
+ - https
+
+# Users
+users:
+ tom: passwd
+ bob: passwd
+
+neo4j:
+ host: neo4jhost
+ port: 7474
+ user: neo4j
+ password: "12345"
+
+cassandraConfig:
+ cassandraHosts: ['localhost']
+ reconnectTimeout : 30000
+ authenticate: true
+ username: asdc_user
+ password: password
+ ssl: false
+ truststorePath : /path/path
+ truststorePassword : password
+ keySpaces:
+ - { name: dox, replicationStrategy: SimpleStrategy, replicationInfo: ['1']}
+ - { name: zusammen_dox, replicationStrategy: SimpleStrategy, replicationInfo: ['1']}
+ - { name: sdcartifact, replicationStrategy: SimpleStrategy, replicationInfo: ['1']}
+
+#Application-specific settings of ES
+elasticSearch:
+ # Mapping of index prefix to time-based frame. For example, if below is configured:
+ #
+ # - indexPrefix: auditingevents
+ # creationPeriod: minute
+ #
+ # then ES object of type which is mapped to "auditingevents-*" template, and created on 2015-12-23 13:24:54, will enter "auditingevents-2015-12-23-13-24" index.
+ # Another object created on 2015-12-23 13:25:54, will enter "auditingevents-2015-12-23-13-25" index.
+ # If creationPeriod: month, both of the above will enter "auditingevents-2015-12" index.
+ #
+ # PLEASE NOTE: the timestamps are created in UTC/GMT timezone! This is needed so that timestamps will be correctly presented in Kibana.
+ #
+ # Legal values for creationPeriod - year, month, day, hour, minute, none (meaning no time-based behaviour).
+ #
+ # If no creationPeriod is configured for indexPrefix, default behavour is creationPeriod: month.
+
+ indicesTimeFrequency:
+ - indexPrefix: auditingevents
+ creationPeriod: month
+ - indexPrefix: monitoring_events
+ creationPeriod: month
+
+artifactTypes:
+ - CHEF
+ - PUPPET
+ - SHELL
+ - YANG
+ - YANG_XML
+ - HEAT
+ - BPEL
+ - DG_XML
+ - MURANO_PKG
+ - OTHER
+
+licenseTypes:
+ - User
+ - Installation
+ - CPU
+
+#Deployment artifacts placeHolder
+deploymentResourceArtifacts:
+ heat:
+ displayName: "HEAT Template"
+ type: HEAT
+
+deploymentResourceInstanceArtifacts:
+ heatEnv:
+ displayName: "HEAT ENV"
+ type: HEAT_ENV
+ description: "Auto-generated HEAT Environment deployment artifact"
+ fileExtension: "env"
+
+#Informational artifacts placeHolder
+excludeResourceCategory:
+ - Generic
+informationalResourceArtifacts:
+ features:
+ displayName: Features
+ type: OTHER
+ capacity:
+ displayName: Capacity
+ type: OTHER
+ vendorTestResult:
+ displayName: Vendor Test Result
+ type: OTHER
+ testScripts:
+ displayName: Test Scripts
+ type: OTHER
+ cloudQuestionnaire:
+ displayName: Cloud Questionnaire (completed)
+ type: OTHER
+ HEATTemplateFromVendor:
+ displayName: HEAT Template from Vendor
+ type: HEAT
+
+excludeServiceCategory:
+
+informationalServiceArtifacts:
+ messageFlows:
+ displayName: Message Flows
+ type: OTHER
+ instantiationFlows:
+ displayName: Management Flows
+ type: OTHER
+ serviceArtifactPlan:
+ displayName: Service Artifact Plan
+ type: OTHER
+ summaryOfImpactsToECOMPElements:
+ displayName: Summary of impacts to OPENECOMP elements,OSSs, BSSs
+ type: OTHER
+ controlLoopFunctions:
+ displayName: Control Loop Functions
+ type: OTHER
+ dimensioningInfo:
+ displayName: Dimensioning Info
+ type: OTHER
+ affinityRules:
+ displayName: Affinity Rules
+ type: OTHER
+ operationalPolicies:
+ displayName: Operational Policies
+ type: OTHER
+ serviceSpecificPolicies:
+ displayName: Service-specific Policies
+ type: OTHER
+ engineeringRules:
+ displayName: Engineering Rules (ERD)
+ type: OTHER
+ distributionInstructions:
+ displayName: Distribution Instructions
+ type: OTHER
+ certificationTestResults:
+ displayName: TD Certification Test Results
+ type: OTHER
+ deploymentVotingRecord:
+ displayName: Deployment Voting Record
+ type: OTHER
+ serviceQuestionnaire:
+ displayName: Service Questionnaire
+ type: OTHER
+
+serviceApiArtifacts:
+ configuration:
+ displayName: Configuration
+ type: OTHER
+ instantiation:
+ displayName: Instantiation
+ type: OTHER
+ monitoring:
+ displayName: Monitoring
+ type: OTHER
+ reporting:
+ displayName: Reporting
+ type: OTHER
+ logging:
+ displayName: Logging
+ type: OTHER
+ testing:
+ displayName: Testing
+ type: OTHER
+
+
+additionalInformationMaxNumberOfKeys: 50
+
+systemMonitoring:
+ enabled: false
+ isProxy: false
+ probeIntervalInSeconds: 15
+
+defaultHeatArtifactTimeoutMinutes: 60
+
+serviceDeploymentArtifacts:
+
+resourceDeploymentArtifacts:
+ HEAT:
+ acceptedTypes:
+ - yaml
+ - yml
+
+resourceInformationalDeployedArtifacts:
+ YANG_XML:
+ acceptedTypes:
+ - xml
+
+
+unLoggedUrls:
+ - /sdc2/rest/healthCheck
+
+cleanComponentsConfiguration:
+ cleanIntervalInMinutes: 1440
+ componentsToClean:
+ - Resource
+
+artifactsIndex: resources
+
+heatEnvArtifactHeader:
+ " # _______________________________________________________________________________________________________________________________________\n
+ #| AT&T Proprietary (Restricted) |\n
+ #| Only for use by authorized individuals or any above-designated team(s) |\n
+ #| within the AT&T companies and not for general distribution |\n
+ #|_______________________________________________________________________________________________________________________________________|\n"
+heatEnvArtifactFooter:
+ " # _______________________________________________________________________________________________________________________________________\n
+ #| AT&T Proprietary (Restricted) |\n
+ #| Only for use by authorized individuals or any above-designated team(s) |\n
+ #| within the AT&T companies and not for general distribution |\n
+ #|_______________________________________________________________________________________________________________________________________|\n"
diff --git a/openecomp-be/tools/zusammen-tools/src/test/resources/queries.yaml b/openecomp-be/tools/zusammen-tools/src/test/resources/queries.yaml
new file mode 100644
index 0000000..6ca8cd6
--- /dev/null
+++ b/openecomp-be/tools/zusammen-tools/src/test/resources/queries.yaml
@@ -0,0 +1,16 @@
+queries:
+ - select * from zusammen_dox.element;
+ - select * from zusammen_dox.element_namespace;
+ - select * from zusammen_dox.item;
+ - select * from zusammen_dox.version;
+ - select * from zusammen_dox.version_elements;
+ - select * from dox.item_permissions;
+ - select * from dox.vsp_merge_hint;
+item_columns:
+ - item_id
+ - item_id
+ - item_id
+ - item_id
+ - item_id
+ - item_id
+ - item_id
\ No newline at end of file