protected ManageableObjects doGetCollection()

in src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/NTCollectionConverterImpl.java [208:245]


    protected ManageableObjects doGetCollection(Session session,
                                                   Node parentNode,
                                                   CollectionDescriptor collectionDescriptor,
                                                   Class collectionFieldClass) throws RepositoryException {
	    ClassDescriptor elementClassDescriptor = mapper.getClassDescriptorByClass( ReflectionUtils.forName(collectionDescriptor.getElementClassName()));
        ManageableObjects objects = ManageableObjectsUtil.getManageableObjects(collectionFieldClass);

        NodeIterator nodes = this.getCollectionNodes(session, parentNode, elementClassDescriptor.getJcrType());

        if (nodes == null || nodes.getSize() == 0)
        {
        	return null;
        }

        while (nodes.hasNext()) {
            Node itemNode = (Node) nodes.next();
            log.debug("Collection node found : " + itemNode.getPath());
            Object item = objectConverter.getObject(session,  itemNode.getPath());
            mapper.getClassDescriptorByClass(item.getClass());
            if ( objects instanceof ManageableCollection)
            	((ManageableCollection)objects).addObject(item);
            else {
            	if (!elementClassDescriptor.hasIdField())
            	{
            		throw new JcrMappingException("Impossible to use a map for the field : "
            				                      + collectionDescriptor.getFieldName()
            				                      + "in the class : " + collectionDescriptor.getCollectionClassName()
            				                      + ". The element objects have no id field (check their OCM mapping)");
            	}
            	Object elementId = ReflectionUtils.getNestedProperty(item,
            			                           elementClassDescriptor.getIdFieldDescriptor().getFieldName());
                ((ManageableMap) objects).addObject(elementId, item);
            }

        }

        return objects;
    }