@Override protected MessageSendNotAllowedException doBuild(final DittoHeaders dittoHeaders, @Nullable final String message, @Nullable final String description, @Nullable final Throwable cause, @Nullable final URI href) { return new MessageSendNotAllowedException(dittoHeaders, message, description, cause, href); }
/** * Deserialize from a JSON object. * * @param jsonObject the JSON object to deserialize. * @param dittoHeaders the headers. * @return an instance of this class. * @throws NullPointerException if any argument is {@code null}. */ public static MessageSendNotAllowedException fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new Builder() .loadJson(jsonObject) .dittoHeaders(dittoHeaders) .message(readMessage(jsonObject)) .description(readDescription(jsonObject).orElse(DEFAULT_DESCRIPTION)) .href(readHRef(jsonObject).orElse(null)) .build(); }
private void rejectMessageCommand(final MessageCommand command, final ActorRef sender) { final MessageSendNotAllowedException error = MessageSendNotAllowedException.newBuilder(command.getThingId()) .dittoHeaders(command.getDittoHeaders()) .build(); log(command).info( "The command <{}> was not forwarded due to insufficient rights {}: {} - AuthorizationSubjects: {}", command.getType(), error.getClass().getSimpleName(), error.getMessage(), command.getDittoHeaders().getAuthorizationSubjects()); replyToSender(error, sender); }