revert-70aa11f8
geethkokila 9 years ago
commit ae3d5564ff

@ -65,6 +65,10 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
return providers.get(type); return providers.get(type);
} }
public Map<String, DeviceManagementService> getAllDeviceManagementServices() {
return providers;
}
@Override @Override
public void notifyObserver() { public void notifyObserver() {
synchronized (providers) { synchronized (providers) {

@ -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 {
@ -637,10 +638,24 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
@Override @Override
public List<DeviceType> getAvailableDeviceTypes() throws DeviceManagementException { public List<DeviceType> getAvailableDeviceTypes() throws DeviceManagementException {
List<DeviceType> deviceTypes; List<DeviceType> deviceTypesInDatabase;
List<DeviceType> deviceTypesResponse = new ArrayList<>();
try { try {
DeviceManagementDAOFactory.openConnection(); DeviceManagementDAOFactory.openConnection();
deviceTypes = deviceDAO.getDeviceTypes(); deviceTypesInDatabase = deviceDAO.getDeviceTypes();
Map<String, DeviceManagementService> registeredTypes = pluginRepository.getAllDeviceManagementServices();
DeviceType deviceType;
if (registeredTypes != null && deviceTypesInDatabase != null) {
for (int x = 0; x < deviceTypesInDatabase.size(); x++) {
if (registeredTypes.get(deviceTypesInDatabase.get(x).getName()) != null) {
deviceType = new DeviceType();
deviceType.setId(deviceTypesInDatabase.get(x).getId());
deviceType.setName(deviceTypesInDatabase.get(x).getName());
deviceTypesResponse.add(deviceType);
}
}
}
} catch (DeviceManagementDAOException e) { } catch (DeviceManagementDAOException e) {
throw new DeviceManagementException("Error occurred while obtaining the device types.", e); throw new DeviceManagementException("Error occurred while obtaining the device types.", e);
} catch (SQLException e) { } catch (SQLException e) {
@ -648,7 +663,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
} finally { } finally {
DeviceManagementDAOFactory.closeConnection(); DeviceManagementDAOFactory.closeConnection();
} }
return deviceTypes; return deviceTypesResponse;
} }
@Override @Override

Loading…
Cancel
Save