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.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+import javax.inject.Inject;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.DELETE;
+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.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic;
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum;
import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
import org.openecomp.sdc.exception.ResponseFormat;
import org.springframework.stereotype.Controller;
-import javax.inject.Inject;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.DELETE;
-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.Context;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
-
/**
* This Servlet serves external users operations on artifacts.
*
*/
@Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
@Path("/v1/catalog")
-@Tags({@Tag(name = "SDC External APIs")})
-@Servers({@Server(url = "/sdc")})
+@Tag(name = "SDC External APIs")
+@Server(url = "/sdc")
@Controller
public class ArtifactExternalServlet extends AbstractValidationsServlet {
ResponseFormat responseFormat = null;
String requestURI = request.getRequestURI();
String url = request.getMethod() + " " + requestURI;
- log.debug("{} {}", startLog, url);
+ log.debug(DOUBLE_CURLY_BRACKETS, startLog, url);
ResourceCommonInfo resourceCommonInfo = new ResourceCommonInfo(assetType);
ArtifactDefinition artifactDefinition = null;
* 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.
package org.openecomp.sdc.be.externalapi.servlet;
+import static com.google.common.base.Strings.isNullOrEmpty;
+
import com.fasterxml.jackson.databind.ObjectMapper;
import com.jcabi.aspects.Loggable;
import fj.data.Either;
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.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
+import javax.inject.Inject;
+import javax.servlet.http.HttpServletRequest;
+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.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
import org.apache.commons.lang3.StringUtils;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.openecomp.sdc.exception.ResponseFormat;
import org.springframework.stereotype.Controller;
-import javax.inject.Inject;
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-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.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
-import static com.google.common.base.Strings.isNullOrEmpty;
-
-
@Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
@Path("/v1/catalog")
-@Tags({@Tag(name = "SDC External APIs")})
-@Servers({@Server(url = "/sdc")})
+@Tag(name = "SDC External APIs")
+@Server(url = "/sdc")
@Controller
public class CrudExternalServlet extends AbstractValidationsServlet {
ResourceCommonInfo resourceCommonInfo = new ResourceCommonInfo(ComponentTypeEnum.RESOURCE.getValue());
Service service = null;
- ServletContext context = request.getSession().getServletContext();
try {
// Validate X-ECOMP-InstanceID Header
if (responseWrapper.isEmpty()) {
}
//validate name exist
- if(responseWrapper.isEmpty()){
- if(isNullOrEmpty(resource.getName())){
+ if(responseWrapper.isEmpty() && isNullOrEmpty(resource.getName())){
responseWrapper.setInnerElement(getComponentsUtils().getResponseFormat(
ActionStatus.MISSING_COMPONENT_NAME, ComponentTypeEnum.RESOURCE.getValue()));
-
- }
}
if(responseWrapper.isEmpty()){
validateHttpCspUserIdHeader(request.getHeader(Constants.USER_ID_HEADER),responseWrapper);
}
// Validate assetType
- if (responseWrapper.isEmpty()) {
- if( !AssetTypeEnum.RESOURCES.getValue().equals(assetType) && !AssetTypeEnum.SERVICES.getValue().equals(assetType)){
+ if (responseWrapper.isEmpty()
+ && !AssetTypeEnum.RESOURCES.getValue().equals(assetType)
+ && !AssetTypeEnum.SERVICES.getValue().equals(assetType)) {
responseWrapper.setInnerElement(getComponentsUtils().getResponseFormat(ActionStatus.RESTRICTED_OPERATION));
- }
}
return responseWrapper;
* 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.
import io.swagger.v3.oas.annotations.Parameter;
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.io.IOException;
+import javax.inject.Inject;
+import javax.servlet.http.HttpServletRequest;
+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.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
import org.apache.commons.lang3.StringUtils;
import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
import org.openecomp.sdc.be.components.impl.ResourceImportManager;
import org.openecomp.sdc.exception.ResponseFormat;
import org.springframework.stereotype.Controller;
-import javax.inject.Inject;
-import javax.servlet.http.HttpServletRequest;
-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.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.io.IOException;
-
/**
* Created by chaya on 10/17/2017.
*/
@SuppressWarnings("ALL")
@Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
@Path("/v1/catalog")
-@Tags({@Tag(name = "SDC External APIs")})
-@Servers({@Server(url = "/sdc")})
+@Tag(name = "SDC External APIs")
+@Server(url = "/sdc")
@Controller
public class ServiceActivationServlet extends AbstractValidationsServlet {
* 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.
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.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Type;
import org.springframework.stereotype.Controller;
/**
- * Root resource (exposed at "/" path) .json
+ * Root resource (exposed at "/" path) .json.
*/
@Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
@Path("/v1/catalog")
-@Tags({@Tag(name = "SDC Internal APIs")})
-@Servers({@Server(url = "/sdc2/rest")})
+@Tag(name = "SDC Internal APIs")
+@Server(url = "/sdc2/rest")
@Controller
public class ComponentInstanceServlet extends AbstractValidationsServlet {
private static final LoggerSupportability loggerSupportability = LoggerSupportability.getLogger(ComponentInstanceServlet.class.getName());
private final GroupBusinessLogic groupBL;
- private final ComponentInstanceBusinessLogic componentInstanceBusinessLogic;
private final ComponentNodeFilterBusinessLogic nodeFilterBusinessLogic;
ComponentNodeFilterBusinessLogic nodeFilterBusinessLogic) {
super(userBusinessLogic, componentInstanceBL, componentsUtils, servletUtils, resourceImportManager);
this.groupBL = groupBL;
- this.componentInstanceBusinessLogic = componentInstanceBL;
this.nodeFilterBusinessLogic = nodeFilterBusinessLogic;
}
@HeaderParam(value = Constants.USER_ID_HEADER) @Parameter(description = "USER_ID of modifier user",
required = true) String userId,
@Context final HttpServletRequest request) {
-
+
validateNotEmptyBody(data);
ComponentInstance componentInstance = null;
try {
log.debug(START_HANDLE_REQUEST_OF, url);
loggerSupportability.log(LoggerSupportabilityActions.UPDATE_COMPONENT_INSTANCE,StatusCode.STARTED,"update Component Instance Metadata");
final String userId = request.getHeader(Constants.USER_ID_HEADER);
- componentInstanceBusinessLogic.validateUser(userId);
- try {
+ try {
+ if (componentInstanceBusinessLogic == null) {
+ log.debug(UNSUPPORTED_COMPONENT_TYPE, containerComponentType);
+ return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR,
+ containerComponentType));
+ }
+ componentInstanceBusinessLogic.validateUser(userId);
log.debug(START_HANDLE_REQUEST_OF, url);
final byte[] bytes = IOUtils.toByteArray(request.getInputStream());
final String data = new String(bytes);
final ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType);
- if (componentInstanceBusinessLogic == null) {
- log.debug(UNSUPPORTED_COMPONENT_TYPE, containerComponentType);
- return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR,
- containerComponentType));
- }
final Either<ComponentInstance, ResponseFormat> convertResponse = convertToResourceInstance(data);
if (convertResponse.isRight()) {
BeEcompErrorManager.getInstance().logBeSystemError(RESOURCE_INSTANCE_UPDATE_RESOURCE_INSTANCE);
String userId = request.getHeader(Constants.USER_ID_HEADER);
- ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType);
if (componentInstanceBusinessLogic == null) {
log.debug(UNSUPPORTED_COMPONENT_TYPE, containerComponentType);
return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, containerComponentType));
ComponentTypeEnum.SERVICE_PARAM_NAME,
ComponentTypeEnum.PRODUCT_PARAM_NAME})) @PathParam("containerComponentType") final String containerComponentType,
@Context final HttpServletRequest request) {
-
+
String url = request.getMethod() + " " + request.getRequestURI();
try {
log.debug(START_HANDLE_REQUEST_OF, url);
- ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType);
if (componentInstanceBusinessLogic == null) {
log.debug(UNSUPPORTED_COMPONENT_TYPE, containerComponentType);
return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, containerComponentType));
String url = request.getMethod() + " " + request.getRequestURI();
log.debug(START_HANDLE_REQUEST_OF, url);
- Response response = null;
loggerSupportability.log(LoggerSupportabilityActions.ASSOCIATE_RI_TO_RI, StatusCode.STARTED,"Starting to associate RI To RI for component {} ",componentId + " by " + userId );
try {
}
String userId = request.getHeader(Constants.USER_ID_HEADER);
-
String data = new String(bytes);
- ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType);
if (componentInstanceBusinessLogic == null) {
log.debug(UNSUPPORTED_COMPONENT_TYPE, containerComponentType);
return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, containerComponentType));
return buildErrorResponse(errorWrapper.getInnerElement());
}
log.debug(START_HANDLE_REQUEST_OF_UPDATE_RESOURCE_INSTANCE_PROPERTY_RECEIVED_PROPERTY_IS, propertiesToUpdate);
-
+
ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType);
if (componentInstanceBusinessLogic == null) {
log.debug(UNSUPPORTED_COMPONENT_TYPE, containerComponentType);
return buildErrorResponse(errorWrapper.getInnerElement());
}
log.debug(START_HANDLE_REQUEST_OF_UPDATE_RESOURCE_INSTANCE_PROPERTY_RECEIVED_PROPERTY_IS, inputsToUpdate);
-
+
ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType);
if (componentInstanceBusinessLogic == null) {
log.debug(UNSUPPORTED_COMPONENT_TYPE, containerComponentType);
value = Constants.USER_ID_HEADER) String userId,
@Context final HttpServletRequest request) {
-
+
loggerSupportability.log(LoggerSupportabilityActions.UPDATE_PROPERTIES, StatusCode.STARTED,"Starting to delete Resource Instance Property for component {} ",componentId + " by " + userId );
String url = request.getMethod() + " " + request.getRequestURI();
log.debug(START_HANDLE_REQUEST_OF, url);
}
String userId = request.getHeader(Constants.USER_ID_HEADER);
-
String data = new String(bytes);
- ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType);
if (componentInstanceBusinessLogic == null) {
log.debug(UNSUPPORTED_COMPONENT_TYPE, containerComponentType);
return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, containerComponentType));
log.debug(START_HANDLE_REQUEST_OF_UPDATE_RESOURCE_INSTANCE_PROPERTY_RECEIVED_PROPERTY_IS, property);
-
+
ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType);
if (componentInstanceBusinessLogic == null) {
@PathParam("componentInstanceUniqueId") final String componentInstanceUniqueId,
@Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
-
+
String url = request.getMethod() + " " + request.getRequestURI();
log.debug(GET_START_HANDLE_REQUEST_OF, url);
@PathParam("capabilityName") final String capabilityName, @PathParam("ownerId") final String ownerId,
@Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
-
+
String url = request.getMethod() + " " + request.getRequestURI();
log.debug(GET_START_HANDLE_REQUEST_OF, url);
try {
- ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType);
-
List<ComponentInstanceProperty> componentInstancePropertiesById = componentInstanceBusinessLogic.getComponentInstanceCapabilityPropertiesById(containerComponentType, containerComponentId, componentInstanceUniqueId,
capabilityType, capabilityName, ownerId, userId);
schema = @Schema(allowableValues = {ComponentTypeEnum.RESOURCE_PARAM_NAME,
ComponentTypeEnum.SERVICE_PARAM_NAME})) @PathParam("containerComponentType") final String containerComponentType,
@Context final HttpServletRequest request) {
-
+
String url = request.getMethod() + " " + request.getRequestURI();
try {
log.debug(START_HANDLE_REQUEST_OF, url);
- ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType);
if (componentInstanceBusinessLogic == null) {
log.debug(UNSUPPORTED_COMPONENT_TYPE, containerComponentType);
return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, containerComponentType));
}
- String userId = request.getHeader(Constants.USER_ID_HEADER);
Either<ComponentInstance, ResponseFormat> actionResponse = componentInstanceBusinessLogic.deleteServiceProxy();
if (actionResponse.isRight()) {
schema = @Schema(allowableValues = {ComponentTypeEnum.RESOURCE_PARAM_NAME,
ComponentTypeEnum.SERVICE_PARAM_NAME})) @PathParam("containerComponentType") final String containerComponentType,
@Context final HttpServletRequest request) {
-
+
String url = request.getMethod() + " " + request.getRequestURI();
log.debug(START_HANDLE_REQUEST_OF, url);
try {
-
- String userId = request.getHeader(Constants.USER_ID_HEADER);
-
- ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType);
if (componentInstanceBusinessLogic == null) {
log.debug(UNSUPPORTED_COMPONENT_TYPE, containerComponentType);
return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, containerComponentType));
@PathParam("componentId") final String componentId, @PathParam("relationId") final String relationId,
@Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
-
+
String url = request.getMethod() + " " + request.getRequestURI();
log.debug(GET_START_HANDLE_REQUEST_OF, url);
try {
if (convertStatus.isRight()) {
throw new ByActionStatusComponentException(convertStatus.right().value());
}
- RequirementCapabilityRelDef requirementCapabilityRelDef = convertStatus.left().value();
- return requirementCapabilityRelDef;
+ return convertStatus.left().value();
}
public <T> Either<T, ActionStatus> convertJsonToObject(String data, Class<T> clazz) {
if (newComponentInstanceId == null){
return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.MISSING_NEW_COMPONENT_INSTANCE));
}
-
+
String url = request.getMethod() + " " + request.getRequestURI();
log.debug(START_HANDLE_REQUEST_OF, url);
- ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType);
if (componentInstanceBusinessLogic == null) {
log.debug(UNSUPPORTED_COMPONENT_TYPE, containerComponentType);
return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, containerComponentType));
if (componentInstanceBusinessLogic == null) {
- log.error("Unsupported component type {}", containerComponentType);
+ log.error(UNSUPPORTED_COMPONENT_TYPE, containerComponentType);
return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, containerComponentType));
}
if (convertResponse.isRight()) {
BeEcompErrorManager.getInstance().logBeSystemError("Resource Instance - batchDeleteResourceInstances");
- log.error("Failed to convert received data to BE format.");
+ log.error(FAILED_TO_CONVERT_RECEIVED_DATA_TO_BE_FORMAT);
return buildErrorResponse(convertResponse.right().value());
}
@HeaderParam(value = Constants.USER_ID_HEADER) String userId,
@Parameter(description = "RelationshipInfo", required = true) String data,
@Context final HttpServletRequest request) {
-
+
try {
if (data == null || data.length() == 0) {
ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType);
if (componentInstanceBusinessLogic == null) {
- log.debug("Unsupported component type {}", containerComponentType);
+ log.debug(UNSUPPORTED_COMPONENT_TYPE, containerComponentType);
return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, containerComponentType));
}