|
|
@ -22,7 +22,11 @@ import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationResponse;
|
|
|
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationResponse;
|
|
|
|
import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
|
|
|
|
import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dto.operation.mgt.*;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.dto.operation.mgt.ConfigOperation;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.dto.operation.mgt.PolicyOperation;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.dto.operation.mgt.ProfileOperation;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
@ -32,6 +36,7 @@ import java.sql.SQLException;
|
|
|
|
|
|
|
|
|
|
|
|
public class OperationDAOUtil {
|
|
|
|
public class OperationDAOUtil {
|
|
|
|
private static final Log log = LogFactory.getLog(OperationDAOUtil.class);
|
|
|
|
private static final Log log = LogFactory.getLog(OperationDAOUtil.class);
|
|
|
|
|
|
|
|
|
|
|
|
public static Operation convertOperation(org.wso2.carbon.device.mgt.common.operation.mgt.Operation operation) {
|
|
|
|
public static Operation convertOperation(org.wso2.carbon.device.mgt.common.operation.mgt.Operation operation) {
|
|
|
|
|
|
|
|
|
|
|
|
Operation dtoOperation = null;
|
|
|
|
Operation dtoOperation = null;
|
|
|
@ -40,28 +45,28 @@ public class OperationDAOUtil {
|
|
|
|
dtoOperation = new CommandOperation();
|
|
|
|
dtoOperation = new CommandOperation();
|
|
|
|
} else if (operation.getType().equals(org.wso2.carbon.device.mgt.common.operation.mgt.Operation.Type.PROFILE)) {
|
|
|
|
} else if (operation.getType().equals(org.wso2.carbon.device.mgt.common.operation.mgt.Operation.Type.PROFILE)) {
|
|
|
|
dtoOperation = new ProfileOperation();
|
|
|
|
dtoOperation = new ProfileOperation();
|
|
|
|
}else if(operation.getType().equals(org.wso2.carbon.device.mgt.common.operation.mgt.Operation.Type.POLICY)){
|
|
|
|
} else if (operation.getType().equals(org.wso2.carbon.device.mgt.common.operation.mgt.Operation.Type.POLICY)) {
|
|
|
|
dtoOperation = new PolicyOperation();
|
|
|
|
dtoOperation = new PolicyOperation();
|
|
|
|
}else if(operation.getType().equals(org.wso2.carbon.device.mgt.common.operation.mgt.Operation.Type.CONFIG)) {
|
|
|
|
} else if (operation.getType().equals(org.wso2.carbon.device.mgt.common.operation.mgt.Operation.Type.CONFIG)) {
|
|
|
|
dtoOperation = new ConfigOperation();
|
|
|
|
dtoOperation = new ConfigOperation();
|
|
|
|
}else{
|
|
|
|
} else {
|
|
|
|
dtoOperation = new Operation();
|
|
|
|
dtoOperation = new Operation();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dtoOperation.setEnabled(operation.isEnabled());
|
|
|
|
dtoOperation.setEnabled(operation.isEnabled());
|
|
|
|
dtoOperation.setCode(operation.getCode());
|
|
|
|
dtoOperation.setCode(operation.getCode());
|
|
|
|
|
|
|
|
|
|
|
|
if (operation.getType() != null){
|
|
|
|
if (operation.getType() != null) {
|
|
|
|
dtoOperation.setType(Operation.Type.valueOf(operation.getType().toString()));
|
|
|
|
dtoOperation.setType(Operation.Type.valueOf(operation.getType().toString()));
|
|
|
|
}else{
|
|
|
|
} else {
|
|
|
|
dtoOperation.setType(null);
|
|
|
|
dtoOperation.setType(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dtoOperation.setCreatedTimeStamp(operation.getCreatedTimeStamp());
|
|
|
|
dtoOperation.setCreatedTimeStamp(operation.getCreatedTimeStamp());
|
|
|
|
|
|
|
|
|
|
|
|
if (operation.getStatus() != null){
|
|
|
|
if (operation.getStatus() != null) {
|
|
|
|
dtoOperation.setStatus(Operation.Status.valueOf(operation.getStatus().toString()));
|
|
|
|
dtoOperation.setStatus(Operation.Status.valueOf(operation.getStatus().toString()));
|
|
|
|
}else{
|
|
|
|
} else {
|
|
|
|
dtoOperation.setStatus(null);
|
|
|
|
dtoOperation.setStatus(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -70,31 +75,35 @@ public class OperationDAOUtil {
|
|
|
|
dtoOperation.setReceivedTimeStamp(operation.getReceivedTimeStamp());
|
|
|
|
dtoOperation.setReceivedTimeStamp(operation.getReceivedTimeStamp());
|
|
|
|
dtoOperation.setProperties(operation.getProperties());
|
|
|
|
dtoOperation.setProperties(operation.getProperties());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (operation.getControl() != null) {
|
|
|
|
|
|
|
|
dtoOperation.setControl(Operation.Control.valueOf(operation.getControl().toString()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return dtoOperation;
|
|
|
|
return dtoOperation;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static org.wso2.carbon.device.mgt.common.operation.mgt.Operation convertOperation(Operation dtoOperation){
|
|
|
|
public static org.wso2.carbon.device.mgt.common.operation.mgt.Operation convertOperation(Operation dtoOperation) {
|
|
|
|
|
|
|
|
|
|
|
|
org.wso2.carbon.device.mgt.common.operation.mgt.Operation operation = null;
|
|
|
|
org.wso2.carbon.device.mgt.common.operation.mgt.Operation operation = null;
|
|
|
|
|
|
|
|
|
|
|
|
if (dtoOperation.getType().equals(Operation.Type.COMMAND)){
|
|
|
|
if (dtoOperation.getType().equals(Operation.Type.COMMAND)) {
|
|
|
|
operation = new org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation();
|
|
|
|
operation = new org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation();
|
|
|
|
}else if(dtoOperation.getType().equals(Operation.Type.PROFILE)){
|
|
|
|
} else if (dtoOperation.getType().equals(Operation.Type.PROFILE)) {
|
|
|
|
operation = new org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation();
|
|
|
|
operation = new org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation();
|
|
|
|
}else{
|
|
|
|
} else {
|
|
|
|
operation = new org.wso2.carbon.device.mgt.common.operation.mgt.Operation();
|
|
|
|
operation = new org.wso2.carbon.device.mgt.common.operation.mgt.Operation();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
operation.setEnabled(dtoOperation.isEnabled());
|
|
|
|
operation.setEnabled(dtoOperation.isEnabled());
|
|
|
|
operation.setCode(dtoOperation.getCode());
|
|
|
|
operation.setCode(dtoOperation.getCode());
|
|
|
|
|
|
|
|
|
|
|
|
if(dtoOperation.getType() != null) {
|
|
|
|
if (dtoOperation.getType() != null) {
|
|
|
|
operation.setType(org.wso2.carbon.device.mgt.common.operation.mgt.Operation.Type.valueOf(dtoOperation
|
|
|
|
operation.setType(org.wso2.carbon.device.mgt.common.operation.mgt.Operation.Type.valueOf(dtoOperation
|
|
|
|
.getType().toString()));
|
|
|
|
.getType().toString()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
operation.setCreatedTimeStamp(dtoOperation.getCreatedTimeStamp());
|
|
|
|
operation.setCreatedTimeStamp(dtoOperation.getCreatedTimeStamp());
|
|
|
|
|
|
|
|
|
|
|
|
if(dtoOperation.getStatus() != null) {
|
|
|
|
if (dtoOperation.getStatus() != null) {
|
|
|
|
operation.setStatus(org.wso2.carbon.device.mgt.common.operation.mgt.Operation.Status.valueOf(dtoOperation
|
|
|
|
operation.setStatus(org.wso2.carbon.device.mgt.common.operation.mgt.Operation.Status.valueOf(dtoOperation
|
|
|
|
.getStatus().toString()));
|
|
|
|
.getStatus().toString()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|