/** * Return all normalized containers where key is the identifier. Note the result does not use cache, so reflect the * current state of internal representation and implies a poor performance. Cache manager is not involved. * * @return the whole set of containers. Key is the normalized identifier. Value is the corresponding LDAP container * containing real CN, DN and normalized UID members. * * @since 3.0.2 */ default Map<String, T> findAllNoCache() { return findAll(); }
/** * 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. 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); }
protected String getTypeName() { return getRepository().getTypeName(); } }
/** * Find a container from its identifier. If the container is not found or * cannot be seen by the current user, the error code * {@link org.ligoj.bootstrap.core.resource.BusinessException#KEY_UNKNOW_ID} * will be returned. * * @param id * The container's identifier. Will be normalized. * @return The container from its identifier. */ public T findByIdExpected(final String id) { return getRepository().findByIdExpected(securityHelper.getLogin(), id); }
/** * Delete an existing container.<br> * The delegation system is involved for this operation and requires * administration privilege on this container. * * @param id * The container's identifier. */ @DELETE @Path("{id}") public void delete(@PathParam("id") final String id) { // Check the container exists final T container = findByIdExpected(id); // Check the container can be deleted by current user checkForDeletion(container); // Perform the deletion when checked getRepository().delete(container); }
protected T create(final V container, final ContainerScope type, final String newDn) { log.info("Creating a {}@{}-{} '{}'", this.type, type.getName(), type.getId(), container.getName()); return getRepository().create(newDn, container.getName()); }
/** * 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); }
/** * Return the container corresponding to the given identifier using the user cache. * * @param id * The container's identifier. Case is sensitive. Corresponds to the normalized container's name. * @return The container corresponding to the given identifier. May be <code>null</code> */ default T findById(final String id) { return findAll().get(id); }
if (getRepository().findById(Normalizer.normalize(container.getName())) != null) { throw new ValidationJsonException("name", "already-exist", "0", getTypeName(), "1", container.getName());
/** * Return the internal representation of the container set. Not existing * cache items are removed. * * @param cacheItems * The database base cache containers to convert. * @return The internal representation of container set. Ordered is kept. */ protected Set<T> toInternal(final Collection<C> cacheItems) { return cacheItems.stream().map(CacheContainer::getId).map(getRepository().findAll()::get).filter(Objects::nonNull) .collect(Collectors.toCollection(LinkedHashSet::new)); }