private void retrieveThings(final SudoRetrieveThings sudoRetrieveThings, final ActorRef resultReceiver) { final JsonFieldSelector selectedFields = sudoRetrieveThings.getSelectedFields().orElse(null); retrieveThingsAndSendResult(sudoRetrieveThings.getThingIds(), selectedFields, sudoRetrieveThings, resultReceiver); }
/** * Creates a new {@code SudoRetrieveThings}. * * @param thingIds one or more Thing IDs to be retrieved. * @param selectedFields the Fields which should be included in the Thing's JSON representation. * @param dittoHeaders the command headers of the request. * @return a command for retrieving Things without authorization. * @throws NullPointerException if any argument but {@code selectedFields} is {@code null}. */ public static SudoRetrieveThings of(final List<String> thingIds, @Nullable final JsonFieldSelector selectedFields, final DittoHeaders dittoHeaders) { return new SudoRetrieveThings(thingIds, selectedFields, dittoHeaders); }
/** * Creates a new {@code SudoRetrieveThings}. * * @param thingIds one or more Thing IDs to be retrieved. * @param dittoHeaders the command headers of the request. * @return a command for retrieving Things without authorization. * @throws NullPointerException if any argument is {@code null}. */ public static SudoRetrieveThings of(final List<String> thingIds, final DittoHeaders dittoHeaders) { return of(thingIds, null, dittoHeaders); }
private void handleSudoRetrieveThings(final SudoRetrieveThings rt, final Object msgToAsk) { LogUtil.enhanceLogWithCorrelationId(log, rt.getDittoHeaders().getCorrelationId()); log.info("Got '{}' message. Retrieving requested '{}' Things..", SudoRetrieveThings.class.getSimpleName(), rt.getThingIds().size()); final ActorRef sender = getSender(); PatternsCS.ask(targetActor, msgToAsk, Duration.ofSeconds(ASK_TIMEOUT)) .thenAccept(sourceRef -> handleSourceRef((SourceRef) sourceRef, rt.getThingIds(), rt, sender) ); }
@SuppressWarnings({"squid:MethodCyclomaticComplexity", "squid:S1067", "pmd:SimplifyConditional"}) @Override public boolean equals(@Nullable final Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } final SudoRetrieveThings that = (SudoRetrieveThings) obj; return that.canEqual(this) && Objects.equals(thingIds, that.thingIds) && Objects.equals(selectedFields, that.selectedFields) && super.equals(that); }
/** * Creates a new {@code SudoRetrieveThings} from a JSON string. * * @param jsonString the JSON string of which a new SudoRetrieveThings is to be created. * @param dittoHeaders the optional command headers of the request. * @return the SudoRetrieveThings which was created from the given JSON string. * @throws NullPointerException if {@code jsonString} is {@code null}. * @throws IllegalArgumentException if {@code jsonString} is empty. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonString} does not contain a JSON * object or if it is not valid JSON. * @throws org.eclipse.ditto.json.JsonMissingFieldException if the passed in {@code jsonString} was not in the * expected format. */ public static SudoRetrieveThings fromJson(final String jsonString, final DittoHeaders dittoHeaders) { return fromJson(JsonFactory.newObject(jsonString), dittoHeaders); }
@Override public Receive createReceive() { return ReceiveBuilder.create() // # handle "RetrieveThings" command .match(RetrieveThings.class, rt -> { LogUtil.enhanceLogWithCorrelationId(log, rt.getDittoHeaders().getCorrelationId()); log.info("Got '{}' message. Retrieving requested '{}' Things..", RetrieveThings.class.getSimpleName(), rt.getThingIds().size()); retrieveThings(rt, getSender()); }) // # handle "SudoRetrieveThings" command .match(SudoRetrieveThings.class, rt -> { LogUtil.enhanceLogWithCorrelationId(log, rt.getDittoHeaders().getCorrelationId()); log.info("Got '{}' message. Retrieving requested '{}' Things..", SudoRetrieveThings.class.getSimpleName(), rt.getThingIds().size()); retrieveThings(rt, getSender()); }) // # handle unknown message .matchAny(m -> { log.warning("Got unknown message: {}", m); unhandled(m); }) // # build PartialFunction .build(); }
@SuppressWarnings({"squid:MethodCyclomaticComplexity", "squid:S1067", "pmd:SimplifyConditional"}) @Override public boolean equals(@Nullable final Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } final SudoRetrieveThings that = (SudoRetrieveThings) obj; return that.canEqual(this) && Objects.equals(thingIds, that.thingIds) && Objects.equals(selectedFields, that.selectedFields) && super.equals(that); }
/** * Creates a new {@code SudoRetrieveThings} from a JSON string. * * @param jsonString the JSON string of which a new SudoRetrieveThings is to be created. * @param dittoHeaders the optional command headers of the request. * @return the SudoRetrieveThings which was created from the given JSON string. * @throws NullPointerException if {@code jsonString} is {@code null}. * @throws IllegalArgumentException if {@code jsonString} is empty. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonString} does not contain a JSON * object or if it is not valid JSON. * @throws org.eclipse.ditto.json.JsonMissingFieldException if the passed in {@code jsonString} was not in the * expected format. */ public static SudoRetrieveThings fromJson(final String jsonString, final DittoHeaders dittoHeaders) { return fromJson(JsonFactory.newObject(jsonString), dittoHeaders); }
/** * Creates a new {@code SudoRetrieveThings}. * * @param thingIds one or more Thing IDs to be retrieved. * @param dittoHeaders the command headers of the request. * @return a command for retrieving Things without authorization. * @throws NullPointerException if any argument is {@code null}. */ public static SudoRetrieveThings of(final List<String> thingIds, final DittoHeaders dittoHeaders) { return of(thingIds, null, dittoHeaders); }
/** * Creates a new {@code SudoRetrieveThings}. * * @param thingIds one or more Thing IDs to be retrieved. * @param selectedFields the Fields which should be included in the Thing's JSON representation. * @param dittoHeaders the command headers of the request. * @return a command for retrieving Things without authorization. * @throws NullPointerException if any argument but {@code selectedFields} is {@code null}. */ public static SudoRetrieveThings of(final List<String> thingIds, @Nullable final JsonFieldSelector selectedFields, final DittoHeaders dittoHeaders) { return new SudoRetrieveThings(thingIds, selectedFields, dittoHeaders); }
@Override public SudoRetrieveThings setDittoHeaders(final DittoHeaders dittoHeaders) { return of(thingIds, selectedFields, dittoHeaders); }
@Override public SudoRetrieveThings setDittoHeaders(final DittoHeaders dittoHeaders) { return of(thingIds, selectedFields, dittoHeaders); }
/** * Creates a new {@code SudoRetrieveThings} from a JSON object. * * @param jsonObject the JSON string of which a new SudoRetrieveThings is to be created. * @param dittoHeaders the optional command headers of the request. * @return the SudoRetrieveThings which was created from the given JSON object. * @throws NullPointerException if {@code jsonObject} is {@code null}. * @throws org.eclipse.ditto.json.JsonMissingFieldException if the passed in {@code jsonObject} was not in the * expected format. */ public static SudoRetrieveThings fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { final List<String> extractedThingIds = jsonObject.getValueOrThrow(JSON_THING_IDS) .stream() .filter(JsonValue::isString) .map(JsonValue::asString) .collect(Collectors.toList()); final JsonFieldSelector extractedFieldSelector = jsonObject.getValue(SudoCommand.JsonFields.SELECTED_FIELDS) .map(str -> JsonFactory.newFieldSelector(str, JsonFactory.newParseOptionsBuilder() .withoutUrlDecoding() .build())) .orElse(null); return SudoRetrieveThings.of(extractedThingIds, extractedFieldSelector, dittoHeaders); }
/** * Creates a new {@code SudoRetrieveThings} from a JSON object. * * @param jsonObject the JSON string of which a new SudoRetrieveThings is to be created. * @param dittoHeaders the optional command headers of the request. * @return the SudoRetrieveThings which was created from the given JSON object. * @throws NullPointerException if {@code jsonObject} is {@code null}. * @throws org.eclipse.ditto.json.JsonMissingFieldException if the passed in {@code jsonObject} was not in the * expected format. */ public static SudoRetrieveThings fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { final List<String> extractedThingIds = jsonObject.getValueOrThrow(JSON_THING_IDS) .stream() .filter(JsonValue::isString) .map(JsonValue::asString) .collect(Collectors.toList()); final JsonFieldSelector extractedFieldSelector = jsonObject.getValue(SudoCommand.JsonFields.SELECTED_FIELDS) .map(str -> JsonFactory.newFieldSelector(str, JsonFactory.newParseOptionsBuilder() .withoutUrlDecoding() .build())) .orElse(null); return SudoRetrieveThings.of(extractedThingIds, extractedFieldSelector, dittoHeaders); }