use of org.apache.syncope.core.persistence.api.entity.Implementation in project syncope by apache.
the class ImplementationLogic method read.
@PreAuthorize("hasRole('" + StandardEntitlement.IMPLEMENTATION_READ + "')")
@Transactional(readOnly = true)
public ImplementationTO read(final ImplementationType type, final String key) {
Implementation implementation = implementationDAO.find(key);
if (implementation == null) {
LOG.error("Could not find implementation '" + key + "'");
throw new NotFoundException(key);
}
if (implementation.getType() != type) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRequest);
sce.getElements().add("Found " + type + ", expected " + implementation.getType());
throw sce;
}
return binder.getImplementationTO(implementation);
}
use of org.apache.syncope.core.persistence.api.entity.Implementation in project syncope by apache.
the class ImplementationLogic method create.
@PreAuthorize("hasRole('" + StandardEntitlement.IMPLEMENTATION_CREATE + "')")
public ImplementationTO create(final ImplementationTO implementationTO) {
if (StringUtils.isBlank(implementationTO.getKey())) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.RequiredValuesMissing);
sce.getElements().add("Implementation key");
throw sce;
}
Implementation implementation = implementationDAO.find(implementationTO.getKey());
if (implementation != null) {
throw new DuplicateException(implementationTO.getKey());
}
return binder.getImplementationTO(implementationDAO.save(binder.create(implementationTO)));
}
use of org.apache.syncope.core.persistence.api.entity.Implementation in project syncope by apache.
the class ImplementationLogic method delete.
@PreAuthorize("hasRole('" + StandardEntitlement.IMPLEMENTATION_DELETE + "')")
public void delete(final ImplementationType type, final String key) {
Implementation implementation = implementationDAO.find(key);
if (implementation == null) {
LOG.error("Could not find implementation '" + key + "'");
throw new NotFoundException(key);
}
if (implementation.getType() != type) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRequest);
sce.getElements().add("Found " + type + ", expected " + implementation.getType());
throw sce;
}
boolean inUse = false;
switch(implementation.getType()) {
case REPORTLET:
inUse = !reportDAO.findByReportlet(implementation).isEmpty();
break;
case ACCOUNT_RULE:
inUse = !policyDAO.findByAccountRule(implementation).isEmpty();
break;
case PASSWORD_RULE:
inUse = !policyDAO.findByPasswordRule(implementation).isEmpty();
break;
case ITEM_TRANSFORMER:
inUse = !resourceDAO.findByTransformer(implementation).isEmpty();
break;
case TASKJOB_DELEGATE:
inUse = !taskDAO.findByDelegate(implementation).isEmpty();
break;
case RECON_FILTER_BUILDER:
inUse = !taskDAO.findByReconFilterBuilder(implementation).isEmpty();
break;
case LOGIC_ACTIONS:
inUse = !realmDAO.findByLogicActions(implementation).isEmpty();
break;
case PROPAGATION_ACTIONS:
inUse = !resourceDAO.findByPropagationActions(implementation).isEmpty();
break;
case PULL_ACTIONS:
inUse = !taskDAO.findByPullActions(implementation).isEmpty();
break;
case PUSH_ACTIONS:
inUse = !taskDAO.findByPushActions(implementation).isEmpty();
break;
case PULL_CORRELATION_RULE:
inUse = !policyDAO.findByCorrelationRule(implementation).isEmpty();
break;
case VALIDATOR:
inUse = !plainSchemaDAO.findByValidator(implementation).isEmpty();
break;
case RECIPIENTS_PROVIDER:
inUse = !notificationDAO.findByRecipientsProvider(implementation).isEmpty();
break;
default:
}
if (inUse) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InUse);
sce.getElements().add("This implementation is in use");
throw sce;
}
implementationDAO.delete(key);
}
use of org.apache.syncope.core.persistence.api.entity.Implementation in project syncope by apache.
the class JPAImplementationDAO method delete.
@Override
public void delete(final String key) {
Implementation implementation = find(key);
if (implementation == null) {
return;
}
entityManager().remove(implementation);
ImplementationManager.purge(key);
}
use of org.apache.syncope.core.persistence.api.entity.Implementation in project syncope by apache.
the class PolicyTest method create.
@Test
public void create() {
PullPolicy policy = entityFactory.newEntity(PullPolicy.class);
policy.setConflictResolutionAction(ConflictResolutionAction.IGNORE);
policy.setDescription("Pull policy");
final String pullURuleName = "net.tirasa.pull.correlation.TirasaURule";
final String pullGRuleName = "net.tirasa.pull.correlation.TirasaGRule";
Implementation impl1 = entityFactory.newEntity(Implementation.class);
impl1.setKey(pullURuleName);
impl1.setEngine(ImplementationEngine.JAVA);
impl1.setType(ImplementationType.PULL_CORRELATION_RULE);
impl1.setBody(PullCorrelationRule.class.getName());
impl1 = implementationDAO.save(impl1);
CorrelationRule rule1 = entityFactory.newEntity(CorrelationRule.class);
rule1.setAnyType(anyTypeDAO.findUser());
rule1.setPullPolicy(policy);
rule1.setImplementation(impl1);
policy.add(rule1);
Implementation impl2 = entityFactory.newEntity(Implementation.class);
impl2.setKey(pullGRuleName);
impl2.setEngine(ImplementationEngine.JAVA);
impl2.setType(ImplementationType.PULL_CORRELATION_RULE);
impl2.setBody(PullCorrelationRule.class.getName());
impl2 = implementationDAO.save(impl2);
CorrelationRule rule2 = entityFactory.newEntity(CorrelationRule.class);
rule2.setAnyType(anyTypeDAO.findGroup());
rule2.setPullPolicy(policy);
rule2.setImplementation(impl2);
policy.add(rule2);
policy = policyDAO.save(policy);
assertNotNull(policy);
assertEquals(pullURuleName, policy.getCorrelationRule(anyTypeDAO.findUser()).get().getImplementation().getKey());
assertEquals(pullGRuleName, policy.getCorrelationRule(anyTypeDAO.findGroup()).get().getImplementation().getKey());
}
Aggregations