@PreAuthorize("hasRole('" + StandardEntitlement.IMPLEMENTATION_CREATE + "')") public ImplementationTO create(final ImplementationTO implementationTO) { if (StringUtils.isBlank(implementationTO.getKey())) { SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.RequiredValuesMissing); sce.getElements().add("Implementation key"); throw sce; } Implementation implementation = implementationDAO.find(implementationTO.getKey()); if (implementation != null) { throw new DuplicateException(implementationTO.getKey()); } return binder.getImplementationTO(implementationDAO.save(binder.create(implementationTO))); }
@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); }
@PreAuthorize("hasRole('" + StandardEntitlement.IMPLEMENTATION_READ + "')") @Transactional(readOnly = true) public ImplementationTO read(final ImplementationType type, final String key) { Implementation implementation = implementationDAO.find(key); if (implementation == null) { LOG.error("Could not find implementation '" + key + "'"); throw new NotFoundException(key); } if (implementation.getType() != type) { SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRequest); sce.getElements().add("Found " + type + ", expected " + implementation.getType()); throw sce; } return binder.getImplementationTO(implementation); }
@Override protected ImplementationTO resolveReference(final Method method, final Object... args) throws UnresolvedReferenceException { String key = null; if (ArrayUtils.isNotEmpty(args)) { for (int i = 0; key == null && i < args.length; i++) { if (args[i] instanceof String) { key = (String) args[i]; } else if (args[i] instanceof ImplementationTO) { key = ((ImplementationTO) args[i]).getKey(); } } } if (StringUtils.isNotBlank(key)) { try { return binder.getImplementationTO(implementationDAO.find(key)); } catch (Throwable ignore) { LOG.debug("Unresolved reference", ignore); throw new UnresolvedReferenceException(ignore); } } throw new UnresolvedReferenceException(); }