Removed constants associated with audit/metrics logging.
Deleted unused code. Some other safe cleanup and refactoring.
Change-Id: Idfda72e1fb27ca695a74f2a09cb46381c9caed1a
Issue-ID: SDC-772
Signed-off-by: vempo <vitaliy.emporopulo@amdocs.com>
import org.openecomp.core.utilities.applicationconfig.type.ConfigurationData;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.sdc.applicationconfig.ApplicationConfigManager;
-import org.openecomp.sdc.logging.types.LoggerConstants;
-import org.openecomp.sdc.logging.types.LoggerServiceName;
import org.openecomp.sdcrests.applicationconfig.rest.ApplicationConfiguration;
import org.openecomp.sdcrests.applicationconfig.rest.mapping.MapApplicationConfigEntityToApplicationConfigDto;
import org.openecomp.sdcrests.applicationconfig.rest.mapping.MapConfigurationDataToConfigurationDataDto;
import org.openecomp.sdcrests.applicationconfiguration.types.ApplicationConfigDto;
import org.openecomp.sdcrests.applicationconfiguration.types.ConfigurationDataDto;
import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper;
-import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
@Override
public Response insertToTable(String namespace, String key, InputStream fileContainingSchema) {
- MDC.put(LoggerConstants.SERVICE_NAME,
- LoggerServiceName.Insert_To_ApplicationConfig_Table.toString());
String value = new String(FileUtils.toByteArray(fileContainingSchema));
-
applicationConfigManager.insertIntoTable(namespace, key, value);
return Response.ok().build();
}
@Override
public Response getFromTable(String namespace, String key) {
- MDC.put(LoggerConstants.SERVICE_NAME,
- LoggerServiceName.Get_From_ApplicationConfig_Table.toString());
ConfigurationData value = applicationConfigManager.getFromTable(namespace, key);
ConfigurationDataDto valueDto = new MapConfigurationDataToConfigurationDataDto()
.applyMapping(value, ConfigurationDataDto.class);
@Override
public Response getListOfConfigurationByNamespaceFromTable(String namespace) {
- MDC.put(LoggerConstants.SERVICE_NAME, LoggerServiceName
- .Get_List_From_ApplicationConfig_Table_By_Namespace.toString());
Collection<ApplicationConfigEntity> applicationConfigEntities =
applicationConfigManager.getListOfConfigurationByNamespace(namespace);
GenericCollectionWrapper<ApplicationConfigDto> applicationConfigWrapper =
package org.openecomp.sdcrests.validation.rest.services;
-import org.openecomp.sdc.datatypes.error.ErrorLevel;
-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.LoggerServiceName;
-import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
import org.openecomp.sdc.validation.UploadValidationManager;
import org.openecomp.sdc.validation.types.ValidationFileResponse;
import org.openecomp.sdcrests.validation.rest.Validation;
import org.openecomp.sdcrests.validation.rest.mapping.MapValidationFileResponseToValidationFileResponseDto;
import org.openecomp.sdcrests.validation.types.ValidationFileResponseDto;
-import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
@Override
public Response validateFile(String type, InputStream fileToValidate) {
- MDC.put(LoggerConstants.SERVICE_NAME,
- LoggerServiceName.Validate.toString());
- ValidationFileResponse validationFileResponse = null;
+ ValidationFileResponse validationFileResponse;
try {
validationFileResponse = uploadValidationManager.validateFile(type, fileToValidate);
} catch (IOException exception) {
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.types.LoggerConstants;
-import org.openecomp.sdc.logging.types.LoggerServiceName;
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.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.types.LoggerConstants;
-import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
import org.openecomp.sdc.vendorsoftwareproduct.errors.ComponentDependencyModelErrorBuilder;
import org.openecomp.sdcrests.mapping.MappingBase;
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.types.LoggerConstants;
-import org.openecomp.sdc.logging.types.LoggerErrorCode;
-import org.openecomp.sdc.logging.types.LoggerErrorDescription;
-import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
import java.util.Collection;
*/
public class ApplicationConfigManagerImpl implements ApplicationConfigManager {
- private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
+ private final Logger log = LoggerFactory.getLogger(this.getClass().getName());
private static final String SCHEMA_GENERATOR_INITIALIZATION_ERROR =
"SCHEMA_GENERATOR_INITIALIZATION_ERROR";
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;
import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList;
import org.openecomp.sdc.heat.services.tree.HeatTreeManager;
import org.openecomp.sdc.heat.services.tree.HeatTreeManagerUtil;
-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.validation.UploadValidationManager;
import org.openecomp.sdc.validation.types.ValidationFileResponse;
import org.openecomp.sdc.validation.util.ValidationManagerUtil;
-import org.slf4j.MDC;
import java.io.ByteArrayInputStream;
import java.io.File;
}
if (CollectionUtils.isNotEmpty(folderList)) {
- MDC.put(LoggerConstants.ERROR_DESCRIPTION, LoggerErrorDescription.INVALID_ZIP);
throw new CoreException((new ErrorCode.ErrorCodeBuilder())
.withMessage(Messages.ZIP_SHOULD_NOT_CONTAIN_FOLDERS.getErrorMessage())
.withId(Messages.ZIP_SHOULD_NOT_CONTAIN_FOLDERS.getErrorMessage())
HeatTreeManager tree;
ValidationStructureList validationStructureList = new ValidationStructureList();
- if (type.toLowerCase().equals("heat")) {
+ if (type.equalsIgnoreCase("heat")) {
FileContentHandler content = getFileContent(fileToValidate);
if (!content.containsFile(SdcCommon.MANIFEST_NAME)) {
throw new CoreException((new ErrorCode.ErrorCodeBuilder())
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.types.LoggerConstants;
-import org.openecomp.sdc.logging.types.LoggerErrorCode;
-import org.openecomp.sdc.logging.types.LoggerErrorDescription;
-import org.openecomp.sdc.logging.types.LoggerServiceName;
-import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
import org.openecomp.sdc.vendorlicense.VendorLicenseConstants;
import org.openecomp.sdc.vendorlicense.VendorLicenseManager;
import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDao;
private EntitlementPoolDao entitlementPoolDao;
private LicenseKeyGroupDao licenseKeyGroupDao;
private LimitDao limitDao;
- private static final String VLM_ID = "VLM id";
- private static final String EP_LKGID = "EP/LKGId";
- private static final String VLM_ID_LKG_ID = "VLM id, LKG id";
- private static final String VLM_ID_LA_ID = "VLM id, LA id";
- private static final String VLM_ID_FG_ID = "VLM id, FG id";
- private static final String VLM_ID_EP_ID = "VLM id, EP id";
private static final String EP_POOL_START_TIME = "T00:00:00Z";
private static final String EP_POOL_EXPIRY_TIME = "T23:59:59Z";
private static final DateTimeFormatter FORMATTER
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.types.LoggerConstants;
-import org.openecomp.sdc.logging.types.LoggerErrorDescription;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity;
import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse;
-import org.slf4j.MDC;
import java.io.File;
import java.util.ArrayList;
*/
public static void validateContentZipData(FileContentHandler contentMap,
Map<String, List<ErrorMessage>> errors) {
- MDC.put(LoggerConstants.ERROR_DESCRIPTION, LoggerErrorDescription.INVALID_ZIP);
if (contentMap.getFileList().isEmpty()) {
ErrorMessage.ErrorMessageUtil.addMessage(SdcCommon.UPLOAD_FILE, errors)
.add(new ErrorMessage(ErrorLevel.ERROR, Messages.INVALID_ZIP_FILE.getErrorMessage()));
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.logging.types.LoggerConstants;
-import org.openecomp.sdc.logging.types.LoggerErrorDescription;
-import org.slf4j.MDC;
import java.io.ByteArrayInputStream;
import java.io.File;
public class CommonUtil {
+ private CommonUtil() {
+ // prevent instantiation
+ }
+
public static FileContentHandler validateAndUploadFileContent(OnboardingTypesEnum type,
byte[] uploadedFileData)
throws IOException {
private static void validateNoFolders(List<String> folderList) {
if (CollectionUtils.isNotEmpty(folderList)) {
- MDC.put(LoggerConstants.ERROR_DESCRIPTION, LoggerErrorDescription.INVALID_ZIP);
throw new CoreException((new ErrorCode.ErrorCodeBuilder())
.withMessage(Messages.ZIP_SHOULD_NOT_CONTAIN_FOLDERS.getErrorMessage())
.withId(Messages.ZIP_SHOULD_NOT_CONTAIN_FOLDERS.getErrorMessage())
public static boolean isFileOriginFromZip(String fileOrigin){
return Objects.nonNull(fileOrigin)
- && fileOrigin.toLowerCase().equals(OnboardingTypesEnum.ZIP.toString());
+ && fileOrigin.equalsIgnoreCase(OnboardingTypesEnum.ZIP.toString());
}
}
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.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;
private boolean isPrivateHealingNeededByFlag(String itemId, String version, String user) {
Optional<Boolean> userHealingFlag = getHealingFlag(itemId, version, user);
- return userHealingFlag.isPresent()
- ? userHealingFlag.get()
- : isPublicHealingNeededByFlag(itemId, version);
+ return userHealingFlag.orElseGet(() -> isPublicHealingNeededByFlag(itemId, version));
}
private boolean isPublicHealingNeededByFlag(String itemId, String versionId) {
import com.datastax.driver.mapping.annotations.Table;
import com.google.common.io.ByteStreams;
import org.openecomp.sdc.common.errors.SdcRuntimeException;
-import org.openecomp.sdc.datatypes.error.ErrorLevel;
-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.dao.types.Version;
import java.io.IOException;
import com.datastax.driver.mapping.annotations.Table;
import com.google.common.io.ByteStreams;
import org.openecomp.sdc.common.errors.SdcRuntimeException;
-import org.openecomp.sdc.datatypes.error.ErrorLevel;
-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.dao.types.Version;
import java.io.IOException;
import com.datastax.driver.mapping.annotations.Table;
import com.google.common.io.ByteStreams;
import org.openecomp.sdc.common.errors.SdcRuntimeException;
-import org.openecomp.sdc.datatypes.error.ErrorLevel;
-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.dao.types.Version;
import java.io.IOException;
import com.datastax.driver.mapping.annotations.Table;
import com.google.common.io.ByteStreams;
import org.openecomp.sdc.common.errors.SdcRuntimeException;
-import org.openecomp.sdc.datatypes.error.ErrorLevel;
-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.dao.types.Version;
import java.io.IOException;
package org.openecomp.sdc.generator.core.utils;
-import org.openecomp.sdc.datatypes.error.ErrorLevel;
-import org.openecomp.sdc.logging.types.LoggerConstants;
-import org.openecomp.sdc.logging.types.LoggerErrorCode;
-import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
import org.openecomp.sdc.tosca.datatypes.ToscaElementTypes;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.tosca.datatypes.model.CapabilityDefinition;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
*/
public class GeneratorUtils {
- 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"));
+ private GeneratorUtils() {
+ // prevent instantiation
}
+ //TODO : Read from configuration
+ private static final List<String> SUPPORTED_CAPABILITIES = Arrays.asList("host", "os", "endpoint", "scalable");
+ private static final List<String> SUPPORTED_REQUIREMENTS = Collections.singletonList("link");
/**
* Add service template to tosca service model.
for (Map.Entry<String, RequirementDefinition> requirementDefinitionEntry :
requirementDefinitionMap.entrySet()) {
String requirementKey = requirementDefinitionEntry.getKey();
- if (!supportedRequirements.contains(requirementKey)) {
+ if (!SUPPORTED_REQUIREMENTS.contains(requirementKey)) {
iterator.remove();
}
}
Map.Entry<String, CapabilityDefinition> capabilityDefinitionEntry = iterator.next();
//Expected Capability is of the format <capabilityId>_<componentName>
String capabilityKey = capabilityDefinitionEntry.getKey().split("_")[0];
- if (!supportedCapabilities.contains(capabilityKey)) {
+ if (!SUPPORTED_CAPABILITIES.contains(capabilityKey)) {
iterator.remove();
}
}
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.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;
public class HeatValidationService {
private static final Logger LOGGER = LoggerFactory.getLogger(HeatValidator.class);
- private static final String NESTED_FILE = "nested file";
private static final String NO_CONTENT_IN_FILE_MSG = "The file ' %s ' has no content";
private HeatValidationService(){
Collection<Resource> nestedResources =
nestedHeatOrchestrationTemplate.getResources() == null ? null
: nestedHeatOrchestrationTemplate.getResources().values();
- boolean isNestedLoopExist = addNestedFilesInLoopAndCheckIfNestedLoopExist(nestedResources,
+ return addNestedFilesInLoopAndCheckIfNestedLoopExist(nestedResources,
callingFileName, filesInLoop, globalContext);
- return isNestedLoopExist;
}
private static boolean addNestedFilesInLoopAndCheckIfNestedLoopExist(
Collection<Resource> nestedResources,String callingFileName,
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.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;
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()
+ Collection<Object> resourcePropertiesValues =
+ value.getProperties() == null ? null : value.getProperties()
.values();
if (CollectionUtils.isNotEmpty(resourcePropertiesValues)) {
for (Object propertyValue : resourcePropertiesValues) {
heatOrchestrationTemplate,
GlobalValidationContext
globalContext) {
- Map<String, Parameter> parametersMap = heatOrchestrationTemplate.getParameters() == null ? null
- : heatOrchestrationTemplate.getParameters();
+ Map<String, Parameter> parametersMap = heatOrchestrationTemplate.getParameters();
if (parametersMap != null && MapUtils.isNotEmpty(parametersMap)) {
for (Map.Entry<String, Parameter> parameterEntry : parametersMap.entrySet()) {
import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
-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.validation.Validator;
import org.openecomp.sdc.heat.services.HeatStructureUtil;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
-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 com.fasterxml.jackson.dataformat.xml.XmlMapper;
import org.openecomp.sdc.common.errors.CoreException;
-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.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.vendorlicense.VendorLicenseConstants;
import org.openecomp.sdc.vendorlicense.errors.JsonErrorBuilder;
public abstract class XmlArtifact {
XmlMapper xmlMapper = new XmlMapper();
- private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
+ private final Logger log = LoggerFactory.getLogger(this.getClass().getName());
abstract void initMapper();
*/
public String toXml() {
initMapper();
- String xml = "";
+ String xml;
try {
xml = xmlMapper.writeValueAsString(this);
} catch (com.fasterxml.jackson.core.JsonProcessingException exception) {
log.debug("",exception);
throw new CoreException(new JsonErrorBuilder(exception.getMessage()).build());
-
}
return xml.replaceAll(VendorLicenseConstants.VENDOR_LICENSE_MODEL_ARTIFACT_REGEX_REMOVE, "");
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.openecomp.core.utilities.json.JsonUtil;
-import org.openecomp.sdc.datatypes.error.ErrorLevel;
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.VendorInfo;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
-import org.openecomp.sdc.logging.types.LoggerConstants;
-import org.openecomp.sdc.logging.types.LoggerErrorCode;
-import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupModel;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
private static final VendorLicenseFacade vendorLicenseFacade =
VendorLicenseFacadeFactory.getInstance().createInterface();
- private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
+ private final Logger log = LoggerFactory.getLogger(this.getClass().getName());
/**
* Gets vendor name for the vsp.
private Optional<ComputeFlavor> getComputeFlavor(String vspId, Version version,
String componentId, String computeFlavorId) {
ComputeFlavor computeFlavor = null;
- ComputeEntity computeQuestionnaire = null;
+ ComputeEntity computeQuestionnaire;
try {
computeQuestionnaire = computeDao.getQuestionnaireData(vspId, version, componentId,
computeFlavorId);
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.openecomp.sdc.common.errors.CoreException;
-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.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.datatypes.ToscaCapabilityType;
import org.openecomp.sdc.tosca.datatypes.ToscaFunctions;
import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
List<ServiceTemplate> toscaServiceTemplates = toscaServiceModel.getServiceTemplates().entrySet()
.stream()
.filter(map -> map.getKey().equals(mainTemplate))
- .map(map -> map.getValue())
+ .map(Map.Entry::getValue)
.collect(Collectors.toList());
ServiceTemplate serviceTemplate = toscaServiceTemplates.get(0);
network.setName(networkId);
Optional<Boolean> networkDhcpValue =
getNetworkDhcpValue(serviceTemplate, networkNodeTemplates.get(networkId));
- network.setDhcp(networkDhcpValue.isPresent() ? networkDhcpValue.get() : true);
+ network.setDhcp(networkDhcpValue.orElse(true));
networks.add(network);
}
return networks;
*/
public class VersioningUtil {
+ private VersioningUtil() {
+ // prevent instantiation
+ }
+
/**
* Validate entity existence.
*
T inputEntity,
String firstClassCitizenType) {
if (retrievedEntity == null) {
- //MdcDataErrorMessage.createErrorMessageAndUpdateMDC(LoggerServiceName
- // .getServiceName(LoggerServiceName.Submit_Entity),
- // LoggerConstants.TARGET_ENTITY_DB, LoggerTragetServiceName.SUBMIT_ENTITY,
- // ErrorLevel.ERROR.name(), null, LoggerErrorDescription.SUBMIT_ENTITY);
throw new CoreException(new VersionableSubEntityNotFoundErrorBuilder(
inputEntity.getEntityType(),
inputEntity.getId(),
}
}
- if (nonExistingIds.size() > 0) {
- //MdcDataErrorMessage.createErrorMessageAndUpdateMDC
- // (LoggerServiceName.getServiceName(LoggerServiceName.Submit_Entity),
- // LoggerConstants.TARGET_ENTITY_DB, LoggerTragetServiceName.SUBMIT_ENTITY,
- // ErrorLevel.ERROR.name(), null, LoggerErrorDescription.SUBMIT_ENTITY);
+ if (!nonExistingIds.isEmpty()) {
if (nonExistingIds.size() == 1) {
throw new CoreException(new VersionableSubEntityNotFoundErrorBuilder(
entity.getEntityType(),
.filter(entityId -> !retrievedContainedEntityIds.contains(entityId))
.collect(Collectors.toList());
- if (nonExistingIds.size() > 0) {
+ if (!nonExistingIds.isEmpty()) {
if (nonExistingIds.size() == 1) {
- //MdcDataErrorMessage.createErrorMessageAndUpdateMDC(LoggerServiceName
- // .getServiceName(LoggerServiceName.Submit_Entity), LoggerConstants.TARGET_ENTITY_DB,
- // LoggerTragetServiceName.ENTIT, ErrorLevel.ERROR.name(),
- // null, LoggerErrorDescription.SUBMIT_ENTITY);
throw new CoreException(new VersionableSubEntityNotFoundErrorBuilder(
containedEntityType,
nonExistingIds.get(0),
containingEntity.getId(),
containingEntity.getVersion()).build());
}
- //MdcDataErrorMessage.createErrorMessageAndUpdateMDC(LoggerServiceName
- // .getServiceName(LoggerServiceName.Submit_Entity),
- // LoggerConstants.TARGET_ENTITY_DB, LoggerTragetServiceName.SUBMIT_ENTITY,
- // ErrorLevel.ERROR.name(), null, LoggerErrorDescription.SUBMIT_ENTITY);
throw new CoreException(new VersionableSubEntityNotFoundErrorBuilder(
containedEntityType,
nonExistingIds,
import org.apache.commons.collections4.MapUtils;
import org.openecomp.core.utilities.CommonMethods;
import org.openecomp.sdc.common.errors.CoreException;
-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.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.datatypes.ToscaCapabilityType;
import org.openecomp.sdc.tosca.datatypes.ToscaFunctions;
import org.openecomp.sdc.tosca.datatypes.ToscaRelationshipType;
*/
public class DataModelUtil {
+ private DataModelUtil() {
+ // prevent instantiation
+ }
+
/**
* Add substitution mapping.
*/
import org.apache.commons.lang3.StringUtils;
import org.openecomp.core.utilities.CommonMethods;
import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.datatypes.error.ErrorLevel;
-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.datatypes.ToscaElementTypes;
import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
public Optional<NodeType> fetchNodeType(String nodeTypeKey, Collection<ServiceTemplate>
serviceTemplates) {
Optional<Map<String, NodeType>> nodeTypeMap = serviceTemplates.stream()
- .map(st -> st.getNode_types())
+ .map(ServiceTemplate::getNode_types)
.filter(nodeTypes -> Objects.nonNull(nodeTypes) && nodeTypes.containsKey(nodeTypeKey))
.findFirst();
- if (nodeTypeMap.isPresent()) {
- return Optional.ofNullable(nodeTypeMap.get().get(nodeTypeKey));
- }
- return Optional.empty();
+ return nodeTypeMap.map(stringNodeTypeMap -> stringNodeTypeMap.get(nodeTypeKey));
}
@Override
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.sdc.common.errors.CoreException;
-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.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.datatypes.ToscaServiceModel;
import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
import org.openecomp.sdc.tosca.exceptions.CsarCreationErrorBuilder;