use of org.wso2.iot.sampledevice.plugin.exception.DeviceMgtPluginException in project product-iots by wso2.
the class DeviceTypeManager method disenrollDevice.
@Override
public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
boolean status;
try {
if (log.isDebugEnabled()) {
log.debug("Dis-enrolling sampledevice device : " + deviceId);
}
DeviceTypeDAO.beginTransaction();
status = deviceTypeDAO.getDeviceTypeDAO().deleteDevice(deviceId.getId());
DeviceTypeDAO.commitTransaction();
} catch (DeviceMgtPluginException e) {
try {
DeviceTypeDAO.rollbackTransaction();
} catch (DeviceMgtPluginException iotDAOEx) {
String msg = "Error occurred while roll back the device dis enrol transaction :" + deviceId.toString();
log.warn(msg, iotDAOEx);
}
String msg = "Error while removing the sampledevice device : " + deviceId.getId();
log.error(msg, e);
throw new DeviceManagementException(msg, e);
}
return status;
}
use of org.wso2.iot.sampledevice.plugin.exception.DeviceMgtPluginException in project product-iots by wso2.
the class DeviceTypeDAO method beginTransaction.
public static void beginTransaction() throws DeviceMgtPluginException {
try {
Connection conn = dataSource.getConnection();
conn.setAutoCommit(false);
currentConnection.set(conn);
} catch (SQLException e) {
throw new DeviceMgtPluginException("Error occurred while retrieving datasource connection", e);
}
}
Aggregations