Search in sources :

Example 51 with NotFoundException

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

the class ConfigurationLogic method delete.

@PreAuthorize("hasRole('" + StandardEntitlement.CONFIGURATION_DELETE + "')")
public void delete(final String schema) {
    Optional<? extends CPlainAttr> conf = confDAO.find(schema);
    if (!conf.isPresent()) {
        PlainSchema plainSchema = plainSchemaDAO.find(schema);
        if (plainSchema == null) {
            throw new NotFoundException("Configuration schema " + schema);
        }
    }
    confDAO.delete(schema);
}
Also used : NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) PlainSchema(org.apache.syncope.core.persistence.api.entity.PlainSchema) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 52 with NotFoundException

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

the class ConnectorHistoryLogic method delete.

@PreAuthorize("hasRole('" + StandardEntitlement.CONNECTOR_HISTORY_DELETE + "')")
public void delete(final String key) {
    ConnInstanceHistoryConf connInstanceHistoryConf = connInstanceHistoryConfDAO.find(key);
    if (connInstanceHistoryConf == null) {
        throw new NotFoundException("Connector History Conf '" + key + "'");
    }
    connInstanceHistoryConfDAO.delete(key);
}
Also used : ConnInstanceHistoryConf(org.apache.syncope.core.persistence.api.entity.ConnInstanceHistoryConf) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 53 with NotFoundException

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

the class ConnectorLogic method delete.

@PreAuthorize("hasRole('" + StandardEntitlement.CONNECTOR_DELETE + "')")
public ConnInstanceTO delete(final String key) {
    ConnInstance connInstance = connInstanceDAO.authFind(key);
    if (connInstance == null) {
        throw new NotFoundException("Connector '" + key + "'");
    }
    Set<String> effectiveRealms = RealmUtils.getEffective(AuthContextUtils.getAuthorizations().get(StandardEntitlement.CONNECTOR_DELETE), connInstance.getAdminRealm().getFullPath());
    securityChecks(effectiveRealms, connInstance.getAdminRealm().getFullPath(), connInstance.getKey());
    if (!connInstance.getResources().isEmpty()) {
        SyncopeClientException associatedResources = SyncopeClientException.build(ClientExceptionType.AssociatedResources);
        connInstance.getResources().forEach(resource -> {
            associatedResources.getElements().add(resource.getKey());
        });
        throw associatedResources;
    }
    ConnInstanceTO deleted = binder.getConnInstanceTO(connInstance);
    connInstanceDAO.delete(key);
    return deleted;
}
Also used : ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) ConnInstance(org.apache.syncope.core.persistence.api.entity.ConnInstance) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 54 with NotFoundException

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

the class ConnectorLogic method read.

@PreAuthorize("hasRole('" + StandardEntitlement.CONNECTOR_READ + "')")
@Transactional(readOnly = true)
public ConnInstanceTO read(final String key, final String lang) {
    CurrentLocale.set(StringUtils.isBlank(lang) ? Locale.ENGLISH : new Locale(lang));
    ConnInstance connInstance = connInstanceDAO.authFind(key);
    if (connInstance == null) {
        throw new NotFoundException("Connector '" + key + "'");
    }
    return binder.getConnInstanceTO(connInstance);
}
Also used : Locale(java.util.Locale) CurrentLocale(org.identityconnectors.common.l10n.CurrentLocale) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) ConnInstance(org.apache.syncope.core.persistence.api.entity.ConnInstance) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Transactional(org.springframework.transaction.annotation.Transactional)

Example 55 with NotFoundException

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

the class DomainLogic method delete.

@PreAuthorize("hasRole('" + StandardEntitlement.DOMAIN_DELETE + "') and authentication.details.domain == " + "T(org.apache.syncope.common.lib.SyncopeConstants).MASTER_DOMAIN")
public DomainTO delete(final String key) {
    Domain domain = domainDAO.find(key);
    if (domain == null) {
        LOG.error("Could not find domain '" + key + "'");
        throw new NotFoundException(key);
    }
    DomainTO deleted = binder.getDomainTO(domain);
    domainDAO.delete(key);
    return deleted;
}
Also used : DomainTO(org.apache.syncope.common.lib.to.DomainTO) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) Domain(org.apache.syncope.core.persistence.api.entity.Domain) 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