Logging

Change-Id: I28395f345a26992adac5e1f32dea97979dc3b3dc
Issue-ID: SDC-1518
Signed-off-by: ayalaben <ayala.benzvi@amdocs.com>
diff --git a/workflow/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImpl.java b/workflow/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImpl.java
index 2cb897f..97d8168 100644
--- a/workflow/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImpl.java
+++ b/workflow/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImpl.java
@@ -15,6 +15,8 @@
 import org.onap.sdc.workflow.services.WorkflowNameComparator;
 import org.onap.sdc.workflow.services.exceptions.EntityNotFoundException;
 import org.onap.sdc.workflow.services.impl.mappers.WorkflowMapper;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
 import org.openecomp.sdc.versioning.ItemManager;
 import org.openecomp.sdc.versioning.types.Item;
 import org.openecomp.sdc.versioning.types.ItemStatus;
@@ -35,6 +37,7 @@
     private final ItemManager itemManager;
     private final UniqueValueService uniqueValueService;
     private final WorkflowMapper workflowMapper;
+    private static final Logger LOGGER = LoggerFactory.getLogger(WorkflowManagerImpl.class);
 
     @Autowired
     public WorkflowManagerImpl(ItemManager itemManager,
@@ -56,6 +59,7 @@
     public Workflow get(Workflow workflow) {
         Item retrievedItem = itemManager.get(workflow.getId());
         if (retrievedItem == null) {
+            LOGGER.error(String.format("Workflow with id %s was not found",workflow.getId()));
             throw new EntityNotFoundException(String.format(WORKFLOW_NOT_FOUND_ERROR_MSG, workflow.getId()));
         }
         return this.workflowMapper.itemToWorkflow(retrievedItem);
@@ -76,6 +80,7 @@
     public void update(Workflow workflow) {
         Item retrievedItem = itemManager.get(workflow.getId());
         if (retrievedItem == null) {
+            LOGGER.error(String.format("Workflow with id %s was not found",workflow.getId()));
             throw new EntityNotFoundException(String.format(WORKFLOW_NOT_FOUND_ERROR_MSG, workflow.getId()));
         }
 
diff --git a/workflow/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java b/workflow/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java
index 0f88d37..de9c8dd 100644
--- a/workflow/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java
+++ b/workflow/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java
@@ -31,6 +31,8 @@
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 import org.springframework.web.multipart.MultipartFile;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
 
 @Service("workflowVersionManager")
 public class WorkflowVersionManagerImpl implements WorkflowVersionManager {
@@ -41,7 +43,7 @@
     private final ParameterRepository parameterRepository;
     private final VersionMapper versionMapper;
     private final VersionStateMapper versionStateMapper;
-
+    private static final Logger LOGGER = LoggerFactory.getLogger(WorkflowVersionManagerImpl.class);
 
     @Autowired
     public WorkflowVersionManagerImpl(VersioningManager versioningManager, ArtifactRepository artifactRepository,
@@ -130,6 +132,9 @@
         WorkflowVersionState retrievedState =
             versionStateMapper.versionStatusToWorkflowVersionState(retrievedVersion.getStatus());
         if (WorkflowVersionState.CERTIFIED.equals(retrievedState) || retrievedState.equals(state)) {
+            LOGGER.error(String.format(
+                    "Workflow Version is certified and can not be edited.Workflow id %s and version id %s", workflowId,
+                    versionId));
             throw new VersionStateModificationException(workflowId, versionId, retrievedState, state);
         }
 
@@ -144,6 +149,8 @@
         Version retrievedVersion = getVersion(workflowId, versionId);
         if (WorkflowVersionState.CERTIFIED
             .equals(versionStateMapper.versionStatusToWorkflowVersionState(retrievedVersion.getStatus()))) {
+            LOGGER.error(String.format("Workflow Version Artifact was not found for workflow id %s and version id %s",
+                    workflowId, versionId));
             throw new VersionModificationException(workflowId, versionId);
         }
 
@@ -154,6 +161,8 @@
             versioningManager.publish(workflowId, new Version(versionId), "Update Artifact");
 
         } catch (IOException e) {
+            LOGGER.error(String.format("Upload Artifact failed for workflow id %s and version id %s",
+                    workflowId, versionId),e);
             throw new InvalidArtifactException(e.getMessage());
         }
     }
@@ -163,8 +172,10 @@
         getVersion(workflowId, versionId);
         Optional<ArtifactEntity> artifactOptional = artifactRepository.get(workflowId, versionId);
         if (!artifactOptional.isPresent()) {
+            LOGGER.error(String.format("Workflow Version Artifact was not found for workflow id %s and version id %s",
+                    workflowId, versionId));
             throw new EntityNotFoundException(
-                String.format("Artifact for workflow id %S version id %S was not found", workflowId, versionId));
+                    String.format("Artifact for workflow id %S version id %S was not found", workflowId, versionId));
         }
         return artifactOptional.get();
     }
@@ -173,6 +184,9 @@
     public void deleteArtifact(String workflowId, String versionId) {
         WorkflowVersion retrievedVersion = get(workflowId, versionId);
         if (WorkflowVersionState.CERTIFIED.equals(retrievedVersion.getState())) {
+            LOGGER.error(String.format(
+                    "Workflow Version is certified and can not be edited.Workflow id %s and version id %s", workflowId,
+                    versionId));
             throw new VersionModificationException(workflowId, versionId);
         }
 
@@ -198,6 +212,9 @@
             }
             return version;
         } catch (Exception e) {
+            LOGGER.error(String.format(
+                    "Workflow Version was not found.Workflow id %s and version id %s", workflowId,
+                    versionId),e);
             throw new EntityNotFoundException(String.format(VERSION_NOT_EXIST_MSG, versionId, workflowId));
         }
     }