Search in sources :

Example 1 with ComposablePolicy

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;
}
Also used : ImplementationTO(org.apache.syncope.common.lib.to.ImplementationTO) ComposablePolicy(org.apache.syncope.common.lib.policy.ComposablePolicy) PolicyTO(org.apache.syncope.common.lib.policy.PolicyTO)

Aggregations

ComposablePolicy (org.apache.syncope.common.lib.policy.ComposablePolicy)1 PolicyTO (org.apache.syncope.common.lib.policy.PolicyTO)1 ImplementationTO (org.apache.syncope.common.lib.to.ImplementationTO)1