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;
}
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;
}
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);
}
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));
}
}
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;
}
Aggregations