|
|
@ -111,23 +111,23 @@ public final class DeviceManagerUtil {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Adds a new device type to the database if it does not exists.
|
|
|
|
* Adds a new device type to the database if it does not exists.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param deviceType device type
|
|
|
|
* @param typeName device type
|
|
|
|
* @return status of the operation
|
|
|
|
* @return status of the operation
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static boolean registerDeviceType(String deviceType) throws DeviceManagementException {
|
|
|
|
public static boolean registerDeviceType(String typeName) throws DeviceManagementException {
|
|
|
|
boolean status;
|
|
|
|
boolean status;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
DeviceTypeDAO deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO();
|
|
|
|
DeviceTypeDAO deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO();
|
|
|
|
DeviceType deviceTypeId = deviceTypeDAO.getDeviceType(deviceType);
|
|
|
|
DeviceType deviceType = deviceTypeDAO.getDeviceType(typeName);
|
|
|
|
if (deviceTypeId == null) {
|
|
|
|
if (deviceType == null) {
|
|
|
|
DeviceType dt = new DeviceType();
|
|
|
|
DeviceType dt = new DeviceType();
|
|
|
|
dt.setName(deviceType);
|
|
|
|
dt.setName(typeName);
|
|
|
|
deviceTypeDAO.addDeviceType(dt);
|
|
|
|
deviceTypeDAO.addDeviceType(dt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
status = true;
|
|
|
|
status = true;
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
throw new DeviceManagementException("Error occurred while registering the device type '" +
|
|
|
|
throw new DeviceManagementException("Error occurred while registering the device type '" +
|
|
|
|
deviceType + "'", e);
|
|
|
|
typeName + "'", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return status;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -135,22 +135,22 @@ public final class DeviceManagerUtil {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Un-registers an existing device type from the device management metadata repository.
|
|
|
|
* Un-registers an existing device type from the device management metadata repository.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param deviceType device type
|
|
|
|
* @param typeName device type
|
|
|
|
* @return status of the operation
|
|
|
|
* @return status of the operation
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static boolean unregisterDeviceType(String deviceType) throws DeviceManagementException {
|
|
|
|
public static boolean unregisterDeviceType(String typeName) throws DeviceManagementException {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
DeviceTypeDAO deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO();
|
|
|
|
DeviceTypeDAO deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO();
|
|
|
|
DeviceType deviceTypeId = deviceTypeDAO.getDeviceType(deviceType);
|
|
|
|
DeviceType deviceType = deviceTypeDAO.getDeviceType(typeName);
|
|
|
|
if (deviceTypeId == null) {
|
|
|
|
if (deviceType == null) {
|
|
|
|
DeviceType dt = new DeviceType();
|
|
|
|
DeviceType dt = new DeviceType();
|
|
|
|
dt.setName(deviceType);
|
|
|
|
dt.setName(typeName);
|
|
|
|
deviceTypeDAO.removeDeviceType(deviceType);
|
|
|
|
deviceTypeDAO.removeDeviceType(typeName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
throw new DeviceManagementException("Error occurred while registering the device type '" +
|
|
|
|
throw new DeviceManagementException("Error occurred while registering the device type '" +
|
|
|
|
deviceType + "'", e);
|
|
|
|
typeName + "'", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|