summaryrefslogtreecommitdiffstats
path: root/catalog-be/src
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/AuditBaseEventFactory.java4
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/AuditingManager.java4
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistributionEngineEventFactoryManager.java6
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/externalapi/AuditExternalApiEventFactory.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditResourceEventFactoryManager.java6
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/catalog/impl/DmaapProducer.java4
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/catalog/impl/DmaapProducerHealth.java6
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/attribute/DefaultAttributeDeclarator.java15
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java48
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/ArtifactInfoImpl.java4
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineClusterHealth.java10
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DmaapConsumer.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DmaapHealth.java6
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngine.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/VfModuleArtifactPayload.java36
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/health/HealthCheckBusinessLogic.java6
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AdditionalInformationBusinessLogic.java6
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArchiveBusinessLogic.java6
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CADIHealthCheck.java4
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CategoriesImportManager.java3
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java24
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java44
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CsarValidationUtils.java6
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java18
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PropertyBusinessLogic.java22
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java131
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CheckinTransition.java3
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/utils/MapUtils.java9
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java47
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/LifecycleServlet.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java7
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaCapability.java3
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditResourceEventFactoryManangerTest.java4
35 files changed, 242 insertions, 262 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/AuditBaseEventFactory.java b/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/AuditBaseEventFactory.java
index 986b60bdc8..a3367a3ab5 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/AuditBaseEventFactory.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/AuditBaseEventFactory.java
@@ -34,11 +34,11 @@ public abstract class AuditBaseEventFactory implements AuditEventFactory {
private AuditingActionEnum action;
- public AuditBaseEventFactory(AuditingActionEnum action) {
+ protected AuditBaseEventFactory(AuditingActionEnum action) {
this.action = Objects.requireNonNull(action);
}
- public AuditBaseEventFactory() {
+ protected AuditBaseEventFactory() {
}
public static String buildUserNameExtended(User user) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/AuditingManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/AuditingManager.java
index 71306666c4..3e37691546 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/AuditingManager.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/AuditingManager.java
@@ -23,10 +23,12 @@ package org.openecomp.sdc.be.auditing.impl;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.openecomp.sdc.be.auditing.api.AuditEventFactory;
+import org.openecomp.sdc.be.components.impl.ResourceBusinessLogic;
import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao;
import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus;
import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent;
import org.openecomp.sdc.common.log.elements.LogFieldsMdcHandler;
+import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode;
import org.openecomp.sdc.common.log.enums.LogLevel;
import org.openecomp.sdc.common.log.enums.Severity;
import org.openecomp.sdc.common.log.wrappers.Logger;
@@ -71,7 +73,7 @@ public class AuditingManager {
private void saveEventToCassandra(AuditingGenericEvent event) {
CassandraOperationStatus result = cassandraDao.saveRecord(event);
if (result != CassandraOperationStatus.OK) {
- log.warn("Failed to persist to cassandra auditing event: {}", result.name());
+ log.warn(EcompLoggerErrorCode.SCHEMA_ERROR, "AuditingManager", "catalog-be", "Failed to persist to cassandra auditing event: {}", result.name());
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistributionEngineEventFactoryManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistributionEngineEventFactoryManager.java
index f4bb5bedf7..16556715df 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistributionEngineEventFactoryManager.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistributionEngineEventFactoryManager.java
@@ -27,6 +27,12 @@ import org.openecomp.sdc.common.util.ThreadLocalsHolder;
public class AuditDistributionEngineEventFactoryManager {
+ /**
+ * Utility classes, which are collections of static members, are not meant to be instantiated
+ */
+ private AuditDistributionEngineEventFactoryManager() {
+ }
+
public static AuditEventFactory createDistributionEngineEventFactory(AuditingActionEnum action, String environmentName,
DistributionTopicData distributionTopicData, String role, String apiKey,
String status) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/externalapi/AuditExternalApiEventFactory.java b/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/externalapi/AuditExternalApiEventFactory.java
index 3fa8c8fe47..cee65b9281 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/externalapi/AuditExternalApiEventFactory.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/externalapi/AuditExternalApiEventFactory.java
@@ -34,7 +34,7 @@ public abstract class AuditExternalApiEventFactory extends AuditBaseEventFactory
protected final ExternalApiEvent event;
- public AuditExternalApiEventFactory(AuditingActionEnum action, CommonAuditData commonAuditData, ResourceCommonInfo resourceCommonInfo,
+ protected AuditExternalApiEventFactory(AuditingActionEnum action, CommonAuditData commonAuditData, ResourceCommonInfo resourceCommonInfo,
DistributionData distributionData, ResourceVersionInfo prevParams, ResourceVersionInfo currParams,
String invariantUuid, User modifier, String artifactData) {
super(action);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditResourceEventFactoryManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditResourceEventFactoryManager.java
index 78cd70f228..863faaaa08 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditResourceEventFactoryManager.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditResourceEventFactoryManager.java
@@ -29,6 +29,12 @@ import org.openecomp.sdc.be.resources.data.auditing.model.ResourceVersionInfo;
public class AuditResourceEventFactoryManager {
+ /**
+ * Utility classes, which are collections of static members, are not meant to be instantiated
+ */
+ private AuditResourceEventFactoryManager() {
+ }
+
public static AuditEventFactory createResourceEventFactory(AuditingActionEnum action, CommonAuditData commonFields,
ResourceCommonInfo resourceCommonInfo, ResourceVersionInfo prevParams,
ResourceVersionInfo currParams, String invariantUuid, User modifier,
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/catalog/impl/DmaapProducer.java b/catalog-be/src/main/java/org/openecomp/sdc/be/catalog/impl/DmaapProducer.java
index 855ef64d9c..69fd0824af 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/catalog/impl/DmaapProducer.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/catalog/impl/DmaapProducer.java
@@ -53,7 +53,7 @@ public class DmaapProducer implements IMessageQueueHandlerProducer {
public IStatus pushMessage(ITypeMessage message) {
try {
DmaapProducerConfiguration producerConfiguration = configurationManager.getConfiguration().getDmaapProducerConfiguration();
- if (!producerConfiguration.getActive()) {
+ if (Boolean.FALSE.equals(producerConfiguration.getActive())) { // avoid NPE
LOG.info("[Microservice DMAAP] producer is disabled [re-enable in configuration->isActive],message not sent.");
dmaapHealth.report(false);
return IStatus.getServiceDisabled();
@@ -87,7 +87,7 @@ public class DmaapProducer implements IMessageQueueHandlerProducer {
public IStatus init() {
LOG.debug("MessageQueueHandlerProducer:: Start initializing");
DmaapProducerConfiguration configuration = configurationManager.getConfiguration().getDmaapProducerConfiguration();
- if (configuration.getActive()) {
+ if (Boolean.TRUE.equals(configuration.getActive())) { // avoid NPE
try {
publisher = dmaapClientFactory.createProducer(configuration);
if (publisher == null) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/catalog/impl/DmaapProducerHealth.java b/catalog-be/src/main/java/org/openecomp/sdc/be/catalog/impl/DmaapProducerHealth.java
index 4000be39b3..c0150fa3cb 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/catalog/impl/DmaapProducerHealth.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/catalog/impl/DmaapProducerHealth.java
@@ -43,7 +43,6 @@ public class DmaapProducerHealth {
private static final Logger logHealth = Logger.getLogger(DMAAP_HEALTH_LOG_CONTEXT);
private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
private HealthCheckInfo healthCheckInfo = DmaapProducerHealth.HealthCheckInfoResult.UNAVAILABLE.getHealthCheckInfo();
- private long healthCheckReadTimeout = 20;
private long reconnectInterval = 5;
private HealthCheckScheduledTask healthCheckScheduledTask = null;
private ScheduledFuture<?> scheduledFuture = null;
@@ -60,10 +59,6 @@ public class DmaapProducerHealth {
if (pollingInterval != null && pollingInterval != 0) {
reconnectInterval = pollingInterval;
}
- Integer healthCheckReadTimeoutConfig = configuration.getTimeoutMs();
- if (healthCheckReadTimeoutConfig != null) {
- this.healthCheckReadTimeout = healthCheckReadTimeoutConfig;
- }
this.healthCheckScheduledTask = new HealthCheckScheduledTask(configuration); //what is the representation? csv? delimiter? json or other
startHealthCheckTask(true);
}
@@ -149,7 +144,6 @@ public class DmaapProducerHealth {
*/
public class HealthCheckScheduledTask implements Runnable {
- private static final int TIMEOUT = 8192;
private final DmaapProducerConfiguration config;
HealthCheckScheduledTask(final DmaapProducerConfiguration config) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/attribute/DefaultAttributeDeclarator.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/attribute/DefaultAttributeDeclarator.java
index 62f4211925..79bfcc6df7 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/attribute/DefaultAttributeDeclarator.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/attribute/DefaultAttributeDeclarator.java
@@ -308,22 +308,23 @@ public abstract class DefaultAttributeDeclarator<PROPERTYOWNER extends Propertie
* @return mutated @param toscaElement , where empty maps are deleted , return null for empty map.
**/
private Object cleanEmptyNestedValuesInMap(final Object toscaElement, short loopProtectionLevel) {
- if (loopProtectionLevel <= 0 || toscaElement == null || !(toscaElement instanceof Map)) {
+ if (loopProtectionLevel <= 0 || !(toscaElement instanceof Map)) {
return toscaElement;
}
- if (MapUtils.isNotEmpty((Map) toscaElement)) {
+ Map<Object, Object> toscaMap = (Map<Object, Object>) toscaElement;
+ if (MapUtils.isNotEmpty(toscaMap)) {
Object ret;
final Set<Object> keysToRemove = new HashSet<>(); // use different set to avoid ConcurrentModificationException
- for (final Object key : ((Map) toscaElement).keySet()) {
- final Object value = ((Map) toscaElement).get(key);
+ for (final Object key : toscaMap.keySet()) {
+ final Object value = toscaMap.get(key);
ret = cleanEmptyNestedValuesInMap(value, --loopProtectionLevel);
if (ret == null) {
keysToRemove.add(key);
}
}
- final Collection set = ((Map) toscaElement).keySet();
- if (CollectionUtils.isNotEmpty(set)) {
- set.removeAll(keysToRemove);
+ final Set<Object> keySet = toscaMap.keySet();
+ if (CollectionUtils.isNotEmpty(keySet)) {
+ keySet.removeAll(keysToRemove);
}
if (isEmptyNestedMap(toscaElement)) {
return null;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
index 32e0918ef6..e227b5ed8a 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
@@ -189,7 +189,8 @@ public class YamlTemplateParsingHandler {
String policyName = policyNameValue.getKey();
emptyPolicyDef.setName(policyName);
try {
- if (policyNameValue.getValue() != null && policyNameValue.getValue() instanceof Map) {
+ // There's no need to null test in conjunction with an instanceof test. null is not an instanceof anything, so a null check is redundant.
+ if (policyNameValue.getValue() instanceof Map) {
Map<String, Object> policyTemplateJsonMap = (Map<String, Object>) policyNameValue.getValue();
validateAndFillPolicy(emptyPolicyDef, policyTemplateJsonMap);
} else {
@@ -346,7 +347,7 @@ public class YamlTemplateParsingHandler {
GroupDefinition group = new GroupDefinition();
group.setName(groupNameValue.getKey());
try {
- if (groupNameValue.getValue() != null && groupNameValue.getValue() instanceof Map) {
+ if (groupNameValue.getValue() instanceof Map) {
Map<String, Object> groupTemplateJsonMap = (Map<String, Object>) groupNameValue.getValue();
validateAndFillGroup(group, groupTemplateJsonMap);
validateUpdateGroupProperties(group, groupTemplateJsonMap);
@@ -534,8 +535,10 @@ public class YamlTemplateParsingHandler {
private void verifyMissingProperties(ActionStatus actionStatus, String name, String type, List<String> missingProperties) {
if (CollectionUtils.isNotEmpty(missingProperties)) {
- log.debug("#validateProperties - Failed to validate properties. The properties {} are missing on {} of the type {}. ",
- missingProperties.toString(), name, type);
+ if (log.isDebugEnabled()) {
+ log.debug("#validateProperties - Failed to validate properties. The properties {} are missing on {} of the type {}. ",
+ missingProperties.toString(), name, type);
+ }
rollbackWithException(actionStatus, missingProperties.toString(), missingProperties.toString(), name, type);
}
}
@@ -725,17 +728,17 @@ public class YamlTemplateParsingHandler {
@SuppressWarnings("unchecked")
private Map<String, Map<String, UploadArtifactInfo>> createArtifactsModuleFromYaml(Map<String, Object> nodeTemplateJsonMap) {
Map<String, Map<String, UploadArtifactInfo>> moduleArtifacts = new HashMap<>();
- Either<List<Object>, ResultStatusEnum> ArtifactsListRes = findFirstToscaListElement(nodeTemplateJsonMap, ARTIFACTS);
- if (ArtifactsListRes.isLeft()) {
- for (Object jsonArtifactObj : ArtifactsListRes.left().value()) {
+ Either<List<Object>, ResultStatusEnum> artifactsListRes = findFirstToscaListElement(nodeTemplateJsonMap, ARTIFACTS);
+ if (artifactsListRes.isLeft()) {
+ for (Object jsonArtifactObj : artifactsListRes.left().value()) {
String key = ((Map<String, Object>) jsonArtifactObj).keySet().iterator().next();
Object artifactJson = ((Map<String, Object>) jsonArtifactObj).get(key);
addModuleNodeTemplateArtifacts(moduleArtifacts, artifactJson, key);
}
} else {
- Either<Map<String, Map<String, Object>>, ResultStatusEnum> ArtifactsMapRes = findFirstToscaMapElement(nodeTemplateJsonMap, ARTIFACTS);
- if (ArtifactsMapRes.isLeft()) {
- for (Map.Entry<String, Map<String, Object>> entry : ArtifactsMapRes.left().value().entrySet()) {
+ Either<Map<String, Map<String, Object>>, ResultStatusEnum> artifactsMapRes = findFirstToscaMapElement(nodeTemplateJsonMap, ARTIFACTS);
+ if (artifactsMapRes.isLeft()) {
+ for (Map.Entry<String, Map<String, Object>> entry : artifactsMapRes.left().value().entrySet()) {
String artifactName = entry.getKey();
Object artifactJson = entry.getValue();
addModuleNodeTemplateArtifacts(moduleArtifacts, artifactJson, artifactName);
@@ -979,8 +982,9 @@ public class YamlTemplateParsingHandler {
@SuppressWarnings("unchecked")
private void findAndFillInputRecursively(Map<String, Object> propValue, UploadPropInfo propertyDef) {
- for (String propName : propValue.keySet()) {
- Object value = propValue.get(propName);
+ for (Map.Entry<String,Object> entry : propValue.entrySet()) {
+ String propName = entry.getKey();
+ Object value = entry.getValue();
if (value instanceof Map) {
fillInputRecursively(propName, (Map<String, Object>) value, propertyDef);
} else if (value instanceof List) {
@@ -990,7 +994,9 @@ public class YamlTemplateParsingHandler {
}
private void fillInputsRecursively(UploadPropInfo propertyDef, String propName, List<Object> inputs) {
- inputs.stream().filter(o -> o instanceof Map).forEach(o -> fillInputRecursively(propName, (Map<String, Object>) o, propertyDef));
+ inputs.stream()
+ .filter(Map.class::isInstance)
+ .forEach(o -> fillInputRecursively(propName, (Map<String, Object>) o, propertyDef));
}
@SuppressWarnings("unchecked")
@@ -1036,18 +1042,22 @@ public class YamlTemplateParsingHandler {
}
private void failOnMissingCapabilityTypes(GroupDefinition groupDefinition, List<String> missingCapTypes) {
- log.debug(
- "#failOnMissingCapabilityTypes - Failed to validate the capabilities of the group {}. The capability types {} are missing on the group type {}. ",
- groupDefinition.getName(), missingCapTypes.toString(), groupDefinition.getType());
+ if (log.isDebugEnabled()) {
+ log.debug(
+ "#failOnMissingCapabilityTypes - Failed to validate the capabilities of the group {}. The capability types {} are missing on the group type {}. ",
+ groupDefinition.getName(), missingCapTypes.toString(), groupDefinition.getType());
+ }
if (CollectionUtils.isNotEmpty(missingCapTypes)) {
rollbackWithException(ActionStatus.MISSING_CAPABILITY_TYPE, missingCapTypes.toString());
}
}
private void failOnMissingCapabilityNames(GroupDefinition groupDefinition, List<String> missingCapNames) {
- log.debug(
- "#failOnMissingCapabilityNames - Failed to validate the capabilities of the group {}. The capabilities with the names {} are missing on the group type {}. ",
- groupDefinition.getName(), missingCapNames.toString(), groupDefinition.getType());
+ if (log.isDebugEnabled()) {
+ log.debug(
+ "#failOnMissingCapabilityNames - Failed to validate the capabilities of the group {}. The capabilities with the names {} are missing on the group type {}. ",
+ groupDefinition.getName(), missingCapNames.toString(), groupDefinition.getType());
+ }
rollbackWithException(ActionStatus.MISSING_CAPABILITIES, missingCapNames.toString(), CapabilityDataDefinition.OwnerType.GROUP.getValue(),
groupDefinition.getName());
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/ArtifactInfoImpl.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/ArtifactInfoImpl.java
index 410626390c..6dc0d9ade9 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/ArtifactInfoImpl.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/ArtifactInfoImpl.java
@@ -64,8 +64,8 @@ public class ArtifactInfoImpl implements IArtifactInfo {
public static List<ArtifactInfoImpl> convertToArtifactInfoImpl(Service service, ComponentInstance resourceInstance,
Collection<ArtifactDefinition> list) {
List<ArtifactInfoImpl> ret = new ArrayList<>();
- Map<String, List<ArtifactDefinition>> artifactIdToDef = list.stream().collect(Collectors.groupingBy(ArtifactDefinition::getUniqueId));
if (list != null) {
+ Map<String, List<ArtifactDefinition>> artifactIdToDef = list.stream().collect(Collectors.groupingBy(ArtifactDefinition::getUniqueId));
for (ArtifactDefinition artifactDef : list) {
String generatedFromUUID = null;
if (artifactDef.getGeneratedFromId() != null && !artifactDef.getGeneratedFromId().isEmpty()) {
@@ -85,8 +85,8 @@ public class ArtifactInfoImpl implements IArtifactInfo {
public static List<ArtifactInfoImpl> convertServiceArtifactToArtifactInfoImpl(Service service, Collection<ArtifactDefinition> list) {
List<ArtifactInfoImpl> ret = new ArrayList<>();
- Map<String, List<ArtifactDefinition>> artifactIdToDef = list.stream().collect(Collectors.groupingBy(ArtifactDefinition::getUniqueId));
if (list != null) {
+ Map<String, List<ArtifactDefinition>> artifactIdToDef = list.stream().collect(Collectors.groupingBy(ArtifactDefinition::getUniqueId));
for (ArtifactDefinition artifactDef : list) {
String generatedFromUUID = null;
if (artifactDef.getGeneratedFromId() != null && !artifactDef.getGeneratedFromId().isEmpty()) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineClusterHealth.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineClusterHealth.java
index 1e9899b09f..b1bf59f3aa 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineClusterHealth.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineClusterHealth.java
@@ -47,7 +47,7 @@ public class DistributionEngineClusterHealth {
private static final String UEB_HEALTH_CHECK_STR = "uebHealthCheck";
private static final Logger logger = Logger.getLogger(DistributionEngineClusterHealth.class.getName());
- protected static String UEB_HEALTH_LOG_CONTEXT = "ueb.healthcheck";
+ protected static final String UEB_HEALTH_LOG_CONTEXT = "ueb.healthcheck";
//TODO use LoggerMetric instead
private static final Logger healthLogger = Logger.getLogger(UEB_HEALTH_LOG_CONTEXT);
boolean lastHealthState = false;
@@ -212,10 +212,10 @@ public class DistributionEngineClusterHealth {
}
});
- public HealthCheckScheduledTask(List<String> uebServers) {
- logger.debug("Create health check calls for servers {}", uebServers);
- if (uebServers != null) {
- for (String server : uebServers) {
+ public HealthCheckScheduledTask(List<String> localUebServers) {
+ logger.debug("Create health check calls for servers {}", localUebServers);
+ if (localUebServers != null) {
+ for (String server : localUebServers) {
healthCheckCalls.add(new UebHealthCheckCall(server, publicApiKey));
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DmaapConsumer.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DmaapConsumer.java
index 81fa3ddf1b..d0c3a732ed 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DmaapConsumer.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DmaapConsumer.java
@@ -39,7 +39,7 @@ import org.springframework.stereotype.Service;
public class DmaapConsumer {
private static final String LOG_PARTNER_NAME = "SDC.BE";
- private static final Logger logger = Logger.getLogger(DmaapClientFactory.class.getName());
+ private static final Logger logger = Logger.getLogger(DmaapConsumer.class.getName());
private static LogFieldsMdcHandler mdcFieldsHandler = new LogFieldsMdcHandler();
private final ExecutorFactory executorFactory;
private final DmaapClientFactory dmaapClientFactory;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DmaapHealth.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DmaapHealth.java
index 96ac07063d..8d053bf051 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DmaapHealth.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DmaapHealth.java
@@ -95,15 +95,15 @@ public class DmaapHealth {
log.trace("Enter init method of Dmaap health");
synchronized (DmaapHealth.class) {
this.configuration = ConfigurationManager.getConfigurationManager().getConfiguration().getDmaapConsumerConfiguration();
- Integer pollingInterval = configuration.getPollingInterval();
+ Integer pollingInterval = this.configuration.getPollingInterval();
if (pollingInterval != null && pollingInterval != 0) {
reconnectInterval = pollingInterval;
}
- Integer healthCheckReadTimeoutConfig = configuration.getTimeoutMs();
+ Integer healthCheckReadTimeoutConfig = this.configuration.getTimeoutMs();
if (healthCheckReadTimeoutConfig != null) {
this.healthCheckReadTimeout = healthCheckReadTimeoutConfig;
}
- this.healthCheckScheduledTask = new HealthCheckScheduledTask(configuration); //what is the representation? csv? delimiter? json or other
+ this.healthCheckScheduledTask = new HealthCheckScheduledTask(this.configuration); //what is the representation? csv? delimiter? json or other
startHealthCheckTask(true);
}
log.trace("Exit init method of DistributionEngineClusterHealth");
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngine.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngine.java
index 315ba1de14..26992b9c3d 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngine.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngine.java
@@ -489,7 +489,7 @@ public class EnvironmentsEngine implements INotificationHandler {
}
public OperationalEnvironmentEntry getEnvironmentByDmaapUebAddress(List<String> dmaapUebAddress) {
- return environments.values().stream().filter(e -> e.getDmaapUebAddress().stream().filter(dmaapUebAddress::contains).findAny().isPresent())
+ return environments.values().stream().filter(e -> e.getDmaapUebAddress().stream().anyMatch(dmaapUebAddress::contains))
.findFirst()
.orElseThrow(() -> new ByActionStatusComponentException(ActionStatus.DISTRIBUTION_ENV_DOES_NOT_EXIST, dmaapUebAddress.toString()));
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/VfModuleArtifactPayload.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/VfModuleArtifactPayload.java
index 9222da0105..0af2bb55ed 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/VfModuleArtifactPayload.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/VfModuleArtifactPayload.java
@@ -23,44 +23,30 @@ import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.Optional;
import java.util.stream.Collectors;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.model.GroupDefinition;
import org.openecomp.sdc.be.model.GroupInstance;
import org.openecomp.sdc.be.model.GroupInstanceProperty;
-import org.openecomp.sdc.be.model.GroupProperty;
import org.openecomp.sdc.common.api.Constants;
public class VfModuleArtifactPayload {
- private String vfModuleModelName, vfModuleModelInvariantUUID, vfModuleModelVersion, vfModuleModelUUID, vfModuleModelCustomizationUUID, vfModuleModelDescription;
- private Boolean isBase;
+ private String vfModuleModelName;
private List<String> artifacts;
private Map<String, Object> properties;
public VfModuleArtifactPayload(GroupDefinition group) {
vfModuleModelName = group.getName();
- vfModuleModelInvariantUUID = group.getInvariantUUID();
- vfModuleModelVersion = group.getVersion();
- vfModuleModelUUID = group.getGroupUUID();
- vfModuleModelDescription = group.getDescription();
artifacts = group.getArtifactsUuid();
// Base Value is set from properties
- setBaseValue(group);
}
public VfModuleArtifactPayload(GroupInstance group) {
vfModuleModelName = group.getGroupName();
- vfModuleModelInvariantUUID = group.getInvariantUUID();
- vfModuleModelVersion = group.getVersion();
- vfModuleModelUUID = group.getGroupUUID();
- vfModuleModelCustomizationUUID = group.getCustomizationUUID();
- vfModuleModelDescription = group.getDescription();
artifacts = new ArrayList<>(group.getArtifactsUuid() != null ? group.getArtifactsUuid() : new LinkedList<>());
artifacts.addAll(group.getGroupInstanceArtifactsUuid() != null ? group.getGroupInstanceArtifactsUuid() : new LinkedList<>());
// Base Value is set from properties
- setBaseValue(group);
if (group.convertToGroupInstancesProperties() != null) {
setProperties(group.convertToGroupInstancesProperties());
}
@@ -72,26 +58,6 @@ public class VfModuleArtifactPayload {
return thisCounter.compareTo(otherCounter);
}
- private void setBaseValue(GroupInstance group) {
- if (group.convertToGroupInstancesProperties() != null) {
- Optional<GroupInstanceProperty> findBaseProperty = group.convertToGroupInstancesProperties().stream()
- .filter(p -> p.getName().equals(Constants.IS_BASE)).findAny();
- if (findBaseProperty.isPresent()) {
- isBase = Boolean.valueOf(findBaseProperty.get().getValue());
- }
- }
- }
-
- private void setBaseValue(GroupDefinition group) {
- if (group.getProperties() != null) {
- Optional<GroupProperty> findBaseProperty = group.convertToGroupProperties().stream().filter(p -> p.getName().equals(Constants.IS_BASE))
- .findAny();
- if (findBaseProperty.isPresent()) {
- isBase = Boolean.valueOf(findBaseProperty.get().getValue());
- }
- }
- }
-
public List<String> getArtifacts() {
return artifacts;
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/health/HealthCheckBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/health/HealthCheckBusinessLogic.java
index a90ebf9b3c..3372d551ca 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/health/HealthCheckBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/health/HealthCheckBusinessLogic.java
@@ -168,8 +168,8 @@ public class HealthCheckBusinessLogic {
dmaapProducerHealth.getHealthCheckInfo().setVersion(appVersion);
return dmaapProducerHealth.getHealthCheckInfo();
} else {
- log.debug("Dmaap health check disabled");
- String description = ("Dmaap health check disabled");
+ String description = "Dmaap health check disabled";
+ log.debug(description);
return new HealthCheckInfo(HC_COMPONENT_DMAAP_PRODUCER, DOWN, null, description);
}
}
@@ -210,12 +210,10 @@ public class HealthCheckBusinessLogic {
}
if (isCassandraUp) {
description = "OK";
-// healthCheckInfos.add(new HealthCheckInfo(HC_COMPONENT_CASSANDRA, UP, null, description));
healthCheckInfo.setHealthCheckStatus(HealthCheckStatus.UP);
healthCheckInfo.setDescription(description);
} else {
description = "Cassandra is down";
-// healthCheckInfos.add(new HealthCheckInfo(HC_COMPONENT_CASSANDRA, DOWN, null, description));
healthCheckInfo.setDescription(description);
}
return healthCheckInfo;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AdditionalInformationBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AdditionalInformationBusinessLogic.java
index c3efa610fc..837b1185f3 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AdditionalInformationBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AdditionalInformationBusinessLogic.java
@@ -156,10 +156,8 @@ public class AdditionalInformationBusinessLogic extends BaseBusinessLogic {
result = valueValidRes.right().value();
} else {
String newValue = valueValidRes.left().value();
- if (log.isTraceEnabled()) {
- if (value != null && !value.equals(newValue)) {
- log.trace("The additional information value was normalized from {} to {}", value, newValue);
- }
+ if (log.isTraceEnabled() && (value != null && !value.equals(newValue))) {
+ log.trace("The additional information value was normalized from {} to {}", value, newValue);
}
additionalInfoParameterInfo.setValue(newValue);
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArchiveBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArchiveBusinessLogic.java
index 34b01c7fd0..58a0ebf41a 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArchiveBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArchiveBusinessLogic.java
@@ -139,7 +139,7 @@ public class ArchiveBusinessLogic {
return comps.stream().collect(Collectors.groupingBy(cmpt -> ComponentTypeEnum.findParamByType(cmpt.getComponentType())));
} else {
log.info("No components found");
- return new HashMap();
+ return new HashMap<>();
}
} catch (Exception e) {
log.error("Error fetching archived elements", e);
@@ -182,7 +182,9 @@ public class ArchiveBusinessLogic {
}
protected Either<Component, ResponseFormat> sendNotificationToFacade(String componentId, ChangeTypeEnum changeStatus) {
- log.debug("build {} notification for facade start", changeStatus.name());
+ if (log.isDebugEnabled()) {
+ log.debug("build {} notification for facade start", changeStatus.name());
+ }
Either<Component, StorageOperationStatus> toscaElement = toscaOperationFacade.getToscaElement(componentId);
Component component = toscaElement.left().value();
ActionStatus status = catalogOperations.updateCatalog(changeStatus, component);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
index 849e3c8bdb..55c4353f17 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
@@ -2947,7 +2947,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
}
sb.append(ConfigurationManager.getConfigurationManager().getConfiguration().getHeatEnvArtifactFooter());
// DE265919 fix
- return sb.toString().replaceAll("\\\\n", "\n");
+ return sb.toString().replace("\\\\n", "\n");
}
/**
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CADIHealthCheck.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CADIHealthCheck.java
index 2fc012b720..bb12b317c6 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CADIHealthCheck.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CADIHealthCheck.java
@@ -47,7 +47,9 @@ public class CADIHealthCheck {
}
public void setIsCADIUp(HealthCheckInfo.HealthCheckStatus cadiStatus) {
- log.debug("Setting cadiHealthCheckInstance status to: {}", cadiStatus.toString());
+ if (log.isDebugEnabled()) {
+ log.debug("Setting cadiHealthCheckInstance status to: {}", cadiStatus.toString());
+ }
isCADIUpOrDown = cadiStatus;
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CategoriesImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CategoriesImportManager.java
index 1efb4b6b9c..12eb8379b2 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CategoriesImportManager.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CategoriesImportManager.java
@@ -140,8 +140,7 @@ public class CategoriesImportManager {
}
}
log.debug("Failed to create groupingcategory for {} category {} subcategory {} grouping {} error {}", entry.getKey(), category.getName(),
- subcategory.getName(), grouping != null ? grouping.getName() : null,
- createdGrouping != null && createdGrouping.right() != null ? createdGrouping.right().value() : null);
+ subcategory.getName(), grouping != null ? grouping.getName() : null, createdGrouping.right().value());
return Either.right(componentsUtils.getResponseFormat(createdGrouping.right().value()));
} else {
log.debug("createGroupingDeo: create Grouping was successful {}", createdGrouping.left().value());
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
index 9ce54c2cc8..afb84a9ea8 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
@@ -111,7 +111,6 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
protected ComponentProjectCodeValidator componentProjectCodeValidator;
protected CatalogOperation catalogOperations;
protected ComponentIconValidator componentIconValidator;
- protected ComponentValidator componentValidator;
protected ComponentTagsValidator componentTagsValidator;
protected ComponentNameValidator componentNameValidator;
protected ComponentContactIdValidator componentContactIdValidator;
@@ -131,7 +130,6 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
this.componentContactIdValidator = componentContactIdValidator;
this.componentNameValidator = componentNameValidator;
this.componentTagsValidator = componentTagsValidator;
- this.componentValidator = componentValidator;
this.componentIconValidator = componentIconValidator;
this.componentProjectCodeValidator = componentProjectCodeValidator;
this.componentDescriptionValidator = componentDescriptionValidator;
@@ -887,16 +885,20 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
Either<Map<String, PropertyDefinition>, String> validPropertiesMerge = validateNoConflictingProperties(genericTypeProps,
((Resource) componentToCheckOut).getProperties());
if (validPropertiesMerge.isRight()) {
- log.debug("property {} cannot be overriden, check out performed without upgrading to latest generic",
- validPropertiesMerge.right().value());
+ if (log.isDebugEnabled()) {
+ log.debug("property {} cannot be overriden, check out performed without upgrading to latest generic",
+ validPropertiesMerge.right().value());
+ }
return false;
}
List<AttributeDefinition> genericTypeAttributes = latestGeneric.getAttributes();
final Either<Map<String, AttributeDefinition>, String> validAttributesMerge = validateNoConflictingProperties(genericTypeAttributes,
((Resource) componentToCheckOut).getAttributes());
if (validAttributesMerge.isRight()) {
- log.debug("attribute {} cannot be overriden, check out performed without upgrading to latest generic",
- validAttributesMerge.right().value());
+ if (log.isDebugEnabled()) {
+ log.debug("attribute {} cannot be overriden, check out performed without upgrading to latest generic",
+ validAttributesMerge.right().value());
+ }
return false;
}
return true;
@@ -925,7 +927,9 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
}
Either<Map<String, InputDefinition>, String> eitherMerged = validateNoConflictingProperties(genericTypeInputs, currentList);
if (eitherMerged.isRight()) {
- log.debug("input {} cannot be overriden, check out performed without upgrading to latest generic", eitherMerged.right().value());
+ if (log.isDebugEnabled()) {
+ log.debug("input {} cannot be overriden, check out performed without upgrading to latest generic", eitherMerged.right().value());
+ }
return false;
}
componentToCheckOut.setInputs(new ArrayList<>(eitherMerged.left().value().values()));
@@ -963,8 +967,10 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
}
protected Either<Component, ResponseFormat> updateCatalog(Component component, ChangeTypeEnum changeStatus) {
- log.debug("update Catalog start with Component Type {} And Componet Name {} with change status {}", component.getComponentType().name(),
- component.getName(), changeStatus.name());
+ if (log.isDebugEnabled()) {
+ log.debug("update Catalog start with Component Type {} And Componet Name {} with change status {}",
+ component.getComponentType().name(),component.getName(), changeStatus.name());
+ }
ActionStatus status = catalogOperations.updateCatalog(changeStatus, component);
if (status != ActionStatus.OK) {
return Either.right(componentsUtils.getResponseFormat(status));
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
index 90716f9f86..8b1537a009 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
@@ -161,6 +161,14 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
+ "container {}";
private static final String SERVICE_PROXY = "serviceProxy";
private static final String ASSOCIATE_RI_TO_RI = "associateRIToRI";
+ private static final String COMPONENT_ARCHIVED = "Component is archived. Component id: {}";
+ private static final String RESTRICTED_OPERATION_ON_SERVIVE = "Restricted operation for user: {} on service {}";
+ private static final String FAILED_TO_LOCK_COMPONENT = "Failed to lock component {}";
+ private static final String RESTRICTED_OPERATION_ON_COMPONENT = "Restricted operation for user: {} on component {}";
+ private static final String RESOURCE_INSTANCE = "resource instance";
+ private static final String SERVICE = "service";
+ private static final String UPDATE_PROPERTY_CONTEXT = "UpdatePropertyValueOnComponentInstance";
+
private ComponentInstanceOperation componentInstanceOperation;
private ArtifactsBusinessLogic artifactBusinessLogic;
private ComponentInstanceMergeDataBusinessLogic compInstMergeDataBL;
@@ -1919,17 +1927,17 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
if (!ComponentValidationUtils.canWorkOnComponent(containerComponent, userId)) {
if (Boolean.TRUE.equals(containerComponent.isArchived())) {
- log.info("Component is archived. Component id: {}", componentId);
+ log.info(COMPONENT_ARCHIVED, componentId);
return Either.right(componentsUtils.getResponseFormat(ActionStatus.COMPONENT_IS_ARCHIVED, containerComponent.getName()));
}
- log.info("Restricted operation for user: {} on service {}", userId, componentId);
+ log.info(RESTRICTED_OPERATION_ON_SERVIVE, userId, componentId);
return Either.right(componentsUtils.getResponseFormat(ActionStatus.RESTRICTED_OPERATION));
}
Either<ComponentInstance, StorageOperationStatus> resourceInstanceStatus = getResourceInstanceById(containerComponent, resourceInstanceId);
if (resourceInstanceStatus.isRight()) {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND_ON_CONTAINER,
- resourceInstanceId, "resource instance", "service", componentId));
+ resourceInstanceId, RESOURCE_INSTANCE, SERVICE, componentId));
}
ComponentInstance foundResourceInstance = resourceInstanceStatus.left().value();
@@ -2019,10 +2027,10 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
if (!ComponentValidationUtils.canWorkOnComponent(containerComponent, userId)) {
if (Boolean.TRUE.equals(containerComponent.isArchived())) {
- log.info("Component is archived. Component id: {}", componentId);
+ log.info(COMPONENT_ARCHIVED, componentId);
return Either.right(componentsUtils.getResponseFormat(ActionStatus.COMPONENT_IS_ARCHIVED, containerComponent.getName()));
}
- log.info("Restricted operation for user: {} on service {}", userId, componentId);
+ log.info(RESTRICTED_OPERATION_ON_SERVIVE, userId, componentId);
return Either.right(componentsUtils.getResponseFormat(ActionStatus.RESTRICTED_OPERATION));
}
@@ -2030,7 +2038,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
resourceInstanceId);
if (resourceInstanceStatus.isRight()) {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND_ON_CONTAINER,
- resourceInstanceId, "resource instance", "service", componentId));
+ resourceInstanceId, RESOURCE_INSTANCE, SERVICE, componentId));
}
final ComponentInstance foundResourceInstance = resourceInstanceStatus.left().value();
@@ -2223,7 +2231,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
if (allDataTypesEither.isRight()) {
JanusGraphOperationStatus status = allDataTypesEither.right().value();
BeEcompErrorManager.getInstance()
- .logInternalFlowError("UpdatePropertyValueOnComponentInstance", "Failed to update property value on instance. Status is " + status,
+ .logInternalFlowError(UPDATE_PROPERTY_CONTEXT, "Failed to update property value on instance. Status is " + status,
ErrorSeverity.ERROR);
return Either.right(componentsUtils
.getResponseFormat(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status))));
@@ -2271,7 +2279,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
if (allDataTypesEither.isRight()) {
JanusGraphOperationStatus status = allDataTypesEither.right().value();
BeEcompErrorManager.getInstance()
- .logInternalFlowError("UpdatePropertyValueOnComponentInstance", "Failed to update property value on instance. Status is " + status,
+ .logInternalFlowError(UPDATE_PROPERTY_CONTEXT, "Failed to update property value on instance. Status is " + status,
ErrorSeverity.ERROR);
return Either.right(componentsUtils
.getResponseFormat(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status))));
@@ -2337,7 +2345,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
if (allDataTypesEither.isRight()) {
JanusGraphOperationStatus status = allDataTypesEither.right().value();
BeEcompErrorManager.getInstance()
- .logInternalFlowError("UpdatePropertyValueOnComponentInstance", "Failed to update attribute value on instance. Status is " + status,
+ .logInternalFlowError(UPDATE_PROPERTY_CONTEXT, "Failed to update attribute value on instance. Status is " + status,
ErrorSeverity.ERROR);
return Either.right(componentsUtils
.getResponseFormat(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status))));
@@ -2446,17 +2454,17 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
if (!ComponentValidationUtils.canWorkOnComponent(containerComponent, userId)) {
if (Boolean.TRUE.equals(containerComponent.isArchived())) {
- log.info("Component is archived. Component id: {}", componentId);
+ log.info(COMPONENT_ARCHIVED, componentId);
return Either.right(componentsUtils.getResponseFormat(ActionStatus.COMPONENT_IS_ARCHIVED, containerComponent.getName()));
}
- log.info("Restricted operation for user: {} on service {}", userId, componentId);
+ log.info(RESTRICTED_OPERATION_ON_SERVIVE, userId, componentId);
resultOp = Either.right(componentsUtils.getResponseFormat(ActionStatus.RESTRICTED_OPERATION));
return resultOp;
}
Either<ComponentInstance, StorageOperationStatus> resourceInstanceStatus = getResourceInstanceById(containerComponent, resourceInstanceId);
if (resourceInstanceStatus.isRight()) {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND_ON_CONTAINER,
- resourceInstanceId, "resource instance", "service", componentId));
+ resourceInstanceId, RESOURCE_INSTANCE, SERVICE, componentId));
}
ComponentInstance foundResourceInstance = resourceInstanceStatus.left().value();
@@ -3200,7 +3208,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
}
Component containerComponent = getResourceResult.left().value();
if (!ComponentValidationUtils.canWorkOnComponent(containerComponent, userId)) {
- log.info("Restricted operation for user: {} on component {}", userId, containerComponentId);
+ log.info(RESTRICTED_OPERATION_ON_COMPONENT, userId, containerComponentId);
return Either.right(componentsUtils.getResponseFormat(ActionStatus.RESTRICTED_OPERATION));
}
Either<ComponentInstance, StorageOperationStatus> resourceInstanceStatus = getResourceInstanceById(containerComponent,
@@ -3212,7 +3220,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
// lock resource
StorageOperationStatus lockStatus = graphLockOperation.lockComponent(containerComponentId, componentTypeEnum.getNodeType());
if (lockStatus != StorageOperationStatus.OK) {
- log.debug("Failed to lock component {}", containerComponentId);
+ log.debug(FAILED_TO_LOCK_COMPONENT, containerComponentId);
return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(lockStatus)));
}
try {
@@ -3260,7 +3268,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
}
final Component containerComponent = getResourceResult.left().value();
if (!ComponentValidationUtils.canWorkOnComponent(containerComponent, userId)) {
- log.info("Restricted operation for user: {} on component {}", userId, containerComponentId);
+ log.info(RESTRICTED_OPERATION_ON_COMPONENT, userId, containerComponentId);
return Either.right(componentsUtils.getResponseFormat(ActionStatus.RESTRICTED_OPERATION));
}
final Either<ComponentInstance, StorageOperationStatus> resourceInstanceStatus =
@@ -3272,7 +3280,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
// lock resource
final StorageOperationStatus lockStatus = graphLockOperation.lockComponent(containerComponentId, containerComponentType.getNodeType());
if (lockStatus != StorageOperationStatus.OK) {
- log.debug("Failed to lock component {}", containerComponentId);
+ log.debug(FAILED_TO_LOCK_COMPONENT, containerComponentId);
return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(lockStatus)));
}
var success = false;
@@ -3325,7 +3333,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
}
Component containerComponent = getResourceResult.left().value();
if (!ComponentValidationUtils.canWorkOnComponent(containerComponent, userId)) {
- log.info("Restricted operation for user: {} on component {}", userId, containerComponentId);
+ log.info(RESTRICTED_OPERATION_ON_COMPONENT, userId, containerComponentId);
return Either.right(componentsUtils.getResponseFormat(ActionStatus.RESTRICTED_OPERATION));
}
Either<ComponentInstance, StorageOperationStatus> resourceInstanceStatus = getResourceInstanceById(containerComponent,
@@ -3338,7 +3346,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
// lock resource
StorageOperationStatus lockStatus = graphLockOperation.lockComponent(containerComponentId, componentTypeEnum.getNodeType());
if (lockStatus != StorageOperationStatus.OK) {
- log.debug("Failed to lock component {}", containerComponentId);
+ log.debug(FAILED_TO_LOCK_COMPONENT, containerComponentId);
return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(lockStatus)));
}
try {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CsarValidationUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CsarValidationUtils.java
index fad72ccd14..c6aa1b7237 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CsarValidationUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CsarValidationUtils.java
@@ -69,6 +69,12 @@ public class CsarValidationUtils {
private static final Pattern floatPattern = Pattern.compile("^\\d{1}[.]\\d{1}$");
/**
+ * Utility classes, which are collections of static members, are not meant to be instantiated
+ */
+ private CsarValidationUtils() {
+ }
+
+ /**
* Validates Csar
*
* @param csar
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java
index fee80c65c1..0d59b141a1 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java
@@ -802,17 +802,13 @@ public class GroupBusinessLogic extends BaseBusinessLogic {
GroupInstance oldGroupInstance,
List<GroupInstanceProperty> newProperties) {
Either<GroupInstance, ResponseFormat> actionResult = null;
- Either<GroupInstance, StorageOperationStatus> updateGroupInstanceResult = null;
- List<GroupInstanceProperty> validateRes = validateReduceGroupInstancePropertiesBeforeUpdate(oldGroupInstance, newProperties);
- if (actionResult == null) {
- List<GroupInstanceProperty> validatedReducedNewProperties = validateRes;
- updateGroupInstanceResult = groupsOperation
- .updateGroupInstancePropertyValuesOnGraph(componentId, instanceId, oldGroupInstance, validatedReducedNewProperties);
- if (updateGroupInstanceResult.isRight()) {
- log.debug("Failed to update group instance {} property values. ", oldGroupInstance.getName());
- actionResult = Either
- .right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(updateGroupInstanceResult.right().value())));
- }
+ List<GroupInstanceProperty> validatedReducedNewProperties = validateReduceGroupInstancePropertiesBeforeUpdate(oldGroupInstance, newProperties);
+ Either<GroupInstance, StorageOperationStatus> updateGroupInstanceResult = groupsOperation
+ .updateGroupInstancePropertyValuesOnGraph(componentId, instanceId, oldGroupInstance, validatedReducedNewProperties);
+ if (updateGroupInstanceResult.isRight()) {
+ log.debug("Failed to update group instance {} property values. ", oldGroupInstance.getName());
+ actionResult = Either
+ .right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(updateGroupInstanceResult.right().value())));
}
if (actionResult == null) {
actionResult = Either.left(updateGroupInstanceResult.left().value());
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
index da84921a5b..d3cc6dc274 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
@@ -732,7 +732,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
}
// convert property
ToscaPropertyType type = getType(newInputDefinition.getType());
- if (type != null && newInputDefinition != null) {
+ if (type != null) {
PropertyValueConverter converter = type.getConverter();
// get inner type
SchemaDefinition schema = newInputDefinition.getSchema();
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PropertyBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PropertyBusinessLogic.java
index baab08d0cd..d7564ed50e 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PropertyBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PropertyBusinessLogic.java
@@ -136,20 +136,18 @@ public class PropertyBusinessLogic extends BaseBusinessLogic {
PropertyValueConverter converter = type.getConverter();
// get inner type
String innerType = null;
- if (newPropertyDefinition != null) {
- SchemaDefinition schema = newPropertyDefinition.getSchema();
- if (schema != null) {
- PropertyDataDefinition prop = schema.getProperty();
- if (prop != null) {
- innerType = prop.getType();
- }
- }
- String convertedValue = null;
- if (newPropertyDefinition.getDefaultValue() != null) {
- convertedValue = converter.convert(newPropertyDefinition.getDefaultValue(), innerType, allDataTypes);
- newPropertyDefinition.setDefaultValue(convertedValue);
+ SchemaDefinition schema = newPropertyDefinition.getSchema();
+ if (schema != null) {
+ PropertyDataDefinition prop = schema.getProperty();
+ if (prop != null) {
+ innerType = prop.getType();
}
}
+ String convertedValue = null;
+ if (newPropertyDefinition.getDefaultValue() != null) {
+ convertedValue = converter.convert(newPropertyDefinition.getDefaultValue(), innerType, allDataTypes);
+ newPropertyDefinition.setDefaultValue(convertedValue);
+ }
}
Either<PropertyDefinition, StorageOperationStatus> addPropertyEither = toscaOperationFacade
.addPropertyToComponent(propertyName, newPropertyDefinition, component);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
index c8162d700b..ba982826d5 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
@@ -393,10 +393,10 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
csarBusinessLogic.validateCsarBeforeCreate(resource, auditingAction, user, csarUUID);
log.debug("CsarUUID is {} - going to create resource from CSAR", csarUUID);
Resource createResourceFromCsar = createResourceFromCsar(resource, user, csarUIPayload, csarUUID);
- return updateCatalog(createResourceFromCsar, ChangeTypeEnum.LIFECYCLE).left().map(r -> (Resource) r).left().value();
+ return updateCatalog(createResourceFromCsar, ChangeTypeEnum.LIFECYCLE).left().map(Resource.class::cast).left().value();
}
final Resource createResourceByDao = createResourceByDao(resource, user, auditingAction, false, false);
- return updateCatalog(createResourceByDao, ChangeTypeEnum.LIFECYCLE).left().map(r -> (Resource) r).left().value();
+ return updateCatalog(createResourceByDao, ChangeTypeEnum.LIFECYCLE).left().map(Resource.class::cast).left().value();
}
public Resource validateAndUpdateResourceFromCsar(Resource resource, User user, Map<String, byte[]> csarUIPayload, String payloadName,
@@ -832,7 +832,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
List<ArtifactDefinition> artifactsToUpdate, List<ArtifactDefinition> artifactsToDelete,
Map<String, ArtifactDefinition> existingArtifacts) {
if (!existingArtifacts.isEmpty()) {
- extractedArtifacts.stream().forEach(a -> processNodeTypeArtifact(artifactsToUpload, artifactsToUpdate, existingArtifacts, a));
+ extractedArtifacts.forEach(a -> processNodeTypeArtifact(artifactsToUpload, artifactsToUpdate, existingArtifacts, a));
artifactsToDelete.addAll(existingArtifacts.values());
}
}
@@ -953,9 +953,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
handledNodeTypeArtifacts.addAll(handleNodeTypeArtifactsRequestRes);
}
}
- if (handleNodeTypeArtifactsRes == null) {
- handleNodeTypeArtifactsRes = Either.left(handledNodeTypeArtifacts);
- }
+ handleNodeTypeArtifactsRes = Either.left(handledNodeTypeArtifacts);
} catch (Exception e) {
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR);
handleNodeTypeArtifactsRes = Either.right(responseFormat);
@@ -969,11 +967,9 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
final Map<String, ImmutablePair<String, String>> vfcToscaNames = new HashMap<>();
final Map<String, Object> nodes = extractAllNodes(nodeTypesInfo, csarInfo);
if (!nodes.isEmpty()) {
- final Iterator<Entry<String, Object>> nodesNameEntry = nodes.entrySet().iterator();
- while (nodesNameEntry.hasNext()) {
- final Entry<String, Object> nodeType = nodesNameEntry.next();
+ for (Entry<String, Object> nodeType : nodes.entrySet()) {
final ImmutablePair<String, String> toscaResourceName = buildNestedToscaResourceName(ResourceTypeEnum.VFC.name(), vfResourceName,
- nodeType.getKey());
+ nodeType.getKey());
vfcToscaNames.put(nodeType.getKey(), toscaResourceName);
}
}
@@ -1309,7 +1305,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
throw new ByActionStatusComponentException(ActionStatus.INVALID_NODE_TEMPLATE, yamlName, resourceMetaData.getName(), nodeName);
}
// Setting name
- resourceMetaData.setName(new StringBuilder(resourceVf.getSystemName()).append(actualName).toString());
+ resourceMetaData.setName(resourceVf.getSystemName() + actualName);
// Setting type from name
final String type = resourceType.toUpperCase();
resourceMetaData.setResourceType(type);
@@ -1598,7 +1594,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return rollbackWithEither(ActionStatus.INPUTS_NOT_FOUND, inputName);
} else {
Optional<InputDefinition> inputOpt = inputs.stream().filter(p -> p.getName().equals(inputName)).findFirst();
- if (!inputOpt.isPresent()) {
+ if (inputOpt.isEmpty()) {
log.debug("#findInputByName - Failed to find the input {} ", inputName);
return rollbackWithEither(ActionStatus.INPUTS_NOT_FOUND, inputName);
} else {
@@ -1655,7 +1651,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
for (GroupDefinition group : groupsFromResource) {
Optional<GroupDefinition> op = groupsAsList.stream().filter(p -> p.getInvariantName().equalsIgnoreCase(group.getInvariantName()))
.findAny();
- if (!op.isPresent() && (group.getArtifacts() == null || group.getArtifacts().isEmpty())) {
+ if (op.isEmpty() && (group.getArtifacts() == null || group.getArtifacts().isEmpty())) {
groupsToDelete.add(group);
}
}
@@ -1719,7 +1715,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
List<ComponentInstance> componentInstances, String groupName, Map<String, String> members) {
Set<String> compInstancesNames = members.keySet();
if (CollectionUtils.isEmpty(componentInstances)) {
- String membersAstString = compInstancesNames.stream().collect(joining(","));
+ String membersAstString = String.join(",", compInstancesNames);
log.debug("The members: {}, in group: {}, cannot be found in component {}. There are no component instances.", membersAstString,
groupName, component.getNormalizedName());
throw new ByActionStatusComponentException(ActionStatus.GROUP_INVALID_COMPONENT_INSTANCE, membersAstString, groupName,
@@ -1730,13 +1726,10 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
memberNames.putAll(groups.keySet().stream().collect(toMap(g -> g, g -> "")));
Map<String, String> relevantInstances = memberNames.entrySet().stream().filter(n -> compInstancesNames.contains(n.getKey()))
.collect(toMap(Entry::getKey, Entry::getValue));
- if (relevantInstances == null || relevantInstances.size() != compInstancesNames.size()) {
- List<String> foundMembers = new ArrayList<>();
- if (relevantInstances != null) {
- foundMembers = relevantInstances.keySet().stream().collect(toList());
- }
- compInstancesNames.removeAll(foundMembers);
- String membersAstString = compInstancesNames.stream().collect(joining(","));
+ if (relevantInstances.size() != compInstancesNames.size()) {
+ List<String> foundMembers = new ArrayList<>(relevantInstances.keySet());
+ foundMembers.forEach(compInstancesNames::remove);
+ String membersAstString = String.join(",", compInstancesNames);
log.debug("The members: {}, in group: {}, cannot be found in component: {}", membersAstString, groupName, component.getNormalizedName());
throw new ByActionStatusComponentException(ActionStatus.GROUP_INVALID_COMPONENT_INSTANCE, membersAstString, groupName,
component.getNormalizedName(), getComponentTypeForResponse(component));
@@ -1809,11 +1802,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
private boolean isfillGroupMemebersRecursivlyStopCondition(String groupName, Map<String, GroupDefinition> allGroups,
Set<String> allGroupMembers) {
- boolean stop = false;
+ boolean stop = !allGroups.containsKey(groupName);
// In Case Not Group Stop
- if (!allGroups.containsKey(groupName)) {
- stop = true;
- }
// In Case Group Has no members stop
if (!stop) {
GroupDefinition groupDefinition = allGroups.get(groupName);
@@ -1859,7 +1849,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
private void handleAndAddExtractedVfcsArtifacts(List<ArtifactDefinition> vfcArtifacts, List<ArtifactDefinition> artifactsToAdd) {
List<String> vfcArtifactNames = vfcArtifacts.stream().map(ArtifactDataDefinition::getArtifactName).collect(toList());
- artifactsToAdd.stream().forEach(a -> {
+ artifactsToAdd.forEach(a -> {
if (!vfcArtifactNames.contains(a.getArtifactName())) {
vfcArtifacts.add(a);
} else {
@@ -2158,7 +2148,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
List<String> artifactsToIgnore = new ArrayList<>();
// collect IDs of Artifacts of VF which belongs to any group
if (resource.getGroups() != null) {
- resource.getGroups().stream().forEach(g -> {
+ resource.getGroups().forEach(g -> {
if (g.getArtifacts() != null && !g.getArtifacts().isEmpty()) {
artifactsToIgnore.addAll(g.getArtifacts());
}
@@ -2171,20 +2161,12 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
private boolean isNonMetaArtifact(ArtifactDefinition artifact) {
- boolean result = true;
- if (artifact.getMandatory() || artifact.getArtifactName() == null || !isValidArtifactType(artifact)) {
- result = false;
- }
- return result;
+ return !artifact.getMandatory() && artifact.getArtifactName() != null && isValidArtifactType(artifact);
}
private boolean isValidArtifactType(ArtifactDefinition artifact) {
- boolean result = true;
- if (artifact.getArtifactType() == null || ArtifactTypeEnum.parse(artifact.getArtifactType()) == ArtifactTypeEnum.VENDOR_LICENSE
- || ArtifactTypeEnum.parse(artifact.getArtifactType()) == ArtifactTypeEnum.VF_LICENSE) {
- result = false;
- }
- return result;
+ return artifact.getArtifactType() != null && ArtifactTypeEnum.parse(artifact.getArtifactType()) != ArtifactTypeEnum.VENDOR_LICENSE
+ && ArtifactTypeEnum.parse(artifact.getArtifactType()) != ArtifactTypeEnum.VF_LICENSE;
}
private Resource createResourceInstancesRelations(User user, String yamlName, Resource resource, Resource oldResource,
@@ -2455,7 +2437,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
UploadComponentInstanceInfo uploadComponentInstanceInfo) {
Optional<ComponentInstance> currentCompInstanceOpt = componentInstancesList.stream()
.filter(i -> i.getName().equals(uploadComponentInstanceInfo.getName())).findFirst();
- if (!currentCompInstanceOpt.isPresent()) {
+ if (currentCompInstanceOpt.isEmpty()) {
log.debug(COMPONENT_INSTANCE_WITH_NAME_IN_RESOURCE, uploadComponentInstanceInfo.getName(), resource.getUniqueId());
BeEcompErrorManager.getInstance()
.logInternalDataError(COMPONENT_INSTANCE_WITH_NAME + uploadComponentInstanceInfo.getName() + IN_RESOURCE, resource.getUniqueId(),
@@ -2602,7 +2584,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Map<String, UploadComponentInstanceInfo> uploadResInstancesMap,
Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> updatedInstCapabilities,
Map<ComponentInstance, Map<String, List<RequirementDefinition>>> updatedInstRequirements) {
- componentInstances.stream().forEach(i -> {
+ componentInstances.forEach(i -> {
fillUpdatedInstCapabilities(updatedInstCapabilities, i, uploadResInstancesMap.get(i.getName()).getCapabilitiesNamesToUpdate());
fillUpdatedInstRequirements(updatedInstRequirements, i, uploadResInstancesMap.get(i.getName()).getRequirementsNamesToUpdate());
});
@@ -2670,26 +2652,24 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
String resourceInstanceId = currentCompInstance.getUniqueId();
Map<String, List<UploadReqInfo>> regMap = nodesInfoValue.getRequirements();
if (regMap != null) {
- Iterator<Entry<String, List<UploadReqInfo>>> nodesRegValue = regMap.entrySet().iterator();
- while (nodesRegValue.hasNext()) {
- Entry<String, List<UploadReqInfo>> nodesRegInfoEntry = nodesRegValue.next();
+ for (Entry<String, List<UploadReqInfo>> nodesRegInfoEntry : regMap.entrySet()) {
List<UploadReqInfo> uploadRegInfoList = nodesRegInfoEntry.getValue();
for (UploadReqInfo uploadRegInfo : uploadRegInfoList) {
log.debug("Going to create relation {}", uploadRegInfo.getName());
loggerSupportability
- .log(LoggerSupportabilityActions.CREATE_RELATIONS, resource.getComponentMetadataForSupportLog(), StatusCode.STARTED,
- "Started to create relations on instance: {}", uploadRegInfo.getName());
+ .log(LoggerSupportabilityActions.CREATE_RELATIONS, resource.getComponentMetadataForSupportLog(), StatusCode.STARTED,
+ "Started to create relations on instance: {}", uploadRegInfo.getName());
String regName = uploadRegInfo.getName();
RequirementCapabilityRelDef regCapRelDef = new RequirementCapabilityRelDef();
regCapRelDef.setFromNode(resourceInstanceId);
log.debug("try to find available requirement {} ", regName);
Either<RequirementDefinition, ResponseFormat> eitherReqStatus = findAviableRequiremen(regName, yamlName, nodesInfoValue,
- currentCompInstance, uploadRegInfo.getCapabilityName());
+ currentCompInstance, uploadRegInfo.getCapabilityName());
if (eitherReqStatus.isRight()) {
log.debug("failed to find available requirement {} status is {}", regName, eitherReqStatus.right().value());
loggerSupportability
- .log(LoggerSupportabilityActions.CREATE_RELATIONS, resource.getComponentMetadataForSupportLog(), StatusCode.ERROR,
- "ERROR while search available requirement {} status is: {}", regName, eitherReqStatus.right().value());
+ .log(LoggerSupportabilityActions.CREATE_RELATIONS, resource.getComponentMetadataForSupportLog(), StatusCode.ERROR,
+ "ERROR while search available requirement {} status is: {}", regName, eitherReqStatus.right().value());
return eitherReqStatus.right().value();
}
RequirementDefinition validReq = eitherReqStatus.left().value();
@@ -2714,11 +2694,11 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (currentCapCompInstance == null) {
log.debug("The component instance with name {} not found on resource {} ", uploadRegInfo.getNode(), resource.getUniqueId());
loggerSupportability
- .log(LoggerSupportabilityActions.CREATE_RELATIONS, resource.getComponentMetadataForSupportLog(), StatusCode.ERROR,
- "ERROR component instance with name: {} not found on resource: {}", uploadRegInfo.getNode(), resource.getUniqueId());
+ .log(LoggerSupportabilityActions.CREATE_RELATIONS, resource.getComponentMetadataForSupportLog(), StatusCode.ERROR,
+ "ERROR component instance with name: {} not found on resource: {}", uploadRegInfo.getNode(), resource.getUniqueId());
BeEcompErrorManager.getInstance()
- .logInternalDataError(COMPONENT_INSTANCE_WITH_NAME + uploadRegInfo.getNode() + IN_RESOURCE, resource.getUniqueId(),
- ErrorSeverity.ERROR);
+ .logInternalDataError(COMPONENT_INSTANCE_WITH_NAME + uploadRegInfo.getNode() + IN_RESOURCE, resource.getUniqueId(),
+ ErrorSeverity.ERROR);
return componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
}
regCapRelDef.setToNode(currentCapCompInstance.getUniqueId());
@@ -2726,14 +2706,14 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
CapabilityDefinition aviableCapForRel = findAvailableCapabilityByTypeOrName(validReq, currentCapCompInstance, uploadRegInfo);
if (aviableCapForRel == null) {
log.debug("aviable capability was not found. req name is {} component instance is {}", validReq.getName(),
- currentCapCompInstance.getUniqueId());
- loggerSupportability
- .log(LoggerSupportabilityActions.CREATE_RELATIONS, resource.getComponentMetadataForSupportLog(), StatusCode.ERROR,
- "ERROR available capability was not found. req name is: {} component instance is: {}", validReq.getName(),
currentCapCompInstance.getUniqueId());
+ loggerSupportability
+ .log(LoggerSupportabilityActions.CREATE_RELATIONS, resource.getComponentMetadataForSupportLog(), StatusCode.ERROR,
+ "ERROR available capability was not found. req name is: {} component instance is: {}", validReq.getName(),
+ currentCapCompInstance.getUniqueId());
BeEcompErrorManager.getInstance().logInternalDataError(
- "aviable capability was not found. req name is " + validReq.getName() + " component instance is " + currentCapCompInstance
- .getUniqueId(), resource.getUniqueId(), ErrorSeverity.ERROR);
+ "aviable capability was not found. req name is " + validReq.getName() + " component instance is " + currentCapCompInstance
+ .getUniqueId(), resource.getUniqueId(), ErrorSeverity.ERROR);
return componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
}
reqAndRelationshipPair.setCapability(aviableCapForRel.getName());
@@ -2815,7 +2795,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
throw new ByActionStatusComponentException(ActionStatus.INVALID_CONTENT);
}
Optional<InputDefinition> optional = inputs.stream().filter(p -> p.getName().equals(getInput.getInputName())).findAny();
- if (!optional.isPresent()) {
+ if (optional.isEmpty()) {
loggerSupportability.log(LoggerSupportabilityActions.PROPERTY, resource.getComponentMetadataForSupportLog(), StatusCode.ERROR,
"ERROR Failed to find input: " + getInput.getInputName());
log.debug("Failed to find input {} ", getInput.getInputName());
@@ -2840,7 +2820,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Optional<InputDefinition> optional;
if (getInputIndex != null) {
optional = inputs.stream().filter(p -> p.getName().equals(getInputIndex.getInputName())).findAny();
- if (!optional.isPresent()) {
+ if (optional.isEmpty()) {
log.debug("Failed to find input {} ", getInputIndex.getInputName());
// @@TODO error message
throw new ByActionStatusComponentException(ActionStatus.INVALID_CONTENT);
@@ -2981,7 +2961,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
Optional<CapabilityDefinition> capByName = capMap.get(validReq.getCapability()).stream()
.filter(p -> p.getName().equals(uploadReqInfo.getCapabilityName())).findAny();
- if (!capByName.isPresent()) {
+ if (capByName.isEmpty()) {
return null;
}
cap = capByName.get();
@@ -3169,7 +3149,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Map<String, ToscaArtifactDataDefinition> toscaArtifacts = new HashMap<>();
Map<String, Map<String, UploadArtifactInfo>> arts = artifacts.entrySet().stream()
.filter(e -> e.getKey().contains(TypeUtils.ToscaTagNamesEnum.ARTIFACTS.getElementName()))
- .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue()));
+ .collect(Collectors.toMap(Entry::getKey, Entry::getValue));
Map<String, UploadArtifactInfo> artifact = arts.get(TypeUtils.ToscaTagNamesEnum.ARTIFACTS.getElementName());
for (Map.Entry<String, UploadArtifactInfo> entry : artifact.entrySet()) {
ToscaArtifactDataDefinition to = new ToscaArtifactDataDefinition();
@@ -3180,7 +3160,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
componentInstance.setToscaArtifacts(toscaArtifacts);
}
if (!existingnodeTypeMap.containsKey(uploadComponentInstanceInfo.getType())) {
- log.debug("createResourceInstances - not found lates version for resource instance with name {} and type ",
+ log.debug("createResourceInstances - not found lates version for resource instance with name {} and type {}",
uploadComponentInstanceInfo.getName(), uploadComponentInstanceInfo.getType());
throw new ByActionStatusComponentException(ActionStatus.INVALID_NODE_TEMPLATE, yamlName, uploadComponentInstanceInfo.getName(),
uploadComponentInstanceInfo.getType());
@@ -3196,13 +3176,13 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Map<String, List<UploadCapInfo>> uploadedCapabilities) {
for (Entry<String, List<UploadCapInfo>> currEntry : uploadedCapabilities.entrySet()) {
if (originCapabilities.containsKey(currEntry.getKey())) {
- currEntry.getValue().stream().forEach(cap -> cap.setType(currEntry.getKey()));
+ currEntry.getValue().forEach(cap -> cap.setType(currEntry.getKey()));
}
}
for (Map.Entry<String, List<CapabilityDefinition>> capabilities : originCapabilities.entrySet()) {
- capabilities.getValue().stream().forEach(cap -> {
+ capabilities.getValue().forEach(cap -> {
if (uploadedCapabilities.containsKey(cap.getName())) {
- uploadedCapabilities.get(cap.getName()).stream().forEach(c -> {
+ uploadedCapabilities.get(cap.getName()).forEach(c -> {
c.setName(cap.getName());
c.setType(cap.getType());
});
@@ -3239,7 +3219,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
refResource.getName(), componentState);
}
if (!ModelConverter.isAtomicComponent(refResource) && refResource.getResourceType() != ResourceTypeEnum.CVFC) {
- log.debug("validateResourceInstanceBeforeCreate - ref resource type is ", refResource.getResourceType());
+ log.debug("validateResourceInstanceBeforeCreate - ref resource type is {} ", refResource.getResourceType());
throw new ByActionStatusComponentException(ActionStatus.INVALID_NODE_TEMPLATE, yamlName, uploadComponentInstanceInfo.getName(),
uploadComponentInstanceInfo.getType());
}
@@ -3493,8 +3473,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
List<GroupDefinition> oldForUpdate = oldResource.getGroups();
if (CollectionUtils.isNotEmpty(oldForUpdate)) {
- List<GroupDefinition> groupForUpdate = oldForUpdate.stream().map(group -> new GroupDefinition(group)).collect(Collectors.toList());
- groupForUpdate.stream().filter(group -> group.isVspOriginated()).forEach(group -> group.setName(group.getInvariantName()));
+ List<GroupDefinition> groupForUpdate = oldForUpdate.stream().map(GroupDefinition::new).collect(Collectors.toList());
+ groupForUpdate.stream().filter(GroupDataDefinition::isVspOriginated).forEach(group -> group.setName(group.getInvariantName()));
newResource.setGroups(groupForUpdate);
}
if (newResource.getResourceType().isAtomicType() && !newResource.getName().equals("Root")
@@ -3917,7 +3897,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
return responseFormat;
} finally {
- if (result == null || result != StorageOperationStatus.OK) {
+ if (!StorageOperationStatus.OK.equals(result)) {
janusGraphDao.rollback();
} else {
janusGraphDao.commit();
@@ -3957,7 +3937,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
failed = true;
throw e;
} finally {
- if (failed || result == null || result != StorageOperationStatus.OK) {
+ if (failed || !StorageOperationStatus.OK.equals(result)) {
janusGraphDao.rollback();
} else {
janusGraphDao.commit();
@@ -3978,7 +3958,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return Either.right(
componentsUtils.getResponseFormatByResource(componentsUtils.convertFromStorageResponse(storageStatus.right().value()), resourceId));
}
- if (!(storageStatus.left().value() instanceof Resource)) {
+ if (storageStatus.left().value() == null) {
return Either.right(componentsUtils
.getResponseFormatByResource(componentsUtils.convertFromStorageResponse(StorageOperationStatus.NOT_FOUND), resourceId));
}
@@ -4541,13 +4521,14 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
List<CategoryDefinition> categoryList = categories.left().value();
Optional<CategoryDefinition> foundCategory = categoryList.stream().filter(cat -> cat.getName().equals(category.getName())).findFirst();
- if (!foundCategory.isPresent()) {
+ if (foundCategory.isEmpty()) {
log.debug("Category {} is not part of resource category group. Resource category valid values are {}", category, categoryList);
failOnInvalidCategory(user, resource, actionEnum);
+ return; // explisite output even if failOnInvalidCategory throw an exception
}
Optional<SubCategoryDefinition> foundSubcategory = foundCategory.get().getSubcategories().stream()
.filter(subcat -> subcat.getName().equals(subcategory.getName())).findFirst();
- if (!foundSubcategory.isPresent()) {
+ if (foundSubcategory.isEmpty()) {
log.debug("SubCategory {} is not part of resource category group. Resource subcategory valid values are {}", subcategory,
foundCategory.get().getSubcategories());
failOnInvalidCategory(user, resource, actionEnum);
@@ -4789,7 +4770,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
ResponseFormat responseFormat = null;
ImmutablePair<String, Boolean> propertyInnerTypeValid = propertyOperation.isPropertyInnerTypeValid(property, allDataTypes);
innerType = propertyInnerTypeValid.getLeft();
- if (!propertyInnerTypeValid.getRight().booleanValue()) {
+ if (!propertyInnerTypeValid.getRight()) {
log.info("Invalid inner type for property {}", property);
responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_PROPERTY_INNER_TYPE, innerType, property.getName());
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CheckinTransition.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CheckinTransition.java
index 71c41caf3a..61243d4aba 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CheckinTransition.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CheckinTransition.java
@@ -136,7 +136,8 @@ public class CheckinTransition extends LifeCycleTransition {
owner.getUserId());
return Either.right(error);
}
- if (oldState.equals(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT) && !modifier.getUserId().equals(owner.getUserId()) && !modifier.getRole()
+ // here oldState == NOT_CERTIFIED_CHECKOUT because of previous if with a return
+ if (!modifier.getUserId().equals(owner.getUserId()) && !modifier.getRole()
.equals(Role.ADMIN.name())) {
ResponseFormat error = componentUtils
.getResponseFormat(ActionStatus.COMPONENT_CHECKOUT_BY_ANOTHER_USER, componentName, componentType.name().toLowerCase(),
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/utils/MapUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/utils/MapUtils.java
index 045658d973..9e8c0e6e74 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/utils/MapUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/utils/MapUtils.java
@@ -28,7 +28,7 @@ public class MapUtils {
if (source == null && target == null) {
return true;
}
- if ((source == null && target != null) || source != null && target == null || source.keySet().size() != target.keySet().size()) {
+ if (source == null || target == null || source.keySet().size() != target.keySet().size()) {
return false;
}
for (Map.Entry<String, Object> entry : source.entrySet()) {
@@ -48,7 +48,7 @@ public class MapUtils {
if (source == null && target == null) {
return true;
}
- if ((source == null && target != null) || source != null && target == null || source.size() != target.size()) {
+ if (source == null || target == null || source.size() != target.size()) {
return false;
}
for (int i = 0; i < source.size(); i++) {
@@ -68,7 +68,7 @@ public class MapUtils {
if (sourceObj == null && targetObj == null) {
return true;
}
- if (sourceObj == null && targetObj != null) {
+ if (sourceObj == null) {
return false;
}
if (sourceObj.getClass().equals(targetObj.getClass())) {
@@ -81,9 +81,6 @@ public class MapUtils {
return false;
}
} else {
- if (sourceObj.getClass() != targetObj.getClass()) {
- return false;
- }
if (!sourceObj.equals(targetObj)) {
return false;
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java
index 2bb28dd2f5..b444532bc3 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java
@@ -741,18 +741,23 @@ public class ArtifactExternalServlet extends AbstractValidationsServlet {
responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
}
ResourceCommonInfo resourceCommonInfo = new ResourceCommonInfo(componentTypeValue);
- try {
- if (responseWrapper.isEmpty()) {
- byte[] value = artifactsBusinessLogic.downloadComponentArtifactByUUIDs(componentType, uuid, artifactUUID, resourceCommonInfo);
- InputStream is = new ByteArrayInputStream(value);
- Map<String, String> headers = new HashMap<>();
- headers.put(Constants.MD5_HEADER, GeneralUtility.calculateMD5Base64EncodedByByteArray(value));
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
- responseWrapper.setInnerElement(buildOkResponse(responseFormat, is, headers));
- }
+ if (!responseWrapper.isEmpty()) {
+ getComponentsUtils().auditExternalDownloadArtifact(responseFormat,
+ resourceCommonInfo, new DistributionData(instanceIdHeader, requestURI),
+ requestId, artifactUUID, userId);
+ return responseWrapper.getInnerElement();
+ }
+ byte[] value = artifactsBusinessLogic.downloadComponentArtifactByUUIDs(componentType, uuid, artifactUUID, resourceCommonInfo);
+ try (InputStream is = new ByteArrayInputStream(value)) {
+ Map<String, String> headers = new HashMap<>();
+ headers.put(Constants.MD5_HEADER, GeneralUtility.calculateMD5Base64EncodedByByteArray(value));
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
+ responseWrapper.setInnerElement(buildOkResponse(responseFormat, is, headers));
} catch (ComponentException e) {
responseFormat = getComponentsUtils().getResponseFormat(e);
throw e;
+ } catch (IOException e) {
+ log.debug("close ByteArrayInputStream error");
} finally {
getComponentsUtils()
.auditExternalDownloadArtifact(responseFormat, resourceCommonInfo, new DistributionData(instanceIdHeader, requestURI), requestId,
@@ -805,19 +810,23 @@ public class ArtifactExternalServlet extends AbstractValidationsServlet {
responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID);
responseWrapper.setInnerElement(buildErrorResponse(responseFormat));
}
- try {
- if (responseWrapper.isEmpty()) {
- byte[] value = artifactsBusinessLogic
- .downloadResourceInstanceArtifactByUUIDs(componentType, uuid, resourceInstanceName, artifactUUID);
- InputStream is = new ByteArrayInputStream(value);
- Map<String, String> headers = new HashMap<>();
- headers.put(Constants.MD5_HEADER, GeneralUtility.calculateMD5Base64EncodedByByteArray(value));
- responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
- responseWrapper.setInnerElement(buildOkResponse(responseFormat, is, headers));
- }
+ if (!responseWrapper.isEmpty()) {
+ getComponentsUtils().auditExternalDownloadArtifact(responseFormat, new ResourceCommonInfo(resourceInstanceName, componentTypeValue),
+ new DistributionData(instanceIdHeader, requestURI), requestId, artifactUUID, userId);
+ return responseWrapper.getInnerElement();
+ }
+ byte[] value = artifactsBusinessLogic
+ .downloadResourceInstanceArtifactByUUIDs(componentType, uuid, resourceInstanceName, artifactUUID);
+ try (InputStream is = new ByteArrayInputStream(value)) {
+ Map<String, String> headers = new HashMap<>();
+ headers.put(Constants.MD5_HEADER, GeneralUtility.calculateMD5Base64EncodedByByteArray(value));
+ responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
+ responseWrapper.setInnerElement(buildOkResponse(responseFormat, is, headers));
} catch (ComponentException e) {
responseFormat = getComponentsUtils().getResponseFormat(e);
throw e;
+ } catch (IOException e) {
+ log.debug("close ByteArrayInputStream error");
} finally {
getComponentsUtils().auditExternalDownloadArtifact(responseFormat, new ResourceCommonInfo(resourceInstanceName, componentTypeValue),
new DistributionData(instanceIdHeader, requestURI), requestId, artifactUUID, userId);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/LifecycleServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/LifecycleServlet.java
index 77b36f0d48..bd61ad6efe 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/LifecycleServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/LifecycleServlet.java
@@ -156,7 +156,7 @@ public class LifecycleServlet extends BeGenericServlet {
try {
value = RepresentationUtils.toRepresentation(componentMetatdata);
} catch (IOException e) {
- e.printStackTrace();
+ log.debug("toRepresentation of componentMetatdata error :", e);
}
response = buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), value);
loggerSupportability
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java
index b083fbfe2a..282efc415f 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java
@@ -135,7 +135,7 @@ public class CsarUtils {
private static final String TOSCA_META_VERSION = "1.0";
private static final String CSAR_VERSION = "1.1";
// add manifest
- private static final String Service_Manifest = "NS.mf";
+ private static final String SERVICE_MANIFEST = "NS.mf";
private static final String DEFINITION = "Definitions";
private static final String DEL_PATTERN = "([/\\\\]+)";
private static final String WORD_PATTERN = "\\w\\_\\@\\-\\.\\s]+)";
@@ -173,7 +173,8 @@ public class CsarUtils {
public CsarUtils() {
if (SDC_VERSION != null && !SDC_VERSION.isEmpty()) {
- Matcher matcher = Pattern.compile("(?!\\.)(\\d+(\\.\\d+)+)(?![\\d\\.])").matcher(SDC_VERSION);
+ // change regex to avoid DoS sonar issue
+ Matcher matcher = Pattern.compile("(?!\\.)(\\d{1,9}(\\.\\d{1,9}){1,9})(?![\\d\\.])").matcher(SDC_VERSION);
matcher.find();
setVersionFirstThreeOctets(matcher.group(0));
} else {
@@ -478,7 +479,7 @@ public class CsarUtils {
String nsMfBlock0 = createNsMfBlock0(serviceName, createdBy, serviceVersion, releaseTime, serviceType, description, serviceTemplate,
hash);
byte[] nsMfBlock0Byte = nsMfBlock0.getBytes();
- zip.putNextEntry(new ZipEntry(Service_Manifest));
+ zip.putNextEntry(new ZipEntry(SERVICE_MANIFEST));
zip.write(nsMfBlock0Byte);
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaCapability.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaCapability.java
index 8a748eddfb..8cda46f604 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaCapability.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaCapability.java
@@ -30,9 +30,6 @@ public class ToscaCapability {
private List<String> valid_source_types;
private Map<String, ToscaProperty> properties;
- public ToscaCapability() {
- }
-
public List<String> getValid_source_types() {
return valid_source_types;
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditResourceEventFactoryManangerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditResourceEventFactoryManangerTest.java
index d41f3ce689..548048deba 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditResourceEventFactoryManangerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/auditing/impl/AuditResourceEventFactoryManangerTest.java
@@ -32,10 +32,6 @@ import org.openecomp.sdc.be.resources.data.auditing.model.ResourceVersionInfo;
public class AuditResourceEventFactoryManangerTest {
- private AuditResourceEventFactoryManager createTestSubject() {
- return new AuditResourceEventFactoryManager();
- }
-
@Test
public void testCreateResourceEventFactory() throws Exception {
AuditingActionEnum action = null;