@FunctionalInterface public interface ArchiveUnitProfileValidator
private static ArchiveUnitProfileValidator checkDuplicateInDatabaseValidator() {
return (profile, profileIdentifier) -> {
GenericRejectionCause rejection = null;
boolean exist = ... exists in database?;
if (exist) {
rejection = GenericRejectionCause.rejectDuplicatedInDatabase(profileIdentifier);
}
return (rejection == null) ? Optional.empty() : Optional.of(rejection);
};
}
The call the method like this to validate the archive unit profile aup:
GenericRejectionCause rejection = checkDuplicateInDatabaseValidator().validate(aup, aup.getName());
Check if rejection is present then do the resolution| Modifier and Type | Interface and Description |
|---|---|
static class |
ArchiveUnitProfileValidator.RejectionCause
Rejection Cause
|
| Modifier and Type | Method and Description |
|---|---|
Optional<ArchiveUnitProfileValidator.RejectionCause> |
validate(ArchiveUnitProfileModel profile)
Validate an archive unit profile object
|
Optional<ArchiveUnitProfileValidator.RejectionCause> validate(ArchiveUnitProfileModel profile)
profile - to validateCopyright © 2021 Vitam. All rights reserved.