private void validateAdministrativeUnits(
      RetentionRule retentionRule, MetadataSchema schema, ValidationErrors validationErrors) {

    List<String> administrativeUnits = retentionRule.getAdministrativeUnits();
    boolean responsibleAdministrativeUnits = retentionRule.isResponsibleAdministrativeUnits();

    if (administrativeUnits.isEmpty() && !responsibleAdministrativeUnits) {
      validationErrors.add(getClass(), MUST_SPECIFY_ADMINISTRATIVE_UNITS_XOR_RESPONSIBLES_FLAG);

    } else if (!administrativeUnits.isEmpty() && responsibleAdministrativeUnits) {
      validationErrors.add(getClass(), MUST_SPECIFY_ADMINISTRATIVE_UNITS_XOR_RESPONSIBLES_FLAG);
    }
  }
 private void addCopyRetentionRuleError(
     String code, MetadataSchema schema, ValidationErrors validationErrors) {
   Map<String, String> parameters = new HashMap<>();
   parameters.put(RecordMetadataValidator.METADATA_CODE, RetentionRule.COPY_RETENTION_RULES);
   parameters.put(
       RecordMetadataValidator.METADATA_LABEL,
       schema.getMetadata(RetentionRule.COPY_RETENTION_RULES).getLabel());
   validationErrors.add(getClass(), code, parameters);
 }
 private void addCopyRetentionRuleIntegrityError(
     int index, String field, MetadataSchema schema, ValidationErrors validationErrors) {
   Map<String, String> parameters = new HashMap<>();
   parameters.put(COPY_RETENTION_RULE_FIELD_REQUIRED_FIELD, field);
   parameters.put(COPY_RETENTION_RULE_FIELD_REQUIRED_INDEX, "" + index);
   parameters.put(RecordMetadataValidator.METADATA_CODE, RetentionRule.COPY_RETENTION_RULES);
   parameters.put(
       RecordMetadataValidator.METADATA_LABEL,
       schema.getMetadata(RetentionRule.COPY_RETENTION_RULES).getLabel());
   validationErrors.add(getClass(), COPY_RETENTION_RULE_FIELD_REQUIRED, parameters);
 }
  private void validateDocumentTypes(
      RetentionRule retentionRule, ValidationErrors validationErrors) {

    List<RetentionRuleDocumentType> documentTypes = retentionRule.getDocumentTypesDetails();
    if (retentionRule.hasCopyRetentionRuleWithSortDispositionType()) {
      for (int i = 0; i < documentTypes.size(); i++) {
        RetentionRuleDocumentType documentType = documentTypes.get(i);

        if (documentType.getDisposalType() == null
            || documentType.getDisposalType() == DisposalType.SORT) {

          Map<String, String> parameters = new HashMap<>();
          parameters.put(MISSING_DOCUMENT_TYPE_DISPOSAL_INDEX, "" + i);
          validationErrors.add(getClass(), MISSING_DOCUMENT_TYPE_DISPOSAL, parameters);
        }
      }
    }
  }