Fix not adhering 'initiated by'

revert-70ac1926
Charitha Goonetilleke 4 years ago
parent 31a6497950
commit 911bd62a44

@ -18,6 +18,7 @@
package org.wso2.carbon.device.mgt.core.operation.mgt; 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.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.CarbonContext;
@ -186,16 +187,13 @@ public class OperationManagerImpl implements OperationManager {
boolean isScheduledOperation = this.isTaskScheduledOperation(operation); boolean isScheduledOperation = this.isTaskScheduledOperation(operation);
String initiatedBy = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); String initiatedBy = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
if (initiatedBy == null && isScheduledOperation) { if (initiatedBy == null && isScheduledOperation) {
if (log.isDebugEnabled()) {
log.debug("initiatedBy : " + SYSTEM);
}
operation.setInitiatedBy(SYSTEM); operation.setInitiatedBy(SYSTEM);
} else { } else if (StringUtils.isEmpty(operation.getInitiatedBy())) {
if (log.isDebugEnabled()) {
log.debug("initiatedBy : " + initiatedBy);
}
operation.setInitiatedBy(initiatedBy); operation.setInitiatedBy(initiatedBy);
} }
if (log.isDebugEnabled()) {
log.debug("initiatedBy : " + operation.getInitiatedBy());
}
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation operationDto = org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation operationDto =
OperationDAOUtil.convertOperation(operation); OperationDAOUtil.convertOperation(operation);

Loading…
Cancel
Save