aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/main')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandler.java9
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogic.java6
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java11
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java34
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java4
5 files changed, 36 insertions, 28 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandler.java
index 62e6ce5182..de8f2934d5 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandler.java
@@ -75,8 +75,9 @@ public class InterfaceDefinitionHandler {
* @param interfaceDefinitionToscaMap the TOSCA interface definition structure
* @return an interface definition representation
*/
- public InterfaceDefinition create(final Map<String, Object> interfaceDefinitionToscaMap) {
+ public InterfaceDefinition create(final Map<String, Object> interfaceDefinitionToscaMap, final String model) {
final InterfaceDefinition interfaceDefinition = new InterfaceDefinition();
+ interfaceDefinition.setModel(model);
if (interfaceDefinitionToscaMap.containsKey(TYPE.getElementName())) {
final Object typeObj = interfaceDefinitionToscaMap.get(TYPE.getElementName());
if (!(typeObj instanceof String)) {
@@ -101,18 +102,18 @@ public class InterfaceDefinitionHandler {
operationMap = handleLegacyOperations(interfaceDefinitionToscaMap);
}
if (!operationMap.isEmpty()) {
- validateOperations(interfaceDefinition.getType(), operationMap);
+ validateOperations(interfaceDefinition.getType(), operationMap, model);
interfaceDefinition.setOperations(operationMap);
}
return interfaceDefinition;
}
- private void validateOperations(final String interfaceType, final Map<String, OperationDataDefinition> operationMap) {
+ private void validateOperations(final String interfaceType, final Map<String, OperationDataDefinition> operationMap, final String model) {
if (MapUtils.isEmpty(operationMap)) {
return;
}
Either<Map<String, InterfaceDefinition>, ResponseFormat> interfaceDefinitionMapEither = interfaceOperationBusinessLogic
- .getAllInterfaceLifecycleTypes();
+ .getAllInterfaceLifecycleTypes(model);
if (interfaceDefinitionMapEither.isRight() || MapUtils.isEmpty(interfaceDefinitionMapEither.left().value())) {
throw new ByActionStatusComponentException(ActionStatus.INTERFACE_UNKNOWN, interfaceType);
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogic.java
index e23818c957..d633141fdf 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogic.java
@@ -258,7 +258,7 @@ public class InterfaceOperationBusinessLogic extends BaseBusinessLogic {
}
org.openecomp.sdc.be.model.Component storedComponent = componentEither.left().value();
lockComponentResult(lock, storedComponent, errorContext);
- Either<Map<String, InterfaceDefinition>, ResponseFormat> interfaceLifecycleTypes = getAllInterfaceLifecycleTypes();
+ Either<Map<String, InterfaceDefinition>, ResponseFormat> interfaceLifecycleTypes = getAllInterfaceLifecycleTypes(storedComponent.getModel());
if (interfaceLifecycleTypes.isRight()) {
return Either.right(interfaceLifecycleTypes.right().value());
}
@@ -349,9 +349,9 @@ public class InterfaceOperationBusinessLogic extends BaseBusinessLogic {
}
}
- public Either<Map<String, InterfaceDefinition>, ResponseFormat> getAllInterfaceLifecycleTypes() {
+ public Either<Map<String, InterfaceDefinition>, ResponseFormat> getAllInterfaceLifecycleTypes(final String model) {
Either<Map<String, InterfaceDefinition>, StorageOperationStatus> interfaceLifecycleTypes = interfaceLifecycleTypeOperation
- .getAllInterfaceLifecycleTypes();
+ .getAllInterfaceLifecycleTypes(model);
if (interfaceLifecycleTypes.isRight()) {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.INTERFACE_LIFECYCLE_TYPES_NOT_FOUND));
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
index a7defab60a..6efdab4a96 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
@@ -24,7 +24,6 @@ package org.openecomp.sdc.be.components.impl;
import static org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaElementOperation.createDataType;
import static org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaElementOperation.createDataTypeDefinitionWithName;
-import fj.data.Either;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -37,7 +36,9 @@ import java.util.Set;
import java.util.function.Function;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
+
import javax.servlet.ServletContext;
+
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
@@ -97,6 +98,8 @@ import org.springframework.stereotype.Component;
import org.springframework.web.context.WebApplicationContext;
import org.yaml.snakeyaml.Yaml;
+import fj.data.Either;
+
@Component("resourceImportManager")
public class ResourceImportManager {
@@ -351,7 +354,7 @@ public class ResourceImportManager {
Map<String, Object> jsonInterfaces = toscaInterfaces.left().value();
Map<String, InterfaceDefinition> moduleInterfaces = new HashMap<>();
for (final Entry<String, Object> interfaceNameValue : jsonInterfaces.entrySet()) {
- final Either<InterfaceDefinition, ResultStatusEnum> eitherInterface = createModuleInterface(interfaceNameValue.getValue());
+ final Either<InterfaceDefinition, ResultStatusEnum> eitherInterface = createModuleInterface(interfaceNameValue.getValue(), resource.getModel());
if (eitherInterface.isRight()) {
log.info("error when creating interface:{}, for resource:{}", interfaceNameValue.getKey(), resource.getName());
} else {
@@ -365,7 +368,7 @@ public class ResourceImportManager {
}
}
- private Either<InterfaceDefinition, ResultStatusEnum> createModuleInterface(final Object interfaceJson) {
+ private Either<InterfaceDefinition, ResultStatusEnum> createModuleInterface(final Object interfaceJson, final String model) {
try {
if (interfaceJson instanceof String) {
final InterfaceDefinition interfaceDefinition = new InterfaceDefinition();
@@ -374,7 +377,7 @@ public class ResourceImportManager {
}
if (interfaceJson instanceof Map) {
final Map<String, Object> interfaceJsonMap = (Map<String, Object>) interfaceJson;
- final InterfaceDefinition interfaceDefinition = interfaceDefinitionHandler.create(interfaceJsonMap);
+ final InterfaceDefinition interfaceDefinition = interfaceDefinitionHandler.create(interfaceJsonMap, model);
return Either.left(interfaceDefinition);
}
return Either.right(ResultStatusEnum.GENERAL_ERROR);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java
index c3c42e27f5..ac195f9315 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java
@@ -19,22 +19,11 @@
*/
package org.openecomp.sdc.be.servlets;
-import com.jcabi.aspects.Loggable;
-import fj.data.Either;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.media.ArraySchema;
-import io.swagger.v3.oas.annotations.media.Content;
-import io.swagger.v3.oas.annotations.media.Schema;
-import io.swagger.v3.oas.annotations.responses.ApiResponse;
-import io.swagger.v3.oas.annotations.servers.Server;
-import io.swagger.v3.oas.annotations.servers.Servers;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import io.swagger.v3.oas.annotations.tags.Tags;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
+
import javax.inject.Inject;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
@@ -47,8 +36,8 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+
import org.apache.commons.collections4.ListUtils;
-import org.glassfish.jersey.media.multipart.FormDataParam;
import org.openecomp.sdc.be.components.impl.CapabilitiesBusinessLogic;
import org.openecomp.sdc.be.components.impl.ComponentBusinessLogic;
import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
@@ -79,6 +68,20 @@ import org.openecomp.sdc.common.log.wrappers.Logger;
import org.openecomp.sdc.exception.ResponseFormat;
import org.springframework.stereotype.Controller;
+import com.jcabi.aspects.Loggable;
+
+import fj.data.Either;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.media.ArraySchema;
+import io.swagger.v3.oas.annotations.media.Content;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import io.swagger.v3.oas.annotations.servers.Server;
+import io.swagger.v3.oas.annotations.servers.Servers;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import io.swagger.v3.oas.annotations.tags.Tags;
+
@Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
@Path("/v1/catalog")
@Tags({@Tag(name = "SDCE-2 APIs")})
@@ -145,7 +148,8 @@ public class TypesFetchServlet extends AbstractValidationsServlet {
@ApiResponse(responseCode = "404", description = "Interface lifecycle types not found")})
@PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
public Response getInterfaceLifecycleTypes(@Context final HttpServletRequest request,
- @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
+ @HeaderParam(value = Constants.USER_ID_HEADER) String userId,
+ @Parameter(description = "model") @QueryParam("model") String modelName) {
Wrapper<Response> responseWrapper = new Wrapper<>();
Wrapper<User> userWrapper = new Wrapper<>();
try {
@@ -154,7 +158,7 @@ public class TypesFetchServlet extends AbstractValidationsServlet {
String url = request.getMethod() + " " + request.getRequestURI();
log.info("Start handle request of {} | modifier id is {}", url, userId);
Either<Map<String, InterfaceDefinition>, ResponseFormat> allInterfaceLifecycleTypes = interfaceOperationBusinessLogic
- .getAllInterfaceLifecycleTypes();
+ .getAllInterfaceLifecycleTypes(modelName);
if (allInterfaceLifecycleTypes.isRight()) {
log.info("Failed to get all interface lifecycle types. Reason - {}", allInterfaceLifecycleTypes.right().value());
Response errorResponse = buildErrorResponse(allInterfaceLifecycleTypes.right().value());
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
index 4f815a316d..3fe3bd5c42 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
@@ -693,7 +693,7 @@ public class ToscaExportHandler {
log.debug("start convert node type for {}", component.getUniqueId());
ToscaNodeType toscaNodeType = createNodeType(component);
Either<Map<String, InterfaceDefinition>, StorageOperationStatus> lifecycleTypeEither = interfaceLifecycleOperation
- .getAllInterfaceLifecycleTypes();
+ .getAllInterfaceLifecycleTypes(component.getModel());
if (lifecycleTypeEither.isRight()) {
log.debug("Failed to fetch all interface types :", lifecycleTypeEither.right().value());
return Either.right(ToscaError.GENERAL_ERROR);
@@ -1077,7 +1077,7 @@ public class ToscaExportHandler {
}
Either<Map<String, InterfaceDefinition>, StorageOperationStatus> lifecycleTypeEither =
- interfaceLifecycleOperation.getAllInterfaceLifecycleTypes();
+ interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(serviceComponent.getModel());
if (lifecycleTypeEither.isRight()) {
log.debug("Failed to retrieve global interface types :", lifecycleTypeEither.right().value());
return Either.right(ToscaError.GENERAL_ERROR);