protected ManageableObjects doGetCollection()

in src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/MultiValueCollectionConverterImpl.java [152:197]


    protected ManageableObjects doGetCollection(Session session,
                                                   Node parentNode,
                                                   CollectionDescriptor collectionDescriptor,
                                                   Class collectionFieldClass) throws RepositoryException {
        try {
            String jcrName = getCollectionJcrName(collectionDescriptor);
            if (!parentNode.hasProperty(jcrName)) {
                return null;
            }
            Property property = parentNode.getProperty(jcrName);
            Value[] values = property.getValues();

            ManageableObjects objects = ManageableObjectsUtil.getManageableObjects(collectionFieldClass);
            String elementClassName = collectionDescriptor.getElementClassName();
            Class elementClass = ReflectionUtils.forName(elementClassName);
            // For multi value collections, only Collections are supported
            if (! (objects instanceof ManageableCollection))
            {

            	throw new JcrMappingException("Impossible to retrieve the attribute "
            			+ collectionDescriptor.getFieldName() + " in the class "
            			+ collectionDescriptor.getClassDescriptor().getClassName()
            			+  " because it is not a collection");
            }

            for (int i = 0; i < values.length; i++) {
                AtomicTypeConverter atomicTypeConverter = (AtomicTypeConverter) atomicTypeConverters
                    .get(elementClass);
                //If there is no proper conversion strategy defined for a specific bean type
                //then system will make a best effort conversion strategy using UndefinedTypeConverter.
                //@author:Boni Gopalan
                if (atomicTypeConverter == null){
                	atomicTypeConverter = new UndefinedTypeConverterImpl();
                }
                ((ManageableCollection) objects).addObject(atomicTypeConverter.getObject(values[i]));
            }

            return objects;
        }
        catch(ValueFormatException vfe) {
          throw new ObjectContentManagerException("Cannot get the collection field : "
                  + collectionDescriptor.getFieldName()
                  + "for class " + collectionDescriptor.getClassDescriptor().getClassName(),
                  vfe);
        }
    }