Sonar code smell fixes 43/73243/1
authorSonsino, Ofir (os0695) <os0695@intl.att.com>
Wed, 21 Nov 2018 11:34:44 +0000 (13:34 +0200)
committerSonsino, Ofir (os0695) <os0695@intl.att.com>
Wed, 21 Nov 2018 11:34:44 +0000 (13:34 +0200)
Change-Id: I324de653e8e3b4c74bd3723f6bed221f21094f5c
Issue-ID: SDC-1948
Signed-off-by: Sonsino, Ofir (os0695) <os0695@intl.att.com>
catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/usersadmin/AuditUserAccessEventFactory.java
catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngine.java
catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineInitTask.java
catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
openecomp-be/backend/openecomp-sdc-action-manager/src/main/java/org/openecomp/sdc/action/impl/ActionManagerImpl.java

index 758e585..d7fbe58 100644 (file)
@@ -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) {
index 334b3f6..fa8d1ee 100644 (file)
@@ -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;
index 2b1e716..52b1967 100644 (file)
@@ -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) {
index 62f62f1..fc4a739 100644 (file)
@@ -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<List<GroupDefinition>, 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<List<GroupDefinition>, 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<List<GroupInstance>, 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<Boolean, ResponseFormat> lockComponent = lockComponent(parent, "Update Artifact - lock ");
+            Either<Boolean, ResponseFormat> 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<Boolean, ResponseFormat> lockComponent = lockComponent(component, "Update Artifact - lock ");
+        Either<Boolean, ResponseFormat> 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<Boolean, ResponseFormat> lockComponent = lockComponent(parent, "Update Artifact - lock ");
+            Either<Boolean, ResponseFormat> 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<Boolean, ActionStatus> 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<List<GroupInstance>, 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<List<GroupDefinition>, 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<ImmutablePair<String, byte[]>, 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<ImmutablePair<String, byte[]>, 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<ImmutablePair<String, byte[]>, 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<List<GroupInstance>, 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<Boolean, ResponseFormat> lockComponent = lockComponent(parent, "Update Artifact - lock ");
+            Either<Boolean, ResponseFormat> 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);
index 299f818..e92f5f3 100644 (file)
@@ -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<Component, ResponseFormat> eitherResourceName = getOriginComponentFromComponentInstance(resourceInstance);
 
             if (eitherResourceName.isRight()) {
@@ -1062,7 +1062,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
 
     public Either<RequirementCapabilityRelDef, ResponseFormat> 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<RequirementCapabilityRelDef, ResponseFormat> resultOp = null;
 
         Either<RequirementCapabilityRelDef, StorageOperationStatus> result = toscaOperationFacade.associateResourceInstances(containerComponent.getUniqueId(), requirementDef);
@@ -1179,7 +1179,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
             String componentId, RequirementCapabilityRelDef requirementDef, Component containerComponent) {
 
         Either<RequirementCapabilityRelDef, ResponseFormat> resultOp = null;
-        log.debug("Try to create entry on graph");
+        log.debug(TRY_TO_CREATE_ENTRY_ON_GRAPH);
         Either<RequirementCapabilityRelDef, StorageOperationStatus> 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<Component, StorageOperationStatus> 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<ComponentInstanceProperty, ResponseFormat> 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<Component, StorageOperationStatus> 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<Component, StorageOperationStatus> 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;
         }
index 458883e..87edc9a 100644 (file)
@@ -58,1133 +58,1138 @@ import static org.openecomp.sdc.action.util.ActionUtil.*;
 import static org.openecomp.sdc.versioning.dao.types.Version.VERSION_STRING_VIOLATION_MSG;
 
 /**
- * Manager Implementation for {@link ActionManager Action Library Operations} <br> Handles Business
- * layer validations and acts as an interface between the REST and DAO layers.
+ * Manager Implementation for {@link ActionManager Action Library Operations}
+ * <br>
+ * Handles Business layer validations and acts as an interface between the REST
+ * and DAO layers.
  */
 public class ActionManagerImpl implements ActionManager {
 
-  private   final ActionDao actionDao;
-  private   final ActionVersioningManager versioningManager;
-  private  final ActionArtifactDao actionArtifactDao;
-  private  final VersionInfoDao versionInfoDao;
-
-  private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
-
-  public ActionManagerImpl() {
-    actionDao = ActionDaoFactory.getInstance().createInterface();
-    versioningManager = ActionVersioningManagerFactory.getInstance().createInterface();
-    actionArtifactDao = ActionArtifactDaoFactory.getInstance().createInterface();
-    versionInfoDao = VersionInfoDaoFactory.getInstance().createInterface();
-    actionDao.registerVersioning(ACTION_VERSIONABLE_TYPE);
-  }
-
-  public ActionManagerImpl(ActionDao actionDao, ActionVersioningManager versioningManager,
-                           ActionArtifactDao actionArtifactDao, VersionInfoDao versionInfoDao) {
-    this.actionDao = actionDao;
-    this.versioningManager = versioningManager;
-    this.actionArtifactDao = actionArtifactDao;
-    this.versionInfoDao = versionInfoDao;
-  }
-  /**
-   * List All Major, Last Minor and Candidate version (if any) for Given Action Invariant UUID
-   *
-   * @param invariantId Invariant UUID of the action for which the information is required
-   * @return List of All Major, Last Minor and Candidate version if any Of {@link Action} with given
-   * actionInvariantUuId.
-   * @throws ActionException Exception with an action library specific code, short description and
-   *                         detailed message for the error occurred during the operation
-   */
-
-  @Override
-  public List<Action> getActionsByActionInvariantUuId(String invariantId) throws ActionException {
-    List<Action> actions;
-
-    log.debug(" entering getActionsByActionInvariantUuId with  invariantID = " + invariantId);
-    actions = actionDao
-        .getActionsByActionInvariantUuId(invariantId != null ? invariantId.toUpperCase() : null);
-
-    if (actions != null && actions.isEmpty()) {
-      throw new ActionException(ACTION_ENTITY_NOT_EXIST_CODE, ACTION_ENTITY_NOT_EXIST);
+    private static final String ARTIFACT_UUID = "artifactUUID= ";
+    private static final String BY_USER = " by user = ";
+    private static final String WITH_VALUE = " With value = ";
+    private static final String AND_VERSION = " and version";
+    private final ActionDao actionDao;
+    private final ActionVersioningManager versioningManager;
+    private final ActionArtifactDao actionArtifactDao;
+    private final VersionInfoDao versionInfoDao;
+
+    private final Logger log = LoggerFactory.getLogger(this.getClass()
+            .getName());
+
+    public ActionManagerImpl() {
+        actionDao = ActionDaoFactory.getInstance()
+                .createInterface();
+        versioningManager = ActionVersioningManagerFactory.getInstance()
+                .createInterface();
+        actionArtifactDao = ActionArtifactDaoFactory.getInstance()
+                .createInterface();
+        versionInfoDao = VersionInfoDaoFactory.getInstance()
+                .createInterface();
+        actionDao.registerVersioning(ACTION_VERSIONABLE_TYPE);
     }
 
-    log.debug(" exit getActionsByActionInvariantUuId with  invariantID = " + invariantId);
-    return actions;
-  }
-
-  /**
-   * Get list of actions based on a filter criteria. If no filter is sent all actions will be
-   * returned
-   *
-   * @param filterType  Filter by Vendor/Category/Model/Component/None
-   * @param filterValue Filter Parameter Value (Vendor ID/Category ID/Model ID/Component ID)
-   * @return List of {@link Action} objects based on a filter criteria <br> Empty List if no records
-   * match the provided filter criteria
-   * @throws ActionException Exception with an action library specific code, short description and
-   *                         detailed message for the error occurred for the error occurred during
-   *                         the operation
-   */
-  @Override
-  public List<Action> getFilteredActions(String filterType, String filterValue)
-      throws ActionException {
-    List<Action> actions;
-    log.debug(" entering getFilteredActions By filterType = " + filterType + " With value = "
-        + filterValue);
-    switch (filterType) {
-      case FILTER_TYPE_NONE:
-        //Business validation for OPENECOMP Component type fetch (if any)
-        break;
-      case FILTER_TYPE_VENDOR:
-        //Business validation for vendor type fetch (if any)
-        break;
-      case FILTER_TYPE_CATEGORY:
-        //Business validation for Category type fetch (if any)
-        break;
-      case FILTER_TYPE_MODEL:
-        //Business validation for model type fetch (if any)
-        break;
-      case FILTER_TYPE_OPEN_ECOMP_COMPONENT:
-        //Business validation for OPENECOMP Component type fetch (if any)
-        break;
-      case FILTER_TYPE_NAME:
-        actions = actionDao
-            .getFilteredActions(filterType, filterValue != null ? filterValue.toLowerCase() : null);
+    public ActionManagerImpl(ActionDao actionDao, ActionVersioningManager versioningManager,
+            ActionArtifactDao actionArtifactDao, VersionInfoDao versionInfoDao) {
+        this.actionDao = actionDao;
+        this.versioningManager = versioningManager;
+        this.actionArtifactDao = actionArtifactDao;
+        this.versionInfoDao = versionInfoDao;
+    }
+
+    /**
+     * List All Major, Last Minor and Candidate version (if any) for Given
+     * Action Invariant UUID
+     *
+     * @param invariantId
+     *            Invariant UUID of the action for which the information is
+     *            required
+     * @return List of All Major, Last Minor and Candidate version if any Of
+     *         {@link Action} with given actionInvariantUuId.
+     */
+
+    @Override
+    public List<Action> getActionsByActionInvariantUuId(String invariantId) {
+        List<Action> actions;
+
+        log.debug(" entering getActionsByActionInvariantUuId with  invariantID = " + invariantId);
+        actions = actionDao.getActionsByActionInvariantUuId(invariantId != null ? invariantId.toUpperCase() : null);
+
         if (actions != null && actions.isEmpty()) {
-          throw new ActionException(ACTION_ENTITY_NOT_EXIST_CODE, ACTION_ENTITY_NOT_EXIST);
+            throw new ActionException(ACTION_ENTITY_NOT_EXIST_CODE, ACTION_ENTITY_NOT_EXIST);
         }
-        log.debug(" exit getFilteredActions By filterType = " + filterType + " With value = "
-            + filterValue);
+
+        log.debug(" exit getActionsByActionInvariantUuId with  invariantID = " + invariantId);
         return actions;
-      default:
-        break;
-    }
-    actions = actionDao
-        .getFilteredActions(filterType, filterValue != null ? filterValue.toLowerCase() : null);
-    List<Action> majorMinorVersionList = getMajorMinorVersionActions(actions);
-    Collections.sort(majorMinorVersionList);
-    log.debug(
-        " exit getFilteredActions By filterType = " + filterType + " With value = " + filterValue);
-    return majorMinorVersionList;
-  }
-
-  /**
-   * Get the properties of an action version by its UUID.
-   *
-   * @param actionUuId UUID of the specific action version
-   * @return {@link Action} object corresponding the version represented by the UUID
-   * @throws ActionException Exception with an action library specific code, short description and
-   *                         detailed message for the error occurred for the error occurred during
-   *                         the operation
-   */
-  @Override
-  public Action getActionsByActionUuId(String actionUuId) throws ActionException {
-    log.debug(" entering getActionsByActionUuId with  actionUUID = " + actionUuId);
-    Action action =
-        actionDao.getActionsByActionUuId(actionUuId != null ? actionUuId.toUpperCase() : null);
-
-    if (action == null) {
-      throw new ActionException(ACTION_ENTITY_NOT_EXIST_CODE, ACTION_ENTITY_NOT_EXIST);
     }
 
-    log.debug(" exit getActionsByActionUuId with  actionUUID = " + actionUuId);
-    return action;
-  }
-
-  /**
-   * List OPENECOMP Components supported by Action Library.
-   *
-   * @return List of {@link OpenEcompComponent} objects supported by Action Library <br> Empty List if
-   * no components are found
-   * @throws ActionException Exception with an action library specific code, short description and
-   *                         detailed message for the error occurred for the error occurred during
-   *                         the operation
-   */
-  @Override
-  public List<OpenEcompComponent> getOpenEcompComponents() throws ActionException {
-    return actionDao.getOpenEcompComponents();
-  }
-
-
-  /**
-   * Delete an action.
-   *
-   * @param actionInvariantUuId Invariant UUID of the action to be deleted
-   * @param user                User id of the user performing the operation
-   */
-  @Override
-  public void deleteAction(String actionInvariantUuId, String user) throws ActionException {
-    try {
-      log.debug("entering deleteAction with actionInvariantUuId = " + actionInvariantUuId
-          + " and user = " + user);
-      actionLogPreProcessor(ActionSubOperation.DELETE_ACTION, TARGET_ENTITY_API);
-      versioningManager.delete(ACTION_VERSIONABLE_TYPE, actionInvariantUuId, user);
-      actionLogPostProcessor(StatusCode.COMPLETE);
-      log.metrics("");
-      actionDao.deleteAction(actionInvariantUuId);
-    } catch (CoreException ce) {
-      formAndThrowException(ce);
+    /**
+     * Get list of actions based on a filter criteria. If no filter is sent all
+     * actions will be returned
+     *
+     * @param filterType
+     *            Filter by Vendor/Category/Model/Component/None
+     * @param filterValue
+     *            Filter Parameter Value (Vendor ID/Category ID/Model
+     *            ID/Component ID)
+     * @return List of {@link Action} objects based on a filter criteria <br>
+     *         Empty List if no records match the provided filter criteria
+     */
+    @Override
+    public List<Action> getFilteredActions(String filterType, String filterValue) {
+        List<Action> actions;
+        log.debug(" entering getFilteredActions By filterType = " + filterType + WITH_VALUE + filterValue);
+        switch (filterType) {
+        case FILTER_TYPE_NONE:
+            // Business validation for OPENECOMP Component type fetch (if any)
+            break;
+        case FILTER_TYPE_VENDOR:
+            // Business validation for vendor type fetch (if any)
+            break;
+        case FILTER_TYPE_CATEGORY:
+            // Business validation for Category type fetch (if any)
+            break;
+        case FILTER_TYPE_MODEL:
+            // Business validation for model type fetch (if any)
+            break;
+        case FILTER_TYPE_OPEN_ECOMP_COMPONENT:
+            // Business validation for OPENECOMP Component type fetch (if any)
+            break;
+        case FILTER_TYPE_NAME:
+            actions = actionDao.getFilteredActions(filterType, filterValue != null ? filterValue.toLowerCase() : null);
+            if (actions != null && actions.isEmpty()) {
+                throw new ActionException(ACTION_ENTITY_NOT_EXIST_CODE, ACTION_ENTITY_NOT_EXIST);
+            }
+            log.debug(" exit getFilteredActions By filterType = " + filterType + WITH_VALUE + filterValue);
+            return actions;
+        default:
+            break;
+        }
+        actions = actionDao.getFilteredActions(filterType, filterValue != null ? filterValue.toLowerCase() : null);
+        List<Action> majorMinorVersionList = getMajorMinorVersionActions(actions);
+        Collections.sort(majorMinorVersionList);
+        log.debug(" exit getFilteredActions By filterType = " + filterType + WITH_VALUE + filterValue);
+        return majorMinorVersionList;
     }
-  }
-
-  /**
-   * Create a new Action.
-   *
-   * @param action Action object model of the user request for creating an action
-   * @param user   AT&T id of the user sending the create request
-   * @return {@link Action} model object for the created action
-   * @throws ActionException Exception with an action library specific code, short description and
-   *                         detailed message for the error occurred for the error occurred during
-   *                         the operation
-   */
-  @Override
-  public Action createAction(Action action, String user) throws ActionException {
-    UniqueValueUtil uniqueValueUtil =
-        new UniqueValueUtil(UniqueValueDaoFactory.getInstance().createInterface());
-    try {
-      actionLogPreProcessor(ActionSubOperation.VALIDATE_ACTION_UNIQUE_NAME, TARGET_ENTITY_API);
-      uniqueValueUtil
-          .validateUniqueValue(ActionConstants.UniqueValues.ACTION_NAME, action.getName());
-      actionLogPostProcessor(StatusCode.COMPLETE);
-    } catch (CoreException exception) {
-      String errorDesc = String
-          .format(ACTION_ENTITY_UNIQUE_VALUE_MSG, ActionConstants.UniqueValues.ACTION_NAME,
-              action.getName());
-      log.error(errorDesc, exception);
-      actionLogPostProcessor(StatusCode.ERROR, ACTION_ENTITY_UNIQUE_VALUE_ERROR, errorDesc, false);
-      throw new ActionException(ACTION_ENTITY_UNIQUE_VALUE_ERROR, errorDesc);
-    } finally {
-      log.metrics("");
+
+    /**
+     * Get the properties of an action version by its UUID.
+     *
+     * @param actionUuId
+     *            UUID of the specific action version
+     * @return {@link Action} object corresponding the version represented by
+     *         the UUID
+     */
+    @Override
+    public Action getActionsByActionUuId(String actionUuId) {
+        log.debug(" entering getActionsByActionUuId with  actionUUID = " + actionUuId);
+        Action action = actionDao.getActionsByActionUuId(actionUuId != null ? actionUuId.toUpperCase() : null);
+
+        if (action == null) {
+            throw new ActionException(ACTION_ENTITY_NOT_EXIST_CODE, ACTION_ENTITY_NOT_EXIST);
+        }
+
+        log.debug(" exit getActionsByActionUuId with  actionUUID = " + actionUuId);
+        return action;
     }
-    action.setUser(user);
-    action.setTimestamp(getCurrentTimeStampUtc());
-    action.setActionInvariantUuId(CommonMethods.nextUuId());
-    action.setActionUuId(CommonMethods.nextUuId());
-
-    actionLogPreProcessor(ActionSubOperation.CREATE_ACTION_VERSION, TARGET_ENTITY_API);
-    Version version =
-        versioningManager.create(ACTION_VERSIONABLE_TYPE, action.getActionInvariantUuId(), user);
-    actionLogPostProcessor(StatusCode.COMPLETE);
-    log.metrics("");
-
-    action.setVersion(version.toString());
-    action.setStatus(ActionStatus.Locked);
-    action = updateData(action);
-    action = actionDao.createAction(action);
-
-    actionLogPreProcessor(ActionSubOperation.CREATE_ACTION_UNIQUE_VALUE, TARGET_ENTITY_API);
-    uniqueValueUtil.createUniqueValue(ActionConstants.UniqueValues.ACTION_NAME, action.getName());
-    actionLogPostProcessor(StatusCode.COMPLETE);
-    log.metrics("");
-
-    return action;
-  }
-
-  /**
-   * Update an existing action.
-   *
-   * @param action Action object model of the user request for creating an action
-   * @param user   AT&T id of the user sending the update request
-   * @return {@link Action} model object for the update action
-   * @throws ActionException Exception with an action library specific code, short description and
-   *                         detailed message for the error occurred for the error occurred during
-   *                         the operation
-   */
-  @Override
-  public Action updateAction(Action action, String user) throws ActionException {
-    try {
-      log.debug("entering updateAction to update action with invariantUuId = "
-          + action.getActionInvariantUuId() + " by user = " + user);
-      String invariantUuId = action.getActionInvariantUuId();
-      actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_API);
-      VersionInfo versionInfo = versioningManager
-          .getEntityVersionInfo(ACTION_VERSIONABLE_TYPE, invariantUuId, user,
-              VersionableEntityAction.Write);
-      actionLogPostProcessor(StatusCode.COMPLETE);
-      log.metrics("");
-
-      Version activeVersion = versionInfo.getActiveVersion();
-      validateActions(action, activeVersion);
-      action.setStatus(ActionStatus.Locked); //Status will be Checkout for update
-      updateData(action);
-      action.setUser(user);
-      action.setTimestamp(getCurrentTimeStampUtc());
-      actionDao.updateAction(action);
-
-    } catch (CoreException ce) {
-      formAndThrowException(ce);
+
+    /**
+     * List OPENECOMP Components supported by Action Library.
+     *
+     * @return List of {@link OpenEcompComponent} objects supported by Action
+     *         Library <br>
+     *         Empty List if no components are found
+     */
+    @Override
+    public List<OpenEcompComponent> getOpenEcompComponents() {
+        return actionDao.getOpenEcompComponents();
     }
-    log.debug("exit updateAction");
-    return action;
-  }
-
-  /**
-   * Checkout an existing action.
-   *
-   * @param invariantUuId actionInvariantUuId of the action to be checked out
-   * @param user          AT&T id of the user sending the checkout request
-   * @return {@link Action} model object for the checkout action
-   * @throws ActionException Exception with an action library specific code, short description and
-   *                         detailed message for the error occurred for the error occurred during
-   *                         the operation
-   */
-  @Override
-  public Action checkout(String invariantUuId, String user) throws ActionException {
-    Version version = null;
-    ActionEntity actionEntity = null;
-    try {
-      log.debug(
-          "entering checkout for Action with invariantUUID= " + invariantUuId + " by user = "
-              + user);
-      actionLogPreProcessor(ActionSubOperation.CHECKOUT_ACTION, TARGET_ENTITY_API);
-      version = versioningManager.checkout(ACTION_VERSIONABLE_TYPE, invariantUuId, user);
-      actionLogPostProcessor(StatusCode.COMPLETE);
-      log.metrics("");
-
-      actionEntity =
-          updateUniqueIdForVersion(invariantUuId, version, ActionStatus.Locked.name(), user);
-    } catch (CoreException exception) {
-      if (exception.code() != null && exception.code().id().equals(
-          VersioningErrorCodes.CHECKOT_ON_LOCKED_ENTITY)) {
-        actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_DB);
-        VersionInfoEntity versionInfoEntity =
-            versionInfoDao.get(new VersionInfoEntity(ACTION_VERSIONABLE_TYPE, invariantUuId));
-        actionLogPostProcessor(StatusCode.COMPLETE);
-        log.metrics("");
-        String checkoutUser = versionInfoEntity.getCandidate().getUser();
-        log.debug(
-            "Actual checkout user for Action with invariantUUID= " + invariantUuId + " is = "
-                + checkoutUser);
-        if (!checkoutUser.equals(user)) {
-          throw new ActionException(ACTION_CHECKOUT_ON_LOCKED_ENTITY_OTHER_USER,
-              exception.getMessage());
+
+    /**
+     * Delete an action.
+     *
+     * @param actionInvariantUuId
+     *            Invariant UUID of the action to be deleted
+     * @param user
+     *            User id of the user performing the operation
+     */
+    @Override
+    public void deleteAction(String actionInvariantUuId, String user) {
+        try {
+            log.debug(
+                    "entering deleteAction with actionInvariantUuId = " + actionInvariantUuId + " and user = " + user);
+            actionLogPreProcessor(ActionSubOperation.DELETE_ACTION, TARGET_ENTITY_API);
+            versioningManager.delete(ACTION_VERSIONABLE_TYPE, actionInvariantUuId, user);
+            actionLogPostProcessor(StatusCode.COMPLETE);
+            log.metrics("");
+            actionDao.deleteAction(actionInvariantUuId);
+        } catch (CoreException ce) {
+            formAndThrowException(ce);
         }
-      }
-      formAndThrowException(exception);
     }
-    log.debug(
-        "exit checkout for Action with invariantUUID= " + invariantUuId + " by user = " + user);
-    return actionEntity != null ? actionEntity.toDto() : new Action();
-  }
-
-  /**
-   * Undo an already checked out action.
-   *
-   * @param invariantUuId actionInvariantUuId of the checked out action
-   * @param user          AT&T id of the user sending the request
-   * @throws ActionException Exception with an action library specific code, short description and
-   *                         detailed message for the error occurred for the error occurred during
-   *                         the operation
-   */
-  @Override
-  public void undoCheckout(String invariantUuId, String user) throws ActionException {
-    Version version;
-    try {
-      log.debug(
-          "entering undoCheckout for Action with invariantUUID= " + invariantUuId + " by user = "
-              + user);
-
-      actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_DB);
-      //Get list of uploaded artifacts in this checked out version
-      VersionInfoEntity versionInfoEntity =
-          versionInfoDao.get(new VersionInfoEntity(ACTION_VERSIONABLE_TYPE, invariantUuId));
-      actionLogPostProcessor(StatusCode.COMPLETE);
-      log.metrics("");
-      if (versionInfoEntity == null) {
-        throw new CoreException(
-            new EntityNotExistErrorBuilder(ACTION_VERSIONABLE_TYPE, invariantUuId).build());
-      }
-      UserCandidateVersion candidate = versionInfoEntity.getCandidate();
-      Version activeVersion;
-      if (candidate != null) {
-        activeVersion = candidate.getVersion();
-      } else {
-        activeVersion = versionInfoEntity.getActiveVersion();
-      }
-
-      actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_VERSION, TARGET_ENTITY_DB);
-      Action action = actionDao.get(new ActionEntity(invariantUuId, activeVersion)).toDto();
-      actionLogPostProcessor(StatusCode.COMPLETE);
-      log.metrics("");
-
-      //Perform undo checkout on the action
-      actionLogPreProcessor(ActionSubOperation.UNDO_CHECKOUT_ACTION, TARGET_ENTITY_API);
-      version = versioningManager.undoCheckout(ACTION_VERSIONABLE_TYPE, invariantUuId, user);
-      actionLogPostProcessor(StatusCode.COMPLETE);
-      log.metrics("");
-
-      if (version.equals(new Version(0, 0))) {
-        actionLogPreProcessor(ActionSubOperation.DELETE_UNIQUEVALUE, TARGET_ENTITY_API);
-        UniqueValueUtil uniqueValueUtil =
-            new UniqueValueUtil(UniqueValueDaoFactory.getInstance().createInterface());
-        uniqueValueUtil
-            .deleteUniqueValue(ActionConstants.UniqueValues.ACTION_NAME, action.getName());
+
+    /**
+     * Create a new Action.
+     *
+     * @param action
+     *            Action object model of the user request for creating an action
+     * @param user
+     *            AT&T id of the user sending the create request
+     * @return {@link Action} model object for the created action
+     */
+    @Override
+    public Action createAction(Action action, String user) {
+        UniqueValueUtil uniqueValueUtil = new UniqueValueUtil(UniqueValueDaoFactory.getInstance()
+                .createInterface());
+        try {
+            actionLogPreProcessor(ActionSubOperation.VALIDATE_ACTION_UNIQUE_NAME, TARGET_ENTITY_API);
+            uniqueValueUtil.validateUniqueValue(ActionConstants.UniqueValues.ACTION_NAME, action.getName());
+            actionLogPostProcessor(StatusCode.COMPLETE);
+        } catch (CoreException exception) {
+            String errorDesc = String.format(ACTION_ENTITY_UNIQUE_VALUE_MSG, ActionConstants.UniqueValues.ACTION_NAME,
+                    action.getName());
+            log.error(errorDesc, exception);
+            actionLogPostProcessor(StatusCode.ERROR, ACTION_ENTITY_UNIQUE_VALUE_ERROR, errorDesc, false);
+            throw new ActionException(ACTION_ENTITY_UNIQUE_VALUE_ERROR, errorDesc);
+        } finally {
+            log.metrics("");
+        }
+        action.setUser(user);
+        action.setTimestamp(getCurrentTimeStampUtc());
+        action.setActionInvariantUuId(CommonMethods.nextUuId());
+        action.setActionUuId(CommonMethods.nextUuId());
+
+        actionLogPreProcessor(ActionSubOperation.CREATE_ACTION_VERSION, TARGET_ENTITY_API);
+        Version version = versioningManager.create(ACTION_VERSIONABLE_TYPE, action.getActionInvariantUuId(), user);
         actionLogPostProcessor(StatusCode.COMPLETE);
         log.metrics("");
 
-        actionLogPreProcessor(ActionSubOperation.DELETE_ACTIONVERSION, TARGET_ENTITY_DB);
-        //Added for the case where Create->Undo_Checkout->Checkout should not get the action
-        versionInfoDao.delete(new VersionInfoEntity(ACTION_VERSIONABLE_TYPE, invariantUuId));
+        action.setVersion(version.toString());
+        action.setStatus(ActionStatus.Locked);
+        action = updateData(action);
+        action = actionDao.createAction(action);
+
+        actionLogPreProcessor(ActionSubOperation.CREATE_ACTION_UNIQUE_VALUE, TARGET_ENTITY_API);
+        uniqueValueUtil.createUniqueValue(ActionConstants.UniqueValues.ACTION_NAME, action.getName());
         actionLogPostProcessor(StatusCode.COMPLETE);
         log.metrics("");
-      }
-
-      List<ActionArtifact> currentVersionArtifacts = action.getArtifacts();
-
-      //Delete the artifacts from action_artifact table (if any)
-      if (CollectionUtils.isNotEmpty(currentVersionArtifacts) &&
-          currentVersionArtifacts.size() > 0) {
-        for (ActionArtifact artifact : currentVersionArtifacts) {
-          ActionArtifactEntity artifactDeleteEntity =
-              new ActionArtifactEntity(artifact.getArtifactUuId(),
-                  getEffectiveVersion(activeVersion.toString()));
-          actionLogPreProcessor(ActionSubOperation.DELETE_ARTIFACT, TARGET_ENTITY_DB);
-          actionArtifactDao.delete(artifactDeleteEntity);
-          actionLogPostProcessor(StatusCode.COMPLETE);
-          log.metrics("");
-        }
-      }
-    } catch (CoreException exception) {
-      formAndThrowException(exception);
-    }
-    log.debug(
-        "exit undoCheckout for Action with invariantUUID= " + invariantUuId + " by user = " + user);
-  }
-
-  /**
-   * Checkin a checked out action.
-   *
-   * @param invariantUuId actionInvariantUuId of the checked out action
-   * @param user          AT&T id of the user sending the request
-   * @return {@link Action} model object for the updated action
-   * @throws ActionException Exception with an action library specific code, short description and
-   *                         detailed message for the error occurred for the error occurred during
-   *                         the operation
-   */
-  @Override
-  public Action checkin(String invariantUuId, String user) throws ActionException {
-    Version version = null;
-    ActionEntity actionEntity = null;
-    try {
-      log.debug("entering checkin for Action with invariantUUID= " + invariantUuId + " by user = "
-          + user);
-      actionLogPreProcessor(ActionSubOperation.CHECKIN_ACTION, TARGET_ENTITY_API);
-      version = versioningManager.checkin(ACTION_VERSIONABLE_TYPE, invariantUuId, user, null);
-      actionLogPostProcessor(StatusCode.COMPLETE);
-      log.metrics("");
-      actionEntity =
-          updateStatusForVersion(invariantUuId, version, ActionStatus.Available.name(), user);
-    } catch (CoreException exception) {
-      formAndThrowException(exception);
-    }
-    log.debug(
-        "exit checkin for Action with invariantUUID= " + invariantUuId + " by user = " + user);
-    return actionEntity != null ? actionEntity.toDto() : new Action();
-  }
-
-  /**
-   * Submit a checked in action.
-   *
-   * @param invariantUuId actionInvariantUuId of the checked in action
-   * @param user          AT&T id of the user sending the request
-   * @return {@link Action} model object for the updated action
-   * @throws ActionException Exception with an action library specific code, short description and
-   *                         detailed message for the error occurred for the error occurred during
-   *                         the operation
-   */
-  @Override
-  public Action submit(String invariantUuId, String user) throws ActionException {
-    Version version = null;
-    ActionEntity actionEntity = null;
-    try {
-      log.debug(
-          "entering submit for Action with invariantUUID= " + invariantUuId + " by user = " + user);
-      actionLogPreProcessor(ActionSubOperation.SUBMIT_ACTION, TARGET_ENTITY_API);
-      version = versioningManager.submit(ACTION_VERSIONABLE_TYPE, invariantUuId, user, null);
-      actionLogPostProcessor(StatusCode.COMPLETE);
-      log.metrics("");
-      actionEntity =
-          updateUniqueIdForVersion(invariantUuId, version, ActionStatus.Final.name(), user);
-    } catch (CoreException exception) {
-      formAndThrowException(exception);
-    }
-    log.debug("exit submit for Action with invariantUUID= " + invariantUuId + " by user = " + user);
-    return actionEntity != null ? actionEntity.toDto() : new Action();
-  }
-
-  /**
-   * Download an artifact of an action.
-   *
-   * @param artifactUuId {@link ActionArtifact} object representing the artifact and its metadata
-   * @param actionUuId   UUID of the action for which the artifact has to be downloaded
-   * @return downloaded action artifact object
-   */
-  @Override
-  public ActionArtifact downloadArtifact(String actionUuId, String artifactUuId)
-      throws ActionException {
-    log.debug(" entering downloadArtifact with actionUUID= " + actionUuId + " and artifactUUID= "
-        + artifactUuId);
-    Action action = actionDao.getActionsByActionUuId(actionUuId);
-    ActionArtifact actionArtifact;
-    if (action != null) {
-      MDC.put(SERVICE_INSTANCE_ID, action.getActionInvariantUuId());
-      List<ActionArtifact> artifacts = action.getArtifacts();
-      String actionVersion = action.getVersion();
-      int effectiveVersion = getEffectiveVersion(actionVersion);
-      ActionArtifact artifactMetadata =
-          getArtifactMetadataFromAction(artifacts, ARTIFACT_METADATA_ATTR_UUID, artifactUuId);
-      if (artifactMetadata != null) {
-        String artifactName = artifactMetadata.getArtifactName();
-        actionArtifact = actionArtifactDao.downloadArtifact(effectiveVersion, artifactUuId);
-        actionArtifact.setArtifactName(artifactName);
-
-      } else {
-        throw new ActionException(ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST_CODE,
-            ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST);
-      }
-    } else {
-      throw new ActionException(ActionErrorConstants.ACTION_ENTITY_NOT_EXIST_CODE,
-          ActionErrorConstants.ACTION_ENTITY_NOT_EXIST);
-    }
-    log.debug(" exit downloadArtifact with actionUUID= " + actionUuId + " and artifactUUID= "
-        + artifactUuId);
-    return actionArtifact;
-  }
-
-  /**
-   * Upload an artifact to an action.
-   *
-   * @param artifact            {@link ActionArtifact} object representing the artifact and its
-   *                            metadata
-   * @param actionInvariantUuId Invariant UUID of the action to which the artifact has to be
-   *                            uploaded
-   * @param user                User ID of the user sending the request
-   * @return Uploaded action artifact object
-   */
-  @Override
-  public ActionArtifact uploadArtifact(ActionArtifact artifact, String actionInvariantUuId,
-                                       String user) {
-    ActionArtifact uploadArtifactResponse = new ActionArtifact();
-    try {
-      log.debug("entering uploadArtifact with actionInvariantUuId= " + actionInvariantUuId
-          + "artifactName= " + artifact.getArtifactName());
-      actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_DB);
-      VersionInfo versionInfo = versioningManager
-          .getEntityVersionInfo(ACTION_VERSIONABLE_TYPE, actionInvariantUuId, user,
-              VersionableEntityAction.Write);
-      actionLogPostProcessor(StatusCode.COMPLETE);
-      log.metrics("");
-      Version activeVersion = versionInfo.getActiveVersion();
-      actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_ACTIONINVID, TARGET_ENTITY_DB);
-      Action action = actionDao.get(new ActionEntity(actionInvariantUuId, activeVersion)).toDto();
-      actionLogPostProcessor(StatusCode.COMPLETE);
-      log.metrics("");
-      String artifactUuId = generateActionArtifactUuId(action, artifact.getArtifactName());
-      //Check for Unique document name
-      List<ActionArtifact> actionArtifacts = action.getArtifacts();
-      ActionArtifact artifactMetadata =
-          getArtifactMetadataFromAction(actionArtifacts, ARTIFACT_METADATA_ATTR_NAME,
-              artifact.getArtifactName());
-      if (artifactMetadata != null) {
-        throw new ActionException(ACTION_ARTIFACT_ALREADY_EXISTS_CODE,
-            String.format(ACTION_ARTIFACT_ALREADY_EXISTS, actionInvariantUuId));
-      }
-
-      //Create the artifact
-      artifact.setArtifactUuId(artifactUuId);
-      artifact.setTimestamp(getCurrentTimeStampUtc());
-      artifact.setEffectiveVersion(getEffectiveVersion(activeVersion.toString()));
-      actionArtifactDao.uploadArtifact(artifact);
-
-      //Update the action data field and timestamp
-      addArtifactMetadataInActionData(action, artifact);
-
-      //Set the response object
-      uploadArtifactResponse.setArtifactUuId(artifact.getArtifactUuId());
-    } catch (CoreException ce) {
-      formAndThrowException(ce);
+
+        return action;
     }
-    log.debug(
-        "exit uploadArtifact with actionInvariantUuId= " + actionInvariantUuId + "artifactName= "
-            + artifact.getArtifactName());
-    return uploadArtifactResponse;
-  }
-
-  @Override
-  public void deleteArtifact(String actionInvariantUuId, String artifactUuId, String user)
-      throws ActionException {
-    log.debug(
-        "enter deleteArtifact with actionInvariantUuId= " + actionInvariantUuId + "artifactUUID= "
-            + artifactUuId + " and user = " + user);
-    Action action = actionDao.getLockedAction(actionInvariantUuId, user);
-    List<ActionArtifact> actionArtifacts = action.getArtifacts();
-    ActionArtifact artifactMetadata =
-        getArtifactMetadataFromAction(actionArtifacts, ARTIFACT_METADATA_ATTR_UUID, artifactUuId);
-    if (artifactMetadata == null) {
-      throw new ActionException(ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST_CODE,
-          ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST);
+
+    /**
+     * Update an existing action.
+     *
+     * @param action
+     *            Action object model of the user request for creating an action
+     * @param user
+     *            AT&T id of the user sending the update request
+     * @return {@link Action} model object for the update action
+     */
+    @Override
+    public Action updateAction(Action action, String user) {
+        try {
+            log.debug("entering updateAction to update action with invariantUuId = " + action.getActionInvariantUuId()
+                    + BY_USER + user);
+            String invariantUuId = action.getActionInvariantUuId();
+            actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_API);
+            VersionInfo versionInfo = versioningManager.getEntityVersionInfo(ACTION_VERSIONABLE_TYPE, invariantUuId,
+                    user, VersionableEntityAction.Write);
+            actionLogPostProcessor(StatusCode.COMPLETE);
+            log.metrics("");
+
+            Version activeVersion = versionInfo.getActiveVersion();
+            validateActions(action, activeVersion);
+            action.setStatus(ActionStatus.Locked); // Status will be Checkout
+                                                   // for update
+            updateData(action);
+            action.setUser(user);
+            action.setTimestamp(getCurrentTimeStampUtc());
+            actionDao.updateAction(action);
+
+        } catch (CoreException ce) {
+            formAndThrowException(ce);
+        }
+        log.debug("exit updateAction");
+        return action;
     }
-    if (artifactMetadata.getArtifactProtection().equals(ActionArtifactProtection.readOnly.name())) {
-      throw new ActionException(ACTION_ARTIFACT_DELETE_READ_ONLY,
-          ACTION_ARTIFACT_DELETE_READ_ONLY_MSG);
-    } else {
-
-      //Update action by removing artifact metadata
-      String jsonData = action.getData();
-      List<ActionArtifact> artifacts = action.getArtifacts();//action.getArtifacts();
-      ActionArtifact artifact = null;
-      Iterator<ActionArtifact> it = artifacts.iterator();
-      while (it.hasNext()) {
-        artifact = it.next();
-        String artifactId = artifact.getArtifactUuId();
-        if (artifactId.equals(artifactUuId)) {
-          it.remove();
+
+    /**
+     * Checkout an existing action.
+     *
+     * @param invariantUuId
+     *            actionInvariantUuId of the action to be checked out
+     * @param user
+     *            AT&T id of the user sending the checkout request
+     * @return {@link Action} model object for the checkout action
+     */
+    @Override
+    public Action checkout(String invariantUuId, String user) {
+        Version version = null;
+        ActionEntity actionEntity = null;
+        try {
+            log.debug("entering checkout for Action with invariantUUID= " + invariantUuId + BY_USER + user);
+            actionLogPreProcessor(ActionSubOperation.CHECKOUT_ACTION, TARGET_ENTITY_API);
+            version = versioningManager.checkout(ACTION_VERSIONABLE_TYPE, invariantUuId, user);
+            actionLogPostProcessor(StatusCode.COMPLETE);
+            log.metrics("");
+
+            actionEntity = updateUniqueIdForVersion(invariantUuId, version, ActionStatus.Locked.name(), user);
+        } catch (CoreException exception) {
+            if (exception.code() != null && exception.code()
+                    .id()
+                    .equals(VersioningErrorCodes.CHECKOT_ON_LOCKED_ENTITY)) {
+                actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_DB);
+                VersionInfoEntity versionInfoEntity = versionInfoDao
+                        .get(new VersionInfoEntity(ACTION_VERSIONABLE_TYPE, invariantUuId));
+                actionLogPostProcessor(StatusCode.COMPLETE);
+                log.metrics("");
+                String checkoutUser = versionInfoEntity.getCandidate()
+                        .getUser();
+                log.debug("Actual checkout user for Action with invariantUUID= " + invariantUuId + " is = "
+                        + checkoutUser);
+                if (!checkoutUser.equals(user)) {
+                    throw new ActionException(ACTION_CHECKOUT_ON_LOCKED_ENTITY_OTHER_USER, exception.getMessage());
+                }
+            }
+            formAndThrowException(exception);
         }
-      }
-
-      Map dataMap = JsonUtil.json2Object(jsonData, LinkedHashMap.class);
-      dataMap.put("artifacts", artifacts);
-      String data = JsonUtil.object2Json(dataMap);
-      ActionEntity actionEntity = action.toEntity();
-      actionEntity.setData(data);
-      actionLogPreProcessor(ActionSubOperation.UPDATE_ACTION, TARGET_ENTITY_DB);
-      actionDao.update(actionEntity);
-      actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
-      log.metrics("");
-      // delete Artifact if it's upload and delete action on same checkout version
-      String artifactName = artifactMetadata.getArtifactName();
-      String generatedArtifactUuId = generateActionArtifactUuId(action, artifactName);
-      if (generatedArtifactUuId.equals(artifactUuId)) {
-        if (artifact != null) {
-          ActionArtifactEntity artifactDeleteEntity =
-              new ActionArtifactEntity(artifact.getArtifactUuId(),
-                  getEffectiveVersion(action.getVersion()));
-          actionLogPreProcessor(ActionSubOperation.DELETE_ACTION_ARTIFACT, TARGET_ENTITY_DB);
-          actionArtifactDao.delete(artifactDeleteEntity);
+        log.debug("exit checkout for Action with invariantUUID= " + invariantUuId + BY_USER + user);
+        return actionEntity != null ? actionEntity.toDto() : new Action();
+    }
+
+    /**
+     * Undo an already checked out action.
+     *
+     * @param invariantUuId
+     *            actionInvariantUuId of the checked out action
+     * @param user
+     *            AT&T id of the user sending the request
+     */
+    @Override
+    public void undoCheckout(String invariantUuId, String user) {
+        Version version;
+        try {
+            log.debug("entering undoCheckout for Action with invariantUUID= " + invariantUuId + BY_USER + user);
+
+            actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_DB);
+            // Get list of uploaded artifacts in this checked out version
+            VersionInfoEntity versionInfoEntity = versionInfoDao
+                    .get(new VersionInfoEntity(ACTION_VERSIONABLE_TYPE, invariantUuId));
+            actionLogPostProcessor(StatusCode.COMPLETE);
+            log.metrics("");
+            if (versionInfoEntity == null) {
+                throw new CoreException(new EntityNotExistErrorBuilder(ACTION_VERSIONABLE_TYPE, invariantUuId).build());
+            }
+            UserCandidateVersion candidate = versionInfoEntity.getCandidate();
+            Version activeVersion;
+            if (candidate != null) {
+                activeVersion = candidate.getVersion();
+            } else {
+                activeVersion = versionInfoEntity.getActiveVersion();
+            }
+
+            actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_VERSION, TARGET_ENTITY_DB);
+            Action action = actionDao.get(new ActionEntity(invariantUuId, activeVersion))
+                    .toDto();
+            actionLogPostProcessor(StatusCode.COMPLETE);
+            log.metrics("");
+
+            // Perform undo checkout on the action
+            actionLogPreProcessor(ActionSubOperation.UNDO_CHECKOUT_ACTION, TARGET_ENTITY_API);
+            version = versioningManager.undoCheckout(ACTION_VERSIONABLE_TYPE, invariantUuId, user);
+            actionLogPostProcessor(StatusCode.COMPLETE);
+            log.metrics("");
+
+            if (version.equals(new Version(0, 0))) {
+                actionLogPreProcessor(ActionSubOperation.DELETE_UNIQUEVALUE, TARGET_ENTITY_API);
+                UniqueValueUtil uniqueValueUtil = new UniqueValueUtil(UniqueValueDaoFactory.getInstance()
+                        .createInterface());
+                uniqueValueUtil.deleteUniqueValue(ActionConstants.UniqueValues.ACTION_NAME, action.getName());
+                actionLogPostProcessor(StatusCode.COMPLETE);
+                log.metrics("");
+
+                actionLogPreProcessor(ActionSubOperation.DELETE_ACTIONVERSION, TARGET_ENTITY_DB);
+                // Added for the case where Create->Undo_Checkout->Checkout
+                // should not get the action
+                versionInfoDao.delete(new VersionInfoEntity(ACTION_VERSIONABLE_TYPE, invariantUuId));
+                actionLogPostProcessor(StatusCode.COMPLETE);
+                log.metrics("");
+            }
+
+            List<ActionArtifact> currentVersionArtifacts = action.getArtifacts();
+
+            // Delete the artifacts from action_artifact table (if any)
+            if (CollectionUtils.isNotEmpty(currentVersionArtifacts) && currentVersionArtifacts.size() > 0) {
+                for (ActionArtifact artifact : currentVersionArtifacts) {
+                    ActionArtifactEntity artifactDeleteEntity = new ActionArtifactEntity(artifact.getArtifactUuId(),
+                            getEffectiveVersion(activeVersion.toString()));
+                    actionLogPreProcessor(ActionSubOperation.DELETE_ARTIFACT, TARGET_ENTITY_DB);
+                    actionArtifactDao.delete(artifactDeleteEntity);
+                    actionLogPostProcessor(StatusCode.COMPLETE);
+                    log.metrics("");
+                }
+            }
+        } catch (CoreException exception) {
+            formAndThrowException(exception);
         }
-        actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
-        log.metrics("");
-      }
+        log.debug("exit undoCheckout for Action with invariantUUID= " + invariantUuId + BY_USER + user);
+    }
 
+    /**
+     * Checkin a checked out action.
+     *
+     * @param invariantUuId
+     *            actionInvariantUuId of the checked out action
+     * @param user
+     *            AT&T id of the user sending the request
+     * @return {@link Action} model object for the updated action
+     */
+    @Override
+    public Action checkin(String invariantUuId, String user) {
+        Version version = null;
+        ActionEntity actionEntity = null;
+        try {
+            log.debug("entering checkin for Action with invariantUUID= " + invariantUuId + BY_USER + user);
+            actionLogPreProcessor(ActionSubOperation.CHECKIN_ACTION, TARGET_ENTITY_API);
+            version = versioningManager.checkin(ACTION_VERSIONABLE_TYPE, invariantUuId, user, null);
+            actionLogPostProcessor(StatusCode.COMPLETE);
+            log.metrics("");
+            actionEntity = updateStatusForVersion(invariantUuId, version, ActionStatus.Available.name(), user);
+        } catch (CoreException exception) {
+            formAndThrowException(exception);
+        }
+        log.debug("exit checkin for Action with invariantUUID= " + invariantUuId + BY_USER + user);
+        return actionEntity != null ? actionEntity.toDto() : new Action();
     }
-    log.debug(
-        "exit deleteArtifact with actionInvariantUuId= " + actionInvariantUuId + "artifactUUID= "
-            + artifactUuId + " and user = " + user);
-  }
-
-  /**
-   * Update an existing artifact.
-   *
-   * @param artifact            {@link ActionArtifact} object representing the artifact and its
-   *                            metadata
-   * @param actionInvariantUuId Invariant UUID of the action to which the artifact has to be
-   *                            uploaded
-   * @param user                User ID of the user sending the request
-   */
-  public void updateArtifact(ActionArtifact artifact, String actionInvariantUuId, String user) {
-    try {
-      log.debug("Enter updateArtifact with actionInvariantUuId= " + actionInvariantUuId
-          + "artifactUUID= " + artifact.getArtifactUuId() + " and user = " + user);
-      actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_API);
-      VersionInfo versionInfo = versioningManager
-          .getEntityVersionInfo(ACTION_VERSIONABLE_TYPE, actionInvariantUuId, user,
-              VersionableEntityAction.Write);
-      actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
-      log.metrics("");
-      Version activeVersion = versionInfo.getActiveVersion();
-      actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_ACTIONINVID, TARGET_ENTITY_DB);
-      Action action = actionDao.get(new ActionEntity(actionInvariantUuId, activeVersion)).toDto();
-      actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
-      log.metrics("");
-      List<ActionArtifact> actionArtifacts = action.getArtifacts();
-      ActionArtifact artifactMetadataByUuId =
-          getArtifactMetadataFromAction(actionArtifacts, ARTIFACT_METADATA_ATTR_UUID,
-              artifact.getArtifactUuId());
-      //Check if artifact is already in action or not
-      if (artifactMetadataByUuId == null) {
-        throw new ActionException(ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST_CODE,
-            ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST);
-      }
-      //If user tries to change artifact name
-      if (artifact.getArtifactName() != null
-          && !artifactMetadataByUuId.getArtifactName().equalsIgnoreCase(
-          artifact.getArtifactName())) {
-        throw new ActionException(ACTION_UPDATE_NOT_ALLOWED_CODE,
-            ACTION_ARTIFACT_UPDATE_NAME_INVALID);
-      }
-
-      byte[] payload = artifact.getArtifact();
-      String artifactLabel = artifact.getArtifactLabel();
-      String artifactCategory = artifact.getArtifactCategory();
-      String artifactDescription = artifact.getArtifactDescription();
-      String artifactProtection = artifact.getArtifactProtection();
-      String artifactName = artifact.getArtifactName();
-      //If artifact read only
-      if (artifactMetadataByUuId.getArtifactProtection()
-          .equals(ActionArtifactProtection.readOnly.name())) {
-        if (artifactName != null || artifactLabel != null || artifactCategory != null
-            || artifactDescription != null || payload != null) {
-          throw new ActionException(ACTION_ARTIFACT_UPDATE_READ_ONLY,
-              ACTION_ARTIFACT_UPDATE_READ_ONLY_MSG);
+
+    /**
+     * Submit a checked in action.
+     *
+     * @param invariantUuId
+     *            actionInvariantUuId of the checked in action
+     * @param user
+     *            AT&T id of the user sending the request
+     * @return {@link Action} model object for the updated action
+     */
+    @Override
+    public Action submit(String invariantUuId, String user) {
+        Version version = null;
+        ActionEntity actionEntity = null;
+        try {
+            log.debug("entering submit for Action with invariantUUID= " + invariantUuId + BY_USER + user);
+            actionLogPreProcessor(ActionSubOperation.SUBMIT_ACTION, TARGET_ENTITY_API);
+            version = versioningManager.submit(ACTION_VERSIONABLE_TYPE, invariantUuId, user, null);
+            actionLogPostProcessor(StatusCode.COMPLETE);
+            log.metrics("");
+            actionEntity = updateUniqueIdForVersion(invariantUuId, version, ActionStatus.Final.name(), user);
+        } catch (CoreException exception) {
+            formAndThrowException(exception);
         }
-        //Changing value from readOnly to readWrite
-        if (artifactProtection != null
-            && artifactProtection.equals(ActionArtifactProtection.readWrite.name())) {
-          artifactMetadataByUuId.setArtifactProtection(ActionArtifactProtection.readWrite.name());
-          artifactMetadataByUuId.setTimestamp(getCurrentTimeStampUtc());
-          updateArtifactMetadataInActionData(action, artifactMetadataByUuId);
+        log.debug("exit submit for Action with invariantUUID= " + invariantUuId + BY_USER + user);
+        return actionEntity != null ? actionEntity.toDto() : new Action();
+    }
+
+    /**
+     * Download an artifact of an action.
+     *
+     * @param artifactUuId
+     *            {@link ActionArtifact} object representing the artifact and
+     *            its metadata
+     * @param actionUuId
+     *            UUID of the action for which the artifact has to be downloaded
+     * @return downloaded action artifact object
+     */
+    @Override
+    public ActionArtifact downloadArtifact(String actionUuId, String artifactUuId) {
+        log.debug(" entering downloadArtifact with actionUUID= " + actionUuId + " and artifactUUID= " + artifactUuId);
+        Action action = actionDao.getActionsByActionUuId(actionUuId);
+        ActionArtifact actionArtifact;
+        if (action != null) {
+            MDC.put(SERVICE_INSTANCE_ID, action.getActionInvariantUuId());
+            List<ActionArtifact> artifacts = action.getArtifacts();
+            String actionVersion = action.getVersion();
+            int effectiveVersion = getEffectiveVersion(actionVersion);
+            ActionArtifact artifactMetadata = getArtifactMetadataFromAction(artifacts, ARTIFACT_METADATA_ATTR_UUID,
+                    artifactUuId);
+            if (artifactMetadata != null) {
+                String artifactName = artifactMetadata.getArtifactName();
+                actionArtifact = actionArtifactDao.downloadArtifact(effectiveVersion, artifactUuId);
+                actionArtifact.setArtifactName(artifactName);
+
+            } else {
+                throw new ActionException(ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST_CODE,
+                        ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST);
+            }
+        } else {
+            throw new ActionException(ActionErrorConstants.ACTION_ENTITY_NOT_EXIST_CODE,
+                    ActionErrorConstants.ACTION_ENTITY_NOT_EXIST);
         }
-      } else {
-        int effectiveVersion = getEffectiveVersion(activeVersion.toString());
-        if (artifactLabel != null) {
-          artifactMetadataByUuId.setArtifactLabel(artifactLabel);
+        log.debug(" exit downloadArtifact with actionUUID= " + actionUuId + " and artifactUUID= " + artifactUuId);
+        return actionArtifact;
+    }
+
+    /**
+     * Upload an artifact to an action.
+     *
+     * @param artifact
+     *            {@link ActionArtifact} object representing the artifact and
+     *            its metadata
+     * @param actionInvariantUuId
+     *            Invariant UUID of the action to which the artifact has to be
+     *            uploaded
+     * @param user
+     *            User ID of the user sending the request
+     * @return Uploaded action artifact object
+     */
+    @Override
+    public ActionArtifact uploadArtifact(ActionArtifact artifact, String actionInvariantUuId, String user) {
+        ActionArtifact uploadArtifactResponse = new ActionArtifact();
+        try {
+            log.debug("entering uploadArtifact with actionInvariantUuId= " + actionInvariantUuId + "artifactName= "
+                    + artifact.getArtifactName());
+            actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_DB);
+            VersionInfo versionInfo = versioningManager.getEntityVersionInfo(ACTION_VERSIONABLE_TYPE,
+                    actionInvariantUuId, user, VersionableEntityAction.Write);
+            actionLogPostProcessor(StatusCode.COMPLETE);
+            log.metrics("");
+            Version activeVersion = versionInfo.getActiveVersion();
+            actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_ACTIONINVID, TARGET_ENTITY_DB);
+            Action action = actionDao.get(new ActionEntity(actionInvariantUuId, activeVersion))
+                    .toDto();
+            actionLogPostProcessor(StatusCode.COMPLETE);
+            log.metrics("");
+            String artifactUuId = generateActionArtifactUuId(action, artifact.getArtifactName());
+            // Check for Unique document name
+            List<ActionArtifact> actionArtifacts = action.getArtifacts();
+            ActionArtifact artifactMetadata = getArtifactMetadataFromAction(actionArtifacts,
+                    ARTIFACT_METADATA_ATTR_NAME, artifact.getArtifactName());
+            if (artifactMetadata != null) {
+                throw new ActionException(ACTION_ARTIFACT_ALREADY_EXISTS_CODE,
+                        String.format(ACTION_ARTIFACT_ALREADY_EXISTS, actionInvariantUuId));
+            }
+
+            // Create the artifact
+            artifact.setArtifactUuId(artifactUuId);
+            artifact.setTimestamp(getCurrentTimeStampUtc());
+            artifact.setEffectiveVersion(getEffectiveVersion(activeVersion.toString()));
+            actionArtifactDao.uploadArtifact(artifact);
+
+            // Update the action data field and timestamp
+            addArtifactMetadataInActionData(action, artifact);
+
+            // Set the response object
+            uploadArtifactResponse.setArtifactUuId(artifact.getArtifactUuId());
+        } catch (CoreException ce) {
+            formAndThrowException(ce);
         }
-        if (artifactCategory != null) {
-          artifactMetadataByUuId.setArtifactCategory(artifactCategory);
+        log.debug("exit uploadArtifact with actionInvariantUuId= " + actionInvariantUuId + "artifactName= "
+                + artifact.getArtifactName());
+        return uploadArtifactResponse;
+    }
+
+    @Override
+    public void deleteArtifact(String actionInvariantUuId, String artifactUuId, String user) {
+        log.debug("enter deleteArtifact with actionInvariantUuId= " + actionInvariantUuId + ARTIFACT_UUID + artifactUuId
+                + " and user = " + user);
+        Action action = actionDao.getLockedAction(actionInvariantUuId, user);
+        List<ActionArtifact> actionArtifacts = action.getArtifacts();
+        ActionArtifact artifactMetadata = getArtifactMetadataFromAction(actionArtifacts, ARTIFACT_METADATA_ATTR_UUID,
+                artifactUuId);
+        if (artifactMetadata == null) {
+            throw new ActionException(ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST_CODE,
+                    ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST);
         }
-        if (artifactDescription != null) {
-          artifactMetadataByUuId.setArtifactDescription(artifactDescription);
+        if (artifactMetadata.getArtifactProtection()
+                .equals(ActionArtifactProtection.readOnly.name())) {
+            throw new ActionException(ACTION_ARTIFACT_DELETE_READ_ONLY, ACTION_ARTIFACT_DELETE_READ_ONLY_MSG);
+        } else {
+
+            // Update action by removing artifact metadata
+            String jsonData = action.getData();
+            List<ActionArtifact> artifacts = action.getArtifacts();// action.getArtifacts();
+            ActionArtifact artifact = null;
+            Iterator<ActionArtifact> it = artifacts.iterator();
+            while (it.hasNext()) {
+                artifact = it.next();
+                String artifactId = artifact.getArtifactUuId();
+                if (artifactId.equals(artifactUuId)) {
+                    it.remove();
+                }
+            }
+
+            Map dataMap = JsonUtil.json2Object(jsonData, LinkedHashMap.class);
+            dataMap.put("artifacts", artifacts);
+            String data = JsonUtil.object2Json(dataMap);
+            ActionEntity actionEntity = action.toEntity();
+            actionEntity.setData(data);
+            actionLogPreProcessor(ActionSubOperation.UPDATE_ACTION, TARGET_ENTITY_DB);
+            actionDao.update(actionEntity);
+            actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
+            log.metrics("");
+            // delete Artifact if it's upload and delete action on same checkout
+            // version
+            String artifactName = artifactMetadata.getArtifactName();
+            String generatedArtifactUuId = generateActionArtifactUuId(action, artifactName);
+            if (generatedArtifactUuId.equals(artifactUuId)) {
+                if (artifact != null) {
+                    ActionArtifactEntity artifactDeleteEntity = new ActionArtifactEntity(artifact.getArtifactUuId(),
+                            getEffectiveVersion(action.getVersion()));
+                    actionLogPreProcessor(ActionSubOperation.DELETE_ACTION_ARTIFACT, TARGET_ENTITY_DB);
+                    actionArtifactDao.delete(artifactDeleteEntity);
+                }
+                actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
+                log.metrics("");
+            }
+
         }
-        if (artifactProtection != null) {
-          artifactMetadataByUuId.setArtifactProtection(artifactProtection);
+        log.debug("exit deleteArtifact with actionInvariantUuId= " + actionInvariantUuId + ARTIFACT_UUID + artifactUuId
+                + " and user = " + user);
+    }
+
+    /**
+     * Update an existing artifact.
+     *
+     * @param artifact
+     *            {@link ActionArtifact} object representing the artifact and
+     *            its metadata
+     * @param actionInvariantUuId
+     *            Invariant UUID of the action to which the artifact has to be
+     *            uploaded
+     * @param user
+     *            User ID of the user sending the request
+     */
+    public void updateArtifact(ActionArtifact artifact, String actionInvariantUuId, String user) {
+        try {
+            log.debug("Enter updateArtifact with actionInvariantUuId= " + actionInvariantUuId + ARTIFACT_UUID
+                    + artifact.getArtifactUuId() + " and user = " + user);
+            actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_API);
+            VersionInfo versionInfo = versioningManager.getEntityVersionInfo(ACTION_VERSIONABLE_TYPE,
+                    actionInvariantUuId, user, VersionableEntityAction.Write);
+            actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
+            log.metrics("");
+            Version activeVersion = versionInfo.getActiveVersion();
+            actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_ACTIONINVID, TARGET_ENTITY_DB);
+            Action action = actionDao.get(new ActionEntity(actionInvariantUuId, activeVersion))
+                    .toDto();
+            actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
+            log.metrics("");
+            List<ActionArtifact> actionArtifacts = action.getArtifacts();
+            ActionArtifact artifactMetadataByUuId = getArtifactMetadataFromAction(actionArtifacts,
+                    ARTIFACT_METADATA_ATTR_UUID, artifact.getArtifactUuId());
+            // Check if artifact is already in action or not
+            if (artifactMetadataByUuId == null) {
+                throw new ActionException(ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST_CODE,
+                        ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST);
+            }
+            // If user tries to change artifact name
+            if (artifact.getArtifactName() != null && !artifactMetadataByUuId.getArtifactName()
+                    .equalsIgnoreCase(artifact.getArtifactName())) {
+                throw new ActionException(ACTION_UPDATE_NOT_ALLOWED_CODE, ACTION_ARTIFACT_UPDATE_NAME_INVALID);
+            }
+
+            byte[] payload = artifact.getArtifact();
+            String artifactLabel = artifact.getArtifactLabel();
+            String artifactCategory = artifact.getArtifactCategory();
+            String artifactDescription = artifact.getArtifactDescription();
+            String artifactProtection = artifact.getArtifactProtection();
+            String artifactName = artifact.getArtifactName();
+            // If artifact read only
+            if (artifactMetadataByUuId.getArtifactProtection()
+                    .equals(ActionArtifactProtection.readOnly.name())) {
+                if (artifactName != null || artifactLabel != null || artifactCategory != null
+                        || artifactDescription != null || payload != null) {
+                    throw new ActionException(ACTION_ARTIFACT_UPDATE_READ_ONLY, ACTION_ARTIFACT_UPDATE_READ_ONLY_MSG);
+                }
+                // Changing value from readOnly to readWrite
+                if (artifactProtection != null
+                        && artifactProtection.equals(ActionArtifactProtection.readWrite.name())) {
+                    artifactMetadataByUuId.setArtifactProtection(ActionArtifactProtection.readWrite.name());
+                    artifactMetadataByUuId.setTimestamp(getCurrentTimeStampUtc());
+                    updateArtifactMetadataInActionData(action, artifactMetadataByUuId);
+                }
+            } else {
+                int effectiveVersion = getEffectiveVersion(activeVersion.toString());
+                if (artifactLabel != null) {
+                    artifactMetadataByUuId.setArtifactLabel(artifactLabel);
+                }
+                if (artifactCategory != null) {
+                    artifactMetadataByUuId.setArtifactCategory(artifactCategory);
+                }
+                if (artifactDescription != null) {
+                    artifactMetadataByUuId.setArtifactDescription(artifactDescription);
+                }
+                if (artifactProtection != null) {
+                    artifactMetadataByUuId.setArtifactProtection(artifactProtection);
+                }
+                if (payload != null) {
+                    // get artifact data from action_artifact table for updating
+                    // the content
+                    ActionArtifact artifactContent = new ActionArtifact();
+                    artifactContent.setArtifactUuId(artifact.getArtifactUuId());
+                    artifactContent.setArtifact(payload);
+                    artifactContent.setEffectiveVersion(effectiveVersion);
+                    actionArtifactDao.updateArtifact(artifactContent);
+                }
+                // Update the action data field and timestamp
+                artifactMetadataByUuId.setTimestamp(getCurrentTimeStampUtc());
+                updateArtifactMetadataInActionData(action, artifactMetadataByUuId);
+            }
+            log.debug("exit updateArtifact with actionInvariantUuId= " + actionInvariantUuId + ARTIFACT_UUID
+                    + artifact.getArtifactUuId() + " and user = " + user);
+        } catch (CoreException coreException) {
+            formAndThrowException(coreException);
         }
-        if (payload != null) {
-          //get artifact data from action_artifact table for updating the content
-          ActionArtifact artifactContent = new ActionArtifact();
-          artifactContent.setArtifactUuId(artifact.getArtifactUuId());
-          artifactContent.setArtifact(payload);
-          artifactContent.setEffectiveVersion(effectiveVersion);
-          actionArtifactDao.updateArtifact(artifactContent);
+    }
+
+    /**
+     * Generate artifact UUID at runtime using action name and effective
+     * version.
+     *
+     * @param action
+     *            {@link Action} for which the artifact is being
+     *            uploaded/updated/downloaded
+     * @param artifactName
+     *            Artifact name
+     * @return Generated UUID string
+     */
+    private String generateActionArtifactUuId(Action action, String artifactName) {
+        int effectiveVersion = getEffectiveVersion(action.getVersion());
+        // Upper case for maintaining case-insensitive behavior for the artifact
+        // names
+        String artifactUuIdString = action.getName()
+                .toUpperCase() + effectiveVersion + artifactName.toUpperCase();
+        String generateArtifactUuId = UUID.nameUUIDFromBytes((artifactUuIdString).getBytes())
+                .toString();
+        String artifactUuId = generateArtifactUuId.replace("-", "");
+        return artifactUuId.toUpperCase();
+    }
+
+    /**
+     * Generate the effective action version for artifact operations.
+     *
+     * @param actionVersion
+     *            Version of the action as a string
+     * @return Effective version to be used for artifact operations
+     */
+    private int getEffectiveVersion(String actionVersion) {
+        Version version = Version.valueOf(actionVersion);
+        return version.getMajor() * 10000 + version.getMinor();
+    }
+
+    /**
+     * Update the data field of the Action object with the modified/generated
+     * fields after an operation.
+     *
+     * @param action
+     *            Action object whose data field has to be updated
+     * @return Updated {@link Action} object
+     */
+    private Action updateData(Action action) {
+        log.debug("entering updateData to update data json for action with actionuuid=  " + action.getActionUuId());
+        Map<String, String> dataMap = new LinkedHashMap<>();
+        dataMap.put(ActionConstants.UNIQUE_ID, action.getActionUuId());
+        dataMap.put(ActionConstants.VERSION, action.getVersion());
+        dataMap.put(ActionConstants.INVARIANTUUID, action.getActionInvariantUuId());
+        dataMap.put(ActionConstants.STATUS, action.getStatus()
+                .name());
+
+        String data = action.getData();
+        Map<String, String> currentDataMap = JsonUtil.json2Object(data, LinkedHashMap.class);
+        dataMap.putAll(currentDataMap);
+        data = JsonUtil.object2Json(dataMap);
+        action.setData(data);
+        log.debug("exit updateData");
+        return action;
+    }
+
+    /**
+     * Method to add the artifact metadata in the data attribute of action
+     * table.
+     *
+     * @param action
+     *            Action to which artifact is uploaded
+     * @param artifact
+     *            Uploaded artifact object
+     */
+    private void addArtifactMetadataInActionData(Action action, ActionArtifact artifact) {
+
+        ActionArtifact artifactMetadata = new ActionArtifact();
+        artifactMetadata.setArtifactUuId(artifact.getArtifactUuId());
+        artifactMetadata.setArtifactName(artifact.getArtifactName());
+        artifactMetadata.setArtifactProtection(artifact.getArtifactProtection());
+        artifactMetadata.setArtifactLabel(artifact.getArtifactLabel());
+        artifactMetadata.setArtifactDescription(artifact.getArtifactDescription());
+        artifactMetadata.setArtifactCategory(artifact.getArtifactCategory());
+        artifactMetadata.setTimestamp(artifact.getTimestamp());
+
+        List<ActionArtifact> actionArtifacts = action.getArtifacts();
+        if (actionArtifacts == null) {
+            actionArtifacts = new ArrayList<>();
         }
-        //Update the action data field and timestamp
-        artifactMetadataByUuId.setTimestamp(getCurrentTimeStampUtc());
-        updateArtifactMetadataInActionData(action, artifactMetadataByUuId);
-      }
-      log.debug("exit updateArtifact with actionInvariantUuId= " + actionInvariantUuId
-          + "artifactUUID= " + artifact.getArtifactUuId() + " and user = " + user);
-    } catch (CoreException coreException) {
-      formAndThrowException(coreException);
+        actionArtifacts.add(artifactMetadata);
+        action.setArtifacts(actionArtifacts);
+        String currentData = action.getData();
+        Map<String, Object> currentDataMap = JsonUtil.json2Object(currentData, LinkedHashMap.class);
+        currentDataMap.put(ActionConstants.ARTIFACTS, actionArtifacts);
+        String updatedActionData = JsonUtil.object2Json(currentDataMap);
+        action.setData(updatedActionData);
+        action.setTimestamp(artifact.getTimestamp());
+        actionDao.updateAction(action);
     }
-  }
-
-  /**
-   * Generate artifact UUID at runtime using action name and effective version.
-   *
-   * @param action       {@link Action} for which the artifact is being uploaded/updated/downloaded
-   * @param artifactName Artifact name
-   * @return Generated UUID string
-   */
-  private String generateActionArtifactUuId(Action action, String artifactName) {
-    int effectiveVersion = getEffectiveVersion(action.getVersion());
-    //Upper case for maintaining case-insensitive behavior for the artifact names
-    String artifactUuIdString =
-        action.getName().toUpperCase() + effectiveVersion + artifactName.toUpperCase();
-    String generateArtifactUuId =
-        UUID.nameUUIDFromBytes((artifactUuIdString).getBytes()).toString();
-    String artifactUuId = generateArtifactUuId.replace("-", "");
-    return artifactUuId.toUpperCase();
-  }
-
-  /**
-   * Generate the effective action version for artifact operations.
-   *
-   * @param actionVersion Version of the action as a string
-   * @return Effective version to be used for artifact operations
-   */
-  private int getEffectiveVersion(String actionVersion) {
-    Version version = Version.valueOf(actionVersion);
-    return version.getMajor() * 10000 + version.getMinor();
-  }
-
-  /**
-   * Update the data field of the Action object with the modified/generated fields after an
-   * operation.
-   *
-   * @param action Action object whose data field has to be updated
-   * @return Updated {@link Action} object
-   */
-  private Action updateData(Action action) {
-    log.debug("entering updateData to update data json for action with actionuuid=  "
-        + action.getActionUuId());
-    Map<String, String> dataMap = new LinkedHashMap<>();
-    dataMap.put(ActionConstants.UNIQUE_ID, action.getActionUuId());
-    dataMap.put(ActionConstants.VERSION, action.getVersion());
-    dataMap.put(ActionConstants.INVARIANTUUID, action.getActionInvariantUuId());
-    dataMap.put(ActionConstants.STATUS, action.getStatus().name());
-
-    String data = action.getData();
-    Map<String, String> currentDataMap = JsonUtil.json2Object(data, LinkedHashMap.class);
-    dataMap.putAll(currentDataMap);
-    data = JsonUtil.object2Json(dataMap);
-    action.setData(data);
-    log.debug("exit updateData");
-    return action;
-  }
-
-  /**
-   * Method to add the artifact metadata in the data attribute of action table.
-   *
-   * @param action   Action to which artifact is uploaded
-   * @param artifact Uploaded artifact object
-   */
-  private void addArtifactMetadataInActionData(Action action, ActionArtifact artifact) {
-
-    ActionArtifact artifactMetadata = new ActionArtifact();
-    artifactMetadata.setArtifactUuId(artifact.getArtifactUuId());
-    artifactMetadata.setArtifactName(artifact.getArtifactName());
-    artifactMetadata.setArtifactProtection(artifact.getArtifactProtection());
-    artifactMetadata.setArtifactLabel(artifact.getArtifactLabel());
-    artifactMetadata.setArtifactDescription(artifact.getArtifactDescription());
-    artifactMetadata.setArtifactCategory(artifact.getArtifactCategory());
-    artifactMetadata.setTimestamp(artifact.getTimestamp());
-
-    List<ActionArtifact> actionArtifacts = action.getArtifacts();
-    if (actionArtifacts == null) {
-      actionArtifacts = new ArrayList<>();
+
+    /**
+     * Get a list of last major and last minor version (no candidate) of action
+     * from a list of actions.
+     *
+     * @param actions
+     *            Exhaustive list of the action versions
+     * @return List {@link Action} of last major and last minor version (no
+     *         candidate) of action from a list of actions
+     */
+    private List<Action> getMajorMinorVersionActions(List<Action> actions) {
+        log.debug(" entering getMajorMinorVersionActions for actions ");
+        List<Action> list = new LinkedList<>();
+        actionLogPreProcessor(ActionSubOperation.GET_VERSIONINFO_FOR_ALL_ACTIONS, TARGET_ENTITY_API);
+        Map<String, VersionInfo> actionVersionMap = versioningManager.listEntitiesVersionInfo(ACTION_VERSIONABLE_TYPE,
+                "", VersionableEntityAction.Read);
+        actionLogPostProcessor(StatusCode.COMPLETE);
+        log.metrics("");
+        for (Action action : actions) {
+            if (action.getStatus() == ActionStatus.Deleted) {
+                continue;
+            }
+            VersionInfo actionVersionInfo = actionVersionMap.get(action.getActionInvariantUuId());
+            if (actionVersionInfo.getActiveVersion() != null && actionVersionInfo.getActiveVersion()
+                    .equals(Version.valueOf(action.getVersion()))) {
+                list.add(action);
+            } else if (actionVersionInfo.getLatestFinalVersion() != null && actionVersionInfo.getLatestFinalVersion()
+                    .equals(Version.valueOf(action.getVersion()))
+                    && !actionVersionInfo.getLatestFinalVersion()
+                            .equals(actionVersionInfo.getActiveVersion())) {
+                list.add(action);
+            }
+        }
+        log.debug(" exit getMajorMinorVersionActions for actions ");
+        return list;
     }
-    actionArtifacts.add(artifactMetadata);
-    action.setArtifacts(actionArtifacts);
-    String currentData = action.getData();
-    Map<String, Object> currentDataMap = JsonUtil.json2Object(currentData, LinkedHashMap.class);
-    currentDataMap.put(ActionConstants.ARTIFACTS, actionArtifacts);
-    String updatedActionData = JsonUtil.object2Json(currentDataMap);
-    action.setData(updatedActionData);
-    action.setTimestamp(artifact.getTimestamp());
-    actionDao.updateAction(action);
-  }
-
-  /**
-   * Get a list of last major and last minor version (no candidate) of action from a list of
-   * actions.
-   *
-   * @param actions Exhaustive list of the action versions
-   * @return List {@link Action} of last major and last minor version (no candidate) of action from
-   * a list of actions
-   */
-  private List<Action> getMajorMinorVersionActions(List<Action> actions) {
-    log.debug(" entering getMajorMinorVersionActions for actions ");
-    List<Action> list = new LinkedList<>();
-    actionLogPreProcessor(ActionSubOperation.GET_VERSIONINFO_FOR_ALL_ACTIONS, TARGET_ENTITY_API);
-    Map<String, VersionInfo> actionVersionMap = versioningManager
-        .listEntitiesVersionInfo(ACTION_VERSIONABLE_TYPE, "", VersionableEntityAction.Read);
-    actionLogPostProcessor(StatusCode.COMPLETE);
-    log.metrics("");
-    for (Action action : actions) {
-      if (action.getStatus() == ActionStatus.Deleted) {
-        continue;
-      }
-      VersionInfo actionVersionInfo = actionVersionMap.get(action.getActionInvariantUuId());
-      if (actionVersionInfo.getActiveVersion() != null
-          && actionVersionInfo.getActiveVersion().equals(Version.valueOf(action.getVersion()))) {
-        list.add(action);
-      } else if (actionVersionInfo.getLatestFinalVersion() != null
-          && actionVersionInfo.getLatestFinalVersion().equals(Version.valueOf(action.getVersion()))
-          &&
-          !actionVersionInfo.getLatestFinalVersion().equals(actionVersionInfo.getActiveVersion())) {
-        list.add(action);
-      }
+
+    /**
+     * CoreException object wrapper from Version library to Action Library
+     * Exception.
+     *
+     * @param exception
+     *            CoreException object from version library
+     */
+    private void formAndThrowException(CoreException exception) {
+        log.debug("entering formAndThrowException with input CoreException =" + exception.code()
+                .id() + " " + exception.getMessage());
+        String errorDescription = exception.getMessage();
+        String errorCode = exception.code()
+                .id();
+        ActionException actionException = new ActionException();
+        switch (errorCode) {
+        case VersioningErrorCodes.VERSIONABLE_ENTITY_NOT_EXIST:
+            actionException.setErrorCode(ACTION_ENTITY_NOT_EXIST_CODE);
+            actionException.setDescription(ACTION_ENTITY_NOT_EXIST);
+            break;
+        case VersioningErrorCodes.CHECKOT_ON_LOCKED_ENTITY:
+            actionException.setErrorCode(ACTION_CHECKOUT_ON_LOCKED_ENTITY);
+            actionException.setDescription(errorDescription);
+            break;
+        case VersioningErrorCodes.CHECKIN_ON_UNLOCKED_ENTITY:
+            actionException.setErrorCode(ACTION_CHECKIN_ON_UNLOCKED_ENTITY);
+            actionException.setDescription(errorDescription);
+            break;
+        case VersioningErrorCodes.SUBMIT_FINALIZED_ENTITY_NOT_ALLOWED:
+            actionException.setErrorCode(ACTION_SUBMIT_FINALIZED_ENTITY_NOT_ALLOWED);
+            actionException.setDescription(errorDescription);
+            break;
+        case VersioningErrorCodes.SUBMIT_LOCKED_ENTITY_NOT_ALLOWED:
+            actionException.setErrorCode(ACTION_SUBMIT_LOCKED_ENTITY_NOT_ALLOWED);
+            actionException.setDescription(errorDescription);
+            break;
+        case VersioningErrorCodes.UNDO_CHECKOUT_ON_UNLOCKED_ENTITY:
+            actionException.setErrorCode(ACTION_UNDO_CHECKOUT_ON_UNLOCKED_ENTITY);
+            actionException.setDescription(errorDescription);
+            break;
+        case VersioningErrorCodes.EDIT_ON_ENTITY_LOCKED_BY_OTHER_USER:
+            actionException.setErrorCode(ACTION_EDIT_ON_ENTITY_LOCKED_BY_OTHER_USER);
+            actionException.setDescription(errorDescription.replace("edit", "updat"));
+            break;
+        case VersioningErrorCodes.CHECKIN_ON_ENTITY_LOCKED_BY_OTHER_USER:
+            actionException.setErrorCode(ACTION_CHECKIN_ON_ENTITY_LOCKED_BY_OTHER_USER);
+            actionException.setDescription(errorDescription);
+            break;
+        case VersioningErrorCodes.UNDO_CHECKOUT_ON_ENTITY_LOCKED_BY_OTHER_USER:
+            actionException.setErrorCode(ACTION_UNDO_CHECKOUT_ON_ENTITY_LOCKED_BY_OTHER_USER);
+            actionException.setDescription(errorDescription);
+            break;
+        case VersioningErrorCodes.EDIT_ON_UNLOCKED_ENTITY:
+            actionException.setErrorCode(ACTION_UPDATE_ON_UNLOCKED_ENTITY);
+            actionException.setDescription(errorDescription.replace("edit", "update"));
+            break;
+        case VersioningErrorCodes.DELETE_ON_LOCKED_ENTITY:
+            actionException.setErrorCode(ACTION_DELETE_ON_LOCKED_ENTITY_CODE);
+            actionException.setDescription(errorDescription);
+            break;
+        default:
+            actionException.setErrorCode(ACTION_INTERNAL_SERVER_ERR_CODE);
+            actionException.setDescription(exception.getMessage());
+
+        }
+        // Todo - Uncomment only if class to be added in ERROR Log
+        /*
+         * actionErrorLogProcessor(CategoryLogLevel.ERROR,
+         * actionException.getErrorCode(), actionException.getDescription());
+         * log.error("");
+         */
+        log.debug("exit formAndThrowException with ActionException =" + actionException.getErrorCode() + " "
+                + actionException.getDescription());
+        throw actionException;
     }
-    log.debug(" exit getMajorMinorVersionActions for actions ");
-    return list;
-  }
-
-  /**
-   * CoreException object wrapper from Version library to Action Library Exception.
-   *
-   * @param exception CoreException object from version library
-   */
-  private void formAndThrowException(CoreException exception) {
-    log.debug("entering formAndThrowException with input CoreException =" + exception.code().id()
-        + " " + exception.getMessage());
-    String errorDescription = exception.getMessage();
-    String errorCode = exception.code().id();
-    ActionException actionException = new ActionException();
-    switch (errorCode) {
-      case VersioningErrorCodes.VERSIONABLE_ENTITY_NOT_EXIST:
-        actionException.setErrorCode(ACTION_ENTITY_NOT_EXIST_CODE);
-        actionException.setDescription(ACTION_ENTITY_NOT_EXIST);
-        break;
-      case VersioningErrorCodes.CHECKOT_ON_LOCKED_ENTITY:
-        actionException.setErrorCode(ACTION_CHECKOUT_ON_LOCKED_ENTITY);
-        actionException.setDescription(errorDescription);
-        break;
-      case VersioningErrorCodes.CHECKIN_ON_UNLOCKED_ENTITY:
-        actionException.setErrorCode(ACTION_CHECKIN_ON_UNLOCKED_ENTITY);
-        actionException.setDescription(errorDescription);
-        break;
-      case VersioningErrorCodes.SUBMIT_FINALIZED_ENTITY_NOT_ALLOWED:
-        actionException.setErrorCode(ACTION_SUBMIT_FINALIZED_ENTITY_NOT_ALLOWED);
-        actionException.setDescription(errorDescription);
-        break;
-      case VersioningErrorCodes.SUBMIT_LOCKED_ENTITY_NOT_ALLOWED:
-        actionException.setErrorCode(ACTION_SUBMIT_LOCKED_ENTITY_NOT_ALLOWED);
-        actionException.setDescription(errorDescription);
-        break;
-      case VersioningErrorCodes.UNDO_CHECKOUT_ON_UNLOCKED_ENTITY:
-        actionException.setErrorCode(ACTION_UNDO_CHECKOUT_ON_UNLOCKED_ENTITY);
-        actionException.setDescription(errorDescription);
-        break;
-      case VersioningErrorCodes.EDIT_ON_ENTITY_LOCKED_BY_OTHER_USER:
-        actionException.setErrorCode(ACTION_EDIT_ON_ENTITY_LOCKED_BY_OTHER_USER);
-        actionException.setDescription(errorDescription.replace("edit", "updat"));
-        break;
-      case VersioningErrorCodes.CHECKIN_ON_ENTITY_LOCKED_BY_OTHER_USER:
-        actionException.setErrorCode(ACTION_CHECKIN_ON_ENTITY_LOCKED_BY_OTHER_USER);
-        actionException.setDescription(errorDescription);
-        break;
-      case VersioningErrorCodes.UNDO_CHECKOUT_ON_ENTITY_LOCKED_BY_OTHER_USER:
-        actionException.setErrorCode(ACTION_UNDO_CHECKOUT_ON_ENTITY_LOCKED_BY_OTHER_USER);
-        actionException.setDescription(errorDescription);
-        break;
-      case VersioningErrorCodes.EDIT_ON_UNLOCKED_ENTITY:
-        actionException.setErrorCode(ACTION_UPDATE_ON_UNLOCKED_ENTITY);
-        actionException.setDescription(errorDescription.replace("edit", "update"));
-        break;
-      case VersioningErrorCodes.DELETE_ON_LOCKED_ENTITY:
-        actionException.setErrorCode(ACTION_DELETE_ON_LOCKED_ENTITY_CODE);
-        actionException.setDescription(errorDescription);
-        break;
-      default:
-        actionException.setErrorCode(ACTION_INTERNAL_SERVER_ERR_CODE);
-        actionException.setDescription(exception.getMessage());
 
+    /**
+     * Validates an action object for business layer validations before an
+     * update operation.
+     *
+     * @param action
+     *            Action object to be validated
+     * @param activeVersion
+     *            Active version of the actoin object
+     */
+    private void validateActions(Action action, Version activeVersion) {
+        try {
+            // Set version if not already available in input request
+            // If version set in input compare it with version from DB
+            if (StringUtils.isEmpty(action.getVersion())) {
+                action.setVersion(activeVersion.toString());
+            } else {
+                if (!activeVersion.equals(Version.valueOf(action.getVersion()))) {
+                    throw new ActionException(ACTION_UPDATE_INVALID_VERSION,
+                            String.format(ACTION_REQUESTED_VERSION_INVALID, action.getVersion()));
+                }
+            }
+            String invariantUuId = action.getActionInvariantUuId();
+            Version version = Version.valueOf(action.getVersion());
+            Action existingAction = getActions(invariantUuId, version);
+            if (existingAction == null || existingAction.getActionInvariantUuId() == null) {
+                throw new ActionException(ACTION_ENTITY_NOT_EXIST_CODE, ACTION_ENTITY_NOT_EXIST);
+            }
+            List<String> invalidParameters = new LinkedList<>();
+            // Prevent update of name, version and id fields
+            if (!existingAction.getName()
+                    .equals(action.getName())) {
+                throw new ActionException(ACTION_UPDATE_NOT_ALLOWED_CODE_NAME, ACTION_UPDATE_NOT_ALLOWED_FOR_NAME);
+            }
+            if (!StringUtils.isEmpty(action.getActionUuId()) && !existingAction.getActionUuId()
+                    .equals(action.getActionUuId())) {
+                invalidParameters.add(UNIQUE_ID);
+            }
+            if (action.getStatus() != null && (existingAction.getStatus() != action.getStatus())) {
+                invalidParameters.add(STATUS);
+            }
+
+            if (!invalidParameters.isEmpty()) {
+                throw new ActionException(ACTION_UPDATE_NOT_ALLOWED_CODE,
+                        String.format(ACTION_UPDATE_PARAM_INVALID, StringUtils.join(invalidParameters, ", ")));
+            }
+            action.setActionUuId(existingAction.getActionUuId());
+        } catch (IllegalArgumentException iae) {
+            String message = iae.getMessage();
+            if (message == VERSION_STRING_VIOLATION_MSG) {
+                throw new ActionException(ACTION_UPDATE_NOT_ALLOWED_CODE, message);
+            } else {
+                throw iae;
+            }
+        }
     }
-    //Todo - Uncomment only if class to be added in ERROR Log
-    /*actionErrorLogProcessor(CategoryLogLevel.ERROR, actionException.getErrorCode(),
-    actionException.getDescription());
-    log.error("");*/
-    log.debug(
-        "exit formAndThrowException with ActionException =" + actionException.getErrorCode()
-            + " " + actionException.getDescription());
-    throw actionException;
-  }
-
-  /**
-   * Validates an action object for business layer validations before an update operation.
-   *
-   * @param action        Action object to be validated
-   * @param activeVersion Active version of the actoin object
-   */
-  private void validateActions(Action action, Version activeVersion) {
-    try {
-      //Set version if not already available in input request
-      //If version set in input compare it with version from DB
-      if (StringUtils.isEmpty(action.getVersion())) {
-        action.setVersion(activeVersion.toString());
-      } else {
-        if (!activeVersion.equals(Version.valueOf(action.getVersion()))) {
-          throw new ActionException(ACTION_UPDATE_INVALID_VERSION,
-              String.format(ACTION_REQUESTED_VERSION_INVALID, action.getVersion()));
+
+    /**
+     * Get an action version entity object.
+     *
+     * @param invariantUuId
+     *            Invariant UUID of the action
+     * @param version
+     *            Version of the action
+     * @return {@link ActionEntity} object of the action version
+     */
+    private ActionEntity getActionsEntityByVersion(String invariantUuId, Version version) {
+        log.debug("entering getActionsEntityByVersion with invariantUUID= " + invariantUuId + AND_VERSION + version);
+        ActionEntity entity = null;
+        if (version != null) {
+            actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_VERSION, TARGET_ENTITY_DB);
+            entity = actionDao
+                    .get(new ActionEntity(invariantUuId != null ? invariantUuId.toUpperCase() : null, version));
+            actionLogPostProcessor(StatusCode.COMPLETE);
+            log.metrics("");
         }
-      }
-      String invariantUuId = action.getActionInvariantUuId();
-      Version version = Version.valueOf(action.getVersion());
-      Action existingAction = getActions(invariantUuId, version);
-      if (existingAction == null || existingAction.getActionInvariantUuId() == null) {
-        throw new ActionException(ACTION_ENTITY_NOT_EXIST_CODE, ACTION_ENTITY_NOT_EXIST);
-      }
-      List<String> invalidParameters = new LinkedList<>();
-      //Prevent update of name, version and id fields
-      if (!existingAction.getName().equals(action.getName())) {
-        throw new ActionException(ACTION_UPDATE_NOT_ALLOWED_CODE_NAME,
-            ACTION_UPDATE_NOT_ALLOWED_FOR_NAME);
-      }
-      if (!StringUtils.isEmpty(action.getActionUuId())
-          && !existingAction.getActionUuId().equals(action.getActionUuId())) {
-        invalidParameters.add(UNIQUE_ID);
-      }
-      if (action.getStatus() != null && (existingAction.getStatus() != action.getStatus())) {
-        invalidParameters.add(STATUS);
-      }
-
-      if (!invalidParameters.isEmpty()) {
-        throw new ActionException(ACTION_UPDATE_NOT_ALLOWED_CODE,
-            String.format(ACTION_UPDATE_PARAM_INVALID, StringUtils.join(invalidParameters, ", ")));
-      }
-      action.setActionUuId(existingAction.getActionUuId());
-    } catch (IllegalArgumentException iae) {
-      String message = iae.getMessage();
-      if (message == VERSION_STRING_VIOLATION_MSG) {
-        throw new ActionException(ACTION_UPDATE_NOT_ALLOWED_CODE, message);
-      } else {
-        throw iae;
-      }
+        log.debug("exit getActionsEntityByVersion with invariantUuId= " + invariantUuId + AND_VERSION + version);
+        return entity;
     }
-  }
-
-  /**
-   * Get an action version entity object.
-   *
-   * @param invariantUuId Invariant UUID of the action
-   * @param version       Version of the action
-   * @return {@link ActionEntity} object of the action version
-   */
-  private ActionEntity getActionsEntityByVersion(String invariantUuId, Version version) {
-    log.debug(
-        "entering getActionsEntityByVersion with invariantUUID= " + invariantUuId + " and version"
-            + version);
-    ActionEntity entity = null;
-    if (version != null) {
-      actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_VERSION, TARGET_ENTITY_DB);
-      entity = actionDao.get(
-          new ActionEntity(invariantUuId != null ? invariantUuId.toUpperCase() : null, version));
-      actionLogPostProcessor(StatusCode.COMPLETE);
-      log.metrics("");
+
+    /**
+     * Get an action version object.
+     *
+     * @param invariantUuId
+     *            Invariant UUID of the action
+     * @param version
+     *            Version of the action
+     * @return {@link Action} object of the action version
+     */
+    private Action getActions(String invariantUuId, Version version) {
+        ActionEntity actionEntity = getActionsEntityByVersion(
+                invariantUuId != null ? invariantUuId.toUpperCase() : null, version);
+        return actionEntity != null ? actionEntity.toDto() : new Action();
     }
-    log.debug(
-        "exit getActionsEntityByVersion with invariantUuId= " + invariantUuId + " and version"
-            + version);
-    return entity;
-  }
-
-  /**
-   * Get an action version object.
-   *
-   * @param invariantUuId Invariant UUID of the action
-   * @param version       Version of the action
-   * @return {@link Action} object of the action version
-   */
-  private Action getActions(String invariantUuId, Version version) {
-    ActionEntity actionEntity =
-        getActionsEntityByVersion(invariantUuId != null ? invariantUuId.toUpperCase() : null,
-            version);
-    return actionEntity != null ? actionEntity.toDto() : new Action();
-  }
-
-  /**
-   * Create and set the Unique ID in for an action version row.
-   *
-   * @param invariantUuId Invariant UUID of the action
-   * @param version       Version of the action
-   * @param status        Status of the action
-   * @param user          AT&T id of the user sending the request
-   * @return {@link ActionEntity} object of the action version
-   */
-  private ActionEntity updateUniqueIdForVersion(String invariantUuId, Version version,
-                                                String status, String user) {
-    log.debug(
-        "entering updateUniqueIdForVersion to update action with invariantUuId= " + invariantUuId
-            + " with version,status and user as ::" + version + " " + status + " " + user);
-    //generate UUID AND update for newly created entity row
-    ActionEntity actionEntity = getActionsEntityByVersion(invariantUuId, version);
-    if (actionEntity != null) {
-      log.debug("Found action to be updated");
-      String data = actionEntity.getData();
-      String uniqueId = CommonMethods.nextUuId();
-      Map<String, String> dataMap = JsonUtil.json2Object(data, LinkedHashMap.class);
-      dataMap.put(ActionConstants.UNIQUE_ID, uniqueId);
-      dataMap.put(ActionConstants.VERSION, version.toString());
-      dataMap.put(ActionConstants.STATUS, status);
-      data = JsonUtil.object2Json(dataMap);
-
-      actionEntity.setData(data);
-      actionEntity.setActionUuId(uniqueId);
-      actionEntity.setStatus(status);
-      actionEntity.setUser(user);
-      actionEntity.setTimestamp(getCurrentTimeStampUtc());
-      actionLogPreProcessor(ActionSubOperation.UPDATE_ACTION, TARGET_ENTITY_DB);
-      actionDao.update(actionEntity);
-      actionLogPostProcessor(StatusCode.COMPLETE);
-      log.metrics("");
+
+    /**
+     * Create and set the Unique ID in for an action version row.
+     *
+     * @param invariantUuId
+     *            Invariant UUID of the action
+     * @param version
+     *            Version of the action
+     * @param status
+     *            Status of the action
+     * @param user
+     *            AT&T id of the user sending the request
+     * @return {@link ActionEntity} object of the action version
+     */
+    private ActionEntity updateUniqueIdForVersion(String invariantUuId, Version version, String status, String user) {
+        log.debug("entering updateUniqueIdForVersion to update action with invariantUuId= " + invariantUuId
+                + " with version,status and user as ::" + version + " " + status + " " + user);
+        // generate UUID AND update for newly created entity row
+        ActionEntity actionEntity = getActionsEntityByVersion(invariantUuId, version);
+        if (actionEntity != null) {
+            log.debug("Found action to be updated");
+            String data = actionEntity.getData();
+            String uniqueId = CommonMethods.nextUuId();
+            Map<String, String> dataMap = JsonUtil.json2Object(data, LinkedHashMap.class);
+            dataMap.put(ActionConstants.UNIQUE_ID, uniqueId);
+            dataMap.put(ActionConstants.VERSION, version.toString());
+            dataMap.put(ActionConstants.STATUS, status);
+            data = JsonUtil.object2Json(dataMap);
+
+            actionEntity.setData(data);
+            actionEntity.setActionUuId(uniqueId);
+            actionEntity.setStatus(status);
+            actionEntity.setUser(user);
+            actionEntity.setTimestamp(getCurrentTimeStampUtc());
+            actionLogPreProcessor(ActionSubOperation.UPDATE_ACTION, TARGET_ENTITY_DB);
+            actionDao.update(actionEntity);
+            actionLogPostProcessor(StatusCode.COMPLETE);
+            log.metrics("");
+        }
+
+        log.debug("exit updateUniqueIdForVersion to update action with invariantUUID= " + invariantUuId);
+        return actionEntity;
     }
 
-    log.debug(
-        "exit updateUniqueIdForVersion to update action with invariantUUID= " + invariantUuId);
-    return actionEntity;
-  }
-
-  /**
-   * Set the status for an action version row.
-   *
-   * @param invariantUuId Invariant UUID of the action
-   * @param version       Version of the action
-   * @param status        Status of the action
-   * @param user          AT&T id of the user sending the request
-   * @return {@link ActionEntity} object of the action version
-   */
-  private ActionEntity updateStatusForVersion(String invariantUuId, Version version, String status,
-                                              String user) {
-    log.debug(
-        "entering updateStatusForVersion with invariantUuId= " + invariantUuId + " and version"
-            + version + " for updating status " + status + " by user " + user);
-    ActionEntity actionEntity = getActionsEntityByVersion(invariantUuId, version);
-    if (actionEntity != null) {
-      String data = actionEntity.getData();
-      Map<String, String> dataMap = JsonUtil.json2Object(data, LinkedHashMap.class);
-      dataMap.put(ActionConstants.STATUS, status);
-      data = JsonUtil.object2Json(dataMap);
-      actionEntity.setData(data);
-      actionEntity.setStatus(status);
-      actionEntity.setUser(user);
-      actionEntity.setTimestamp(getCurrentTimeStampUtc());
-      actionLogPreProcessor(ActionSubOperation.UPDATE_ACTION, TARGET_ENTITY_DB);
-      actionDao.update(actionEntity);
-      actionLogPostProcessor(StatusCode.COMPLETE);
-      log.metrics("");
+    /**
+     * Set the status for an action version row.
+     *
+     * @param invariantUuId
+     *            Invariant UUID of the action
+     * @param version
+     *            Version of the action
+     * @param status
+     *            Status of the action
+     * @param user
+     *            AT&T id of the user sending the request
+     * @return {@link ActionEntity} object of the action version
+     */
+    private ActionEntity updateStatusForVersion(String invariantUuId, Version version, String status, String user) {
+        log.debug("entering updateStatusForVersion with invariantUuId= " + invariantUuId + AND_VERSION + version
+                + " for updating status " + status + " by user " + user);
+        ActionEntity actionEntity = getActionsEntityByVersion(invariantUuId, version);
+        if (actionEntity != null) {
+            String data = actionEntity.getData();
+            Map<String, String> dataMap = JsonUtil.json2Object(data, LinkedHashMap.class);
+            dataMap.put(ActionConstants.STATUS, status);
+            data = JsonUtil.object2Json(dataMap);
+            actionEntity.setData(data);
+            actionEntity.setStatus(status);
+            actionEntity.setUser(user);
+            actionEntity.setTimestamp(getCurrentTimeStampUtc());
+            actionLogPreProcessor(ActionSubOperation.UPDATE_ACTION, TARGET_ENTITY_DB);
+            actionDao.update(actionEntity);
+            actionLogPostProcessor(StatusCode.COMPLETE);
+            log.metrics("");
+        }
+        log.debug("exit updateStatusForVersion with invariantUuId= " + invariantUuId + AND_VERSION + version
+                + " for updating status " + status + " by user " + user);
+        return actionEntity;
+
     }
-    log.debug("exit updateStatusForVersion with invariantUuId= " + invariantUuId + " and version"
-        + version + " for updating status " + status + " by user " + user);
-    return actionEntity;
-
-  }
-
-  /**
-   * Gets an artifact from the action artifact metadata by artifact name.
-   *
-   * @param actionArtifactList  Action's existing artifact list
-   * @param artifactFilterType  Search criteria for artifact in action artifact metadata
-   * @param artifactFilterValue Value of Search parameter
-   * @return Artifact metadata object if artifact is present in action and null otherwise
-   */
-  private ActionArtifact getArtifactMetadataFromAction(List<ActionArtifact> actionArtifactList,
-                                                       String artifactFilterType,
-                                                       String artifactFilterValue) {
-    ActionArtifact artifact = null;
-    if (actionArtifactList != null && !actionArtifactList.isEmpty()) {
-      for (ActionArtifact entry : actionArtifactList) {
-        switch (artifactFilterType) {
-          case ARTIFACT_METADATA_ATTR_UUID:
-            String artifactUuId = entry.getArtifactUuId();
-            if (artifactUuId != null && artifactUuId.equals(artifactFilterValue)) {
-              artifact = entry;
-              break;
-            }
-            break;
-          case ARTIFACT_METADATA_ATTR_NAME:
-            String existingArtifactName = entry.getArtifactName().toLowerCase();
-            if (existingArtifactName.equals(artifactFilterValue.toLowerCase())) {
-              artifact = entry;
-              break;
+
+    /**
+     * Gets an artifact from the action artifact metadata by artifact name.
+     *
+     * @param actionArtifactList
+     *            Action's existing artifact list
+     * @param artifactFilterType
+     *            Search criteria for artifact in action artifact metadata
+     * @param artifactFilterValue
+     *            Value of Search parameter
+     * @return Artifact metadata object if artifact is present in action and
+     *         null otherwise
+     */
+    private ActionArtifact getArtifactMetadataFromAction(List<ActionArtifact> actionArtifactList,
+            String artifactFilterType, String artifactFilterValue) {
+        ActionArtifact artifact = null;
+        if (actionArtifactList != null && !actionArtifactList.isEmpty()) {
+            for (ActionArtifact entry : actionArtifactList) {
+                switch (artifactFilterType) {
+                case ARTIFACT_METADATA_ATTR_UUID:
+                    String artifactUuId = entry.getArtifactUuId();
+                    if (artifactUuId != null && artifactUuId.equals(artifactFilterValue)) {
+                        artifact = entry;
+                        break;
+                    }
+                    break;
+                case ARTIFACT_METADATA_ATTR_NAME:
+                    String existingArtifactName = entry.getArtifactName()
+                            .toLowerCase();
+                    if (existingArtifactName.equals(artifactFilterValue.toLowerCase())) {
+                        artifact = entry;
+                        break;
+                    }
+                    break;
+                default:
+                }
             }
-            break;
-          default:
         }
-      }
+        return artifact;
     }
-    return artifact;
-  }
-
-  /**
-   * Method to update the artifact metadata in the data attribute of action table.
-   *
-   * @param action          Action to which artifact is uploaded
-   * @param updatedArtifact updated artifact object
-   */
-  private void updateArtifactMetadataInActionData(Action action, ActionArtifact updatedArtifact) {
-    for (ActionArtifact entry : action.getArtifacts()) {
-      if (entry.getArtifactUuId().equals(updatedArtifact.getArtifactUuId())) {
-        entry.setArtifactLabel(updatedArtifact.getArtifactLabel());
-        entry.setArtifactCategory(updatedArtifact.getArtifactCategory());
-        entry.setArtifactDescription(updatedArtifact.getArtifactDescription());
-        entry.setArtifactProtection(updatedArtifact.getArtifactProtection());
-        entry.setTimestamp(updatedArtifact.getTimestamp());
-        break;
-      }
+
+    /**
+     * Method to update the artifact metadata in the data attribute of action
+     * table.
+     *
+     * @param action
+     *            Action to which artifact is uploaded
+     * @param updatedArtifact
+     *            updated artifact object
+     */
+    private void updateArtifactMetadataInActionData(Action action, ActionArtifact updatedArtifact) {
+        for (ActionArtifact entry : action.getArtifacts()) {
+            if (entry.getArtifactUuId()
+                    .equals(updatedArtifact.getArtifactUuId())) {
+                entry.setArtifactLabel(updatedArtifact.getArtifactLabel());
+                entry.setArtifactCategory(updatedArtifact.getArtifactCategory());
+                entry.setArtifactDescription(updatedArtifact.getArtifactDescription());
+                entry.setArtifactProtection(updatedArtifact.getArtifactProtection());
+                entry.setTimestamp(updatedArtifact.getTimestamp());
+                break;
+            }
+        }
+        String data = action.getData();
+        Map<String, Object> map = JsonUtil.json2Object(data, LinkedHashMap.class);
+        map.put(ActionConstants.ARTIFACTS, action.getArtifacts());
+        String updatedActionData = JsonUtil.object2Json(map);
+        action.setData(updatedActionData);
+        action.setTimestamp(updatedArtifact.getTimestamp());
+        actionDao.updateAction(action);
     }
-    String data = action.getData();
-    Map<String, Object> map = JsonUtil.json2Object(data, LinkedHashMap.class);
-    map.put(ActionConstants.ARTIFACTS, action.getArtifacts());
-    String updatedActionData = JsonUtil.object2Json(map);
-    action.setData(updatedActionData);
-    action.setTimestamp(updatedArtifact.getTimestamp());
-    actionDao.updateAction(action);
-  }
 }