/** * Set the related node's identifier. Alias for name property. * * @param node * The related node. */ public void setNode(final String node) { setName(node); } }
/** * Validate the user changes regarding the current user's right. * Rules, order is important : * <ul> * <li>Related node must be managed by the current user, directly or via a another parent delegate or act as if the * company does not exist.</li> * <li>'write' flag cannot be <code>true</code> without already owning an applicable delegate with this flag.</li> * <li>'admin' flag cannot be <code>true</code> without already owning an applicable delegate with this flag.</li> * </ul> * Target user is not checked. * * @return Created delegate. */ private DelegateNode validateSaveOrUpdate(final DelegateNode entity) { // Get all delegates of current user final String node = entity.getName(); // Check there is at least one delegate for this user allowing him to update/create this delegate if (repository.manageNode(securityHelper.getLogin(), node, entity.isCanWrite()) == 0) { throw new NotFoundException(); } return repository.saveAndFlush(entity); }
/** * Create a delegate. Rules are : * <ul> * <li>Related node must be managed by the current user, directly or via a another parent delegate.</li> * <li>'write' flag cannot be <code>true</code> without already owning an applicable delegate with this flag.</li> * <li>At least one delegate with 'admin' flag must be present for the current user and the related node.</li> * </ul> * . * Target user is not checked. * * @param vo * the object to create. * @return the entity's identifier. */ @POST public int create(final DelegateNode vo) { return validateSaveOrUpdate(vo).getId(); }