@PreAuthorize("hasRole('" + StandardEntitlement.DOMAIN_CREATE + "') and authentication.details.domain == " + "T(org.apache.syncope.common.lib.SyncopeConstants).MASTER_DOMAIN") public DomainTO create(final DomainTO domainTO) { if (!domainsHolder.getDomains().keySet().contains(domainTO.getKey())) { throw new NotFoundException("No configuration is available for domain " + domainTO.getKey()); } return binder.getDomainTO(domainDAO.save(binder.create(domainTO))); }
@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); }
@PreAuthorize("hasRole('" + StandardEntitlement.DOMAIN_READ + "') and authentication.details.domain == " + "T(org.apache.syncope.common.lib.SyncopeConstants).MASTER_DOMAIN") @Transactional(readOnly = true) public DomainTO read(final String key) { Domain domain = domainDAO.find(key); if (domain == null) { LOG.error("Could not find domain '" + key + "'"); throw new NotFoundException(key); } return binder.getDomainTO(domain); }
@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; }
@Override protected DomainTO 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 DomainTO) { key = ((DomainTO) args[i]).getKey(); } } } if (StringUtils.isNotBlank(key)) { try { return binder.getDomainTO(domainDAO.find(key)); } catch (Throwable ignore) { LOG.debug("Unresolved reference", ignore); throw new UnresolvedReferenceException(ignore); } } throw new UnresolvedReferenceException(); }