/** * Returns a new {@link PolicyTag}. * * @param id the ID of the modified Policy. * @param revision the revision of the modified Policy. * @return a new {@link PolicyTag}. */ public static PolicyTag of(final String id, final long revision) { return new PolicyTag(id, revision); }
/** * Returns a new {@link PolicyReferenceTag}. * * @param entityId the ID of the entity referencing the policy. * @param policyTag the {@link PolicyTag}. * @return a new {@link PolicyReferenceTag}. */ public static PolicyReferenceTag of(final String entityId, final PolicyTag policyTag) { return new PolicyReferenceTag(entityId, policyTag); }
@Override public String asIdentifierString() { return entityId + ENTITY_ID_FROM_POLICY_TAG_SEPARATOR + policyTag.getRevision(); }
@Override public JsonValue toJson() { return JsonFactory.newObjectBuilder() .set(JsonFields.ENTITY_ID, entityId) .set(JsonFields.POLICY_ID, policyTag.getId()) .set(JsonFields.POLICY_REV, policyTag.getRevision()) .build(); }
@Override public Map<String, BiFunction<JsonObject, DittoHeaders, Jsonifiable>> determineStrategy() { final MappingStrategiesBuilder builder = MappingStrategiesBuilder.newInstance(); addPoliciesStrategies(builder); addCommonStrategies(builder); addDevOpsStrategies(builder); addNamespacesStrategies(builder); return builder.build(); }
/** * Constructs a new Mapping Strategy for Things Search. */ public ThingSearchMappingStrategy() { policiesMappingStrategy = new PoliciesMappingStrategy(); thingsMappingStrategy = new ThingsMappingStrategy(); }
/** * Creates a new {@link PolicyReferenceTag} from a JSON object. * * @param jsonObject the JSON object of which a new {@link PolicyReferenceTag} is to be created. * @return the {@link PolicyReferenceTag} which was created from the given JSON object. * @throws NullPointerException if {@code jsonObject} is {@code null}. * @throws IllegalArgumentException if {@code jsonObject} is empty. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonObject} is not valid JSON. * @throws org.eclipse.ditto.json.JsonMissingFieldException if the passed in {@code jsonObject} was not in the * expected format. */ public static PolicyReferenceTag fromJson(final JsonObject jsonObject) { final String extractedEntityId = jsonObject.getValueOrThrow(JsonFields.ENTITY_ID); final String extractedPolicyId = jsonObject.getValueOrThrow(JsonFields.POLICY_ID); final long extractedPolicyRev = jsonObject.getValueOrThrow(JsonFields.POLICY_REV); final PolicyTag extractedPolicyTag = PolicyTag.of(extractedPolicyId, extractedPolicyRev); return new PolicyReferenceTag(extractedEntityId, extractedPolicyTag); }
@Override public Map<String, BiFunction<JsonObject, DittoHeaders, Jsonifiable>> determineStrategy() { final MappingStrategiesBuilder builder = MappingStrategiesBuilder.newInstance(); addPoliciesStrategies(builder); addDevOpsStrategies(builder); return builder.build(); } }
private static PolicyTag createElement(final PidWithSeqNr pidWithSeqNr) { final String id = pidWithSeqNr.getPersistenceId() .replaceFirst(PolicyPersistenceActor.PERSISTENCE_ID_PREFIX, ""); return PolicyTag.of(id, pidWithSeqNr.getSequenceNr()); } }
/** * Creates a new {@code PoliciesValidator} instance. * * @param policyEntries the policyEntries to be validated. * @return a new {@code AclValidator} object. * @throws NullPointerException if any argument is {@code null}. */ public static PoliciesValidator newInstance(final Iterable<PolicyEntry> policyEntries) { requireNonNull(policyEntries, "The policyEntries to validate must not be null!"); return new PoliciesValidator(policyEntries); }
private static Source<Object, NotUsed> toPolicyReferenceTags(final PolicyTag policyTag, final ThingsSearchUpdaterPersistence searchUpdaterPersistence) { return searchUpdaterPersistence.getOutdatedThingIds(policyTag) .map(thingId -> PolicyReferenceTag.of(thingId, policyTag)); } }
@Override public JsonObject toJson() { return JsonFactory.newObjectBuilder() .set(JsonFields.ENTITY_ID, entityId) .set(JsonFields.POLICY_ID, policyTag.getId()) .set(JsonFields.POLICY_REV, policyTag.getRevision()) .build(); }
@Override public String asIdentifierString() { return entityId + ENTITY_ID_FROM_POLICY_TAG_SEPARATOR + policyTag.getRevision(); }
/** * Constructs a new {@code ThingsMappingStrategy} object. */ public ThingSearchMappingStrategy() { policiesMappingStrategy = new PoliciesMappingStrategy(); thingsMappingStrategy = new ThingsMappingStrategy(); }
/** * Creates a new {@link PolicyReferenceTag} from a JSON object. * * @param jsonObject the JSON object of which a new {@link PolicyReferenceTag} is to be created. * @return the {@link PolicyReferenceTag} which was created from the given JSON object. * @throws NullPointerException if {@code jsonObject} is {@code null}. * @throws IllegalArgumentException if {@code jsonObject} is empty. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonObject} is not valid JSON. * @throws org.eclipse.ditto.json.JsonMissingFieldException if the passed in {@code jsonObject} was not in the * expected format. */ public static PolicyReferenceTag fromJson(final JsonObject jsonObject) { final String extractedEntityId = jsonObject.getValueOrThrow(JsonFields.ENTITY_ID); final String extractedPolicyId = jsonObject.getValueOrThrow(JsonFields.POLICY_ID); final long extractedPolicyRev = jsonObject.getValueOrThrow(JsonFields.POLICY_REV); final PolicyTag extractedPolicyTag = PolicyTag.of(extractedPolicyId, extractedPolicyRev); return new PolicyReferenceTag(extractedEntityId, extractedPolicyTag); }
/** * Returns a new {@link PolicyTag}. * * @param id the ID of the modified Policy. * @param revision the revision of the modified Policy. * @return a new {@link PolicyTag}. */ public static PolicyTag of(final String id, final long revision) { return new PolicyTag(id, revision); }
/** * Returns a new {@link PolicyReferenceTag}. * * @param entityId the ID of the entity referencing the policy. * @param policyTag the {@link PolicyTag}. * @return a new {@link PolicyReferenceTag}. */ public static PolicyReferenceTag of(final String entityId, final PolicyTag policyTag) { return new PolicyReferenceTag(entityId, policyTag); }
/** * Creates a new {@code PoliciesValidator} instance. * * @param policyEntries the policyEntries to be validated. * @return a new {@code AclValidator} object. * @throws NullPointerException if any argument is {@code null}. */ public static PoliciesValidator newInstance(final Iterable<PolicyEntry> policyEntries) { requireNonNull(policyEntries, "The policyEntries to validate must not be null!"); return new PoliciesValidator(policyEntries); }
/** * Creates a new {@link PolicyTag} from a JSON object. * * @param jsonObject the JSON object of which a new {@link PolicyTag} is to be created. * @return the {@link PolicyTag} which was created from the given JSON object. * @throws NullPointerException if {@code jsonObject} is {@code null}. * @throws IllegalArgumentException if {@code jsonObject} is empty. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonObject} is not valid JSON. * @throws org.eclipse.ditto.json.JsonMissingFieldException if the passed in {@code jsonObject} was not in the * expected format. */ public static PolicyTag fromJson(final JsonObject jsonObject) { return new PolicyTag(jsonObject); }
/** * Creates a new {@link PolicyTag} from a JSON object. * * @param jsonObject the JSON object of which a new {@link PolicyTag} is to be created. * @return the {@link PolicyTag} which was created from the given JSON object. * @throws NullPointerException if {@code jsonObject} is {@code null}. * @throws IllegalArgumentException if {@code jsonObject} is empty. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonObject} is not valid JSON. * @throws org.eclipse.ditto.json.JsonMissingFieldException if the passed in {@code jsonObject} was not in the * expected format. */ public static PolicyTag fromJson(final JsonObject jsonObject) { return new PolicyTag(jsonObject); }