@Override protected Result doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final RetrieveFeatureProperty command) { final String featureId = command.getFeatureId(); return extractFeature(command, thing) .map(feature -> getRetrieveFeaturePropertyResult(feature, context, command, thing)) .orElseGet(() -> ResultFactory.newErrorResult(ExceptionFactory.featureNotFound(context.getThingId(), featureId, command.getDittoHeaders()))); }
@Override protected Result doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final RetrieveFeatureProperty command) { final String featureId = command.getFeatureId(); return extractFeature(command, thing) .map(feature -> getRetrieveFeaturePropertyResult(feature, context, command, thing)) .orElseGet(() -> ResultFactory.newErrorResult(ExceptionFactory.featureNotFound(context.getThingId(), featureId, command.getDittoHeaders()))); }
private Result getRetrieveFeaturePropertyResult(final Feature feature, final Context context, final RetrieveFeatureProperty command, @Nullable final Thing thing) { return feature.getProperties() .map(featureProperties -> getRetrieveFeaturePropertyResult(featureProperties, context, command, thing)) .orElseGet(() -> ResultFactory.newErrorResult( ExceptionFactory.featurePropertiesNotFound(context.getThingId(), feature.getId(), command.getDittoHeaders()))); }
private Result getRetrieveFeaturePropertyResult(final Feature feature, final Context context, final RetrieveFeatureProperty command, @Nullable final Thing thing) { return feature.getProperties() .map(featureProperties -> getRetrieveFeaturePropertyResult(featureProperties, context, command, thing)) .orElseGet(() -> ResultFactory.newErrorResult( ExceptionFactory.featurePropertiesNotFound(context.getThingId(), feature.getId(), command.getDittoHeaders()))); }
private Result getRetrieveFeaturePropertyResult(final JsonObject featureProperties, final Context context, final RetrieveFeatureProperty command, @Nullable final Thing thing) { final String featureId = command.getFeatureId(); final JsonPointer propertyPointer = command.getPropertyPointer(); final DittoHeaders dittoHeaders = command.getDittoHeaders(); return featureProperties.getValue(propertyPointer) .map(featureProperty -> RetrieveFeaturePropertyResponse.of(context.getThingId(), featureId, propertyPointer, featureProperty, dittoHeaders)) .map(response -> ResultFactory.newQueryResult(command, thing, response, this)) .orElseGet(() -> ResultFactory.newErrorResult( ExceptionFactory.featurePropertyNotFound(context.getThingId(), featureId, propertyPointer, dittoHeaders))); }
private Result getRetrieveFeaturePropertyResult(final JsonObject featureProperties, final Context context, final RetrieveFeatureProperty command, @Nullable final Thing thing) { final String featureId = command.getFeatureId(); final JsonPointer propertyPointer = command.getPropertyPointer(); final DittoHeaders dittoHeaders = command.getDittoHeaders(); return featureProperties.getValue(propertyPointer) .map(featureProperty -> RetrieveFeaturePropertyResponse.of(context.getThingId(), featureId, propertyPointer, featureProperty, dittoHeaders)) .map(response -> ResultFactory.newQueryResult(command, thing, response, this)) .orElseGet(() -> ResultFactory.newErrorResult( ExceptionFactory.featurePropertyNotFound(context.getThingId(), featureId, propertyPointer, dittoHeaders))); }