/** * Returns Subject ID for the given {@code issuer} and {@code subject} sequences. * * @param issuer the character sequence for the SubjectId's {@code issuer}. * @param subject the character sequence for the SubjectId's {@code subject}. * @return a new SubjectId. * @throws NullPointerException if {@code issuer} or {@code subject} is {@code null}. * @throws IllegalArgumentException if {@code issuer} or {@code subject} is empty. */ static SubjectId newInstance(final SubjectIssuer issuer, final CharSequence subject) { return PoliciesModelFactory.newSubjectId(issuer, subject); }
/** * Returns Subject ID for the given character sequence. If the given key value is already a Subject ID, this is * immediately properly cast and returned. * * @param issuerWithSubject the character sequence value of the Subject ID to be created consisting of an issuer * separated by a "{@value #ISSUER_DELIMITER}" from the actual subject value. * @return a new Subject ID with {@code issuerWithSubject} as its value. * @throws NullPointerException if {@code issuerWithSubject} is {@code null}. * @throws IllegalArgumentException if {@code issuerWithSubject} is empty. */ static SubjectId newInstance(final CharSequence issuerWithSubject) { return PoliciesModelFactory.newSubjectId(issuerWithSubject); }
/** * Creates a command for deleting a {@code Subject} of a {@code Policy}'s {@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 DeleteSubject fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new CommandJsonDeserializer<DeleteSubject>(TYPE, jsonObject).deserialize(() -> { final String policyId = jsonObject.getValueOrThrow(PolicyModifyCommand.JsonFields.JSON_POLICY_ID); final Label label = PoliciesModelFactory.newLabel(jsonObject.getValueOrThrow(JSON_LABEL)); final String stringSubjectId = jsonObject.getValueOrThrow(JSON_SUBJECT_ID); final SubjectId subjectId = PoliciesModelFactory.newSubjectId(stringSubjectId); return of(policyId, label, subjectId, dittoHeaders); }); }
/** * Creates a command for deleting a {@code Subject} of a {@code Policy}'s {@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 DeleteSubject fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new CommandJsonDeserializer<DeleteSubject>(TYPE, jsonObject).deserialize(() -> { final String policyId = jsonObject.getValueOrThrow(PolicyModifyCommand.JsonFields.JSON_POLICY_ID); final Label label = PoliciesModelFactory.newLabel(jsonObject.getValueOrThrow(JSON_LABEL)); final String stringSubjectId = jsonObject.getValueOrThrow(JSON_SUBJECT_ID); final SubjectId subjectId = PoliciesModelFactory.newSubjectId(stringSubjectId); return of(policyId, label, subjectId, dittoHeaders); }); }
/** * Creates a response to a {@code DeleteSubject} command from a JSON object. * * @param jsonObject the JSON object of which the response is to be created. * @param dittoHeaders the headers of the preceding command. * @return the response. * @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 DeleteSubjectResponse fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new CommandResponseJsonDeserializer<DeleteSubjectResponse>(TYPE, jsonObject) .deserialize((statusCode) -> { final String policyId = jsonObject.getValueOrThrow(PolicyModifyCommandResponse.JsonFields.JSON_POLICY_ID); final Label label = PoliciesModelFactory.newLabel(jsonObject.getValueOrThrow(JSON_LABEL)); final String stringSubjectId = jsonObject.getValueOrThrow(JSON_SUBJECT_ID); final SubjectId subjectId = PoliciesModelFactory.newSubjectId(stringSubjectId); return of(policyId, label, subjectId, dittoHeaders); }); }
/** * Creates a response to a {@code DeleteSubject} command from a JSON object. * * @param jsonObject the JSON object of which the response is to be created. * @param dittoHeaders the headers of the preceding command. * @return the response. * @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 DeleteSubjectResponse fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new CommandResponseJsonDeserializer<DeleteSubjectResponse>(TYPE, jsonObject) .deserialize((statusCode) -> { final String policyId = jsonObject.getValueOrThrow(PolicyModifyCommandResponse.JsonFields.JSON_POLICY_ID); final Label label = PoliciesModelFactory.newLabel(jsonObject.getValueOrThrow(JSON_LABEL)); final String stringSubjectId = jsonObject.getValueOrThrow(JSON_SUBJECT_ID); final SubjectId subjectId = PoliciesModelFactory.newSubjectId(stringSubjectId); return of(policyId, label, subjectId, dittoHeaders); }); }