Skip to content

Commit

Permalink
Fixed GenericRequestPayload translation
Browse files Browse the repository at this point in the history
Signed-off-by: Alberto Codutti <[email protected]>
  • Loading branch information
Coduz committed Mar 23, 2021
1 parent 8dde961 commit f252762
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.eclipse.kapua.service.device.management.message.response.KapuaResponsePayload;
import org.eclipse.kapua.service.device.management.request.GenericRequestFactory;
import org.eclipse.kapua.service.device.management.request.message.response.GenericResponseMessage;
import org.eclipse.kapua.service.device.management.request.message.response.GenericResponsePayload;
import org.eclipse.kapua.translator.exception.InvalidChannelException;
import org.eclipse.kapua.translator.exception.InvalidPayloadException;
import org.eclipse.kapua.translator.exception.TranslatorErrorCodes;
Expand Down Expand Up @@ -91,7 +92,14 @@ public Class<TO_M> getClassTo() {
@Override
protected TO_P translatePayload(KuraResponsePayload kuraResponsePayload) throws InvalidPayloadException {
try {
TO_P appResponsePayload = payloadClazz.newInstance();
GenericRequestFactory genericRequestFactory = LOCATOR.getFactory(GenericRequestFactory.class);

TO_P appResponsePayload;
if (payloadClazz.equals(GenericResponsePayload.class)) {
appResponsePayload = this.payloadClazz.cast(genericRequestFactory.newResponsePayload());
} else {
appResponsePayload = payloadClazz.newInstance();
}

appResponsePayload.setExceptionMessage(kuraResponsePayload.getExceptionMessage());

Expand Down

0 comments on commit f252762

Please sign in to comment.