use of org.eclipse.kapua.service.device.call.kura.model.bundle.KuraBundles in project kapua by eclipse.
the class TranslatorAppBundleKuraKapua method translate.
private BundleResponsePayload translate(KuraResponsePayload kuraPayload) throws KapuaException {
BundleResponsePayload bundleResponsePayload = new BundleResponsePayload();
bundleResponsePayload.setExceptionMessage((String) kuraPayload.getMetrics().get(ResponseMetrics.RESP_METRIC_EXCEPTION_MESSAGE.getValue()));
bundleResponsePayload.setExceptionStack((String) kuraPayload.getMetrics().get(ResponseMetrics.RESP_METRIC_EXCEPTION_STACK.getValue()));
if (kuraPayload.getBody() != null) {
DeviceManagementSetting config = DeviceManagementSetting.getInstance();
String charEncoding = config.getString(DeviceManagementSettingKey.CHAR_ENCODING);
String body = null;
try {
body = new String(kuraPayload.getBody(), charEncoding);
} catch (Exception e) {
throw new TranslatorException(TranslatorErrorCodes.INVALID_PAYLOAD, e, kuraPayload.getBody());
}
KuraBundles kuraBundles = null;
try {
kuraBundles = XmlUtil.unmarshal(body, KuraBundles.class);
} catch (Exception e) {
throw new TranslatorException(TranslatorErrorCodes.INVALID_PAYLOAD, e, body);
}
translate(bundleResponsePayload, charEncoding, kuraBundles);
}
// Return Kapua Payload
return bundleResponsePayload;
}
Aggregations