Operations Refractor

revert-70aa11f8
manoj 10 years ago
parent 4f4240f176
commit 5a4e4ec4a0

@ -37,7 +37,7 @@ public interface OperationManager {
* operation
*/
public boolean addOperation(Operation operation, List<DeviceIdentifier> devices) throws
OperationManagementException;
OperationManagementException, DeviceManagementException;
/**
* Method to retrieve the list of all operations to a device.

@ -67,6 +67,13 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
this.licenseManager = new LicenseManagerImpl();
}
public DeviceManagementServiceProviderImpl(){
this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO();
this.deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO();
this.operationManager = new OperationManagerImpl();
this.licenseManager = new LicenseManagerImpl();
}
@Override
public String getProviderType() {
return null;
@ -84,6 +91,24 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
return dms.getFeatureManager();
}
@Override
public Device getCoreDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
Device convertedDevice = null;
try {
DeviceType deviceType = this.getDeviceTypeDAO().getDeviceType(deviceId.getType());
org.wso2.carbon.device.mgt.core.dto.Device device = this.getDeviceDAO().getDevice(deviceId);
if (device != null) {
convertedDevice = DeviceManagementDAOUtil.convertDevice(device,
this.getDeviceTypeDAO().getDeviceType(deviceType.getId()));
}
} catch (DeviceManagementDAOException e) {
throw new DeviceManagementException("Error occurred while obtaining the device for id " +
"'" + deviceId.getId() + "' and type:"+deviceId.getType(), e);
}
return convertedDevice;
}
@Override
public boolean enrollDevice(Device device) throws DeviceManagementException {
DeviceManager dms =
@ -336,8 +361,8 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
@Override
public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
DeviceManager dms =
this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
DeviceManager dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
Device convertedDevice = null;
try {
DeviceType deviceType =
@ -375,10 +400,6 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
return dms.setOwnership(deviceId, ownershipType);
}
public OperationManager getOperationManager(String type) throws DeviceManagementException {
return operationManager;
}
@Override
public License getLicense(String deviceType, String languageCode) throws LicenseManagementException {
return licenseManager.getLicense(deviceType, languageCode);
@ -402,8 +423,8 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
}
@Override
public boolean addOperation(Operation operation,
List<DeviceIdentifier> devices) throws OperationManagementException {
public boolean addOperation(Operation operation, List<DeviceIdentifier> devices) throws
OperationManagementException, DeviceManagementException {
return operationManager.addOperation(operation, devices);
}

@ -25,21 +25,19 @@ import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
import org.wso2.carbon.device.mgt.core.dao.DeviceDAO;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.dto.Device;
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationDAO;
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOException;
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationMappingDAO;
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.util.OperationDAOUtil;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementService;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementServiceImpl;
import java.util.ArrayList;
import java.util.List;
/**
* This class implements all the functionalities exposed as part of the OperationManager. Any transaction initiated
* This class implements all the functionality exposed as part of the OperationManager. Any transaction initiated
* upon persisting information related to operation state, etc has to be managed, demarcated and terminated via the
* methods available in OperationManagementDAOFactory.
*/
@ -51,21 +49,21 @@ public class OperationManagerImpl implements OperationManager {
private OperationDAO configOperationDAO;
private OperationDAO profileOperationDAO;
private OperationMappingDAO operationMappingDAO;
private DeviceDAO deviceDAO;
private OperationDAO operationDAO;
private DeviceManagementService deviceManagementService;
public OperationManagerImpl() {
commandOperationDAO = OperationManagementDAOFactory.getCommandOperationDAO();
configOperationDAO = OperationManagementDAOFactory.getConfigOperationDAO();
profileOperationDAO = OperationManagementDAOFactory.getProfileOperationDAO();
operationMappingDAO = OperationManagementDAOFactory.getOperationMappingDAO();
deviceDAO = DeviceManagementDAOFactory.getDeviceDAO();
operationDAO = OperationManagementDAOFactory.getOperationDAO();
deviceManagementService = new DeviceManagementServiceImpl();
}
@Override
public boolean addOperation(Operation operation,
List<DeviceIdentifier> devices) throws OperationManagementException {
public boolean addOperation(Operation operation, List<DeviceIdentifier> devices) throws
OperationManagementException {
if (log.isDebugEnabled()) {
log.debug("operation:[" + operation.toString() + "]");
@ -76,14 +74,21 @@ public class OperationManagerImpl implements OperationManager {
}
try {
OperationManagementDAOFactory.beginTransaction();
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation operationDto = OperationDAOUtil
.convertOperation(operation);
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation operationDto =
OperationDAOUtil.convertOperation(operation);
int operationId = this.lookupOperationDAO(operation).addOperation(operationDto);
org.wso2.carbon.device.mgt.common.Device device;
for (DeviceIdentifier deviceIdentifier : devices) {
Device device = deviceDAO.getDevice(deviceIdentifier);
operationMappingDAO.addOperationMapping(operationId, device.getId());
device = deviceManagementService.getCoreDevice(deviceIdentifier);
if (device == null) {
String errorMsg = "The operation not added for device.The device not found for " +
"device Identifier type -'" + deviceIdentifier.getType() + "' and device Id '" +
deviceIdentifier.getId();
log.info(errorMsg);
} else {
operationMappingDAO.addOperationMapping(operationId, device.getId());
}
}
OperationManagementDAOFactory.commitTransaction();
return true;
@ -95,29 +100,38 @@ public class OperationManagerImpl implements OperationManager {
log.warn("Error occurred while roll-backing the transaction", e1);
}
throw new OperationManagementException("Error occurred while adding operation", e);
} catch (DeviceManagementDAOException e) {
log.error("Error occurred while adding operation device mapping: ", e);
} catch (DeviceManagementException deviceMgtEx) {
try {
OperationManagementDAOFactory.rollbackTransaction();
} catch (OperationManagementDAOException e1) {
log.warn("Error occurred while roll-backing the transaction", e1);
}
throw new OperationManagementException("Error occurred while adding operation", e);
String errorMsg = "Error occurred fetching devices ";
log.error(deviceMgtEx.getErrorMessage(), deviceMgtEx);
throw new OperationManagementException(errorMsg, deviceMgtEx);
}
}
@Override
public List<? extends Operation> getOperations(DeviceIdentifier deviceId) throws OperationManagementException {
public List<? extends Operation> getOperations(DeviceIdentifier deviceIdentifier)
throws OperationManagementException {
try {
List<Operation> operations = new ArrayList<Operation>();
Device device;
org.wso2.carbon.device.mgt.common.Device device;
try {
device = deviceDAO.getDevice(deviceId);
} catch (DeviceManagementDAOException deviceDAOException) {
device = deviceManagementService.getCoreDevice(deviceIdentifier);
} catch (DeviceManagementException deviceMgtEx) {
String errorMsg = "Error occurred while retrieving the device " +
"for device Identifier type -'" + deviceId.getType() + "' and device Id '" + deviceId.getId();
log.error(errorMsg, deviceDAOException);
throw new OperationManagementException(errorMsg, deviceDAOException);
"for device Identifier type -'" + deviceIdentifier.getType() + "' and device Id '" +
deviceIdentifier.getId();
log.error(errorMsg, deviceMgtEx);
throw new OperationManagementException(errorMsg, deviceMgtEx);
}
if (device == null) {
throw new OperationManagementException("Device not found for given device " +
"Identifier:" + deviceIdentifier.getId() + " and given type" + deviceIdentifier.getType());
}
List<? extends org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation> operationList = operationDAO
.getOperationsForDevice(device.getId());
@ -129,40 +143,52 @@ public class OperationManagerImpl implements OperationManager {
return operations;
} catch (OperationManagementDAOException e) {
throw new OperationManagementException("Error occurred while retrieving the list of " +
"operations assigned for '" + deviceId.getType() + "' device '" + deviceId.getId() + "'", e);
"operations assigned for '" + deviceIdentifier.getType() + "' device '" + deviceIdentifier.getId()
+ "'", e);
}
}
@Override
public List<? extends Operation> getPendingOperations(DeviceIdentifier deviceId)
public List<? extends Operation> getPendingOperations(DeviceIdentifier deviceIdentifier)
throws OperationManagementException {
if (log.isDebugEnabled()) {
log.debug("device identifier id:[" + deviceId.getId() + "] type:[" + deviceId.getType() + "]");
log.debug("Device identifier id:[" + deviceIdentifier.getId() + "] type:[" + deviceIdentifier.getType()
+ "]");
}
org.wso2.carbon.device.mgt.common.Device device;
List<Operation> operations;
List<? extends org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation> dtoOperationList;
try {
Device device;
device = deviceDAO.getDevice(deviceId);
List<Operation> operations = new ArrayList<Operation>();
List<? extends org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation> dtoOperationList =
operationDAO.getOperationsByDeviceAndStatus(device.getId(), org.wso2.carbon.device.mgt.core.dto
.operation.mgt.Operation.Status.PENDING);
device = deviceManagementService.getCoreDevice(deviceIdentifier);
if (device == null) {
throw new OperationManagementException("Device not found for given device " +
"Identifier:" + deviceIdentifier.getId() + " and given type" + deviceIdentifier.getType());
}
operations = new ArrayList<Operation>();
dtoOperationList = operationDAO.getOperationsByDeviceAndStatus(device.getId(),
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.PENDING);
Operation operation;
for (org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation dtoOperation : dtoOperationList) {
operation = OperationDAOUtil.convertOperation(dtoOperation);
operations.add(operation);
}
return operations;
} catch (DeviceManagementDAOException deviceDAOException) {
} catch (DeviceManagementException deviceMgtException) {
String errorMsg = "Error occurred while retrieving the device " +
"for device Identifier type -'" + deviceId.getType() + "' and device Id '" + deviceId.getId();
log.error(errorMsg, deviceDAOException);
throw new OperationManagementException(errorMsg, deviceDAOException);
"for device Identifier type -'" + deviceIdentifier.getType() + "' and device Id '"
+ deviceIdentifier.getId();
log.error(errorMsg, deviceMgtException);
throw new OperationManagementException(errorMsg, deviceMgtException);
} catch (OperationManagementDAOException e) {
throw new OperationManagementException("Error occurred while retrieving the list of " +
"pending operations assigned for '" + deviceId.getType() + "' device '" +
deviceId.getId() + "'", e);
"pending operations assigned for '" + deviceIdentifier.getType() + "' device '" +
deviceIdentifier.getId() + "'", e);
}
}
@ -172,10 +198,10 @@ public class OperationManagerImpl implements OperationManager {
if (log.isDebugEnabled()) {
log.debug("device identifier id:[" + deviceId.getId() + "] type:[" + deviceId.getType() + "]");
}
Operation operation = null;
try {
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation dtoOperation = operationDAO
.getNextOperation(deviceId);
Operation operation = null;
if (dtoOperation != null) {
operation = OperationDAOUtil.convertOperation(dtoOperation);
}
@ -194,8 +220,8 @@ public class OperationManagerImpl implements OperationManager {
}
try {
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation dtoOperation = operationDAO.getOperation
(operationId);
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation dtoOperation =
operationDAO.getOperation(operationId);
if (dtoOperation == null) {
throw new OperationManagementException("Operation not found for operation id:" + operationId);
@ -203,7 +229,7 @@ public class OperationManagerImpl implements OperationManager {
dtoOperation.setStatus(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.valueOf
(operationStatus.toString()));
OperationManagementDAOFactory.beginTransaction();
operationDAO.updateOperation(dtoOperation);
lookupOperationDAO(dtoOperation).updateOperation(dtoOperation);
OperationManagementDAOFactory.commitTransaction();
} catch (OperationManagementDAOException ex) {
try {
@ -228,21 +254,14 @@ public class OperationManagerImpl implements OperationManager {
throw new OperationManagementException("Operation not found for operation id:" + operationId);
}
if (operation.getType().equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.COMMAND)) {
commandOperationDAO.deleteOperation(operationId);
} else if (operation.getType().equals(
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.CONFIG)) {
configOperationDAO.deleteOperation(operationId);
} else if (operation.getType().equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type
.PROFILE)) {
profileOperationDAO.deleteOperation(operationId);
}
lookupOperationDAO(operation).deleteOperation(operationId);
OperationManagementDAOFactory.commitTransaction();
} catch (OperationManagementDAOException ex) {
try {
OperationManagementDAOFactory.rollbackTransaction();
} catch (OperationManagementDAOException e1) {
log.warn("Error occurred while roll-backing the delete operation transaction", e1);
} catch (OperationManagementDAOException e) {
log.warn("Error occurred while roll-backing the delete operation transaction", e);
}
log.error("Error occurred while deleting the operation: " + operationId, ex);
throw new OperationManagementException("Error occurred while delete operation", ex);
@ -253,35 +272,36 @@ public class OperationManagerImpl implements OperationManager {
public Operation getOperationByDeviceAndOperationId(DeviceIdentifier deviceIdentifier, int operationId)
throws OperationManagementException {
Device device;
org.wso2.carbon.device.mgt.common.Device device;
Operation operation;
if (log.isDebugEnabled()) {
log.debug("Device Type:" + deviceIdentifier.getType() + " Id:" + deviceIdentifier.getId());
log.debug(
"Operation Id:" + operationId + " Device Type:" + deviceIdentifier.getType() + " Device Identifier:"
+
deviceIdentifier.getId());
}
try {
device = deviceDAO.getDevice(deviceIdentifier);
device = deviceManagementService.getCoreDevice(deviceIdentifier);
if (device == null) {
throw new OperationManagementException(
"Device not found for given device identifier:" + deviceIdentifier.getId
() + " type:" + deviceIdentifier.getType());
throw new OperationManagementException("Device not found for given device identifier:" +
deviceIdentifier.getId() + " type:" + deviceIdentifier.getType());
}
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation dtoOperation = operationDAO
.getOperationByDeviceAndId(device.getId(), operationId);
if (dtoOperation == null) {
throw new OperationManagementException(
"Operation not found for operation Id:" + operationId + " device" +
" Id:" + device.getId());
throw new OperationManagementException("Operation not found for operation Id:" + operationId +
" device" + " Id:" + device.getId());
}
operation = OperationDAOUtil.convertOperation(dtoOperation);
} catch (DeviceManagementDAOException deviceDAOException) {
} catch (DeviceManagementException deviceMgtException) {
String errorMsg = "Error occurred while retrieving the device " +
"for device Identifier type -'" + deviceIdentifier.getType() + "' and device Id '"
+ deviceIdentifier.getId();
log.error(errorMsg, deviceDAOException);
throw new OperationManagementException(errorMsg, deviceDAOException);
log.error(errorMsg, deviceMgtException);
throw new OperationManagementException(errorMsg, deviceMgtException);
} catch (OperationManagementDAOException e) {
throw new OperationManagementException("Error occurred while retrieving the list of " +
"operations assigned for '" + deviceIdentifier.getType() + "' device '" + deviceIdentifier.getId()
@ -296,27 +316,28 @@ public class OperationManagerImpl implements OperationManager {
try {
List<Operation> operations = new ArrayList<Operation>();
Device device = deviceDAO.getDevice(identifier);
org.wso2.carbon.device.mgt.common.Device device = deviceManagementService.getCoreDevice(identifier);
if (device == null) {
throw new DeviceManagementException("Device not found for device id:" + identifier.getId() + " " +
"type:" + identifier.getType());
}
List<? extends org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation> dtoOperationList = operationDAO
.getOperationsByDeviceAndStatus(device.getId(),
List<? extends org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation> dtoOperationList =
operationDAO.getOperationsByDeviceAndStatus(device.getId(),
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status
.valueOf(status.toString()));
Operation operation;
for (org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation dtoOperation : dtoOperationList) {
operation = OperationDAOUtil.convertOperation(dtoOperation);
operations.add(operation);
}
return operations;
} catch (DeviceManagementDAOException deviceDAOException) {
} catch (DeviceManagementException deviceMgtException) {
String errorMsg = "Error occurred while retrieving the device " +
"for device Identifier type -'" + identifier.getType() + "' and device Id '" + identifier.getId();
log.error(errorMsg, deviceDAOException);
throw new OperationManagementException(errorMsg, deviceDAOException);
log.error(errorMsg, deviceMgtException);
throw new OperationManagementException(errorMsg, deviceMgtException);
} catch (OperationManagementDAOException e) {
throw new OperationManagementException("Error occurred while retrieving the list of " +
"operations assigned for '" + identifier.getType() + "' device '" +
@ -350,8 +371,8 @@ public class OperationManagerImpl implements OperationManager {
try {
List<Operation> operations = new ArrayList<Operation>();
List<? extends org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation> dtoOperationList =
operationDAO
.getOperationsForStatus(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status
operationDAO.getOperationsForStatus(
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status
.valueOf(status.toString()));
Operation operation;
for (org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation dtoOperation : dtoOperationList) {
@ -378,17 +399,16 @@ public class OperationManagerImpl implements OperationManager {
}
}
private OperationDAO lookupOperationDAO(Operation.Type type) {
switch (type) {
case CONFIG:
return configOperationDAO;
case PROFILE:
return profileOperationDAO;
case COMMAND:
return commandOperationDAO;
default:
private OperationDAO lookupOperationDAO(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation operation) {
if (operation instanceof org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation) {
return commandOperationDAO;
} else if (operation instanceof org.wso2.carbon.device.mgt.core.dto.operation.mgt.ProfileOperation) {
return profileOperationDAO;
} else if (operation instanceof org.wso2.carbon.device.mgt.core.dto.operation.mgt.ConfigOperation) {
return configOperationDAO;
} else {
return operationDAO;
}
}
}

@ -66,6 +66,7 @@ public class OperationDAOImpl implements OperationDAO {
throw new OperationManagementDAOException("Error occurred while adding operation metadata", e);
} finally {
OperationManagementDAOUtil.cleanupResources(stmt, rs);
OperationManagementDAOFactory.closeConnection();
}
}
@ -398,7 +399,7 @@ public class OperationDAOImpl implements OperationDAO {
ResultSet rs = null;
Operation operation;
ByteArrayInputStream bais;
ByteArrayInputStream byteArrayInputStream;
ObjectInputStream ois;
List<Operation> operationList = new ArrayList<Operation>();
@ -419,8 +420,8 @@ public class OperationDAOImpl implements OperationDAO {
if (rs.getBytes("OPERATION_DETAILS") != null) {
byte[] operationDetails;
operationDetails = rs.getBytes("OPERATION_DETAILS");
bais = new ByteArrayInputStream(operationDetails);
ois = new ObjectInputStream(bais);
byteArrayInputStream = new ByteArrayInputStream(operationDetails);
ois = new ObjectInputStream(byteArrayInputStream);
operation = (ProfileOperation) ois.readObject();
} else {
operation = new Operation();

@ -17,10 +17,7 @@
*/
package org.wso2.carbon.device.mgt.core.service;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.EmailMessageProperties;
import org.wso2.carbon.device.mgt.common.FeatureManager;
import org.wso2.carbon.device.mgt.common.*;
import org.wso2.carbon.device.mgt.common.spi.DeviceManager;
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
@ -44,4 +41,12 @@ public interface DeviceManagementService extends DeviceManager, LicenseManager,
FeatureManager getFeatureManager(String type) throws DeviceManagementException;
/**
* This method returns core device details.
* @param deviceId
* @return
* @throws DeviceManagementException
*/
Device getCoreDevice(DeviceIdentifier deviceId) throws DeviceManagementException;
}

@ -86,6 +86,11 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getFeatureManager(type);
}
@Override
public Device getCoreDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getCoreDevice(deviceId);
}
@Override
public org.wso2.carbon.device.mgt.common.Device getDevice(DeviceIdentifier deviceId)
throws DeviceManagementException {
@ -116,7 +121,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
@Override
public boolean addOperation(Operation operation,
List<DeviceIdentifier> devices) throws OperationManagementException {
List<DeviceIdentifier> devices) throws OperationManagementException, DeviceManagementException {
return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().addOperation(operation, devices);
}

@ -27,6 +27,7 @@ import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation;
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl;
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory;
@ -58,6 +59,7 @@ public class DeviceOperationManagementTests extends DeviceManagementBaseTest {
private void initOperationManager() {
this.operationManager = new OperationManagerImpl();
DeviceManagementDataHolder.getInstance().setDeviceManagementProvider(new DeviceManagementServiceProviderImpl());
}
@Test

@ -54,7 +54,7 @@ public class ProfileDAOImpl implements ProfileDAO {
try {
conn = this.getConnection();
String query = "INSERT INTO DM_PROFILE (PROFILE_NAME,TENANT_ID, DEVICE_TYPE_ID, CREATED_TIME, UPDATED_TIME) VALUES (?, ?, ?)";
stmt = conn.prepareStatement(query, stmt.RETURN_GENERATED_KEYS);
stmt = conn.prepareStatement(query, PreparedStatement.RETURN_GENERATED_KEYS);
stmt.setString(1, profile.getProfileName());
stmt.setInt(2, tenantId);
@ -108,7 +108,7 @@ public class ProfileDAOImpl implements ProfileDAO {
conn = this.getConnection();
String query = "UPDATE DM_PROFILE SET PROFILE_NAME = ? ,TENANT_ID = ?, DEVICE_TYPE_ID = ? , UPDATED_TIME = ? " +
"WHERE ID = ?";
stmt = conn.prepareStatement(query, stmt.RETURN_GENERATED_KEYS);
stmt = conn.prepareStatement(query, PreparedStatement.RETURN_GENERATED_KEYS);
stmt.setString(1, profile.getProfileName());
stmt.setInt(2, tenantId);

Loading…
Cancel
Save