@Override public UnblockNamespace setDittoHeaders(final DittoHeaders dittoHeaders) { return new UnblockNamespace(getNamespace(), dittoHeaders); }
private void unblockNamespace(final UnblockNamespace command) { final String namespace = command.getNamespace(); final ActorRef sender = getSender(); final ActorRef self = getSelf(); blockedNamespaces.remove(namespace) .thenAccept(_void -> { final UnblockNamespaceResponse response = UnblockNamespaceResponse.getInstance(namespace, command.getResourceType(), command.getDittoHeaders()); sender.tell(response, self); }) .exceptionally(error -> handleError(error, command, sender)); }
/** * Returns an instance of {@code UnblockNamespace}. * * @param namespace the namespace to be unblocked. * @param dittoHeaders the headers of the command. * @return the instance. * @throws NullPointerException if any argument is {@code null}. * @throws IllegalArgumentException if {@code namespace} is empty. */ public static UnblockNamespace of(final CharSequence namespace, final DittoHeaders dittoHeaders) { return new UnblockNamespace(namespace, dittoHeaders); }
/** * Creates a new {@code UnblockNamespace} from a JSON object. * * @param jsonObject the JSON object of which the UnblockNamespace is to be created. * @param dittoHeaders the headers. * @return the command. * @throws NullPointerException if {@code jsonObject} is {@code null}. * @throws org.eclipse.ditto.json.JsonMissingFieldException if {@code jsonObject} did not contain * {@link org.eclipse.ditto.signals.commands.namespaces.NamespaceCommand.JsonFields#NAMESPACE}. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonObject} was not in the expected * format. */ public static UnblockNamespace fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new CommandJsonDeserializer<UnblockNamespace>(TYPE, jsonObject).deserialize(() -> { final String namespace = jsonObject.getValueOrThrow(NamespaceCommand.JsonFields.NAMESPACE); return new UnblockNamespace(namespace, dittoHeaders); }); }