use of org.eclipse.kapua.service.device.call.kura.model.configuration.KuraDeviceComponentConfiguration in project kapua by eclipse.
the class TranslatorAppConfigurationKapuaKura method translate.
private KuraDeviceConfiguration translate(DeviceConfiguration kapuaDeviceConfiguration) throws KapuaException {
KuraDeviceConfiguration kuraDeviceConfiguration = new KuraDeviceConfiguration();
for (DeviceComponentConfiguration kapuaDeviceCompConf : kapuaDeviceConfiguration.getComponentConfigurations()) {
KuraDeviceComponentConfiguration kuraComponentConfiguration = new KuraDeviceComponentConfiguration();
kuraComponentConfiguration.setComponentId(kapuaDeviceCompConf.getId());
kuraComponentConfiguration.setProperties(translate(kapuaDeviceCompConf.getProperties()));
// Translate also definitions when they are available
if (kapuaDeviceCompConf.getDefinition() != null) {
kuraComponentConfiguration.setDefinition(translate(kapuaDeviceCompConf.getDefinition()));
}
// Add to kapua configuration
kuraDeviceConfiguration.getConfigurations().add(kuraComponentConfiguration);
}
return kuraDeviceConfiguration;
}
use of org.eclipse.kapua.service.device.call.kura.model.configuration.KuraDeviceComponentConfiguration 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