use of org.openmuc.framework.config.DeviceConfig in project OpenMUC by isc-konstanz.
the class DeviceResourceServlet method doPut.
@Override
public void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType(APPLICATION_JSON);
String[] pathAndQueryString = checkIfItIsACorrectRest(request, response, logger);
if (pathAndQueryString != null) {
setConfigAccess();
String pathInfo = pathAndQueryString[ServletLib.PATH_ARRAY_NR];
String[] pathInfoArray = ServletLib.getPathInfoArray(pathInfo);
FromJson json = ServletLib.getFromJson(request, logger, response);
if (json == null) {
return;
}
if (pathInfoArray.length < 1) {
ServletLib.sendHTTPErrorAndLogDebug(response, HttpServletResponse.SC_NOT_FOUND, logger, REQUESTED_REST_PATH_IS_NOT_AVAILABLE, REST_PATH, request.getPathInfo());
} else {
String deviceId = pathInfoArray[0];
DeviceConfig deviceConfig = rootConfig.getDevice(deviceId);
if (deviceConfig != null && pathInfoArray.length == 2 && pathInfoArray[1].equalsIgnoreCase(Const.CONFIGS)) {
doSetConfigs(deviceId, response, json, true);
} else {
ServletLib.sendHTTPErrorAndLogDebug(response, HttpServletResponse.SC_NOT_FOUND, logger, REQUESTED_REST_PATH_IS_NOT_AVAILABLE, REST_PATH, request.getPathInfo());
}
}
}
}
use of org.openmuc.framework.config.DeviceConfig in project OpenMUC by isc-konstanz.
the class DriverResourceServlet method getChannelList.
private List<Channel> getChannelList(String driverId) {
List<Channel> driverChannels = new ArrayList<>();
DriverConfig driverConfig = rootConfig.getDriver(driverId);
Collection<DeviceConfig> deviceConfigs = driverConfig.getDevices();
for (DeviceConfig deviceConfig : deviceConfigs) {
Collection<ChannelConfig> channelConfigs = deviceConfig.getChannels();
for (ChannelConfig channelConfig : channelConfigs) {
driverChannels.add(dataAccess.getChannel(channelConfig.getId()));
}
}
return driverChannels;
}
Aggregations