public boolean add()

in src/main/java/org/apache/sling/resource/collection/impl/ResourceCollectionImpl.java [99:118]


    public boolean add(Resource res, Map<String, Object> properties) throws PersistenceException {
        if (res != null && !contains(res)) {
            ModifiableValueMap vm = membersResource.adaptTo(ModifiableValueMap.class);
            String[] order = vm.get(ResourceCollectionConstants.REFERENCES_PROP, new String[] {});

            order = ArrayUtils.add(order, res.getPath());
            vm.put(ResourceCollectionConstants.REFERENCES_PROP, order);

            if (properties == null) {
                properties = new HashMap<>();
            }
            properties.put(ResourceCollectionConstants.REF_PROPERTY, res.getPath());
            resolver.create(
                    membersResource, ResourceUtil.createUniqueChildName(membersResource, res.getName()), properties);
            log.debug("added member to resource {} to collection {}", new String[] {res.getPath(), resource.getPath()});
            return true;
        }

        return false;
    }