@Override public RetrieveAclResponse setDittoHeaders(final DittoHeaders dittoHeaders) { return of(thingId, acl, dittoHeaders); }
@Override public RetrieveAclResponse setDittoHeaders(final DittoHeaders dittoHeaders) { return of(thingId, acl, dittoHeaders); }
@Override public RetrieveAclResponse setEntity(final JsonValue entity) { checkNotNull(entity, "entity"); return of(thingId, entity.asObject(), getDittoHeaders()); }
@Override public RetrieveAclResponse setEntity(final JsonValue entity) { checkNotNull(entity, "entity"); return of(thingId, entity.asObject(), getDittoHeaders()); }
@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); }
@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 response to a {@link RetrieveAcl} command from a JSON object. * * @param jsonObject the JSON object of which the response is to be created. * @param dittoHeaders the headers of the preceding command. * @return the response. * @throws NullPointerException if {@code jsonObject} is {@code null}. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonObject} was not in the expected * format. */ public static RetrieveAclResponse fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new CommandResponseJsonDeserializer<RetrieveAclResponse>(TYPE, jsonObject) .deserialize((statusCode) -> { final String thingId = jsonObject.getValueOrThrow(ThingQueryCommandResponse.JsonFields.JSON_THING_ID); final JsonObject aclJsonObject = jsonObject.getValueOrThrow(JSON_ACL); final AccessControlList extractedAcl = ThingsModelFactory.newAcl(aclJsonObject); return of(thingId, extractedAcl, dittoHeaders); }); }
/** * Creates a response to a {@link RetrieveAcl} command from a JSON object. * * @param jsonObject the JSON object of which the response is to be created. * @param dittoHeaders the headers of the preceding command. * @return the response. * @throws NullPointerException if {@code jsonObject} is {@code null}. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonObject} was not in the expected * format. */ public static RetrieveAclResponse fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new CommandResponseJsonDeserializer<RetrieveAclResponse>(TYPE, jsonObject) .deserialize((statusCode) -> { final String thingId = jsonObject.getValueOrThrow(ThingQueryCommandResponse.JsonFields.JSON_THING_ID); final JsonObject aclJsonObject = jsonObject.getValueOrThrow(JSON_ACL); final AccessControlList extractedAcl = ThingsModelFactory.newAcl(aclJsonObject); return of(thingId, extractedAcl, dittoHeaders); }); }
adaptable -> RetrieveAclResponse.of(thingIdFrom(adaptable), aclFrom(adaptable), dittoHeadersFrom(adaptable)));
adaptable -> RetrieveAclResponse.of(thingIdFrom(adaptable), aclFrom(adaptable), dittoHeadersFrom(adaptable)));