Search in sources :

Example 36 with NotFoundException

use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.

the class PolicyLogic method read.

@PreAuthorize("hasRole('" + StandardEntitlement.POLICY_READ + "')")
@Transactional(readOnly = true)
public <T extends PolicyTO> T read(final PolicyType type, final String key) {
    Policy policy = policyDAO.find(key);
    if (policy == null) {
        throw new NotFoundException("Policy " + key + " not found");
    }
    PolicyUtils policyUtils = policyUtilsFactory.getInstance(policy);
    if (type != null && policyUtils.getType() != type) {
        SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRequest);
        sce.getElements().add("Found " + type + ", expected " + policyUtils.getType());
        throw sce;
    }
    return binder.getPolicyTO(policy);
}
Also used : Policy(org.apache.syncope.core.persistence.api.entity.policy.Policy) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) PolicyUtils(org.apache.syncope.core.persistence.api.entity.policy.PolicyUtils) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Transactional(org.springframework.transaction.annotation.Transactional)

Example 37 with NotFoundException

use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.

the class RealmLogic method list.

@PreAuthorize("isAuthenticated()")
@Transactional(readOnly = true)
public List<RealmTO> list(final String fullPath) {
    Realm realm = realmDAO.findByFullPath(fullPath);
    if (realm == null) {
        LOG.error("Could not find realm '" + fullPath + "'");
        throw new NotFoundException(fullPath);
    }
    final boolean admin = AuthContextUtils.getAuthorizations().keySet().contains(StandardEntitlement.REALM_LIST);
    return realmDAO.findDescendants(realm).stream().map(descendant -> binder.getRealmTO(descendant, admin)).collect(Collectors.toList());
}
Also used : StandardEntitlement(org.apache.syncope.common.lib.types.StandardEntitlement) PropagationManager(org.apache.syncope.core.provisioning.api.propagation.PropagationManager) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) AnySearchDAO(org.apache.syncope.core.persistence.api.dao.AnySearchDAO) Realm(org.apache.syncope.core.persistence.api.entity.Realm) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RealmTO(org.apache.syncope.common.lib.to.RealmTO) Autowired(org.springframework.beans.factory.annotation.Autowired) ArrayUtils(org.apache.commons.lang3.ArrayUtils) ProvisioningResult(org.apache.syncope.common.lib.to.ProvisioningResult) ResourceOperation(org.apache.syncope.common.lib.types.ResourceOperation) StringUtils(org.apache.commons.lang3.StringUtils) AnyTypeKind(org.apache.syncope.common.lib.types.AnyTypeKind) RealmDataBinder(org.apache.syncope.core.provisioning.api.data.RealmDataBinder) PropagationTaskTO(org.apache.syncope.common.lib.to.PropagationTaskTO) AttributeCond(org.apache.syncope.core.persistence.api.dao.search.AttributeCond) DuplicateException(org.apache.syncope.core.persistence.api.dao.DuplicateException) PropagationByResource(org.apache.syncope.core.provisioning.api.PropagationByResource) ClientExceptionType(org.apache.syncope.common.lib.types.ClientExceptionType) RealmDAO(org.apache.syncope.core.persistence.api.dao.RealmDAO) AuthContextUtils(org.apache.syncope.core.spring.security.AuthContextUtils) Method(java.lang.reflect.Method) SearchCond(org.apache.syncope.core.persistence.api.dao.search.SearchCond) Set(java.util.Set) PropagationReporter(org.apache.syncope.core.provisioning.api.propagation.PropagationReporter) Collectors(java.util.stream.Collectors) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) List(java.util.List) Component(org.springframework.stereotype.Component) PropagationTaskExecutor(org.apache.syncope.core.provisioning.api.propagation.PropagationTaskExecutor) AnyCond(org.apache.syncope.core.persistence.api.dao.search.AnyCond) Collections(java.util.Collections) Transactional(org.springframework.transaction.annotation.Transactional) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) Realm(org.apache.syncope.core.persistence.api.entity.Realm) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Transactional(org.springframework.transaction.annotation.Transactional)

Example 38 with NotFoundException

use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.

the class RelationshipTypeLogic method delete.

@PreAuthorize("hasRole('" + StandardEntitlement.RELATIONSHIPTYPE_DELETE + "')")
public RelationshipTypeTO delete(final String key) {
    RelationshipType relationshipType = relationshipTypeDAO.find(key);
    if (relationshipType == null) {
        LOG.error("Could not find relationshipType '" + key + "'");
        throw new NotFoundException(key);
    }
    RelationshipTypeTO deleted = binder.getRelationshipTypeTO(relationshipType);
    relationshipTypeDAO.delete(key);
    return deleted;
}
Also used : RelationshipTypeTO(org.apache.syncope.common.lib.to.RelationshipTypeTO) RelationshipType(org.apache.syncope.core.persistence.api.entity.RelationshipType) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 39 with NotFoundException

use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.

the class RemediationLogic method remedy.

@PreAuthorize("hasRole('" + StandardEntitlement.REMEDIATION_REMEDY + "')")
public ProvisioningResult<?> remedy(final String key, final AnyTO anyTO, final boolean nullPriorityAsync) {
    Remediation remediation = remediationDAO.find(key);
    if (remediation == null) {
        LOG.error("Could not find remediation '" + key + "'");
        throw new NotFoundException(key);
    }
    ProvisioningResult<?> result;
    switch(remediation.getAnyType().getKind()) {
        case USER:
        default:
            result = userLogic.create((UserTO) anyTO, true, nullPriorityAsync);
            break;
        case GROUP:
            result = groupLogic.create((GroupTO) anyTO, nullPriorityAsync);
            break;
        case ANY_OBJECT:
            result = anyObjectLogic.create((AnyObjectTO) anyTO, nullPriorityAsync);
    }
    remediationDAO.delete(remediation);
    return result;
}
Also used : AnyObjectTO(org.apache.syncope.common.lib.to.AnyObjectTO) UserTO(org.apache.syncope.common.lib.to.UserTO) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) Remediation(org.apache.syncope.core.persistence.api.entity.Remediation) GroupTO(org.apache.syncope.common.lib.to.GroupTO) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 40 with NotFoundException

use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.

the class RemediationLogic method delete.

@PreAuthorize("hasRole('" + StandardEntitlement.REMEDIATION_DELETE + "')")
public void delete(final String key) {
    Remediation remediation = remediationDAO.find(key);
    if (remediation == null) {
        LOG.error("Could not find remediation '" + key + "'");
        throw new NotFoundException(key);
    }
    remediationDAO.delete(remediation);
}
Also used : NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) Remediation(org.apache.syncope.core.persistence.api.entity.Remediation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)110 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)87 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)41 Transactional (org.springframework.transaction.annotation.Transactional)21 Date (java.util.Date)12 ExternalResource (org.apache.syncope.core.persistence.api.entity.resource.ExternalResource)10 SchedulerException (org.quartz.SchedulerException)10 ArrayList (java.util.ArrayList)8 List (java.util.List)8 AnyType (org.apache.syncope.core.persistence.api.entity.AnyType)8 Report (org.apache.syncope.core.persistence.api.entity.Report)8 SchedTask (org.apache.syncope.core.persistence.api.entity.task.SchedTask)8 User (org.apache.syncope.core.persistence.api.entity.user.User)8 HashMap (java.util.HashMap)7 Collectors (java.util.stream.Collectors)7 Pair (org.apache.commons.lang3.tuple.Pair)7 ExecTO (org.apache.syncope.common.lib.to.ExecTO)7 Autowired (org.springframework.beans.factory.annotation.Autowired)7 StringUtils (org.apache.commons.lang3.StringUtils)6 DuplicateException (org.apache.syncope.core.persistence.api.dao.DuplicateException)6