public Collection getObjects()

in src/main/java/org/apache/jackrabbit/ocm/manager/impl/ObjectContentManagerImpl.java [514:566]


    public Collection getObjects(Class objectClass, String path) throws ObjectContentManagerException {
        final ClassDescriptor classDescriptorByClass = mapper.getClassDescriptorByClass(objectClass);
        if (classDescriptorByClass == null) {
            log.debug("Cannot get objects because no descriptor class exists for '{}'", objectClass.getClass().getName());
            return Collections.emptyList();
        }
        try {
            if (!session.nodeExists(path)) {
                log.debug("Cannot get objects '{}' because no node exists at '{}'", objectClass.getClass().getName(), path);
                return Collections.emptyList();
            }
            Node parentNode = session.getNode(path).getParent();
            String nodeName = NodeUtil.getNodeName(path);
            if (StringUtils.isBlank(nodeName)) {
                nodeName = null;
            }
            NodeIterator candidates = parentNode.getNodes();
            List<Node> validated = new ArrayList<Node>();
            while (candidates.hasNext()) {
                Node child = candidates.nextNode();
                if (nodeName != null && !child.getName().equals(nodeName)) {
                    continue;
                }
                if (child.hasProperty(ManagerConstant.DISCRIMINATOR_CLASS_NAME_PROPERTY)) {
                    if (child.getProperty(ManagerConstant.DISCRIMINATOR_CLASS_NAME_PROPERTY).getString().equals(classDescriptorByClass.getClassName())) {
                        // the discriminator class name matches. This is an object we need
                        validated.add(child);
                    }
                } else {
                    if (child.getPrimaryNodeType().getName().equals(classDescriptorByClass.getJcrType())) {
                        // nodetype matches
                        validated.add(child);
                    }
                }
            }
            Collection result = new ArrayList();
            for (Node n : validated) {
                Object object = objectConverter.getObject(session, n.getPath());
                if (object == null) {
                    log.debug("Could not get object for '{}'", n.getPath());
                    continue;
                }
                // double check whether object is the same or a subclass of objectClass
                if (objectClass.isAssignableFrom(object.getClass())) {
                    result.add(object);
                }
            }
            return result;
        } catch (RepositoryException e) {
            throw new org.apache.jackrabbit.ocm.exception.RepositoryException("Impossible to get the objects at " + path, e);
        }
        
    }