Skip to content

Commit

Permalink
#1893 re-add deleted method
Browse files Browse the repository at this point in the history
  • Loading branch information
thjaeckle committed Feb 22, 2024
1 parent f72c079 commit 1cd5c8f
Showing 1 changed file with 33 additions and 0 deletions.
Expand Up @@ -14,12 +14,14 @@

import static org.eclipse.ditto.base.model.common.ConditionChecker.checkNotNull;

import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.Executor;
import java.util.stream.Collectors;

import javax.annotation.Nullable;

Expand Down Expand Up @@ -153,6 +155,37 @@ public CompletionStage<JsonObject> retrievePartialThing(final ThingId thingId,
.thenApply(jsonObject -> applyJsonFieldSelector(jsonObject, jsonFieldSelector));
}

/**
* Retrieve parts of a thing.
*
* @param thingId ID of the thing.
* @param jsonFieldSelector the selected fields of the thing.
* @param dittoHeaders Ditto headers containing authorization information.
* @param concernedSignals the Signals which caused that this partial thing retrieval was triggered
* (e.g. a {@code ThingEvent})
* @param minAcceptableSeqNr minimum sequence number of the concerned signals to not invalidate the cache.
* @return future that completes with the parts of a thing or fails with an error.
*/
@SuppressWarnings({"java:S1612", "unused"})
public CompletionStage<JsonObject> retrievePartialThing(final EntityId thingId,
final JsonFieldSelector jsonFieldSelector,
final DittoHeaders dittoHeaders,
final Collection<? extends Signal<?>> concernedSignals,
final long minAcceptableSeqNr) {

final List<ThingEvent<?>> thingEvents = concernedSignals.stream()
.filter(signal -> signal instanceof ThingEvent && !Signal.isChannelLive(signal))
.map(signal -> (ThingEvent<?>) signal)
.collect(Collectors.toList());

// as second step only return what was originally requested as fields:
final var cachingParameters =
new CachingParameters(jsonFieldSelector, thingEvents, true, minAcceptableSeqNr);

return doRetrievePartialThing(thingId, dittoHeaders, null, cachingParameters)
.thenApply(jsonObject -> applyJsonFieldSelector(jsonObject, jsonFieldSelector));
}

protected CompletionStage<JsonObject> doRetrievePartialThing(final EntityId thingId,
final DittoHeaders dittoHeaders,
@Nullable final DittoHeaders dittoHeadersNotAddedToCacheKey,
Expand Down

0 comments on commit 1cd5c8f

Please sign in to comment.