@Override public RetrieveAcl setDittoHeaders(final DittoHeaders dittoHeaders) { return of(thingId, dittoHeaders); }
/** * Returns a command for retrieving the ACL of a Thing with the given ID. * * @param thingId the ID of a single Thing whose ACL will be retrieved by this command. * @param dittoHeaders the headers of the command. * @return a Command for retrieving ACL of the Thing with the {@code thingId} as its ID which is readable from the * passed authorization context. * @throws NullPointerException if {@code dittoHeaders} is {@code null}. * @throws org.eclipse.ditto.model.things.ThingIdInvalidException if the parsed thing ID did not comply to {@link * org.eclipse.ditto.model.things.Thing#ID_REGEX}. */ public static RetrieveAcl of(final String thingId, final DittoHeaders dittoHeaders) { return new RetrieveAcl(thingId, dittoHeaders); }
@SuppressWarnings("squid:MethodCyclomaticComplexity") @Override public boolean equals(@Nullable final Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } final RetrieveAcl that = (RetrieveAcl) obj; return that.canEqual(this) && Objects.equals(thingId, that.thingId) && super.equals(that); }
@Override protected Result doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final RetrieveAcl command) { final JsonObject aclJson = extractAcl(thing) .map(acl -> acl.toJson(command.getImplementedSchemaVersion())) .orElseGet(JsonFactory::newObject); return ResultFactory.newQueryResult(command, thing, RetrieveAclResponse.of(context.getThingId(), aclJson, command.getDittoHeaders()), this); }
/** * Creates a new {@code RetrieveAcl} from a JSON string. * * @param jsonString the JSON string of which the command is to be created. * @param dittoHeaders the headers of the command. * @return the command. * @throws NullPointerException if any argument is {@code null}. * @throws IllegalArgumentException if {@code jsonString} is empty. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonString} was not in the expected * format. * @throws org.eclipse.ditto.model.things.ThingIdInvalidException if the parsed thing ID did not comply to {@link * org.eclipse.ditto.model.things.Thing#ID_REGEX}. */ public static RetrieveAcl fromJson(final String jsonString, final DittoHeaders dittoHeaders) { return fromJson(JsonFactory.newObject(jsonString), dittoHeaders); }
@Override protected Result doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final RetrieveAcl command) { final JsonObject aclJson = extractAcl(thing) .map(acl -> acl.toJson(command.getImplementedSchemaVersion())) .orElseGet(JsonFactory::newObject); return ResultFactory.newQueryResult(command, thing, RetrieveAclResponse.of(context.getThingId(), aclJson, command.getDittoHeaders()), this); }
/** * Creates a new {@code RetrieveAcl} from a JSON string. * * @param jsonString the JSON string of which the command is to be created. * @param dittoHeaders the headers of the command. * @return the command. * @throws NullPointerException if any argument is {@code null}. * @throws IllegalArgumentException if {@code jsonString} is empty. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonString} was not in the expected * format. * @throws org.eclipse.ditto.model.things.ThingIdInvalidException if the parsed thing ID did not comply to {@link * org.eclipse.ditto.model.things.Thing#ID_REGEX}. */ public static RetrieveAcl fromJson(final String jsonString, final DittoHeaders dittoHeaders) { return fromJson(JsonFactory.newObject(jsonString), dittoHeaders); }
@Override public RetrieveAcl setDittoHeaders(final DittoHeaders dittoHeaders) { return of(thingId, dittoHeaders); }
@SuppressWarnings("squid:MethodCyclomaticComplexity") @Override public boolean equals(@Nullable final Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } final RetrieveAcl that = (RetrieveAcl) obj; return that.canEqual(this) && Objects.equals(thingId, that.thingId) && super.equals(that); }
/** * Returns a command for retrieving the ACL of a Thing with the given ID. * * @param thingId the ID of a single Thing whose ACL will be retrieved by this command. * @param dittoHeaders the headers of the command. * @return a Command for retrieving ACL of the Thing with the {@code thingId} as its ID which is readable from the * passed authorization context. * @throws NullPointerException if {@code dittoHeaders} is {@code null}. * @throws org.eclipse.ditto.model.things.ThingIdInvalidException if the parsed thing ID did not comply to {@link * org.eclipse.ditto.model.things.Thing#ID_REGEX}. */ public static RetrieveAcl of(final String thingId, final DittoHeaders dittoHeaders) { return new RetrieveAcl(thingId, dittoHeaders); }
/** * Creates a new {@code RetrieveAcl} from a JSON object. * * @param jsonObject the JSON object of which the command is to be created. * @param dittoHeaders the headers of the command. * @return the command. * @throws NullPointerException if any argument is {@code null}. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonObject} was not in the expected * format. * @throws org.eclipse.ditto.model.things.ThingIdInvalidException if the parsed thing ID did not comply to {@link * org.eclipse.ditto.model.things.Thing#ID_REGEX}. */ public static RetrieveAcl fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new CommandJsonDeserializer<RetrieveAcl>(TYPE, jsonObject).deserialize(() -> { final String thingId = jsonObject.getValueOrThrow(ThingQueryCommand.JsonFields.JSON_THING_ID); return of(thingId, dittoHeaders); }); }
/** * Creates a new {@code RetrieveAcl} from a JSON object. * * @param jsonObject the JSON object of which the command is to be created. * @param dittoHeaders the headers of the command. * @return the command. * @throws NullPointerException if any argument is {@code null}. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonObject} was not in the expected * format. * @throws org.eclipse.ditto.model.things.ThingIdInvalidException if the parsed thing ID did not comply to {@link * org.eclipse.ditto.model.things.Thing#ID_REGEX}. */ public static RetrieveAcl fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new CommandJsonDeserializer<RetrieveAcl>(TYPE, jsonObject).deserialize(() -> { final String thingId = jsonObject.getValueOrThrow(ThingQueryCommand.JsonFields.JSON_THING_ID); return of(thingId, dittoHeaders); }); }
.selectedFields(selectedFieldsFrom(adaptable)).build()); mappingStrategies.put(RetrieveAcl.TYPE, adaptable -> RetrieveAcl.of(thingIdFrom(adaptable), dittoHeadersFrom(adaptable)));
.selectedFields(selectedFieldsFrom(adaptable)).build()); mappingStrategies.put(RetrieveAcl.TYPE, adaptable -> RetrieveAcl.of(thingIdFrom(adaptable), dittoHeadersFrom(adaptable)));
private Route thingsEntryAcl(final RequestContext ctx, final DittoHeaders dittoHeaders, final String thingId) { return rawPathPrefix(mergeDoubleSlashes().concat(PATH_ACL), () -> // /things/<thingId>/acl pathEndOrSingleSlash(() -> route( get(() -> // GET /things/<thingId>/acl handlePerRequest(ctx, RetrieveAcl.of(thingId, dittoHeaders)) ), put(() -> // PUT /things/<thingId>/acl extractDataBytes(payloadSource -> handlePerRequest(ctx, dittoHeaders, payloadSource, aclJson -> ModifyAcl.of(thingId, ThingsModelFactory.newAcl(aclJson), dittoHeaders)) ) ) ) ) ); }