Skip to content

Commit

Permalink
[APPS-2907][APPS-2909] Defect fixes in Retention Schedule V1 API's
Browse files Browse the repository at this point in the history
  • Loading branch information
Sathish Kumar authored and Sathish Kumar committed Jul 1, 2024
1 parent ad76b3a commit fba4121
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ public void combineRetentionStepConditionsNotValidForNonAccessionStep()
getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(actionDefinition,retentionSchedule.getId());

assertStatusCode(BAD_REQUEST);

}

@Test(priority = 6)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public CollectionWithPagingInfo<RetentionScheduleActionDefinition> readAll(Strin
*/
private void retentionScheduleStepValidation(NodeRef retentionScheduleNodeRef, RetentionScheduleActionDefinition retentionScheduleActionDefinition)
{
if (retentionScheduleActionDefinition.getName() == null || retentionScheduleActionDefinition.getName().isEmpty())
if (checkStepNameIsEmpty(retentionScheduleActionDefinition.getName()))
{
throw new IllegalArgumentException("'name' parameter is mandatory when creating a disposition action definition");
}
Expand Down Expand Up @@ -181,6 +181,11 @@ private void retentionScheduleStepValidation(NodeRef retentionScheduleNodeRef, R
}
}

private boolean checkStepNameIsEmpty(String name)
{
return name == null || name.isEmpty();
}

/**
* this method is used to validate the request of the retention schedule
* @param retentionScheduleActionDefinition retention schedule action definition
Expand Down Expand Up @@ -209,19 +214,30 @@ private void retentionScheduleRequestValidation(RetentionScheduleActionDefinitio
throw new InvalidArgumentException("periodProperty value is invalid: " + retentionScheduleActionDefinition.getPeriodProperty());
}

if(!retentionScheduleActionDefinition.getName().equals(RetentionSteps.ACCESSION.stepName) && retentionScheduleActionDefinition.isCombineRetentionStepConditions())
if (validateCombineRetentionStepConditionsForNonAccessionStep(retentionScheduleActionDefinition))
{
throw new IllegalArgumentException("combineRetentionStepConditions property is only valid for accession step. Not valid for :" + retentionScheduleActionDefinition.getName());
}

if(retentionScheduleActionDefinition.getLocation() != null
&& !retentionScheduleActionDefinition.getName().equals(RetentionSteps.TRANSFER.stepName)
&& !retentionScheduleActionDefinition.getLocation().isEmpty())
if (validateLocationForNonTransferStep(retentionScheduleActionDefinition))
{
throw new IllegalArgumentException("location property is only valid for transfer step. Not valid for :" + retentionScheduleActionDefinition.getName());
}
}

private boolean validateCombineRetentionStepConditionsForNonAccessionStep(RetentionScheduleActionDefinition retentionScheduleActionDefinition)
{
return !retentionScheduleActionDefinition.getName().equals(RetentionSteps.ACCESSION.stepName)
&& retentionScheduleActionDefinition.isCombineRetentionStepConditions();
}

private boolean validateLocationForNonTransferStep(RetentionScheduleActionDefinition retentionScheduleActionDefinition)
{
return retentionScheduleActionDefinition.getLocation() != null
&& !retentionScheduleActionDefinition.getName().equals(RetentionSteps.TRANSFER.stepName)
&& !retentionScheduleActionDefinition.getLocation().isEmpty();
}

private boolean checkStepAlreadyExists(Set<String> completedActions, String stepName)
{
return completedActions.contains(stepName) && !stepName.equals(RetentionSteps.TRANSFER.stepName);
Expand Down

0 comments on commit fba4121

Please sign in to comment.