use of org.apache.syncope.common.lib.policy.ComposablePolicy in project syncope by apache.
the class PolicyRuleWizardBuilder method onApplyInternal.
@Override
protected Serializable onApplyInternal(final PolicyRuleWrapper modelObject) {
PolicyTO policyTO = restClient.getPolicy(type, policy);
ComposablePolicy composable;
if (policyTO instanceof ComposablePolicy) {
composable = (ComposablePolicy) policyTO;
} else {
throw new IllegalStateException("Non composable policy");
}
if (modelObject.getImplementationEngine() == ImplementationEngine.JAVA) {
ImplementationTO rule = implementationClient.read(implementationType, modelObject.getImplementationKey());
try {
rule.setBody(MAPPER.writeValueAsString(modelObject.getConf()));
implementationClient.update(rule);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
if (modelObject.isNew()) {
composable.getRules().add(modelObject.getImplementationKey());
}
restClient.updatePolicy(type, policyTO);
return modelObject;
}
Aggregations