Search in sources :

Example 21 with NotFoundException

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

the class RoleLogic method getConsoleLayoutInfo.

@PreAuthorize("isAuthenticated()")
public String getConsoleLayoutInfo(final String key) {
    Role role = roleDAO.find(key);
    if (role == null) {
        LOG.error("Could not find role '" + key + "'");
        throw new NotFoundException(key);
    }
    String consoleLayout = role.getConsoleLayoutInfo();
    if (StringUtils.isBlank(consoleLayout)) {
        LOG.error("Could not find console layout for Role '" + key + "'");
        throw new NotFoundException("Console layout for role " + key);
    }
    return consoleLayout;
}
Also used : Role(org.apache.syncope.core.persistence.api.entity.Role) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 22 with NotFoundException

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

the class RoleLogic method delete.

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

Example 23 with NotFoundException

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

the class RoleLogic method setConsoleLayoutInfo.

@PreAuthorize("hasRole('" + StandardEntitlement.ROLE_UPDATE + "')")
public void setConsoleLayoutInfo(final String key, final String consoleLayout) {
    Role role = roleDAO.find(key);
    if (role == null) {
        LOG.error("Could not find role '" + key + "'");
        throw new NotFoundException(key);
    }
    role.setConsoleLayoutInfo(consoleLayout);
    roleDAO.save(role);
}
Also used : Role(org.apache.syncope.core.persistence.api.entity.Role) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 24 with NotFoundException

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

the class SchemaLogic method update.

@PreAuthorize("hasRole('" + StandardEntitlement.SCHEMA_UPDATE + "')")
public <T extends SchemaTO> void update(final SchemaType schemaType, final T schemaTO) {
    if (!doesSchemaExist(schemaType, schemaTO.getKey())) {
        throw new NotFoundException(schemaType + "/" + schemaTO.getKey());
    }
    switch(schemaType) {
        case VIRTUAL:
            VirSchema virSchema = virSchemaDAO.find(schemaTO.getKey());
            if (virSchema == null) {
                throw new NotFoundException("Virtual Schema '" + schemaTO.getKey() + "'");
            }
            virSchemaDAO.save(binder.update((VirSchemaTO) schemaTO, virSchema));
            break;
        case DERIVED:
            DerSchema derSchema = derSchemaDAO.find(schemaTO.getKey());
            if (derSchema == null) {
                throw new NotFoundException("Derived schema '" + schemaTO.getKey() + "'");
            }
            derSchemaDAO.save(binder.update((DerSchemaTO) schemaTO, derSchema));
            break;
        case PLAIN:
        default:
            PlainSchema plainSchema = plainSchemaDAO.find(schemaTO.getKey());
            if (plainSchema == null) {
                throw new NotFoundException("Schema '" + schemaTO.getKey() + "'");
            }
            plainSchemaDAO.save(binder.update((PlainSchemaTO) schemaTO, plainSchema));
    }
}
Also used : PlainSchemaTO(org.apache.syncope.common.lib.to.PlainSchemaTO) DerSchema(org.apache.syncope.core.persistence.api.entity.DerSchema) VirSchema(org.apache.syncope.core.persistence.api.entity.VirSchema) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) VirSchemaTO(org.apache.syncope.common.lib.to.VirSchemaTO) DerSchemaTO(org.apache.syncope.common.lib.to.DerSchemaTO) PlainSchema(org.apache.syncope.core.persistence.api.entity.PlainSchema) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 25 with NotFoundException

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

the class SchemaLogic method read.

@PreAuthorize("isAuthenticated()")
@SuppressWarnings("unchecked")
public <T extends SchemaTO> T read(final SchemaType schemaType, final String schemaKey) {
    T read;
    switch(schemaType) {
        case VIRTUAL:
            VirSchema virSchema = virSchemaDAO.find(schemaKey);
            if (virSchema == null) {
                throw new NotFoundException("Virtual Schema '" + schemaKey + "'");
            }
            read = (T) binder.getVirSchemaTO(virSchema);
            break;
        case DERIVED:
            DerSchema derSchema = derSchemaDAO.find(schemaKey);
            if (derSchema == null) {
                throw new NotFoundException("Derived schema '" + schemaKey + "'");
            }
            read = (T) binder.getDerSchemaTO(derSchema);
            break;
        case PLAIN:
        default:
            PlainSchema schema = plainSchemaDAO.find(schemaKey);
            if (schema == null) {
                throw new NotFoundException("Schema '" + schemaKey + "'");
            }
            read = (T) binder.getPlainSchemaTO(schema);
    }
    return read;
}
Also used : DerSchema(org.apache.syncope.core.persistence.api.entity.DerSchema) VirSchema(org.apache.syncope.core.persistence.api.entity.VirSchema) 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)

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