Skip to content

Commit

Permalink
MCPODS-6583 fixed empty collection serialization, changed handling of…
Browse files Browse the repository at this point in the history
… empty cursor when saving feature
  • Loading branch information
Amaneusz committed Nov 16, 2023
1 parent aae5fed commit 30c1d1e
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package com.here.naksha.app.service.http.tasks;

import static com.here.naksha.lib.core.util.storage.ResultHelper.readFeaturesFromResult;
import static java.util.Collections.emptyList;

import com.here.naksha.app.service.http.HttpResponseType;
import com.here.naksha.app.service.http.NakshaHttpVerticle;
Expand Down Expand Up @@ -90,7 +91,9 @@ protected AbstractApiTask(
wrResult,
type,
() -> verticle.sendErrorResponse(
routingContext, XyzError.NOT_FOUND, "The desired feature does not exist."));
routingContext,
XyzError.EXCEPTION,
"Unexpected error while saving feature, the result cursor is empty / does not exist"));
}

private <R extends XyzFeature> @NotNull XyzResponse transformResultToXyzFeatureResponse(
Expand Down Expand Up @@ -136,7 +139,7 @@ protected AbstractApiTask(
} catch (NoCursor | NoSuchElementException emptyException) {
logger.info("No data found in ResultCursor, returning empty collection");
return verticle.sendXyzResponse(
routingContext, HttpResponseType.FEATURE_COLLECTION, new XyzFeatureCollection());
routingContext, HttpResponseType.FEATURE_COLLECTION, emptyFeatureCollection());
}
}
}
Expand Down Expand Up @@ -176,4 +179,8 @@ protected Result executeWriteRequestFromSpaceStorage(WriteFeatures<?> writeReque
return writer.execute(writeRequest);
}
}

private XyzFeatureCollection emptyFeatureCollection() {
return new XyzFeatureCollection().withFeatures(emptyList());
}
}

0 comments on commit 30c1d1e

Please sign in to comment.