/** * Returns the retrieved Policy entries. * * @return the retrieved Policy entries. */ public Iterable<PolicyEntry> getPolicyEntries() { return PoliciesModelFactory.newPolicyEntries(policyEntries); }
/** * Returns the retrieved Policy entries. * * @return the retrieved Policy entries. */ public Iterable<PolicyEntry> getPolicyEntries() { return PoliciesModelFactory.newPolicyEntries(policyEntries); }
/** * Returns a new immutable Iterable of Policy entries based on the given JSON string. * * @param jsonString the JSON object representation as String of Policy entries. * @return the new initialised {@code Policy}. * @throws org.eclipse.ditto.model.base.exceptions.DittoJsonException if {@code jsonObject} cannot be parsed to * {@link Iterable} of {@link PolicyEntry}s. */ public static Iterable<PolicyEntry> newPolicyEntries(final String jsonString) { final JsonObject jsonObject = wrapJsonRuntimeException(() -> JsonFactory.newObject(jsonString)); return newPolicyEntries(jsonObject); }
/** * Creates a command for modifying a {@code PolicyEntry} from a JSON object. * * @param jsonObject the JSON object of which the command is to be created. * @param dittoHeaders the headers of the command. * @return the command. * @throws NullPointerException if {@code jsonObject} is {@code null}. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonObject} was not in the expected * format. */ public static ModifyPolicyEntries fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new CommandJsonDeserializer<ModifyPolicyEntries>(TYPE, jsonObject).deserialize(() -> { final String policyId = jsonObject.getValueOrThrow(PolicyModifyCommand.JsonFields.JSON_POLICY_ID); final JsonObject policyEntriesJsonObject = jsonObject.getValueOrThrow(JSON_POLICY_ENTRIES); final Iterable<PolicyEntry> policyEntries = PoliciesModelFactory.newPolicyEntries(policyEntriesJsonObject); return of(policyId, policyEntries, dittoHeaders); }); }
/** * Creates a command for modifying a {@code PolicyEntry} from a JSON object. * * @param jsonObject the JSON object of which the command is to be created. * @param dittoHeaders the headers of the command. * @return the command. * @throws NullPointerException if {@code jsonObject} is {@code null}. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonObject} was not in the expected * format. */ public static ModifyPolicyEntries fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new CommandJsonDeserializer<ModifyPolicyEntries>(TYPE, jsonObject).deserialize(() -> { final String policyId = jsonObject.getValueOrThrow(PolicyModifyCommand.JsonFields.JSON_POLICY_ID); final JsonObject policyEntriesJsonObject = jsonObject.getValueOrThrow(JSON_POLICY_ENTRIES); final Iterable<PolicyEntry> policyEntries = PoliciesModelFactory.newPolicyEntries(policyEntriesJsonObject); return of(policyId, policyEntries, dittoHeaders); }); }
/** * Creates a new {@code PolicyEntriesModified} from a JSON object. * * @param jsonObject the JSON object from which a new PolicyEntriesModified instance is to be created. * @param dittoHeaders the headers of the command which was the cause of this event. * @return the {@code PolicyEntriesModified} which was created from the given JSON object. * @throws NullPointerException if {@code jsonObject} is {@code null}. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonObject} was not in the expected 'PolicyEntriesModified' * format. */ public static PolicyEntriesModified fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new EventJsonDeserializer<PolicyEntriesModified>(TYPE, jsonObject) .deserialize((revision, timestamp) -> { final String policyId = jsonObject.getValueOrThrow(JsonFields.POLICY_ID); final JsonObject policyEntriesJsonObject = jsonObject.getValueOrThrow(JSON_POLICY_ENTRIES); final Iterable<PolicyEntry> extractedModifiedPolicyEntry = PoliciesModelFactory.newPolicyEntries(policyEntriesJsonObject); return of(policyId, extractedModifiedPolicyEntry, revision, timestamp, dittoHeaders); }); }
/** * Creates a new {@code PolicyEntriesModified} from a JSON object. * * @param jsonObject the JSON object from which a new PolicyEntriesModified instance is to be created. * @param dittoHeaders the headers of the command which was the cause of this event. * @return the {@code PolicyEntriesModified} which was created from the given JSON object. * @throws NullPointerException if {@code jsonObject} is {@code null}. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonObject} was not in the expected 'PolicyEntriesModified' * format. */ public static PolicyEntriesModified fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new EventJsonDeserializer<PolicyEntriesModified>(TYPE, jsonObject) .deserialize((revision, timestamp) -> { final String policyId = jsonObject.getValueOrThrow(JsonFields.POLICY_ID); final JsonObject policyEntriesJsonObject = jsonObject.getValueOrThrow(JSON_POLICY_ENTRIES); final Iterable<PolicyEntry> extractedModifiedPolicyEntry = PoliciesModelFactory.newPolicyEntries(policyEntriesJsonObject); return of(policyId, extractedModifiedPolicyEntry, revision, timestamp, dittoHeaders); }); }
private Route thingsEntryPolicyEntries(final RequestContext ctx, final DittoHeaders dittoHeaders, final String policyId) { return pathEndOrSingleSlash(() -> Directives.route( get(() -> // GET /entries handlePerRequest(ctx, RetrievePolicyEntries.of(policyId, dittoHeaders)) ), put(() -> // PUT /entries extractDataBytes(payloadSource -> handlePerRequest(ctx, dittoHeaders, payloadSource, policyEntriesJson -> ModifyPolicyEntries.of(policyId, PoliciesModelFactory.newPolicyEntries( policyEntriesJson), dittoHeaders)) ) ) ) ); }