use of org.eclipse.kapua.service.device.management.configuration.internal.DeviceComponentConfigurationImpl in project kapua by eclipse.
the class TranslatorAppConfigurationKuraKapua method translateBody.
private void translateBody(ConfigurationResponsePayload configurationResponsePayload, String charEncoding, KuraDeviceConfiguration kuraDeviceConfiguration) throws TranslatorException {
try {
DeviceConfigurationImpl deviceConfiguration = new DeviceConfigurationImpl();
for (KuraDeviceComponentConfiguration kuraDeviceCompConf : kuraDeviceConfiguration.getConfigurations()) {
String componentId = kuraDeviceCompConf.getComponentId();
DeviceComponentConfigurationImpl deviceComponentConfiguration = new DeviceComponentConfigurationImpl(componentId);
deviceComponentConfiguration.setProperties(translate(kuraDeviceCompConf.getProperties()));
// Translate also definitions when they are available
if (kuraDeviceCompConf.getDefinition() != null) {
deviceComponentConfiguration.setDefinition(translate(kuraDeviceCompConf.getDefinition()));
}
// Add to kapua configuration
deviceConfiguration.getComponentConfigurations().add(deviceComponentConfiguration);
}
StringWriter sw = new StringWriter();
XmlUtil.marshal(deviceConfiguration, sw);
byte[] requestBody = sw.toString().getBytes(charEncoding);
configurationResponsePayload.setBody(requestBody);
} catch (Exception e) {
throw new TranslatorException(TranslatorErrorCodes.INVALID_BODY, e, kuraDeviceConfiguration);
}
}
Aggregations