From 911bd62a44d0c3dec3c5d368e66d8fa9fed52ae7 Mon Sep 17 00:00:00 2001 From: charitha Date: Sat, 28 Nov 2020 15:39:58 +0530 Subject: [PATCH] Fix not adhering 'initiated by' --- .../mgt/core/operation/mgt/OperationManagerImpl.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java index 251d1788ba6..64932f51979 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java @@ -18,6 +18,7 @@ package org.wso2.carbon.device.mgt.core.operation.mgt; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.CarbonContext; @@ -186,16 +187,13 @@ public class OperationManagerImpl implements OperationManager { boolean isScheduledOperation = this.isTaskScheduledOperation(operation); String initiatedBy = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); if (initiatedBy == null && isScheduledOperation) { - if (log.isDebugEnabled()) { - log.debug("initiatedBy : " + SYSTEM); - } operation.setInitiatedBy(SYSTEM); - } else { - if (log.isDebugEnabled()) { - log.debug("initiatedBy : " + initiatedBy); - } + } else if (StringUtils.isEmpty(operation.getInitiatedBy())) { operation.setInitiatedBy(initiatedBy); } + if (log.isDebugEnabled()) { + log.debug("initiatedBy : " + operation.getInitiatedBy()); + } org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation operationDto = OperationDAOUtil.convertOperation(operation);