@PreAuthorize("hasRole('" + StandardEntitlement.RELATIONSHIPTYPE_CREATE + "')") public RelationshipTypeTO create(final RelationshipTypeTO relationshipTypeTO) { return binder.getRelationshipTypeTO(relationshipTypeDAO.save(binder.create(relationshipTypeTO))); }
@PreAuthorize("hasRole('" + StandardEntitlement.RELATIONSHIPTYPE_UPDATE + "')") public RelationshipTypeTO update(final RelationshipTypeTO relationshipTypeTO) { RelationshipType relationshipType = relationshipTypeDAO.find(relationshipTypeTO.getKey()); if (relationshipType == null) { LOG.error("Could not find relationshipType '" + relationshipTypeTO.getKey() + "'"); throw new NotFoundException(relationshipTypeTO.getKey()); } binder.update(relationshipType, relationshipTypeTO); relationshipType = relationshipTypeDAO.save(relationshipType); return binder.getRelationshipTypeTO(relationshipType); }
@PreAuthorize("hasRole('" + StandardEntitlement.RELATIONSHIPTYPE_READ + "')") @Transactional(readOnly = true) public RelationshipTypeTO read(final String key) { RelationshipType relationshipType = relationshipTypeDAO.find(key); if (relationshipType == null) { LOG.error("Could not find relationshipType '" + key + "'"); throw new NotFoundException(key); } return binder.getRelationshipTypeTO(relationshipType); }
@PreAuthorize("hasRole('" + StandardEntitlement.RELATIONSHIPTYPE_DELETE + "')") public RelationshipTypeTO delete(final String key) { RelationshipType relationshipType = relationshipTypeDAO.find(key); if (relationshipType == null) { LOG.error("Could not find relationshipType '" + key + "'"); throw new NotFoundException(key); } RelationshipTypeTO deleted = binder.getRelationshipTypeTO(relationshipType); relationshipTypeDAO.delete(key); return deleted; }
@Override protected RelationshipTypeTO 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 Long) { key = (String) args[i]; } else if (args[i] instanceof RelationshipTypeTO) { key = ((RelationshipTypeTO) args[i]).getKey(); } } } if (StringUtils.isNotBlank(key)) { try { return binder.getRelationshipTypeTO(relationshipTypeDAO.find(key)); } catch (Throwable ignore) { LOG.debug("Unresolved reference", ignore); throw new UnresolvedReferenceException(ignore); } } throw new UnresolvedReferenceException(); }