private boolean shouldForbidNorCriteria() { // should forbid NorCriteria only for API >= 2 return dittoHeaders.getSchemaVersion() .map(JsonSchemaVersion::toInt) .filter(v -> v >= JsonSchemaVersion.V_2.toInt()) .isPresent(); }
private boolean shouldForbidNorCriteria() { // should forbid NorCriteria only for API >= 2 return dittoHeaders.getSchemaVersion() .map(JsonSchemaVersion::toInt) .filter(v -> v >= JsonSchemaVersion.V_2.toInt()) .isPresent(); }
@Override public JsonSchemaVersion getImplementedSchemaVersion() { return dittoHeaders.getSchemaVersion().orElse(getLatestSchemaVersion()); }
private int getForbiddenSchemaVersion() { final JsonSchemaVersion defaultForbiddenVersion = JsonSchemaVersion.V_2; return dittoHeaders.getSchemaVersion().orElse(defaultForbiddenVersion).toInt(); }
private static JsonObject getJsonFields(@Nullable final JsonFieldSelector fieldSelector, @Nullable final Predicate<JsonField> predicate, final DittoHeaders dittoHeaders, final Thing thing) { if (fieldSelector != null) { return predicate != null ? thing.toJson(dittoHeaders.getSchemaVersion().orElse(JsonSchemaVersion.LATEST), fieldSelector, predicate) : thing.toJson(dittoHeaders.getSchemaVersion().orElse(JsonSchemaVersion.LATEST), fieldSelector); } else { return predicate != null ? thing.toJson(dittoHeaders.getSchemaVersion().orElse(JsonSchemaVersion.LATEST), predicate) : thing.toJson(dittoHeaders.getSchemaVersion().orElse(JsonSchemaVersion.LATEST)); } }
@Override public JsonSchemaVersion getImplementedSchemaVersion() { return dittoHeaders.getSchemaVersion().orElse(getLatestSchemaVersion()); }
private static JsonObject getJsonFields(@Nullable final JsonFieldSelector fieldSelector, @Nullable final Predicate<JsonField> predicate, final DittoHeaders dittoHeaders, final Thing thing) { if (fieldSelector != null) { return predicate != null ? thing.toJson(dittoHeaders.getSchemaVersion().orElse(JsonSchemaVersion.LATEST), fieldSelector, predicate) : thing.toJson(dittoHeaders.getSchemaVersion().orElse(JsonSchemaVersion.LATEST), fieldSelector); } else { return predicate != null ? thing.toJson(dittoHeaders.getSchemaVersion().orElse(JsonSchemaVersion.LATEST), predicate) : thing.toJson(dittoHeaders.getSchemaVersion().orElse(JsonSchemaVersion.LATEST)); } }
private int getForbiddenSchemaVersion() { final JsonSchemaVersion defaultForbiddenVersion = JsonSchemaVersion.V_2; return dittoHeaders.getSchemaVersion().orElse(defaultForbiddenVersion).toInt(); }
@Override default JsonSchemaVersion getImplementedSchemaVersion() { return getDittoHeaders().getSchemaVersion().orElse(getLatestSchemaVersion()); }
@Override default JsonSchemaVersion getImplementedSchemaVersion() { return getDittoHeaders().getSchemaVersion().orElse(getLatestSchemaVersion()); }
@Override default JsonSchemaVersion getImplementedSchemaVersion() { return getDittoHeaders().getSchemaVersion().orElse(getLatestSchemaVersion()); }
@Override default JsonSchemaVersion getImplementedSchemaVersion() { return getDittoHeaders().getSchemaVersion().orElse(getLatestSchemaVersion()); }
@Override default JsonSchemaVersion getImplementedSchemaVersion() { return getDittoHeaders().getSchemaVersion().orElse(getLatestSchemaVersion()); }
private static boolean shouldCreatePolicyForCreateThing(final CreateThing createThing) { final JsonSchemaVersion commandVersion = createThing.getDittoHeaders().getSchemaVersion().orElse(JsonSchemaVersion.LATEST); return createThing.getInitialPolicy().isPresent() || (JsonSchemaVersion.V_1 != commandVersion && !createThing.getThing().getPolicyId().isPresent()); }
/** * Constructs a new {@code PolicyIdMissingException} object with an exception message for a thing-update scenario. * * @param thingId the ID of the Thing. * @param dittoHeaders the headers of the command which resulted in this exception. * @return the new PolicyIdMissingException. */ public static PolicyIdMissingException fromThingIdOnUpdate(final String thingId, final DittoHeaders dittoHeaders) { final JsonSchemaVersion schemaVersion = dittoHeaders.getSchemaVersion().orElse(JsonSchemaVersion.LATEST); return new Builder(thingId, schemaVersion, MESSAGE_TEMPLATE_UPDATE, DEFAULT_DESCRIPTION_UPDATE) .dittoHeaders(dittoHeaders) .build(); }
/** * Constructs a new {@code PolicyIdMissingException} object with an exception message for a thing-create scenario. * * @param thingId the ID of the Thing. * @param dittoHeaders the headers of the command which resulted in this exception. * @return the new PolicyIdMissingException. */ public static PolicyIdMissingException fromThingIdOnCreate(final String thingId, final DittoHeaders dittoHeaders) { final JsonSchemaVersion schemaVersion = dittoHeaders.getSchemaVersion().orElse(JsonSchemaVersion.LATEST); return new Builder(thingId, schemaVersion, MESSAGE_TEMPLATE_CREATE, DEFAULT_DESCRIPTION_CREATE) .dittoHeaders(dittoHeaders) .build(); }
/** * Constructs a new {@code PolicyIdMissingException} object with an exception message for a thing-update scenario. * * @param thingId the ID of the Thing. * @param dittoHeaders the headers of the command which resulted in this exception. * @return the new PolicyIdMissingException. */ public static PolicyIdMissingException fromThingIdOnUpdate(final String thingId, final DittoHeaders dittoHeaders) { final JsonSchemaVersion schemaVersion = dittoHeaders.getSchemaVersion().orElse(JsonSchemaVersion.LATEST); return new Builder(thingId, schemaVersion, MESSAGE_TEMPLATE_UPDATE, DEFAULT_DESCRIPTION_UPDATE) .dittoHeaders(dittoHeaders) .build(); }
/** * Constructs a new {@code PolicyIdMissingException} object with an exception message for a thing-create scenario. * * @param thingId the ID of the Thing. * @param dittoHeaders the headers of the command which resulted in this exception. * @return the new PolicyIdMissingException. */ public static PolicyIdMissingException fromThingIdOnCreate(final String thingId, final DittoHeaders dittoHeaders) { final JsonSchemaVersion schemaVersion = dittoHeaders.getSchemaVersion().orElse(JsonSchemaVersion.LATEST); return new Builder(thingId, schemaVersion, MESSAGE_TEMPLATE_CREATE, DEFAULT_DESCRIPTION_CREATE) .dittoHeaders(dittoHeaders) .build(); }
private static JsonObject buildJsonRepresentation(final List<CommandResponse<?>> commandResponses, final DittoHeaders dittoHeaders) { final JsonObjectBuilder builder = JsonObject.newBuilder(); commandResponses.forEach(cmdR -> builder.set("/" + calculateServiceName(cmdR) + "/" + calculateInstance(cmdR), cmdR.toJson(dittoHeaders.getSchemaVersion().orElse(JsonSchemaVersion.LATEST)))); if (builder.isEmpty()) { return JsonFactory.nullObject(); } else { return builder.build(); } }
private static JsonObject buildJsonRepresentation(final List<CommandResponse<?>> commandResponses, final DittoHeaders dittoHeaders) { final JsonObjectBuilder builder = JsonObject.newBuilder(); int i = 0; for (final CommandResponse<?> cmdR : commandResponses) { builder.set("/" + calculateServiceName(cmdR) + "/" + calculateInstance(cmdR, i++), cmdR.toJson(dittoHeaders.getSchemaVersion().orElse(JsonSchemaVersion.LATEST))); } if (builder.isEmpty()) { return JsonFactory.nullObject(); } else { return builder.build(); } }