use of org.apache.syncope.common.lib.policy.RuleConf in project syncope by apache.
the class ImplementationDataBinderImpl method update.
@Override
public void update(final Implementation implementation, final ImplementationTO implementationTO) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidImplementation);
if (implementation.getType() != null && implementation.getType() != implementationTO.getType()) {
sce.getElements().add("ImplementationType cannot be changed");
throw sce;
}
if (StringUtils.isBlank(implementationTO.getBody())) {
sce.getElements().add("No actual implementation provided");
throw sce;
}
BeanUtils.copyProperties(implementationTO, implementation);
if (implementation.getEngine() == ImplementationEngine.JAVA) {
Class<?> base = null;
switch(implementation.getType()) {
case REPORTLET:
base = Reportlet.class;
break;
case ACCOUNT_RULE:
base = AccountRule.class;
break;
case PASSWORD_RULE:
base = PasswordRule.class;
break;
case ITEM_TRANSFORMER:
base = ItemTransformer.class;
break;
case TASKJOB_DELEGATE:
base = SchedTaskJobDelegate.class;
break;
case RECON_FILTER_BUILDER:
base = ReconFilterBuilder.class;
break;
case LOGIC_ACTIONS:
base = LogicActions.class;
break;
case PROPAGATION_ACTIONS:
base = PropagationActions.class;
break;
case PULL_ACTIONS:
base = PullActions.class;
break;
case PUSH_ACTIONS:
base = PushActions.class;
break;
case PULL_CORRELATION_RULE:
base = PullCorrelationRule.class;
break;
case VALIDATOR:
base = Validator.class;
break;
case RECIPIENTS_PROVIDER:
base = RecipientsProvider.class;
break;
default:
}
if (base == null) {
sce.getElements().add("No Java interface found for " + implementation.getType());
throw sce;
}
if (implementation.getType() == ImplementationType.REPORTLET) {
ReportletConf reportlet = POJOHelper.deserialize(implementation.getBody(), ReportletConf.class);
if (reportlet == null) {
sce.getElements().add("Could not deserialize as ReportletConf");
throw sce;
}
} else if (implementation.getType() == ImplementationType.ACCOUNT_RULE || implementation.getType() == ImplementationType.PASSWORD_RULE || implementation.getType() == ImplementationType.PULL_CORRELATION_RULE) {
RuleConf rule = POJOHelper.deserialize(implementation.getBody(), RuleConf.class);
if (rule == null) {
sce.getElements().add("Could not deserialize as neither Account, Password nor PullCorrelation RuleConf");
throw sce;
}
} else {
Class<?> clazz = null;
try {
clazz = Class.forName(implementation.getBody());
} catch (Exception e) {
LOG.error("Class '{}' not found", implementation.getBody(), e);
sce.getElements().add("No Java class found: " + implementation.getBody());
throw sce;
}
if (!base.isAssignableFrom(clazz)) {
sce.getElements().add("Java class " + implementation.getBody() + " must comply with " + base.getName());
throw sce;
}
if (Modifier.isAbstract(clazz.getModifiers())) {
sce.getElements().add("Java class " + implementation.getBody() + " is abstract");
throw sce;
}
}
}
}
Aggregations