use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.
the class DomainLogic method update.
@PreAuthorize("hasRole('" + StandardEntitlement.DOMAIN_UPDATE + "') and authentication.details.domain == " + "T(org.apache.syncope.common.lib.SyncopeConstants).MASTER_DOMAIN")
public DomainTO update(final DomainTO domainTO) {
Domain domain = domainDAO.find(domainTO.getKey());
if (domain == null) {
LOG.error("Could not find domain '" + domainTO.getKey() + "'");
throw new NotFoundException(domainTO.getKey());
}
binder.update(domain, domainTO);
domain = domainDAO.save(domain);
return binder.getDomainTO(domain);
}
use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.
the class ImplementationLogic method update.
@PreAuthorize("hasRole('" + StandardEntitlement.IMPLEMENTATION_UPDATE + "')")
public ImplementationTO update(final ImplementationTO implementationTO) {
Implementation implementation = implementationDAO.find(implementationTO.getKey());
if (implementation == null) {
LOG.error("Could not find implementation '" + implementationTO.getKey() + "'");
throw new NotFoundException(implementationTO.getKey());
}
binder.update(implementation, implementationTO);
implementation = implementationDAO.save(implementation);
return binder.getImplementationTO(implementation);
}
use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.
the class SCIMExceptionMapper method toResponse.
@Override
public Response toResponse(final Exception ex) {
LOG.error("Exception thrown", ex);
ResponseBuilder builder;
if (ex instanceof AccessDeniedException || ex instanceof ForbiddenException || ex instanceof NotAuthorizedException) {
// leaves the default exception processing
builder = null;
} else if (ex instanceof NotFoundException) {
return Response.status(Response.Status.NOT_FOUND).entity(new SCIMError(null, Response.Status.NOT_FOUND.getStatusCode(), ExceptionUtils.getRootCauseMessage(ex))).build();
} else if (ex instanceof SyncopeClientException) {
SyncopeClientException sce = (SyncopeClientException) ex;
builder = builder(sce.getType(), ExceptionUtils.getRootCauseMessage(ex));
} else if (ex instanceof DelegatedAdministrationException || ExceptionUtils.getRootCause(ex) instanceof DelegatedAdministrationException) {
builder = builder(ClientExceptionType.DelegatedAdministration, ExceptionUtils.getRootCauseMessage(ex));
} else if (ENTITYEXISTS_EXCLASS.isAssignableFrom(ex.getClass()) || ex instanceof DuplicateException || PERSISTENCE_EXCLASS.isAssignableFrom(ex.getClass()) && ENTITYEXISTS_EXCLASS.isAssignableFrom(ex.getCause().getClass())) {
builder = builder(ClientExceptionType.EntityExists, ExceptionUtils.getRootCauseMessage(ex));
} else if (ex instanceof DataIntegrityViolationException || JPASYSTEM_EXCLASS.isAssignableFrom(ex.getClass())) {
builder = builder(ClientExceptionType.DataIntegrityViolation, ExceptionUtils.getRootCauseMessage(ex));
} else if (CONNECTOR_EXCLASS.isAssignableFrom(ex.getClass())) {
builder = builder(ClientExceptionType.ConnectorException, ExceptionUtils.getRootCauseMessage(ex));
} else {
builder = processInvalidEntityExceptions(ex);
if (builder == null) {
builder = processBadRequestExceptions(ex);
}
// process JAX-RS validation errors
if (builder == null && ex instanceof ValidationException) {
builder = builder(ClientExceptionType.RESTValidation, ExceptionUtils.getRootCauseMessage(ex));
}
// ...or just report as InternalServerError
if (builder == null) {
builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(ExceptionUtils.getRootCauseMessage(ex));
}
}
return builder == null ? null : builder.build();
}
use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.
the class SAML2IdPLogic method read.
@PreAuthorize("hasRole('" + SAML2SPEntitlement.IDP_READ + "')")
@Transactional(readOnly = true)
public SAML2IdPTO read(final String key) {
check();
SAML2IdP idp = idpDAO.find(key);
if (idp == null) {
throw new NotFoundException("SAML 2.0 IdP '" + key + "'");
}
return complete(idp, binder.getIdPTO(idp));
}
use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.
the class SAML2IdPLogic method delete.
@PreAuthorize("hasRole('" + SAML2SPEntitlement.IDP_DELETE + "')")
public void delete(final String key) {
check();
SAML2IdP idp = idpDAO.find(key);
if (idp == null) {
throw new NotFoundException("SAML 2.0 IdP '" + key + "'");
}
idpDAO.delete(key);
cache.remove(idp.getEntityID());
}
Aggregations