From 619adb5955870e3b03250262677eff9b83713f14 Mon Sep 17 00:00:00 2001 From: "Sonsino, Ofir (os0695)" Date: Wed, 21 Nov 2018 13:34:44 +0200 Subject: Sonar code smell fixes Change-Id: I324de653e8e3b4c74bd3723f6bed221f21094f5c Issue-ID: SDC-1948 Signed-off-by: Sonsino, Ofir (os0695) --- .../usersadmin/AuditUserAccessEventFactory.java | 2 +- .../distribution/engine/DistributionEngine.java | 3 - .../engine/DistributionEngineInitTask.java | 16 ++-- .../be/components/impl/ArtifactsBusinessLogic.java | 97 +++++++++++----------- .../impl/ComponentInstanceBusinessLogic.java | 34 ++++---- 5 files changed, 72 insertions(+), 80 deletions(-) (limited to 'catalog-be/src/main') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/usersadmin/AuditUserAccessEventFactory.java b/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/usersadmin/AuditUserAccessEventFactory.java index 758e5858c9..d7fbe58771 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/usersadmin/AuditUserAccessEventFactory.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/usersadmin/AuditUserAccessEventFactory.java @@ -9,7 +9,7 @@ import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData; public class AuditUserAccessEventFactory extends AuditBaseEventFactory { - private final static String LOG_STR = "ACTION = \"%s\" USER = \"%s\" STATUS = \"%s\" DESC = \"%s\""; + private static final String LOG_STR = "ACTION = \"%s\" USER = \"%s\" STATUS = \"%s\" DESC = \"%s\""; private final UserAccessEvent event; public AuditUserAccessEventFactory(CommonAuditData commonFields, User user) { diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngine.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngine.java index 334b3f63d9..fa8d1ee507 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngine.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngine.java @@ -20,8 +20,6 @@ package org.openecomp.sdc.be.components.distribution.engine; -import java.io.File; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -45,7 +43,6 @@ import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.resources.data.OperationalEnvironmentEntry; -import org.openecomp.sdc.common.util.YamlToObjectConverter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineInitTask.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineInitTask.java index 2b1e716fa0..52b1967397 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineInitTask.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineInitTask.java @@ -63,6 +63,10 @@ public class DistributionEngineInitTask implements Runnable { private CambriaHandler cambriaHandler = new CambriaHandler(); + private ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1); + private static final Logger logger = Logger.getLogger(DistributionEngineInitTask.class.getName()); + ScheduledFuture scheduledFuture = null; + public DistributionEngineInitTask(Long delayBeforeStartFlow, DistributionEngineConfiguration deConfiguration, String envName, AtomicBoolean status, ComponentsUtils componentsUtils, DistributionEnginePollingTask distributionEnginePollingTask, OperationalEnvironmentEntry environmentEntry) { super(); this.delayBeforeStartFlow = delayBeforeStartFlow; @@ -77,12 +81,6 @@ public class DistributionEngineInitTask implements Runnable { this.environmentEntry = environmentEntry; } - private ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1); - - private static final Logger logger = Logger.getLogger(DistributionEngineInitTask.class.getName()); - - ScheduledFuture scheduledFuture = null; - public void startTask() { if (scheduledExecutorService != null) { Integer retryInterval = deConfiguration.getInitRetryIntervalSec(); @@ -208,11 +206,7 @@ public class DistributionEngineInitTask implements Runnable { CambriaErrorResponse registerConcumerStatus = registerToTopic(statusTopic, SubscriberTypeEnum.CONSUMER); - if (registerConcumerStatus.getOperationStatus() != CambriaOperationStatus.OK) { - return false; - } - - return true; + return registerConcumerStatus.getOperationStatus() == CambriaOperationStatus.OK; } private CambriaErrorResponse registerToTopic(String topicName, SubscriberTypeEnum subscriberType) { 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 62f62f130d..fc4a739614 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 @@ -103,6 +103,7 @@ import java.util.stream.Collectors; @org.springframework.stereotype.Component("artifactBusinessLogic") public class ArtifactsBusinessLogic extends BaseBusinessLogic { + private static final String RESOURCE_INSTANCE = "resource instance"; private static final String ARTIFACT_TYPE_OTHER = "OTHER"; private static final String ARTIFACT_DESCRIPTION = "artifact description"; private static final String ARTIFACT_LABEL = "artifact label"; @@ -470,7 +471,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { }); Either, StorageOperationStatus> status = toscaOperationFacade.updateGroupsOnComponent(parent, groupToUpdate); if (status.isRight()) { - log.debug("Failed to update groups of the component {}. ", parent.getUniqueId()); + log.debug(FAILED_UPDATE_GROUPS, parent.getUniqueId()); return componentsUtils.convertFromStorageResponse(status.right().value()); } } @@ -497,7 +498,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { }); Either, StorageOperationStatus> status = toscaOperationFacade.updateGroupsOnComponent(parent, groupToUpdate); if (status.isRight()) { - log.debug("Failed to update groups of the component {}. ", parent.getUniqueId()); + log.debug(FAILED_UPDATE_GROUPS, parent.getUniqueId()); return componentsUtils.convertFromStorageResponse(status.right().value()); } } @@ -540,7 +541,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { } Either, StorageOperationStatus> status = toscaOperationFacade.updateGroupInstancesOnComponent(parent, parentId, updatedGroupInstances); if (status.isRight()) { - log.debug("Failed to update groups of the component {}. ", parent.getUniqueId()); + log.debug(FAILED_UPDATE_GROUPS, parent.getUniqueId()); return componentsUtils.convertFromStorageResponse(status.right().value()); } return ActionStatus.OK; @@ -603,7 +604,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { // lock resource if (shouldLock) { - Either lockComponent = lockComponent(parent, "Update Artifact - lock "); + Either lockComponent = lockComponent(parent, UPDATE_ARTIFACT_LOCK); if (lockComponent.isRight()) { handleAuditing(auditingAction, parent, parentId, user, null, null, artifactId, lockComponent.right() .value(), componentType, null); @@ -619,13 +620,13 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { finally { // unlock resource if (resultOp == null || resultOp.isRight()) { - log.debug("all changes rollback"); + log.debug(ROLLBACK); if (!inTransaction) { titanDao.rollback(); } } else { - log.debug("all changes committed"); + log.debug(COMMIT); if (!inTransaction) { titanDao.commit(); } @@ -718,7 +719,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { return resultOp; } component = validateComponent.left().value(); - Either lockComponent = lockComponent(component, "Update Artifact - lock "); + Either lockComponent = lockComponent(component, UPDATE_ARTIFACT_LOCK); if (lockComponent.isRight()) { resultOp = Either.right(lockComponent.right().value()); @@ -772,11 +773,11 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { finally { // unlock resource if (resultOp == null || resultOp.isRight()) { - log.debug("all changes rollback"); + log.debug(ROLLBACK); titanDao.rollback(); } else { - log.debug("all changes committed"); + log.debug(COMMIT); titanDao.commit(); } @@ -900,7 +901,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { // lock resource if (shouldLock) { - Either lockComponent = lockComponent(parent, "Update Artifact - lock "); + Either lockComponent = lockComponent(parent, UPDATE_ARTIFACT_LOCK); if (lockComponent.isRight()) { handleAuditing(auditingAction, parent, parentId, user, null, null, artifactId, lockComponent.right() @@ -1357,7 +1358,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { needCloneRes = artifactToscaOperation.isCloneNeeded(parent.getUniqueId(), foundArtifact, convertParentType(parent .getComponentType())); if (needCloneRes.isRight()) { - log.debug("Failed to delete or update the artifact {}. Parent uniqueId is {}", artifactId, parentId); + log.debug(FAILED_UPDATE_ARTIFACT, artifactId, parentId); responseFormat = componentsUtils.getResponseFormatByArtifactId(componentsUtils.convertFromStorageResponse(needCloneRes .right() .value()), foundArtifact.getArtifactDisplayName()); @@ -1373,7 +1374,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { Either isOnlyResourceInstanceArtifact = isArtifactOnlyResourceInstanceArtifact(foundArtifact, fetchedContainerComponent, instanceId); if (isOnlyResourceInstanceArtifact.isRight()) { - log.debug("Failed to delete or update the artifact {}. Parent uniqueId is {}", artifactId, parentId); + log.debug(FAILED_UPDATE_ARTIFACT, artifactId, parentId); responseFormat = componentsUtils.getResponseFormatByArtifactId(isOnlyResourceInstanceArtifact.right() .value(), foundArtifact .getArtifactDisplayName()); @@ -1387,7 +1388,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { .left() .value()); if (updatedArtifactRes.isRight()) { - log.debug("Failed to delete or update the artifact {}. Parent uniqueId is {}", artifactId, parentId); + log.debug(FAILED_UPDATE_ARTIFACT, artifactId, parentId); responseFormat = componentsUtils.getResponseFormatByArtifactId(componentsUtils.convertFromStorageResponse(updatedArtifactRes .right() .value()), foundArtifact.getArtifactDisplayName()); @@ -1420,7 +1421,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { if (CollectionUtils.isNotEmpty(updatedGroupInstances)) { Either, StorageOperationStatus> status = toscaOperationFacade.updateGroupInstancesOnComponent(fetchedContainerComponent, parentId, updatedGroupInstances); if (status.isRight()) { - log.debug("Failed to update groups of the component {}. ", fetchedContainerComponent.getUniqueId()); + log.debug(FAILED_UPDATE_GROUPS, fetchedContainerComponent.getUniqueId()); responseFormat = componentsUtils.getResponseFormatByArtifactId(componentsUtils.convertFromStorageResponse(status .right() .value()), foundArtifact.getArtifactDisplayName()); @@ -1445,7 +1446,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { if (CollectionUtils.isNotEmpty(updatedGroups)) { Either, StorageOperationStatus> status = toscaOperationFacade.updateGroupsOnComponent(fetchedContainerComponent, updatedGroups); if (status.isRight()) { - log.debug("Failed to update groups of the component {}. ", fetchedContainerComponent.getUniqueId()); + log.debug(FAILED_UPDATE_GROUPS, fetchedContainerComponent.getUniqueId()); responseFormat = componentsUtils.getResponseFormatByArtifactId(componentsUtils.convertFromStorageResponse(status .right() .value()), foundArtifact.getArtifactDisplayName()); @@ -2024,7 +2025,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { boolean res = saveArtifacts(artifactData, parentId); if (res) { - log.debug("Artifact saved into ES - {}", artifactUniqueId); + log.debug(ARTIFACT_SAVED, artifactUniqueId); ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.OK); handleAuditing(auditingActionEnum, parent, parentId, user, artifactInfo, artifactUniqueId, artifactUniqueId, responseFormat, componentTypeEnum, instanceName); @@ -2032,7 +2033,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { } else { BeEcompErrorManager.getInstance().logBeDaoSystemError("Upload Artifact"); - log.debug("Failed to save the artifact."); + log.debug(FAILED_SAVE_ARTIFACT); ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR); handleAuditing(auditingActionEnum, parent, parentId, user, artifactInfo, null, artifactUniqueId, responseFormat, componentTypeEnum, instanceName); @@ -3045,12 +3046,12 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { } if (res) { - log.debug("Artifact saved into ES - {}", artifactUniqueId); + log.debug(ARTIFACT_SAVED, artifactUniqueId); ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.OK); handleAuditing(auditingAction, parent, parentId, user, artifactInfo, prevArtifactId, currArtifactId, responseFormat, componentType, null); } else { - BeEcompErrorManager.getInstance().logBeDaoSystemError("Update Artifact"); - log.debug("Failed to save the artifact."); + BeEcompErrorManager.getInstance().logBeDaoSystemError(UPDATE_ARTIFACT); + log.debug(FAILED_SAVE_ARTIFACT); ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR); handleAuditing(auditingAction, parent, parentId, user, artifactInfo, prevArtifactId, currArtifactId, responseFormat, componentType, null); resultOp = Either.right(responseFormat); @@ -3379,7 +3380,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { // General validation if (serviceName == null || serviceVersion == null || resourceName == null || resourceVersion == null || artifactName == null) { - log.debug("One of the function parameteres is null"); + log.debug(NULL_PARAMETER); return Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT)); } @@ -3412,7 +3413,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { for (ArtifactDefinition artifactDefinition : artifacts.values()) { if (artifactDefinition.getArtifactName() != null && artifactDefinition.getArtifactName() .equals(artifactName)) { - log.debug("Found deployment artifact {}", artifactName); + log.debug(FOUND_DEPLOYMENT_ARTIFACT, artifactName); deploymentArtifact = artifactDefinition; break; } @@ -3426,7 +3427,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { // Downloading the artifact Either, ResponseFormat> downloadArtifactEither = downloadArtifact(deploymentArtifact); if (downloadArtifactEither.isRight()) { - log.debug("Download artifact {} failed", artifactName); + log.debug(FAILED_DOWNLOAD_ARTIFACT, artifactName); return Either.right(downloadArtifactEither.right().value()); } log.trace("Download of resource artifact succeeded, uniqueId {}", deploymentArtifact.getUniqueId()); @@ -3438,7 +3439,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { // General validation if (serviceName == null || serviceVersion == null || resourceInstanceName == null || artifactName == null) { - log.debug("One of the function parameteres is null"); + log.debug(NULL_PARAMETER); return Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT)); } @@ -3476,13 +3477,13 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { return Either.right(componentsUtils.getResponseFormat(ActionStatus.ARTIFACT_NOT_FOUND, artifactName)); } - log.debug("Found deployment artifact {}", artifactName); + log.debug(FOUND_DEPLOYMENT_ARTIFACT, artifactName); deployableArtifact = artifacts.values().stream().filter(filterArtifactByName).findFirst().get(); // Downloading the artifact Either, ResponseFormat> downloadArtifactEither = downloadArtifact(deployableArtifact); if (downloadArtifactEither.isRight()) { - log.debug("Download artifact {} failed", artifactName); + log.debug(FAILED_DOWNLOAD_ARTIFACT, artifactName); return Either.right(downloadArtifactEither.right().value()); } log.trace("Download of resource artifact succeeded, uniqueId {}", deployableArtifact.getUniqueId()); @@ -3549,7 +3550,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { // Validation log.trace("Starting download of service interface artifact, serviceName {}, serviceVersion {}, artifact name {}", serviceName, serviceVersion, artifactName); if (serviceName == null || serviceVersion == null || artifactName == null) { - log.debug("One of the function parameteres is null"); + log.debug(NULL_PARAMETER); return Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT)); } @@ -3588,12 +3589,12 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { log.debug("The artifact {} was not found for service {}", normalizedArtifactName, serviceId); return Either.right(componentsUtils.getResponseFormat(ActionStatus.ARTIFACT_NOT_FOUND, normalizedArtifactName)); } - log.debug("Found deployment artifact {}", normalizedArtifactName); + log.debug(FOUND_DEPLOYMENT_ARTIFACT, normalizedArtifactName); // Downloading the artifact Either, ResponseFormat> downloadArtifactEither = downloadArtifact(foundArtifactOptl .get()); if (downloadArtifactEither.isRight()) { - log.debug("Download artifact {} failed", normalizedArtifactName); + log.debug(FAILED_DOWNLOAD_ARTIFACT, normalizedArtifactName); return Either.right(downloadArtifactEither.right().value()); } log.trace("Download of service artifact succeeded, uniqueId {}", foundArtifactOptl.get().getUniqueId()); @@ -3975,7 +3976,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { }); Either, StorageOperationStatus> status = toscaOperationFacade.updateGroupInstancesOnComponent(component, instanceId, updatedGroupInstances); if (status.isRight()) { - log.debug("Failed to update groups of the component {}. ", component.getUniqueId()); + log.debug(FAILED_UPDATE_GROUPS, component.getUniqueId()); ResponseFormat responseFormat = componentsUtils.getResponseFormatByArtifactId(componentsUtils .convertFromStorageResponse(status.right() .value()), clonedBeforeGenerate.getArtifactDisplayName()); @@ -4332,7 +4333,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { // lock resource if (shouldLock) { - Either lockComponent = lockComponent(parent, "Update Artifact - lock "); + Either lockComponent = lockComponent(parent, UPDATE_ARTIFACT_LOCK); if (lockComponent.isRight()) { handleAuditing(auditingAction, parent, parentId, user, null, null, artifactId, lockComponent.right() .value(), componentType, null); @@ -4348,13 +4349,13 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { finally { // unlock resource if (resultOp == null || resultOp.isRight()) { - log.debug("all changes rollback"); + log.debug(ROLLBACK); if (!inTransaction) { titanDao.rollback(); } } else { - log.debug("all changes committed"); + log.debug(COMMIT); if (!inTransaction) { titanDao.commit(); } @@ -4552,14 +4553,14 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { res = saveArtifacts(esArtifactData, parent.getUniqueId()); if (res) { - log.debug("Artifact saved into ES - {}", updatedHeatArt.getUniqueId()); + log.debug(ARTIFACT_SAVED, updatedHeatArt.getUniqueId()); ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.OK); handleAuditing(auditingAction, parent, parent.getUniqueId(), user, updatedHeatArt, currentHeatId, updatedHeatArt .getUniqueId(), responseFormat, componentType, null); } else { - BeEcompErrorManager.getInstance().logBeDaoSystemError("Update Artifact"); - log.debug("Failed to save the artifact."); + BeEcompErrorManager.getInstance().logBeDaoSystemError(UPDATE_ARTIFACT); + log.debug(FAILED_SAVE_ARTIFACT); ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR); handleAuditing(auditingAction, parent, parent.getUniqueId(), user, updatedHeatArt, currentHeatId, updatedHeatArt .getUniqueId(), responseFormat, componentType, null); @@ -4865,7 +4866,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { actionResult = handleArtifactRequest(componentInstanceId, userId, ComponentTypeEnum.RESOURCE_INSTANCE, operation, null, artifactInfo, origMd5, data, null, null, componentId, ComponentTypeEnum .findParamByType(componentType)); if (actionResult.isRight()) { - log.debug("Failed to upload artifact to component instance {} of component with type {} and uuid {}. Status is {}. ", resourceInstanceName, componentType, componentUuid, actionResult + log.debug(FAILED_UPLOAD_ARTIFACT_TO_INSTANCE, resourceInstanceName, componentType, componentUuid, actionResult .right() .value()); errorWrapper.setInnerElement(actionResult.right().value()); @@ -4934,7 +4935,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { if (errorWrapper.isEmpty()) { actionResult = handleArtifactRequest(componentId, userId, componentType, operation, artifactId, artifactInfo, origMd5, data, null, null, null, null); if (actionResult.isRight()) { - log.debug("Failed to upload artifact to component with type {} and uuid {}. Status is {}. ", componentType, componentUuid, actionResult + log.debug(FAILED_UPLOAD_ARTIFACT_TO_COMPONENT, componentType, componentUuid, actionResult .right() .value()); errorWrapper.setInnerElement(actionResult.right().value()); @@ -5013,7 +5014,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { actionResult = handleArtifactRequest(componentInstanceId, userId, ComponentTypeEnum.RESOURCE_INSTANCE, operation, artifactId, artifactInfo, origMd5, data, null, null, componentId, ComponentTypeEnum .findParamByType(componentType)); if (actionResult.isRight()) { - log.debug("Failed to upload artifact to component instance {} of component with type {} and uuid {}. Status is {}. ", resourceInstanceName, componentType, componentUuid, actionResult + log.debug(FAILED_UPLOAD_ARTIFACT_TO_INSTANCE, resourceInstanceName, componentType, componentUuid, actionResult .right() .value()); errorWrapper.setInnerElement(actionResult.right().value()); @@ -5086,7 +5087,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { artifactUUID, artifactInfo, origMd5, data, interfaceName.left().value(), operationUUID, null, null); if (actionResult.isRight()) { - log.debug("Failed to upload artifact to component with type {} and uuid {}. Status is {}. ", componentType, componentUuid, actionResult + log.debug(FAILED_UPLOAD_ARTIFACT_TO_COMPONENT, componentType, componentUuid, actionResult .right() .value()); errorWrapper.setInnerElement(actionResult.right().value()); @@ -5172,7 +5173,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { if (errorWrapper.isEmpty()) { actionResult = handleArtifactRequest(componentId, userId, componentType, operation, artifactId, null, origMd5, null, null, null, null, null); if (actionResult.isRight()) { - log.debug("Failed to upload artifact to component with type {} and uuid {}. Status is {}. ", componentType, componentUuid, actionResult + log.debug(FAILED_UPLOAD_ARTIFACT_TO_COMPONENT, componentType, componentUuid, actionResult .right() .value()); errorWrapper.setInnerElement(actionResult.right().value()); @@ -5248,7 +5249,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { .findParamByType(componentType)); if (actionResult.isRight()) { - log.debug("Failed to upload artifact to component instance {} of component with type {} and uuid {}. Status is {}. ", resourceInstanceName, componentType, componentUuid, actionResult + log.debug(FAILED_UPLOAD_ARTIFACT_TO_INSTANCE, resourceInstanceName, componentType, componentUuid, actionResult .right() .value()); errorWrapper.setInnerElement(actionResult.right().value()); @@ -5459,10 +5460,10 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { .findFirst() .orElse(null); if (componentInstance == null) { - errorWrapper.setInnerElement(componentsUtils.getResponseFormat(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND_ON_CONTAINER, resourceInstanceName, "resource instance", component + errorWrapper.setInnerElement(componentsUtils.getResponseFormat(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND_ON_CONTAINER, resourceInstanceName, RESOURCE_INSTANCE, component .getComponentType() .getValue(), component.getName())); - log.debug("Component instance {} was not found for component {}", resourceInstanceName, component.getName()); + log.debug(COMPONENT_INSTANCE_NOT_FOUND, resourceInstanceName, component.getName()); } } return componentInstance; @@ -5479,10 +5480,10 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { .findFirst() .orElse(null); if (componentInstance == null) { - errorWrapper.setInnerElement(componentsUtils.getResponseFormat(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND_ON_CONTAINER, resourceInstanceName, "resource instance", component + errorWrapper.setInnerElement(componentsUtils.getResponseFormat(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND_ON_CONTAINER, resourceInstanceName, RESOURCE_INSTANCE, component .getComponentType() .getValue(), component.getName())); - log.debug("Component instance {} was not found for component {}", resourceInstanceName, component.getName()); + log.debug(COMPONENT_INSTANCE_NOT_FOUND, resourceInstanceName, component.getName()); } else { relatedComponentComponentInstancePair = new ImmutablePair<>(component, componentInstance); @@ -5501,10 +5502,10 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { .findFirst() .orElse(null); if (componentInstance == null) { - errorWrapper.setInnerElement(componentsUtils.getResponseFormat(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND_ON_CONTAINER, resourceInstanceName, "resource instance", component + errorWrapper.setInnerElement(componentsUtils.getResponseFormat(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND_ON_CONTAINER, resourceInstanceName, RESOURCE_INSTANCE, component .getComponentType() .getValue(), component.getName())); - log.debug("Component instance {} was not found for component {}", resourceInstanceName, component.getName()); + log.debug(COMPONENT_INSTANCE_NOT_FOUND, resourceInstanceName, component.getName()); } else { relatedComponentComponentInstancePair = new ImmutablePair<>(component, componentInstance); 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 299f8184dd..e92f5f3ebe 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 @@ -368,7 +368,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { } try { - log.debug("Try to create entry on graph"); + log.debug(TRY_TO_CREATE_ENTRY_ON_GRAPH); Either eitherResourceName = getOriginComponentFromComponentInstance(resourceInstance); if (eitherResourceName.isRight()) { @@ -1062,7 +1062,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { public Either associateRIToRIOnGraph(Component containerComponent, RequirementCapabilityRelDef requirementDef, ComponentTypeEnum componentTypeEnum, boolean inTransaction) { - log.debug("Try to create entry on graph"); + log.debug(TRY_TO_CREATE_ENTRY_ON_GRAPH); Either resultOp = null; Either result = toscaOperationFacade.associateResourceInstances(containerComponent.getUniqueId(), requirementDef); @@ -1179,7 +1179,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { String componentId, RequirementCapabilityRelDef requirementDef, Component containerComponent) { Either resultOp = null; - log.debug("Try to create entry on graph"); + log.debug(TRY_TO_CREATE_ENTRY_ON_GRAPH); Either result = toscaOperationFacade.dissociateResourceInstances( componentId, requirementDef); if (result.isLeft()) { @@ -1694,14 +1694,14 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { validateUserExists(userId, "create Or Update Property Value", false); if (componentTypeEnum == null) { - BeEcompErrorManager.getInstance().logInvalidInputError(CREATE_OR_UPDATE_PROPERTY_VALUE, "invalid component type", ErrorSeverity.INFO); + BeEcompErrorManager.getInstance().logInvalidInputError(CREATE_OR_UPDATE_PROPERTY_VALUE, INVALID_COMPONENT_TYPE, ErrorSeverity.INFO); resultOp = Either.right(componentsUtils.getResponseFormat(ActionStatus.NOT_ALLOWED)); return resultOp; } Either getResourceResult = toscaOperationFacade.getToscaElement(componentId, JsonParseFlagEnum.ParseAll); if (getResourceResult.isRight()) { - log.debug("Failed to retrieve component, component id {}", componentId); + log.debug(FAILED_TO_RETRIEVE_COMPONENT_COMPONENT_ID, componentId); resultOp = Either.right(componentsUtils.getResponseFormat(ActionStatus.RESTRICTED_OPERATION)); return resultOp; } @@ -1723,7 +1723,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { // lock resource StorageOperationStatus lockStatus = graphLockOperation.lockComponent(componentId, componentTypeEnum.getNodeType()); if (lockStatus != StorageOperationStatus.OK) { - log.debug("Failed to lock service {}", componentId); + log.debug(FAILED_TO_LOCK_SERVICE, componentId); resultOp = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(lockStatus))); return resultOp; } @@ -1764,7 +1764,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { validateUserExists(userId, "create Or Update Property Value", false); if (componentTypeEnum == null) { - BeEcompErrorManager.getInstance().logInvalidInputError("CreateOrUpdatePropertyValue", "invalid component type", ErrorSeverity.INFO); + BeEcompErrorManager.getInstance().logInvalidInputError(CREATE_OR_UPDATE_PROPERTY_VALUE, INVALID_COMPONENT_TYPE, ErrorSeverity.INFO); resultOp = Either.right(componentsUtils.getResponseFormat(ActionStatus.NOT_ALLOWED)); return resultOp; } @@ -1777,7 +1777,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { // lock resource StorageOperationStatus lockStatus = graphLockOperation.lockComponent(componentId, componentTypeEnum.getNodeType()); if (lockStatus != StorageOperationStatus.OK) { - log.debug("Failed to lock service {}", componentId); + log.debug(FAILED_TO_LOCK_SERVICE, componentId); resultOp = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(lockStatus))); return resultOp; } @@ -1858,7 +1858,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { validateUserExists(userId, "create Or Update Input Value", false); if (componentTypeEnum == null) { - BeEcompErrorManager.getInstance().logInvalidInputError("createOrUpdateInputValue", "invalid component type", ErrorSeverity.INFO); + BeEcompErrorManager.getInstance().logInvalidInputError("createOrUpdateInputValue", INVALID_COMPONENT_TYPE, ErrorSeverity.INFO); resultOp = Either.right(componentsUtils.getResponseFormat(ActionStatus.NOT_ALLOWED)); return resultOp; } @@ -1871,7 +1871,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { // lock resource StorageOperationStatus lockStatus = graphLockOperation.lockComponent(componentId, componentTypeEnum.getNodeType()); if (lockStatus != StorageOperationStatus.OK) { - log.debug("Failed to lock service {}", componentId); + log.debug(FAILED_TO_LOCK_SERVICE, componentId); resultOp = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(lockStatus))); return resultOp; } @@ -1947,7 +1947,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { Either resultOp = null; if (componentTypeEnum == null) { - BeEcompErrorManager.getInstance().logInvalidInputError("CreateOrUpdatePropertyValue", "invalid component type", ErrorSeverity.INFO); + BeEcompErrorManager.getInstance().logInvalidInputError(CREATE_OR_UPDATE_PROPERTY_VALUE, INVALID_COMPONENT_TYPE, ErrorSeverity.INFO); resultOp = Either.right(componentsUtils.getResponseFormat(ActionStatus.NOT_ALLOWED)); return resultOp; } @@ -1960,7 +1960,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { // lock resource StorageOperationStatus lockStatus = graphLockOperation.lockComponent(serviceId, componentTypeEnum.getNodeType()); if (lockStatus != StorageOperationStatus.OK) { - log.debug("Failed to lock service {}", serviceId); + log.debug(FAILED_TO_LOCK_SERVICE, serviceId); resultOp = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(lockStatus))); return resultOp; } @@ -2556,13 +2556,13 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { validateUserExists(userId, "update instance capability property", false); if (componentTypeEnum == null) { - BeEcompErrorManager.getInstance().logInvalidInputError("updateInstanceCapabilityProperty", "invalid component type", ErrorSeverity.INFO); + BeEcompErrorManager.getInstance().logInvalidInputError("updateInstanceCapabilityProperty", INVALID_COMPONENT_TYPE, ErrorSeverity.INFO); return Either.right(componentsUtils.getResponseFormat(ActionStatus.NOT_ALLOWED)); } Either getResourceResult = toscaOperationFacade.getToscaFullElement(containerComponentId); if (getResourceResult.isRight()) { - log.debug("Failed to retrieve component, component id {}", containerComponentId); + log.debug(FAILED_TO_RETRIEVE_COMPONENT_COMPONENT_ID, containerComponentId); return Either.right(componentsUtils.getResponseFormat(ActionStatus.RESTRICTED_OPERATION)); } Component containerComponent = getResourceResult.left().value(); @@ -2625,13 +2625,13 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { validateUserExists(userId, "update instance capability property", false); if (componentTypeEnum == null) { - BeEcompErrorManager.getInstance().logInvalidInputError("updateInstanceCapabilityProperty", "invalid component type", ErrorSeverity.INFO); + BeEcompErrorManager.getInstance().logInvalidInputError("updateInstanceCapabilityProperty", INVALID_COMPONENT_TYPE, ErrorSeverity.INFO); return Either.right(componentsUtils.getResponseFormat(ActionStatus.NOT_ALLOWED)); } Either getResourceResult = toscaOperationFacade.getToscaFullElement(containerComponentId); if (getResourceResult.isRight()) { - log.debug("Failed to retrieve component, component id {}", containerComponentId); + log.debug(FAILED_TO_RETRIEVE_COMPONENT_COMPONENT_ID, containerComponentId); return Either.right(componentsUtils.getResponseFormat(ActionStatus.RESTRICTED_OPERATION)); } Component containerComponent = getResourceResult.left().value(); @@ -2921,7 +2921,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { if (componentTypeEnum == null) { BeEcompErrorManager.getInstance().logInvalidInputError( - "createOrUpdateAttributeValue", "invalid component type", ErrorSeverity.INFO); + "createOrUpdateAttributeValue", INVALID_COMPONENT_TYPE, ErrorSeverity.INFO); resultOp = Either.right(componentsUtils.getResponseFormat(ActionStatus.NOT_ALLOWED)); return resultOp; } -- cgit 1.2.3-korg