コード例 #1
0
  private void validateCopyRetentionRules(
      RetentionRule retentionRule,
      MetadataSchema schema,
      ValidationErrors validationErrors,
      ConfigProvider configProvider) {

    List<CopyRetentionRule> copyRetentionRules = retentionRule.getCopyRetentionRules();

    boolean validIntegrity = true;
    for (int i = 0; i < copyRetentionRules.size(); i++) {
      validIntegrity &= validateIntegrity(copyRetentionRules.get(i), i, schema, validationErrors);
    }

    if (validIntegrity) {
      int principalCount = 0;
      int secondaryCount = 0;
      //
      //			List<String> duplicateContentTypes = new ArrayList<>();
      //			List<String> mediumTypeIds = new ArrayList<>();

      for (CopyRetentionRule copyRetentionRule : retentionRule.getCopyRetentionRules()) {
        if (copyRetentionRule.getCopyType() == CopyType.PRINCIPAL) {
          principalCount++;

          //					for (String mediumTypeId : copyRetentionRule.getMediumTypeIds()) {
          //						if (mediumTypeIds.contains(mediumTypeId)) {
          //							duplicateContentTypes.add(mediumTypeId);
          //						} else {
          //							mediumTypeIds.add(mediumTypeId);
          //						}
          //					}

        } else {
          secondaryCount++;
        }
      }

      boolean copyRulePrincipalRequired =
          configProvider.get(RMConfigs.COPY_RULE_PRINCIPAL_REQUIRED);

      if (principalCount == 0 && copyRulePrincipalRequired) {
        addCopyRetentionRuleError(
            MUST_SPECIFY_AT_LEAST_ONE_PRINCIPAL_COPY_RETENTON_RULE, schema, validationErrors);
      }

      if (secondaryCount != 1) {
        addCopyRetentionRuleError(
            MUST_SPECIFY_ONE_SECONDARY_COPY_RETENTON_RULE, schema, validationErrors);
      }
      //			if (!duplicateContentTypes.isEmpty()) {
      //				addCopyRetentionRuleDuplicatedContentTypesError(duplicateContentTypes, schema,
      // validationErrors);
      //			}

    }
  }
コード例 #2
0
  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);
    }
  }
コード例 #3
0
  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);
        }
      }
    }
  }