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