Skip to content

Instantly share code, notes, and snippets.

@gszeliga
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gszeliga/0c492f19a936e444f7a4 to your computer and use it in GitHub Desktop.
Save gszeliga/0c492f19a936e444f7a4 to your computer and use it in GitHub Desktop.
//Acceptance validation on the range of data being requested
acceptableInterval(from, to, DeviceParameters.from(paramId).getResolution())
.fold(
failure -> asyncResponse
.resume(status(422)
.entity(asErrorReply(failure))
.build())
,
accepted -> runAsync(() -> {
final OptionalLong deployment = activeDeploymentFrom(request);
if (deployment.isPresent()) {
log.info("Active deployment found within request: {}", deployment.getAsLong());
FetchCriteria criteria = ... //Some fetching criteria is created
readings
.fetch(criteria)
.thenApplyAsync(outcome -> replyWith(outcome.mapR(asApiReadings), asyncResponse), executor)
.exceptionally(asyncResponse::resume);
} else {
log.warn("No active deployment nor subject was found within request");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment