|
|
@ -165,22 +165,21 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("operation:[" + operation.toString() + "]");
|
|
|
|
log.debug("operation:[" + operation.toString() + "]");
|
|
|
|
for (DeviceIdentifier deviceIdentifier : deviceIds) {
|
|
|
|
for (DeviceIdentifier deviceIdentifier : deviceIds) {
|
|
|
|
log.debug("device identifier id:[" + deviceIdentifier.getId() + "] type:[" +
|
|
|
|
log.debug("device identifier id:[" + deviceIdentifier.getId() + "] type:[" + deviceIdentifier.getType()
|
|
|
|
deviceIdentifier.getType() + "]");
|
|
|
|
+ "]");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
|
|
|
|
DeviceIDHolder deviceValidationResult = DeviceManagerUtil.validateDeviceIdentifiers(deviceIds);
|
|
|
|
DeviceIDHolder deviceValidationResult = DeviceManagerUtil.validateDeviceIdentifiers(deviceIds);
|
|
|
|
List<DeviceIdentifier> validDeviceIds = deviceValidationResult.getValidDeviceIDList();
|
|
|
|
List<DeviceIdentifier> validDeviceIds = deviceValidationResult.getValidDeviceIDList();
|
|
|
|
if (validDeviceIds.size() > 0) {
|
|
|
|
if (!validDeviceIds.isEmpty()) {
|
|
|
|
DeviceIDHolder deviceAuthorizationResult = this.authorizeDevices(operation, validDeviceIds);
|
|
|
|
DeviceIDHolder deviceAuthorizationResult = this.authorizeDevices(operation, validDeviceIds);
|
|
|
|
List<DeviceIdentifier> authorizedDeviceIds = deviceAuthorizationResult.getValidDeviceIDList();
|
|
|
|
List<DeviceIdentifier> authorizedDeviceIds = deviceAuthorizationResult.getValidDeviceIDList();
|
|
|
|
if (authorizedDeviceIds.size() <= 0) {
|
|
|
|
if (authorizedDeviceIds.isEmpty()) {
|
|
|
|
log.warn("User : " + getUser() + " is not authorized to perform operations on given device-list.");
|
|
|
|
log.warn("User : " + getUser() + " is not authorized to perform operations on given device-list.");
|
|
|
|
Activity activity = new Activity();
|
|
|
|
Activity activity = new Activity();
|
|
|
|
//Send the operation statuses only for admin triggered operations
|
|
|
|
//Send the operation statuses only for admin triggered operations
|
|
|
|
activity.setActivityStatus(this.getActivityStatus(deviceValidationResult,
|
|
|
|
activity.setActivityStatus(this.getActivityStatus(deviceValidationResult, deviceAuthorizationResult));
|
|
|
|
deviceAuthorizationResult));
|
|
|
|
|
|
|
|
return activity;
|
|
|
|
return activity;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -198,8 +197,8 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
operation.setInitiatedBy(initiatedBy);
|
|
|
|
operation.setInitiatedBy(initiatedBy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation operationDto =
|
|
|
|
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation operationDto = OperationDAOUtil
|
|
|
|
OperationDAOUtil.convertOperation(operation);
|
|
|
|
.convertOperation(operation);
|
|
|
|
String operationCode = operationDto.getCode();
|
|
|
|
String operationCode = operationDto.getCode();
|
|
|
|
Map<Integer, Device> enrolments = new HashMap<>();
|
|
|
|
Map<Integer, Device> enrolments = new HashMap<>();
|
|
|
|
Device device;
|
|
|
|
Device device;
|
|
|
@ -208,9 +207,10 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
enrolments.put(device.getEnrolmentInfo().getId(), device);
|
|
|
|
enrolments.put(device.getEnrolmentInfo().getId(), device);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
OperationManagementDAOFactory.beginTransaction();
|
|
|
|
OperationManagementDAOFactory.beginTransaction();
|
|
|
|
if (operationDto.getControl() ==
|
|
|
|
if (operationDto.getControl()
|
|
|
|
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Control.NO_REPEAT) {
|
|
|
|
== org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Control.NO_REPEAT) {
|
|
|
|
Map<Integer, Integer> pendingOperationIDs = operationDAO
|
|
|
|
Map<Integer, Integer> pendingOperationIDs = operationDAO
|
|
|
|
.getExistingOperationIDs(enrolments.keySet().toArray(new Integer[0]), operationCode);
|
|
|
|
.getExistingOperationIDs(enrolments.keySet().toArray(new Integer[0]), operationCode);
|
|
|
|
for (Integer enrolmentId : pendingOperationIDs.keySet()) {
|
|
|
|
for (Integer enrolmentId : pendingOperationIDs.keySet()) {
|
|
|
@ -227,8 +227,8 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
+ operationCode);
|
|
|
|
+ operationCode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Activity activity = new Activity();
|
|
|
|
Activity activity = new Activity();
|
|
|
|
activity.setActivityStatus(this.getActivityStatus(deviceValidationResult,
|
|
|
|
activity.setActivityStatus(
|
|
|
|
deviceAuthorizationResult));
|
|
|
|
this.getActivityStatus(deviceValidationResult, deviceAuthorizationResult));
|
|
|
|
return activity;
|
|
|
|
return activity;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -242,13 +242,10 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
activity.setType(Activity.Type.valueOf(operationDto.getType().toString()));
|
|
|
|
activity.setType(Activity.Type.valueOf(operationDto.getType().toString()));
|
|
|
|
//For now set the operation statuses only for admin triggered operations
|
|
|
|
//For now set the operation statuses only for admin triggered operations
|
|
|
|
if (!isScheduledOperation) {
|
|
|
|
if (!isScheduledOperation) {
|
|
|
|
activity.setActivityStatus(this.getActivityStatus(deviceValidationResult,
|
|
|
|
activity.setActivityStatus(
|
|
|
|
deviceAuthorizationResult));
|
|
|
|
this.getActivityStatus(deviceValidationResult, deviceAuthorizationResult));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return activity;
|
|
|
|
return activity;
|
|
|
|
} else {
|
|
|
|
|
|
|
|
throw new InvalidDeviceException("Invalid device Identifiers found.");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (OperationManagementDAOException e) {
|
|
|
|
} catch (OperationManagementDAOException e) {
|
|
|
|
OperationManagementDAOFactory.rollbackTransaction();
|
|
|
|
OperationManagementDAOFactory.rollbackTransaction();
|
|
|
|
throw new OperationManagementException("Error occurred while adding operation", e);
|
|
|
|
throw new OperationManagementException("Error occurred while adding operation", e);
|
|
|
@ -257,6 +254,9 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
throw new InvalidDeviceException("Invalid device Identifiers found.");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|