use of org.wso2.carbon.device.mgt.common.Device in project product-iots by wso2.
the class DeviceTypeManager method updateDeviceInfo.
@Override
public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException {
boolean status;
try {
if (log.isDebugEnabled()) {
log.debug("updating the details of sampledevice device : " + deviceIdentifier);
}
DeviceTypeDAO.beginTransaction();
status = deviceTypeDAO.getDeviceTypeDAO().updateDevice(device);
DeviceTypeDAO.commitTransaction();
} catch (DeviceMgtPluginException e) {
try {
DeviceTypeDAO.rollbackTransaction();
} catch (DeviceMgtPluginException iotDAOEx) {
String msg = "Error occurred while roll back the update device info transaction :" + device.toString();
log.warn(msg, iotDAOEx);
}
String msg = "Error while updating the sampledevice device : " + deviceIdentifier;
log.error(msg, e);
throw new DeviceManagementException(msg, e);
}
return status;
}
use of org.wso2.carbon.device.mgt.common.Device in project product-iots by wso2.
the class DeviceTypeManager method modifyEnrollment.
@Override
public boolean modifyEnrollment(Device device) throws DeviceManagementException {
boolean status;
try {
if (log.isDebugEnabled()) {
log.debug("Modifying the sampledevice device enrollment data");
}
DeviceTypeDAO.beginTransaction();
status = deviceTypeDAO.getDeviceTypeDAO().updateDevice(device);
DeviceTypeDAO.commitTransaction();
} catch (DeviceMgtPluginException e) {
try {
DeviceTypeDAO.rollbackTransaction();
} catch (DeviceMgtPluginException iotDAOEx) {
String msg = "Error occurred while roll back the update device transaction :" + device.toString();
log.warn(msg, iotDAOEx);
}
String msg = "Error while updating the enrollment of the sampledevice device : " + device.getDeviceIdentifier();
log.error(msg, e);
throw new DeviceManagementException(msg, e);
}
return status;
}
use of org.wso2.carbon.device.mgt.common.Device in project product-iots by wso2.
the class DeviceTypeUtils method setupDeviceManagementSchema.
public static void setupDeviceManagementSchema() throws DeviceMgtPluginException {
try {
Context ctx = new InitialContext();
DataSource dataSource = (DataSource) ctx.lookup(DeviceTypeConstants.DATA_SOURCE_NAME);
DeviceSchemaInitializer initializer = new DeviceSchemaInitializer(dataSource);
log.info("Initializing device management repository database schema");
initializer.createRegistryDatabase();
} catch (NamingException e) {
log.error("Error while looking up the data source: " + DeviceTypeConstants.DATA_SOURCE_NAME);
} catch (Exception e) {
throw new DeviceMgtPluginException("Error occurred while initializing Iot Device " + "Management database schema", e);
}
}
use of org.wso2.carbon.device.mgt.common.Device in project product-iots by wso2.
the class EnrollDevicePage method gotoConnectedCupDeviceTypeViewPage.
/**
* Method to perform the navigation to Device type view page of the Connected cup.
* @return : The corresponding Device type view page. Null, if the element is not visible.
*/
public ConnectedCupDeviceTypeViewPage gotoConnectedCupDeviceTypeViewPage() throws IOException {
boolean check = UIUtils.isElementPresent(log, driver, By.xpath(uiElementMapper.getElement("iot.sample.connectedcup.xpath")));
if (check) {
WebElement deviceDiv = driver.findElement(By.xpath(uiElementMapper.getElement("iot.sample.connectedcup.xpath")));
WebElement tryBtn = deviceDiv.findElement(By.tagName("button"));
tryBtn.click();
return new ConnectedCupDeviceTypeViewPage(driver);
} else {
log.error("Element not found!");
return null;
}
}
use of org.wso2.carbon.device.mgt.common.Device in project product-iots by wso2.
the class MobileDeviceManagement method testGetUserDevices.
@Test(description = "Test getting devices")
public void testGetUserDevices() throws Exception {
int expectedCount = this.userMode == TestUserMode.TENANT_ADMIN ? 3 : 13;
HttpResponse response = client.get(Constants.MobileDeviceManagement.GET_ALL_DEVICES_ENDPOINT + Constants.MobileDeviceManagement.USER_DEVICE_ENDPOINT);
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
JsonObject devices = new JsonParser().parse(response.getData()).getAsJsonObject();
Assert.assertEquals("Expected device count is not received", expectedCount, devices.get("count").getAsInt());
}
Aggregations