Merge pull request #866 from chathurace/rc3

backend fix for the issue with getting next pending operation of cust…
4.x.x
Madhawa Perera 7 years ago committed by GitHub
commit 831e214f01

@ -50,6 +50,7 @@ import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceDetailsMgtExcept
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager; import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager;
import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation; import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation;
import org.wso2.carbon.device.mgt.core.operation.mgt.ConfigOperation; import org.wso2.carbon.device.mgt.core.operation.mgt.ConfigOperation;
import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation;
import org.wso2.carbon.device.mgt.core.search.mgt.SearchManagerService; import org.wso2.carbon.device.mgt.core.search.mgt.SearchManagerService;
import org.wso2.carbon.device.mgt.core.search.mgt.SearchMgtException; import org.wso2.carbon.device.mgt.core.search.mgt.SearchMgtException;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
@ -665,7 +666,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
return Response.status(Response.Status.BAD_REQUEST).build(); return Response.status(Response.Status.BAD_REQUEST).build();
} }
Operation.Type operationType = operationRequest.getOperation().getType(); Operation.Type operationType = operationRequest.getOperation().getType();
if (operationType == Operation.Type.COMMAND || operationType == Operation.Type.CONFIG) { if (operationType == Operation.Type.COMMAND || operationType == Operation.Type.CONFIG || operationType == Operation.Type.PROFILE) {
DeviceIdentifier deviceIdentifier; DeviceIdentifier deviceIdentifier;
List<DeviceIdentifier> deviceIdentifiers = new ArrayList<>(); List<DeviceIdentifier> deviceIdentifiers = new ArrayList<>();
for (String deviceId : operationRequest.getDeviceIdentifiers()) { for (String deviceId : operationRequest.getDeviceIdentifiers()) {
@ -683,7 +684,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
operation.setEnabled(commandOperation.isEnabled()); operation.setEnabled(commandOperation.isEnabled());
operation.setStatus(commandOperation.getStatus()); operation.setStatus(commandOperation.getStatus());
} else { } else if (operationType == Operation.Type.CONFIG) {
Operation configOperation = operationRequest.getOperation(); Operation configOperation = operationRequest.getOperation();
operation = new ConfigOperation(); operation = new ConfigOperation();
operation.setType(Operation.Type.CONFIG); operation.setType(Operation.Type.CONFIG);
@ -691,6 +692,15 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
operation.setEnabled(configOperation.isEnabled()); operation.setEnabled(configOperation.isEnabled());
operation.setPayLoad(configOperation.getPayLoad()); operation.setPayLoad(configOperation.getPayLoad());
operation.setStatus(configOperation.getStatus()); operation.setStatus(configOperation.getStatus());
} else {
Operation profileOperation = operationRequest.getOperation();
operation = new ProfileOperation();
operation.setType(Operation.Type.PROFILE);
operation.setCode(profileOperation.getCode());
operation.setEnabled(profileOperation.isEnabled());
operation.setPayLoad(profileOperation.getPayLoad());
operation.setStatus(profileOperation.getStatus());
} }
String date = new SimpleDateFormat(DATE_FORMAT_NOW).format(new Date()); String date = new SimpleDateFormat(DATE_FORMAT_NOW).format(new Date());
operation.setCreatedTimeStamp(date); operation.setCreatedTimeStamp(date);

@ -130,7 +130,7 @@ public class ConfigOperationDAOImpl extends GenericOperationDAOImpl {
rs = stmt.executeQuery(); rs = stmt.executeQuery();
if (rs.next()) { if (rs.next()) {
byte[] operationDetails = rs.getBytes("OPERATION_DETAILS"); byte[] operationDetails = rs.getBytes("OPERATION_CONFIG");
bais = new ByteArrayInputStream(operationDetails); bais = new ByteArrayInputStream(operationDetails);
ois = new ObjectInputStream(bais); ois = new ObjectInputStream(bais);
configOperation = (ConfigOperation) ois.readObject(); configOperation = (ConfigOperation) ois.readObject();

Loading…
Cancel
Save