/** * Find a container from its identifier. Security is applied regarding the given user. * * @param principal * The user requesting this container. * @param id * The container's identifier. Will be normalized. * @return The container from its identifier. <code>null</code> if the container is not found or cannot be seen by * the given principal user. */ default T findById(String principal, String id) { return findById(id); }
/** * Find a container from its identifier. Security is applied regarding the given user. * * @param principal * The user requesting this container. * @param id * The container's identifier. Will be normalized. * @return The container from its identifier. Never <code>null</code>. * @throws ValidationJsonException * If the container is not found or cannot be seen by the given user. */ default T findByIdExpected(String principal, String id) { // Check the container exists and return the in memory object. return Optional.ofNullable(findById(principal, id)).orElseThrow( () -> new ValidationJsonException(getTypeName(), BusinessException.KEY_UNKNOW_ID, "0", "id", "1", id)); }
/** * Find a container from its identifier. * * @param id * The container's identifier. Will be normalized. * @return The container from its identifier. <code>null</code> if the * container is not found or cannot be seen by the current user */ public T findById(final String id) { return getRepository().findById(securityHelper.getLogin(), id); }
if (getRepository().findById(Normalizer.normalize(container.getName())) != null) { throw new ValidationJsonException("name", "already-exist", "0", getTypeName(), "1", container.getName());