|
|
@ -47,6 +47,7 @@ import java.sql.SQLException;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
public class DeviceManagementProviderServiceImpl implements DeviceManagementProviderService,
|
|
|
|
public class DeviceManagementProviderServiceImpl implements DeviceManagementProviderService,
|
|
|
|
PluginInitializationListener {
|
|
|
|
PluginInitializationListener {
|
|
|
@ -635,21 +636,35 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
return device;
|
|
|
|
return device;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<DeviceType> getAvailableDeviceTypes() throws DeviceManagementException {
|
|
|
|
public List<DeviceType> getAvailableDeviceTypes() throws DeviceManagementException {
|
|
|
|
List<DeviceType> deviceTypes;
|
|
|
|
List<DeviceType> deviceTypesInDatabase;
|
|
|
|
try {
|
|
|
|
List<DeviceType> deviceTypesResponse = new ArrayList<>();
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
try {
|
|
|
|
deviceTypes = deviceDAO.getDeviceTypes();
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
deviceTypesInDatabase = deviceDAO.getDeviceTypes();
|
|
|
|
throw new DeviceManagementException("Error occurred while obtaining the device types.", e);
|
|
|
|
Map<String, DeviceManagementService> registeredTypes = pluginRepository.getAllDeviceManagementServices();
|
|
|
|
} catch (SQLException e) {
|
|
|
|
DeviceType deviceType;
|
|
|
|
throw new DeviceManagementException("Error occurred while opening a connection to the data source", e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
if (registeredTypes != null && deviceTypesInDatabase != null) {
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
for (int x = 0; x < deviceTypesInDatabase.size(); x++) {
|
|
|
|
}
|
|
|
|
if (registeredTypes.get(deviceTypesInDatabase.get(x).getName()) != null) {
|
|
|
|
return deviceTypes;
|
|
|
|
deviceType = new DeviceType();
|
|
|
|
}
|
|
|
|
deviceType.setId(deviceTypesInDatabase.get(x).getId());
|
|
|
|
|
|
|
|
deviceType.setName(deviceTypesInDatabase.get(x).getName());
|
|
|
|
|
|
|
|
deviceTypesResponse.add(deviceType);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementException("Error occurred while obtaining the device types.", e);
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new DeviceManagementException("Error occurred while opening a connection to the data source", e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return deviceTypesResponse;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean updateDeviceInfo(DeviceIdentifier deviceId, Device device) throws DeviceManagementException {
|
|
|
|
public boolean updateDeviceInfo(DeviceIdentifier deviceId, Device device) throws DeviceManagementException {
|
|
|
|