papContainer.updatePolicySet(version, targetPolicySet);
}
private void moveRule(PapContainer papContainer) {
PolicyType targetPolicy = null;
for (PolicyType policy : papContainer.getAllPolicies()) {
if (PolicyHelper.hasRuleWithId(policy, pivotId)) {
targetPolicy = policy;
break;
}
}
if (targetPolicy == null) {
throw new RepositoryException("Id not found or not a rule-id: " + pivotId);
}
RuleType rule = PolicyHelper.removeRule(targetPolicy, id);
if (rule == null) {
throw new RepositoryException(String.format("Id \"%s\" not found into action \"%s\"",
id,
targetPolicy.getPolicyId()));
}
int pivotIndex = PolicyHelper.indexOfRule(targetPolicy, pivotId);
if (moveAfter) {
pivotIndex++;
}
PolicyHelper.addRule(targetPolicy, pivotIndex, rule);
String version = targetPolicy.getVersion();
PolicyWizard.increaseVersion(targetPolicy);
papContainer.updatePolicy(version, targetPolicy);
}