diff --git a/gateway/service/src/main/java/org/eclipse/ditto/gateway/service/proxy/actors/QueryThingsPerRequestActor.java b/gateway/service/src/main/java/org/eclipse/ditto/gateway/service/proxy/actors/QueryThingsPerRequestActor.java index 6e6fb3866d..ee7f3a1b89 100644 --- a/gateway/service/src/main/java/org/eclipse/ditto/gateway/service/proxy/actors/QueryThingsPerRequestActor.java +++ b/gateway/service/src/main/java/org/eclipse/ditto/gateway/service/proxy/actors/QueryThingsPerRequestActor.java @@ -123,7 +123,7 @@ public Receive createReceive() { // shortcuts: we don't have to look up the things // - for no search results // - if only the "thingId" was selected in the QueryThings commands - originatingSender.tell(stripLastModifiedTimestampFromSearchResult(qtr), getSelf()); + originatingSender.tell(qtr, getSelf()); stopMyself(); } else { final Optional selectedFieldsWithThingId = getSelectedFieldsWithThingId(); @@ -166,15 +166,6 @@ public Receive createReceive() { .build(); } - private static QueryThingsResponse stripLastModifiedTimestampFromSearchResult( - final QueryThingsResponse queryThingsResponse) { - - return queryThingsResponse.setEntity(queryThingsResponse.getSearchResult().toBuilder() - .lastModified(null) - .build() - .toJson()); - } - private boolean queryThingsOnlyContainsThingIdSelector() { final Optional fields = queryThings.getFields(); return fields.isPresent() && fields.get().getPointers() diff --git a/thingsearch/model/src/main/java/org/eclipse/ditto/thingsearch/model/ImmutableSearchResult.java b/thingsearch/model/src/main/java/org/eclipse/ditto/thingsearch/model/ImmutableSearchResult.java index 7133f3e5bc..f24083b46a 100755 --- a/thingsearch/model/src/main/java/org/eclipse/ditto/thingsearch/model/ImmutableSearchResult.java +++ b/thingsearch/model/src/main/java/org/eclipse/ditto/thingsearch/model/ImmutableSearchResult.java @@ -14,7 +14,6 @@ import static org.eclipse.ditto.base.model.common.ConditionChecker.checkNotNull; -import java.time.Instant; import java.util.Iterator; import java.util.Objects; import java.util.Optional; @@ -41,14 +40,12 @@ final class ImmutableSearchResult implements SearchResult { private final JsonArray items; @Nullable private final Long nextPageOffset; @Nullable private final String cursor; - @Nullable private final Instant lastModified; private ImmutableSearchResult(final JsonArray items, @Nullable final Long nextPageOffset, - @Nullable final String cursor, @Nullable final Instant lastModified) { + @Nullable final String cursor) { this.items = checkNotNull(items, "items"); this.nextPageOffset = nextPageOffset; this.cursor = cursor; - this.lastModified = lastModified; } /** @@ -57,7 +54,7 @@ private ImmutableSearchResult(final JsonArray items, @Nullable final Long nextPa * @return instance. */ public static SearchResult empty() { - return of(JsonFactory.newArray(), NO_NEXT_PAGE, null, null); + return of(JsonFactory.newArray(), NO_NEXT_PAGE, null); } /** @@ -71,10 +68,9 @@ public static SearchResult empty() { */ public static ImmutableSearchResult of(final JsonArray items, @Nullable final Long nextPageOffset, - @Nullable final String cursor, - @Nullable final Instant lastModified) { + @Nullable final String cursor) { - return new ImmutableSearchResult(items, nextPageOffset, cursor, lastModified); + return new ImmutableSearchResult(items, nextPageOffset, cursor); } /** @@ -90,9 +86,8 @@ public static ImmutableSearchResult fromJson(final JsonObject jsonObject) { final JsonArray extractedItems = jsonObject.getValueOrThrow(JsonFields.ITEMS); final Long extractedNextPageOffset = jsonObject.getValue(JsonFields.NEXT_PAGE_OFFSET).orElse(null); final String extractedCursor = jsonObject.getValue(JsonFields.CURSOR).orElse(null); - final Instant lastModified = jsonObject.getValue(JsonFields.LAST_MODIFIED).map(Instant::parse).orElse(null); - return of(extractedItems, extractedNextPageOffset, extractedCursor, lastModified); + return of(extractedItems, extractedNextPageOffset, extractedCursor); } @Override @@ -110,11 +105,6 @@ public Optional getCursor() { return Optional.ofNullable(cursor); } - @Override - public Optional getLastModified() { - return Optional.ofNullable(lastModified); - } - @Override public boolean hasNextPage() { return cursor != null || nextPageOffset != null && nextPageOffset != NO_NEXT_PAGE; @@ -148,8 +138,6 @@ public JsonObject toJson(final JsonSchemaVersion schemaVersion, final Predicate< builder.set(JsonFields.ITEMS, items, predicate); getNextPageOffset().ifPresent(offset -> builder.set(JsonFields.NEXT_PAGE_OFFSET, offset, predicate)); getCursor().ifPresent(cur -> builder.set(JsonFields.CURSOR, cur, predicate)); - getLastModified().ifPresent(lastModified -> - builder.set(JsonFields.LAST_MODIFIED, lastModified.toString(), predicate)); return builder.build(); } @@ -164,13 +152,12 @@ public boolean equals(final Object o) { final ImmutableSearchResult that = (ImmutableSearchResult) o; return Objects.equals(nextPageOffset, that.nextPageOffset) && Objects.equals(cursor, that.cursor) && - Objects.equals(items, that.items) && - Objects.equals(lastModified, that.lastModified); + Objects.equals(items, that.items); } @Override public int hashCode() { - return Objects.hash(items, nextPageOffset, cursor, lastModified); + return Objects.hash(items, nextPageOffset, cursor); } @Override @@ -178,7 +165,6 @@ public String toString() { return getClass().getSimpleName() + " [items=" + items + ", nextPageOffset=" + nextPageOffset + ", cursor=" + cursor + - ", lastModified=" + lastModified + "]"; } diff --git a/thingsearch/model/src/main/java/org/eclipse/ditto/thingsearch/model/ImmutableSearchResultBuilder.java b/thingsearch/model/src/main/java/org/eclipse/ditto/thingsearch/model/ImmutableSearchResultBuilder.java index 7c4c12a411..dfd348432f 100755 --- a/thingsearch/model/src/main/java/org/eclipse/ditto/thingsearch/model/ImmutableSearchResultBuilder.java +++ b/thingsearch/model/src/main/java/org/eclipse/ditto/thingsearch/model/ImmutableSearchResultBuilder.java @@ -14,8 +14,6 @@ import static org.eclipse.ditto.base.model.common.ConditionChecker.checkNotNull; -import java.time.Instant; - import javax.annotation.Nullable; import javax.annotation.concurrent.NotThreadSafe; @@ -33,7 +31,6 @@ final class ImmutableSearchResultBuilder implements SearchResultBuilder { private final JsonArrayBuilder jsonArrayBuilder; @Nullable private Long offset; @Nullable private String cursor; - @Nullable private Instant lastModified; private ImmutableSearchResultBuilder(final JsonArrayBuilder theJsonArrayBuilder) { jsonArrayBuilder = theJsonArrayBuilder; @@ -63,11 +60,9 @@ public static SearchResultBuilder of(final SearchResult searchResult) { final JsonArrayBuilder jsonArrayBuilder = JsonFactory.newArrayBuilder(searchResult.getItems()); final Long nextPageOffset = searchResult.getNextPageOffset().orElse(null); final String cursor = searchResult.getCursor().orElse(null); - final Instant lastModified = searchResult.getLastModified().orElse(null); return new ImmutableSearchResultBuilder(jsonArrayBuilder).nextPageOffset(nextPageOffset) - .cursor(cursor) - .lastModified(lastModified); + .cursor(cursor); } @Override @@ -82,12 +77,6 @@ public SearchResultBuilder cursor(@Nullable final String cursor) { return this; } - @Override - public SearchResultBuilder lastModified(@Nullable final Instant lastModified) { - this.lastModified = lastModified; - return this; - } - @Override public SearchResultBuilder add(final JsonValue value, final JsonValue... furtherValues) { jsonArrayBuilder.add(value, furtherValues); @@ -109,7 +98,7 @@ public SearchResultBuilder remove(final JsonValue value) { @Override public SearchResult build() { final JsonArray searchResultsJsonArray = jsonArrayBuilder.build(); - return ImmutableSearchResult.of(searchResultsJsonArray, offset, cursor, lastModified); + return ImmutableSearchResult.of(searchResultsJsonArray, offset, cursor); } } diff --git a/thingsearch/model/src/main/java/org/eclipse/ditto/thingsearch/model/SearchModelFactory.java b/thingsearch/model/src/main/java/org/eclipse/ditto/thingsearch/model/SearchModelFactory.java index 54d8aa279f..6fbe202267 100755 --- a/thingsearch/model/src/main/java/org/eclipse/ditto/thingsearch/model/SearchModelFactory.java +++ b/thingsearch/model/src/main/java/org/eclipse/ditto/thingsearch/model/SearchModelFactory.java @@ -16,11 +16,9 @@ import static org.eclipse.ditto.base.model.common.ConditionChecker.checkNotNull; import static org.eclipse.ditto.base.model.exceptions.DittoJsonException.wrapJsonRuntimeException; -import java.time.Instant; import java.util.Collections; import java.util.List; -import javax.annotation.Nullable; import javax.annotation.concurrent.Immutable; import org.eclipse.ditto.json.JsonArray; @@ -54,22 +52,7 @@ private SearchModelFactory() { * @throws NullPointerException if {@code items} is {@code null}. */ public static SearchResult newSearchResult(final JsonArray items, final long nextPageOffset) { - return ImmutableSearchResult.of(items, nextPageOffset, null, null); - } - - /** - * Creates a new {@link SearchResult}. - * - * @param items the items. - * @param nextPageOffset the offset of the next page or {@link org.eclipse.ditto.thingsearch.model.SearchResult#NO_NEXT_PAGE}. - * @param lastModified the last modified timestamp. - * @return the new immutable search results object. - * @throws NullPointerException if {@code items} is {@code null}. - * @since 2.5.0 - */ - public static SearchResult newSearchResult(final JsonArray items, final long nextPageOffset, - @Nullable final Instant lastModified) { - return ImmutableSearchResult.of(items, nextPageOffset, null, lastModified); + return ImmutableSearchResult.of(items, nextPageOffset, null); } /** diff --git a/thingsearch/model/src/main/java/org/eclipse/ditto/thingsearch/model/SearchResult.java b/thingsearch/model/src/main/java/org/eclipse/ditto/thingsearch/model/SearchResult.java index 5d29dd363b..4371dc156b 100755 --- a/thingsearch/model/src/main/java/org/eclipse/ditto/thingsearch/model/SearchResult.java +++ b/thingsearch/model/src/main/java/org/eclipse/ditto/thingsearch/model/SearchResult.java @@ -12,7 +12,6 @@ */ package org.eclipse.ditto.thingsearch.model; -import java.time.Instant; import java.util.Optional; import java.util.stream.Stream; @@ -82,14 +81,6 @@ default SearchResultBuilder toBuilder() { */ Optional getCursor(); - /** - * Get the timestamp of the last modification of the search result. - * - * @return the timestamp. - * @since 2.5.0 - */ - Optional getLastModified(); - /** * Returns {@code true} if there is a next page and thus {@link #getNextPageOffset()} does not equal * {@link #NO_NEXT_PAGE}, otherwise {@code false}. @@ -171,9 +162,6 @@ final class JsonFields { public static final JsonFieldDefinition CURSOR = JsonFactory.newStringFieldDefinition("cursor", FieldType.REGULAR, JsonSchemaVersion.V_2); - public static final JsonFieldDefinition LAST_MODIFIED = - JsonFactory.newStringFieldDefinition("lastModified", FieldType.SPECIAL, JsonSchemaVersion.V_2); - private JsonFields() { throw new AssertionError(); } diff --git a/thingsearch/model/src/main/java/org/eclipse/ditto/thingsearch/model/SearchResultBuilder.java b/thingsearch/model/src/main/java/org/eclipse/ditto/thingsearch/model/SearchResultBuilder.java index 4116fb93f0..94f4a97c0f 100755 --- a/thingsearch/model/src/main/java/org/eclipse/ditto/thingsearch/model/SearchResultBuilder.java +++ b/thingsearch/model/src/main/java/org/eclipse/ditto/thingsearch/model/SearchResultBuilder.java @@ -12,8 +12,6 @@ */ package org.eclipse.ditto.thingsearch.model; -import java.time.Instant; - import javax.annotation.Nullable; import javax.annotation.concurrent.NotThreadSafe; @@ -43,15 +41,6 @@ public interface SearchResultBuilder { */ SearchResultBuilder cursor(@Nullable String cursor); - /** - * Set the timestamp of the last modification of the search result. - * - * @param lastModified the timestamp. - * @return this builder. - * @since 2.5.0 - */ - SearchResultBuilder lastModified(@Nullable Instant lastModified); - /** * Adds at least one {@link JsonValue} to the {@code SearchResult} to be built. * diff --git a/thingsearch/model/src/test/java/org/eclipse/ditto/thingsearch/model/ImmutableSearchResultBuilderTest.java b/thingsearch/model/src/test/java/org/eclipse/ditto/thingsearch/model/ImmutableSearchResultBuilderTest.java index 122e6e0112..4bc43c7991 100755 --- a/thingsearch/model/src/test/java/org/eclipse/ditto/thingsearch/model/ImmutableSearchResultBuilderTest.java +++ b/thingsearch/model/src/test/java/org/eclipse/ditto/thingsearch/model/ImmutableSearchResultBuilderTest.java @@ -14,8 +14,6 @@ import static org.eclipse.ditto.thingsearch.model.assertions.DittoSearchAssertions.assertThat; -import java.time.Instant; - import org.eclipse.ditto.json.JsonArray; import org.eclipse.ditto.json.JsonFactory; import org.junit.Before; @@ -42,7 +40,7 @@ public void tryToCreateNewInstanceWithNullSearchResult() { public void copySearchResultWithBuilder() { final JsonArray items = JsonFactory.newArrayBuilder().add("foo", "bar", "baz").build(); final long offset = 25; - final SearchResult searchResult = SearchModelFactory.newSearchResult(items, offset, null); + final SearchResult searchResult = SearchModelFactory.newSearchResult(items, offset); final SearchResultBuilder underTest = ImmutableSearchResultBuilder.of(searchResult); @@ -53,7 +51,7 @@ public void copySearchResultWithBuilder() { public void copyAndModifyExistingSearchResultWithBuilder() { final JsonArray items = JsonFactory.newArrayBuilder().add("foo", "bar", "baz").build(); final long offset = 25; - final SearchResult searchResult = SearchModelFactory.newSearchResult(items, offset, null); + final SearchResult searchResult = SearchModelFactory.newSearchResult(items, offset); final SearchResult newSearchResult = ImmutableSearchResultBuilder.of(searchResult) .nextPageOffset(SearchResult.NO_NEXT_PAGE) @@ -114,14 +112,6 @@ public void setNextPageOffset() { .isEmpty(); } - @Test - public void setLastModified() { - final Instant expectedLastModified = Instant.now(); - final SearchResult searchResult = underTest.lastModified(expectedLastModified).build(); - - assertThat(searchResult.getLastModified()).contains(expectedLastModified); - } - @Test(expected = NullPointerException.class) public void tryToAddAllNull() { ImmutableSearchResultBuilder.newInstance() diff --git a/thingsearch/model/src/test/java/org/eclipse/ditto/thingsearch/model/ImmutableSearchResultTest.java b/thingsearch/model/src/test/java/org/eclipse/ditto/thingsearch/model/ImmutableSearchResultTest.java index 993649d83f..61293f5839 100755 --- a/thingsearch/model/src/test/java/org/eclipse/ditto/thingsearch/model/ImmutableSearchResultTest.java +++ b/thingsearch/model/src/test/java/org/eclipse/ditto/thingsearch/model/ImmutableSearchResultTest.java @@ -17,8 +17,6 @@ import static org.mutabilitydetector.unittesting.MutabilityAssert.assertInstancesOf; import static org.mutabilitydetector.unittesting.MutabilityMatchers.areImmutable; -import java.time.Instant; - import org.eclipse.ditto.base.model.json.FieldType; import org.eclipse.ditto.base.model.json.Jsonifiable; import org.eclipse.ditto.json.JsonArray; @@ -53,7 +51,7 @@ public void constructorAndGetters() { final JsonArray items = JsonFactory.newArray("[1,2,3]"); final long nextPageOffset = 10L; - final SearchResult searchResult = ImmutableSearchResult.of(items, nextPageOffset, null, null); + final SearchResult searchResult = ImmutableSearchResult.of(items, nextPageOffset, null); assertThat(searchResult.getItems()).isEqualTo(items); assertThat(searchResult.getNextPageOffset()).contains(nextPageOffset); @@ -77,14 +75,12 @@ public void toJsonReturnsExpected() { .add(1, 2, 3) .build(); final long nextPageOffset = 10L; - final Instant now = Instant.now(); final JsonObject expected = JsonFactory.newObjectBuilder() .set(SearchResult.JsonFields.ITEMS, items) .set(SearchResult.JsonFields.NEXT_PAGE_OFFSET, nextPageOffset) - .set(SearchResult.JsonFields.LAST_MODIFIED, now.toString()) .build(); - final Jsonifiable underTest = ImmutableSearchResult.of(items, nextPageOffset, null, now); + final Jsonifiable underTest = ImmutableSearchResult.of(items, nextPageOffset, null); assertThat(underTest.toJson()).isEqualTo(expected); } @@ -94,7 +90,7 @@ public void toJsonWithAllFieldTypes() { final String itemsArray = "[1,2,3]"; final JsonArray items = JsonFactory.newArray(itemsArray); final long nextPageOffset = 10L; - final ImmutableSearchResult searchResult = ImmutableSearchResult.of(items, nextPageOffset, null, null); + final ImmutableSearchResult searchResult = ImmutableSearchResult.of(items, nextPageOffset, null); final String jsonStr = searchResult.toJsonString(FieldType.regularOrSpecial()); @@ -106,7 +102,7 @@ public void toJsonWithRegularFieldTypes() { final String itemsArray = "[1,2,3]"; final JsonArray items = JsonFactory.newArray(itemsArray); final long nextPageOffset = 10L; - final ImmutableSearchResult searchResult = ImmutableSearchResult.of(items, nextPageOffset, null, null); + final ImmutableSearchResult searchResult = ImmutableSearchResult.of(items, nextPageOffset, null); final String jsonStr = searchResult.toJsonString(); @@ -150,7 +146,7 @@ public void ensureSearchResultNewBuilderWorks() { final String itemsArray = "[1,2,3]"; final JsonArray items = JsonFactory.newArray(itemsArray); final long nextPageOffset = 10L; - final ImmutableSearchResult searchResult = ImmutableSearchResult.of(items, nextPageOffset, null, null); + final ImmutableSearchResult searchResult = ImmutableSearchResult.of(items, nextPageOffset, null); final SearchResultBuilder searchResultBuilder = SearchResult.newBuilder() .addAll(items) @@ -164,7 +160,7 @@ public void ensureRelationsToBuilderWorks() { final String itemsArray = "[1,2,3]"; final JsonArray items = JsonFactory.newArray(itemsArray); final long nextPageOffset = 10L; - final ImmutableSearchResult searchResult = ImmutableSearchResult.of(items, nextPageOffset, null, null); + final ImmutableSearchResult searchResult = ImmutableSearchResult.of(items, nextPageOffset, null); DittoJsonAssertions.assertThat(searchResult).isEqualTo(searchResult.toBuilder().build()); } diff --git a/thingsearch/model/src/test/java/org/eclipse/ditto/thingsearch/model/SearchModelFactoryTest.java b/thingsearch/model/src/test/java/org/eclipse/ditto/thingsearch/model/SearchModelFactoryTest.java index 06bd1592a5..9233fdb471 100755 --- a/thingsearch/model/src/test/java/org/eclipse/ditto/thingsearch/model/SearchModelFactoryTest.java +++ b/thingsearch/model/src/test/java/org/eclipse/ditto/thingsearch/model/SearchModelFactoryTest.java @@ -52,7 +52,7 @@ public void assertImmutability() { @Test public void newSearchResult() { final SearchResult searchResult = - SearchModelFactory.newSearchResult(JsonFactory.newArray(), SearchResult.NO_NEXT_PAGE, null); + SearchModelFactory.newSearchResult(JsonFactory.newArray(), SearchResult.NO_NEXT_PAGE); assertThat(searchResult) // .hasNoNextPage() // diff --git a/thingsearch/service/src/main/java/org/eclipse/ditto/thingsearch/service/starter/actors/SearchActor.java b/thingsearch/service/src/main/java/org/eclipse/ditto/thingsearch/service/starter/actors/SearchActor.java index c416fbd395..1cfd27cd51 100644 --- a/thingsearch/service/src/main/java/org/eclipse/ditto/thingsearch/service/starter/actors/SearchActor.java +++ b/thingsearch/service/src/main/java/org/eclipse/ditto/thingsearch/service/starter/actors/SearchActor.java @@ -12,8 +12,6 @@ */ package org.eclipse.ditto.thingsearch.service.starter.actors; -import java.time.Instant; -import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -414,9 +412,8 @@ private QueryThingsResponse toQueryThingsResponse(final QueryThings queryThings, } else { // only respond with the determined "thingIds", the lookup of the things is done in gateway: final JsonArray items = getItems(thingIds); - final Instant lastModified = getLastModified(thingIds); final var searchResults = - SearchModelFactory.newSearchResult(items, thingIds.nextPageOffset(), lastModified); + SearchModelFactory.newSearchResult(items, thingIds.nextPageOffset()); final var processedResults = ThingsSearchCursor.processSearchResult(queryThings, cursor, searchResults, thingIds); @@ -424,14 +421,6 @@ private QueryThingsResponse toQueryThingsResponse(final QueryThings queryThings, } } - private static Instant getLastModified(final ResultList thingIds) { - final var now = Instant.now(); - return thingIds.stream() - .map(timestampedThingId -> timestampedThingId.lastModified().orElse(now)) - .max(Comparator.naturalOrder()) - .orElse(now); - } - private static JsonArray getItems(final ResultList thingIds) { return thingIds.stream() .map(TimestampedThingId::thingId)