chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dcaru...@apache.org
Subject svn commit: r934889 [4/5] - in /incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src: main/java/org/apache/chemistry/opencmis/client/ main/java/org/apache/chemistry/opencmis/client/runtime/ main/java/org/apach...
Date Fri, 16 Apr 2010 14:07:12 GMT
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/FolderTypeImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/FolderTypeImpl.java?rev=934889&r1=934888&r2=934889&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/FolderTypeImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/FolderTypeImpl.java Fri Apr 16 14:07:11 2010
@@ -31,37 +31,35 @@ import org.apache.chemistry.opencmis.com
 /**
  * Folder type.
  */
-public class FolderTypeImpl extends FolderTypeDefinitionImpl implements
-        FolderType {
+public class FolderTypeImpl extends FolderTypeDefinitionImpl implements FolderType {
 
-    private static final long serialVersionUID = 1L;
+	private static final long serialVersionUID = 1L;
 
-    private ObjectTypeHelper helper;
+	private ObjectTypeHelper helper;
 
-    public FolderTypeImpl(Session session,
-            FolderTypeDefinition typeDefinition) {
-        initialize(typeDefinition);
-        helper = new ObjectTypeHelper(session, this);
-    }
-
-    public ObjectType getBaseType() {
-        return helper.getBaseType();
-    }
-
-    public PagingList<ObjectType> getChildren(int itemsPerPage) {
-        return helper.getChildren(itemsPerPage);
-    }
-
-    public List<Tree<ObjectType>> getDescendants(int depth) {
-        return helper.getDescendants(depth);
-    }
-
-    public ObjectType getParentType() {
-        return helper.getParentType();
-    }
-
-    public boolean isBaseType() {
-        return helper.isBaseType();
-    }
+	public FolderTypeImpl(Session session, FolderTypeDefinition typeDefinition) {
+		initialize(typeDefinition);
+		helper = new ObjectTypeHelper(session, this);
+	}
+
+	public ObjectType getBaseType() {
+		return helper.getBaseType();
+	}
+
+	public PagingList<ObjectType> getChildren(int itemsPerPage) {
+		return helper.getChildren(itemsPerPage);
+	}
+
+	public List<Tree<ObjectType>> getDescendants(int depth) {
+		return helper.getDescendants(depth);
+	}
+
+	public ObjectType getParentType() {
+		return helper.getParentType();
+	}
+
+	public boolean isBaseType() {
+		return helper.isBaseType();
+	}
 
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/ObjectTypeHelper.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/ObjectTypeHelper.java?rev=934889&r1=934888&r2=934889&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/ObjectTypeHelper.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/ObjectTypeHelper.java Fri Apr 16 14:07:11 2010
@@ -32,55 +32,54 @@ import org.apache.chemistry.opencmis.cli
  */
 public class ObjectTypeHelper {
 
-    private Session session;
-    private ObjectType objectType;
-    private ObjectType baseType;
-    private ObjectType parentType;
-
-    public ObjectTypeHelper(Session session, ObjectType objectType) {
-        this.session = session;
-        this.objectType = objectType;
-    }
-
-    public Session getSession() {
-        return session;
-    }
-
-    public boolean isBaseType() {
-        return objectType.getParentTypeId() == null;
-    }
-
-    public ObjectType getBaseType() {
-        if (isBaseType()) {
-            return null;
-        }
-        if (baseType != null) {
-            return baseType;
-        }
-        if (objectType.getBaseTypeId() == null) {
-            return null;
-        }
-        baseType = session
-                .getTypeDefinition(objectType.getBaseTypeId().value());
-        return baseType;
-    }
-
-    public ObjectType getParentType() {
-        if (parentType != null) {
-            return parentType;
-        }
-        if (objectType.getParentTypeId() == null) {
-            return null;
-        }
-        parentType = session.getTypeDefinition(objectType.getParentTypeId());
-        return parentType;
-    }
-
-    public PagingList<ObjectType> getChildren(int itemsPerPage) {
-        return session.getTypeChildren(objectType.getId(), true, itemsPerPage);
-    }
-
-    public List<Tree<ObjectType>> getDescendants(int depth) {
-        return session.getTypeDescendants(objectType.getId(), depth, true);
-    }
+	private Session session;
+	private ObjectType objectType;
+	private ObjectType baseType;
+	private ObjectType parentType;
+
+	public ObjectTypeHelper(Session session, ObjectType objectType) {
+		this.session = session;
+		this.objectType = objectType;
+	}
+
+	public Session getSession() {
+		return session;
+	}
+
+	public boolean isBaseType() {
+		return objectType.getParentTypeId() == null;
+	}
+
+	public ObjectType getBaseType() {
+		if (isBaseType()) {
+			return null;
+		}
+		if (baseType != null) {
+			return baseType;
+		}
+		if (objectType.getBaseTypeId() == null) {
+			return null;
+		}
+		baseType = session.getTypeDefinition(objectType.getBaseTypeId().value());
+		return baseType;
+	}
+
+	public ObjectType getParentType() {
+		if (parentType != null) {
+			return parentType;
+		}
+		if (objectType.getParentTypeId() == null) {
+			return null;
+		}
+		parentType = session.getTypeDefinition(objectType.getParentTypeId());
+		return parentType;
+	}
+
+	public PagingList<ObjectType> getChildren(int itemsPerPage) {
+		return session.getTypeChildren(objectType.getId(), true, itemsPerPage);
+	}
+
+	public List<Tree<ObjectType>> getDescendants(int depth) {
+		return session.getTypeDescendants(objectType.getId(), depth, true);
+	}
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/PolicyTypeImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/PolicyTypeImpl.java?rev=934889&r1=934888&r2=934889&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/PolicyTypeImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/PolicyTypeImpl.java Fri Apr 16 14:07:11 2010
@@ -31,37 +31,35 @@ import org.apache.chemistry.opencmis.com
 /**
  * Policy type.
  */
-public class PolicyTypeImpl extends PolicyTypeDefinitionImpl implements
-        PolicyType {
+public class PolicyTypeImpl extends PolicyTypeDefinitionImpl implements PolicyType {
 
-    private static final long serialVersionUID = 1L;
+	private static final long serialVersionUID = 1L;
 
-    private ObjectTypeHelper helper;
+	private ObjectTypeHelper helper;
 
-    public PolicyTypeImpl(Session session,
-            PolicyTypeDefinition typeDefinition) {
-        initialize(typeDefinition);
-        helper = new ObjectTypeHelper(session, this);
-    }
-
-    public ObjectType getBaseType() {
-        return helper.getBaseType();
-    }
-
-    public PagingList<ObjectType> getChildren(int itemsPerPage) {
-        return helper.getChildren(itemsPerPage);
-    }
-
-    public List<Tree<ObjectType>> getDescendants(int depth) {
-        return helper.getDescendants(depth);
-    }
-
-    public ObjectType getParentType() {
-        return helper.getParentType();
-    }
-
-    public boolean isBaseType() {
-        return helper.isBaseType();
-    }
+	public PolicyTypeImpl(Session session, PolicyTypeDefinition typeDefinition) {
+		initialize(typeDefinition);
+		helper = new ObjectTypeHelper(session, this);
+	}
+
+	public ObjectType getBaseType() {
+		return helper.getBaseType();
+	}
+
+	public PagingList<ObjectType> getChildren(int itemsPerPage) {
+		return helper.getChildren(itemsPerPage);
+	}
+
+	public List<Tree<ObjectType>> getDescendants(int depth) {
+		return helper.getDescendants(depth);
+	}
+
+	public ObjectType getParentType() {
+		return helper.getParentType();
+	}
+
+	public boolean isBaseType() {
+		return helper.isBaseType();
+	}
 
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/RelationshipTypeImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/RelationshipTypeImpl.java?rev=934889&r1=934888&r2=934889&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/RelationshipTypeImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/RelationshipTypeImpl.java Fri Apr 16 14:07:11 2010
@@ -32,69 +32,65 @@ import org.apache.chemistry.opencmis.com
 /**
  * Relationship type.
  */
-public class RelationshipTypeImpl extends RelationshipTypeDefinitionImpl
-        implements RelationshipType {
+public class RelationshipTypeImpl extends RelationshipTypeDefinitionImpl implements RelationshipType {
 
-    private static final long serialVersionUID = 1L;
+	private static final long serialVersionUID = 1L;
 
-    private ObjectTypeHelper helper;
-    private List<ObjectType> allowedSourceTypes;
-    private List<ObjectType> allowedTargetTypes;
-
-    public RelationshipTypeImpl(Session session,
-            RelationshipTypeDefinition typeDefinition) {
-        initialize(typeDefinition);
-        helper = new ObjectTypeHelper(session, this);
-    }
-
-    public ObjectType getBaseType() {
-        return helper.getBaseType();
-    }
-
-    public PagingList<ObjectType> getChildren(int itemsPerPage) {
-        return helper.getChildren(itemsPerPage);
-    }
-
-    public List<Tree<ObjectType>> getDescendants(int depth) {
-        return helper.getDescendants(depth);
-    }
-
-    public ObjectType getParentType() {
-        return helper.getParentType();
-    }
-
-    public boolean isBaseType() {
-        return helper.isBaseType();
-    }
-
-    public List<ObjectType> getAllowedSourceTypes() {
-        if (allowedSourceTypes == null) {
-            List<String> ids = getAllowedSourceTypeIds();
-            List<ObjectType> types = new ArrayList<ObjectType>(ids == null ? 0
-                    : ids.size());
-            if (ids != null) {
-                for (String id : ids) {
-                    types.add(helper.getSession().getTypeDefinition(id));
-                }
-            }
-            allowedSourceTypes = types;
-        }
-        return allowedSourceTypes;
-    }
-
-    public List<ObjectType> getAllowedTargetTypes() {
-        if (allowedTargetTypes == null) {
-            List<String> ids = getAllowedTargetTypeIds();
-            List<ObjectType> types = new ArrayList<ObjectType>(ids == null ? 0
-                    : ids.size());
-            if (ids != null) {
-                for (String id : ids) {
-                    types.add(helper.getSession().getTypeDefinition(id));
-                }
-            }
-            allowedTargetTypes = types;
-        }
-        return allowedTargetTypes;
-    }
+	private ObjectTypeHelper helper;
+	private List<ObjectType> allowedSourceTypes;
+	private List<ObjectType> allowedTargetTypes;
+
+	public RelationshipTypeImpl(Session session, RelationshipTypeDefinition typeDefinition) {
+		initialize(typeDefinition);
+		helper = new ObjectTypeHelper(session, this);
+	}
+
+	public ObjectType getBaseType() {
+		return helper.getBaseType();
+	}
+
+	public PagingList<ObjectType> getChildren(int itemsPerPage) {
+		return helper.getChildren(itemsPerPage);
+	}
+
+	public List<Tree<ObjectType>> getDescendants(int depth) {
+		return helper.getDescendants(depth);
+	}
+
+	public ObjectType getParentType() {
+		return helper.getParentType();
+	}
+
+	public boolean isBaseType() {
+		return helper.isBaseType();
+	}
+
+	public List<ObjectType> getAllowedSourceTypes() {
+		if (allowedSourceTypes == null) {
+			List<String> ids = getAllowedSourceTypeIds();
+			List<ObjectType> types = new ArrayList<ObjectType>(ids == null ? 0 : ids.size());
+			if (ids != null) {
+				for (String id : ids) {
+					types.add(helper.getSession().getTypeDefinition(id));
+				}
+			}
+			allowedSourceTypes = types;
+		}
+		return allowedSourceTypes;
+	}
+
+	public List<ObjectType> getAllowedTargetTypes() {
+		if (allowedTargetTypes == null) {
+			List<String> ids = getAllowedTargetTypeIds();
+			List<ObjectType> types = new ArrayList<ObjectType>(ids == null ? 0 : ids.size());
+			if (ids != null) {
+				for (String id : ids) {
+					types.add(helper.getSession().getTypeDefinition(id));
+				}
+			}
+			allowedTargetTypes = types;
+		}
+		return allowedTargetTypes;
+	}
 
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/PersistentObjectFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/PersistentObjectFactoryImpl.java?rev=934889&r1=934888&r2=934889&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/PersistentObjectFactoryImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/PersistentObjectFactoryImpl.java Fri Apr 16 14:07:11 2010
@@ -84,552 +84,514 @@ import org.apache.chemistry.opencmis.com
  */
 public class PersistentObjectFactoryImpl implements ObjectFactory, Serializable {
 
-  private static final long serialVersionUID = 1L;
+	private static final long serialVersionUID = 1L;
 
-  private PersistentSessionImpl session = null;
+	private PersistentSessionImpl session = null;
 
-  /**
-   * Constructor.
-   */
-  protected PersistentObjectFactoryImpl(PersistentSessionImpl session) {
-    if (session == null) {
-      throw new IllegalArgumentException("Session must be set!");
-    }
-
-    this.session = session;
-  }
-
-  /**
-   * Creates a new factory instance.
-   */
-  public static ObjectFactory newInstance(PersistentSessionImpl session) {
-    return new PersistentObjectFactoryImpl(session);
-  }
-
-  /**
-   * Returns the bindings object factory.
-   */
-  protected BindingsObjectFactory getProviderObjectFactory() {
-    return session.getBinding().getObjectFactory();
-  }
-
-  // ACL and ACE
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.repository.ObjectFactory#convertAces(java.util.List)
-   */
-  public Acl convertAces(List<Ace> aces) {
-    if (aces == null) {
-      return null;
-    }
-
-    BindingsObjectFactory pof = getProviderObjectFactory();
-
-    List<Ace> providerAces = new ArrayList<Ace>();
-    for (Ace ace : aces) {
-      providerAces.add(pof.createAccessControlEntry(ace.getPrincipalId(), ace.getPermissions()));
-    }
-
-    return pof.createAccessControlList(providerAces);
-  }
-
-  // policies
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.repository.ObjectFactory#convertPolicies(java.util.List)
-   */
-  public List<String> convertPolicies(List<Policy> policies) {
-    if (policies == null) {
-      return null;
-    }
-
-    List<String> result = new ArrayList<String>();
-
-    for (Policy policy : policies) {
-      if ((policy != null) && (policy.getId() != null)) {
-        result.add(policy.getId());
-      }
-    }
-
-    return result;
-  }
-
-  // renditions
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.repository.ObjectFactory#convertRendition(java.lang.String,
-   * org.apache.opencmis.commons.provider.RenditionData)
-   */
-  public Rendition convertRendition(String objectId, RenditionData rendition) {
-    if (rendition == null) {
-      throw new IllegalArgumentException("Rendition must be set!");
-    }
-
-    // TODO: what should happen if the length is not set?
-    long length = (rendition.getBigLength() == null ? -1 : rendition.getBigLength().longValue());
-    int height = (rendition.getBigHeight() == null ? -1 : rendition.getBigHeight().intValue());
-    int width = (rendition.getBigWidth() == null ? -1 : rendition.getBigWidth().intValue());
-
-    return new RenditionImpl(this.session, objectId, rendition.getStreamId(), rendition
-        .getRenditionDocumentId(), rendition.getKind(), length, rendition.getMimeType(), rendition
-        .getTitle(), height, width);
-  }
-
-  // content stream
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see
-   * org.apache.opencmis.client.api.repository.ObjectFactory#createContentStream(java.lang.String,
-   * long, java.lang.String, java.io.InputStream)
-   */
-  public ContentStream createContentStream(String filename, long length, String mimetype,
-      InputStream stream) {
-    return new ContentStreamImpl(filename, BigInteger.valueOf(length), mimetype, stream);
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see
-   * org.apache.opencmis.client.api.repository.ObjectFactory#convertContentStream(org.apache.opencmis
-   * .client.api.ContentStream)
-   */
-  public ContentStream convertContentStream(ContentStream contentStream) {
-    if (contentStream == null) {
-      return null;
-    }
-
-    BigInteger length = (contentStream.getLength() < 0 ? null : BigInteger.valueOf(contentStream
-        .getLength()));
-
-    return getProviderObjectFactory().createContentStream(contentStream.getFileName(), length,
-        contentStream.getMimeType(), contentStream.getStream());
-  }
-
-  // types
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see
-   * org.apache.opencmis.client.api.repository.ObjectFactory#convertTypeDefinition(org.apache.opencmis
-   * .commons.api.TypeDefinition)
-   */
-  public ObjectType convertTypeDefinition(TypeDefinition typeDefinition) {
-    if (typeDefinition instanceof DocumentTypeDefinition) {
-      return new DocumentTypeImpl(this.session, (DocumentTypeDefinition) typeDefinition);
-    }
-    else if (typeDefinition instanceof FolderTypeDefinition) {
-      return new FolderTypeImpl(this.session, (FolderTypeDefinition) typeDefinition);
-    }
-    else if (typeDefinition instanceof RelationshipTypeDefinition) {
-      return new RelationshipTypeImpl(this.session, (RelationshipTypeDefinition) typeDefinition);
-    }
-    else if (typeDefinition instanceof PolicyTypeDefinition) {
-      return new PolicyTypeImpl(this.session, (PolicyTypeDefinition) typeDefinition);
-    }
-    else {
-      throw new CmisRuntimeException("Unknown base type!");
-    }
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see
-   * org.apache.opencmis.client.api.repository.ObjectFactory#getTypeFromObjectData(org.apache.opencmis
-   * .commons.provider.ObjectData)
-   */
-  public ObjectType getTypeFromObjectData(ObjectData objectData) {
-    if ((objectData == null) || (objectData.getProperties() == null)
-        || (objectData.getProperties().getProperties() == null)) {
-      return null;
-    }
-
-    PropertyData<?> typeProperty = objectData.getProperties().getProperties().get(
-        PropertyIds.OBJECT_TYPE_ID);
-    if (!(typeProperty instanceof PropertyId)) {
-      return null;
-    }
-
-    return this.session.getTypeDefinition((String) typeProperty.getFirstValue());
-  }
-
-  // properties
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see
-   * org.apache.opencmis.client.api.repository.ObjectFactory#createProperty(org.apache.opencmis.
-   * commons.api.PropertyDefinition, java.lang.Object)
-   */
-  public <T> Property<T> createProperty(PropertyDefinition<?> type, T value) {
-    return new PersistentPropertyImpl<T>(type, value);
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see
-   * org.apache.opencmis.client.api.repository.ObjectFactory#createPropertyMultivalue(org.apache
-   * .opencmis.commons.api.PropertyDefinition, java.util.List)
-   */
-  public <T> Property<T> createPropertyMultivalue(PropertyDefinition<?> type, List<T> values) {
-    return new PersistentPropertyImpl<T>(type, values);
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see
-   * org.apache.opencmis.client.api.repository.ObjectFactory#convertProperties(org.apache.opencmis
-   * .client.api.objecttype.ObjectType, org.apache.opencmis.commons.provider.PropertiesData)
-   */
-  @SuppressWarnings("unchecked")
-  public Map<String, Property<?>> convertProperties(ObjectType objectType, Properties properties) {
-    // check input
-    if (objectType == null) {
-      throw new IllegalArgumentException("Object type must set!");
-    }
-
-    if (objectType.getPropertyDefinitions() == null) {
-      throw new IllegalArgumentException("Object type has no property defintions!");
-    }
-
-    if ((properties == null) || (properties.getProperties() == null)) {
-      throw new IllegalArgumentException("Properties must be set!");
-    }
-
-    // iterate through properties and convert them
-    Map<String, Property<?>> result = new LinkedHashMap<String, Property<?>>();
-    for (Map.Entry<String, PropertyData<?>> property : properties.getProperties().entrySet()) {
-      // find property definition
-      PropertyDefinition<?> definition = objectType.getPropertyDefinitions().get(property.getKey());
-      if (definition == null) {
-        // property without definition
-        throw new CmisRuntimeException("Property '" + property.getKey() + "' doesn't exist!");
-      }
-
-      Property<?> apiProperty = null;
-
-      if (definition instanceof PropertyStringDefinition) {
-        apiProperty = createPropertyMultivalue((PropertyStringDefinition) definition,
-            (List<String>) property.getValue().getValues());
-      }
-      else if (definition instanceof PropertyIdDefinition) {
-        apiProperty = createPropertyMultivalue((PropertyIdDefinition) definition,
-            (List<String>) property.getValue().getValues());
-      }
-      else if (definition instanceof PropertyHtmlDefinition) {
-        apiProperty = createPropertyMultivalue((PropertyHtmlDefinition) definition,
-            (List<String>) property.getValue().getValues());
-      }
-      else if (definition instanceof PropertyUriDefinition) {
-        apiProperty = createPropertyMultivalue((PropertyUriDefinition) definition,
-            (List<String>) property.getValue().getValues());
-      }
-      else if (definition instanceof PropertyIntegerDefinition) {
-        apiProperty = createPropertyMultivalue((PropertyIntegerDefinition) definition,
-            (List<BigInteger>) property.getValue().getValues());
-      }
-      else if (definition instanceof PropertyBooleanDefinition) {
-        apiProperty = createPropertyMultivalue((PropertyBooleanDefinition) definition,
-            (List<Boolean>) property.getValue().getValues());
-      }
-      else if (definition instanceof PropertyDecimalDefinition) {
-        apiProperty = createPropertyMultivalue((PropertyDecimalDefinition) definition,
-            (List<BigDecimal>) property.getValue().getValues());
-      }
-      else if (definition instanceof PropertyDateTimeDefinition) {
-        apiProperty = createPropertyMultivalue((PropertyDateTimeDefinition) definition,
-            (List<GregorianCalendar>) property.getValue().getValues());
-      }
-
-      result.put(property.getKey(), apiProperty);
-    }
-
-    return result;
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.repository.ObjectFactory#convertProperties(java.util.Map,
-   * org.apache.opencmis.client.api.objecttype.ObjectType, java.util.Set)
-   */
-  @SuppressWarnings("unchecked")
-  public Properties convertProperties(Map<String, ?> properties, ObjectType type,
-      Set<Updatability> updatabilityFilter) {
-    // check input
-    if (properties == null) {
-      throw new IllegalArgumentException("Properties must be set!");
-    }
-
-    // get the type
-    if (type == null) {
-      Object typeId = properties.get(PropertyIds.OBJECT_TYPE_ID);
-      if (!(typeId instanceof String)) {
-        throw new IllegalArgumentException("Type or type property must be set!");
-      }
-
-      type = session.getTypeDefinition(typeId.toString());
-    }
-
-    // some preparation
-    BindingsObjectFactory pof = getProviderObjectFactory();
-    List<PropertyData<?>> propertyList = new ArrayList<PropertyData<?>>();
-
-    // the big loop
-    for (Map.Entry<String, ?> property : properties.entrySet()) {
-      if ((property == null) || (property.getKey() == null)) {
-        continue;
-      }
-
-      String id = property.getKey();
-      Object value = property.getValue();
-
-      if (value instanceof Property<?>) {
-        Property<?> p = (Property<?>) value;
-        if (!id.equals(p.getId())) {
-          throw new IllegalArgumentException("Property id mismatch: '" + id + "' != '" + p.getId()
-              + "'!");
-        }
-        value = (p.getDefinition().getCardinality() == Cardinality.SINGLE ? p.getFirstValue() : p
-            .getValues());
-      }
-
-      // get the property definition
-      PropertyDefinition<?> definition = type.getPropertyDefinitions().get(id);
-      if (definition == null) {
-        throw new IllegalArgumentException("Property +'" + id + "' is not valid for this type!");
-      }
-
-      // check updatability
-      if (updatabilityFilter != null) {
-        if (!updatabilityFilter.contains(definition.getUpdatability())) {
-          continue;
-        }
-      }
-
-      // single and multi value check
-      List<?> values;
-      if (value == null) {
-        values = null;
-      }
-      else if (value instanceof List<?>) {
-        if (definition.getCardinality() != Cardinality.MULTI) {
-          throw new IllegalArgumentException("Property '" + id + "' is not a multi value property!");
-        }
-        values = (List<?>) value;
-
-        // check if the list is homogeneous and does not contain null values
-        Class<?> valueClazz = null;
-        for (Object o : values) {
-          if (o == null) {
-            throw new IllegalArgumentException("Property '" + id + "' contains null values!");
-          }
-          if (valueClazz == null) {
-            valueClazz = o.getClass();
-          }
-          else {
-            if (!valueClazz.isInstance(o)) {
-              throw new IllegalArgumentException("Property '" + id + "' is inhomogeneous!");
-            }
-          }
-        }
-      }
-      else {
-        if (definition.getCardinality() != Cardinality.SINGLE) {
-          throw new IllegalArgumentException("Property '" + id
-              + "' is not a single value property!");
-        }
-        values = Collections.singletonList(value);
-      }
-
-      // assemble property
-      PropertyData<?> propertyData = null;
-      Object firstValue = (values == null ? null : values.get(0));
-
-      if (definition instanceof PropertyStringDefinition) {
-        if (firstValue == null) {
-          propertyData = pof.createPropertyStringData(id, (List<String>) null);
-        }
-        else if (firstValue instanceof String) {
-          propertyData = pof.createPropertyStringData(id, (List<String>) values);
-        }
-        else {
-          throw new IllegalArgumentException("Property '" + id + "' is a String property!");
-        }
-      }
-      else if (definition instanceof PropertyIdDefinition) {
-        if (firstValue == null) {
-          propertyData = pof.createPropertyIdData(id, (List<String>) null);
-        }
-        else if (firstValue instanceof String) {
-          propertyData = pof.createPropertyIdData(id, (List<String>) values);
-        }
-        else {
-          throw new IllegalArgumentException("Property '" + id + "' is an Id property!");
-        }
-      }
-      else if (definition instanceof PropertyHtmlDefinition) {
-        if (firstValue == null) {
-          propertyData = pof.createPropertyHtmlData(id, (List<String>) values);
-        }
-        else if (firstValue instanceof String) {
-          propertyData = pof.createPropertyHtmlData(id, (List<String>) values);
-        }
-        else {
-          throw new IllegalArgumentException("Property '" + id + "' is a HTML property!");
-        }
-      }
-      else if (definition instanceof PropertyUriDefinition) {
-        if (firstValue == null) {
-          propertyData = pof.createPropertyUriData(id, (List<String>) null);
-        }
-        else if (firstValue instanceof String) {
-          propertyData = pof.createPropertyUriData(id, (List<String>) values);
-        }
-        else {
-          throw new IllegalArgumentException("Property '" + id + "' is an URI property!");
-        }
-      }
-      else if (definition instanceof PropertyIntegerDefinition) {
-        if (firstValue == null) {
-          propertyData = pof.createPropertyIntegerData(id, (List<BigInteger>) null);
-        }
-        else if (firstValue instanceof BigInteger) {
-          propertyData = pof.createPropertyIntegerData(id, (List<BigInteger>) values);
-        }
-        else if ((firstValue instanceof Byte) || (firstValue instanceof Short)
-            || (firstValue instanceof Integer) || (firstValue instanceof Long)) {
-          // we accept all kinds of integers
-          List<BigInteger> list = new ArrayList<BigInteger>(values.size());
-          for (Object v : values) {
-            list.add(BigInteger.valueOf(((Number) v).longValue()));
-          }
-
-          propertyData = pof.createPropertyIntegerData(id, list);
-        }
-        else {
-          throw new IllegalArgumentException("Property '" + id + "' is an Integer property!");
-        }
-      }
-      else if (definition instanceof PropertyBooleanDefinition) {
-        if (firstValue == null) {
-          propertyData = pof.createPropertyBooleanData(id, (List<Boolean>) null);
-        }
-        else if (firstValue instanceof Boolean) {
-          propertyData = pof.createPropertyBooleanData(id, (List<Boolean>) values);
-        }
-        else {
-          throw new IllegalArgumentException("Property '" + id + "' is a Boolean property!");
-        }
-      }
-      else if (definition instanceof PropertyDecimalDefinition) {
-        if (firstValue == null) {
-          propertyData = pof.createPropertyDecimalData(id, (List<BigDecimal>) null);
-        }
-        else if (firstValue instanceof BigDecimal) {
-          propertyData = pof.createPropertyDecimalData(id, (List<BigDecimal>) values);
-        }
-        else {
-          throw new IllegalArgumentException("Property '" + id + "' is a Decimal property!");
-        }
-      }
-      else if (definition instanceof PropertyDateTimeDefinition) {
-        if (firstValue == null) {
-          propertyData = pof.createPropertyDateTimeData(id, (List<GregorianCalendar>) null);
-        }
-        else if (firstValue instanceof GregorianCalendar) {
-          propertyData = pof.createPropertyDateTimeData(id, (List<GregorianCalendar>) values);
-        }
-        else {
-          throw new IllegalArgumentException("Property '" + id + "' is a Decimal property!");
-        }
-      }
-
-      // do we have something?
-      if (propertyData == null) {
-        throw new IllegalArgumentException("Property '" + id
-            + "' doesn't match the property defintion!");
-      }
-
-      propertyList.add(propertyData);
-    }
-
-    return pof.createPropertiesData(propertyList);
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see
-   * org.apache.opencmis.client.api.repository.ObjectFactory#convertQueryProperties(org.apache.opencmis
-   * .commons.provider.PropertiesData)
-   */
-  @SuppressWarnings("unchecked")
-  public List<PropertyData<?>> convertQueryProperties(Properties properties) {
-    // check input
-    if ((properties == null) || (properties.getProperties() == null)) {
-      throw new IllegalArgumentException("Properties must be set!");
-    }
-    return new ArrayList<PropertyData<?>>(properties.getProperties()
-            .values());
-  }
-
-  // objects
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see
-   * org.apache.opencmis.client.api.repository.ObjectFactory#convertObject(org.apache.opencmis.commons
-   * .provider.ObjectData, org.apache.opencmis.client.api.OperationContext)
-   */
-  public CmisObject convertObject(ObjectData objectData, OperationContext context) {
-    if (objectData == null) {
-      throw new IllegalArgumentException("Object data is null!");
-    }
-
-    ObjectType type = getTypeFromObjectData(objectData);
-
-    /* determine type */
-    switch (objectData.getBaseTypeId()) {
-    case CMIS_DOCUMENT:
-      return new PersistentDocumentImpl(this.session, type, objectData, context);
-    case CMIS_FOLDER:
-      return new PersistentFolderImpl(this.session, type, objectData, context);
-    case CMIS_POLICY:
-      return new PersistentPolicyImpl(this.session, type, objectData, context);
-    case CMIS_RELATIONSHIP:
-      return new PersistentRelationshipImpl(this.session, type, objectData, context);
-    default:
-      throw new CmisRuntimeException("unsupported type: " + objectData.getBaseTypeId());
-    }
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see
-   * org.apache.opencmis.client.api.repository.ObjectFactory#convertQueryResult(org.apache.opencmis
-   * .commons.provider.ObjectData)
-   */
-  public QueryResult convertQueryResult(ObjectData objectData) {
-    if (objectData == null) {
-      throw new IllegalArgumentException("Object data is null!");
-    }
+	/**
+	 * Constructor.
+	 */
+	protected PersistentObjectFactoryImpl(PersistentSessionImpl session) {
+		if (session == null) {
+			throw new IllegalArgumentException("Session must be set!");
+		}
+
+		this.session = session;
+	}
+
+	/**
+	 * Creates a new factory instance.
+	 */
+	public static ObjectFactory newInstance(PersistentSessionImpl session) {
+		return new PersistentObjectFactoryImpl(session);
+	}
+
+	/**
+	 * Returns the bindings object factory.
+	 */
+	protected BindingsObjectFactory getProviderObjectFactory() {
+		return session.getBinding().getObjectFactory();
+	}
+
+	// ACL and ACE
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.api.repository.ObjectFactory#convertAces(java
+	 * .util.List)
+	 */
+	public Acl convertAces(List<Ace> aces) {
+		if (aces == null) {
+			return null;
+		}
+
+		BindingsObjectFactory pof = getProviderObjectFactory();
+
+		List<Ace> providerAces = new ArrayList<Ace>();
+		for (Ace ace : aces) {
+			providerAces.add(pof.createAccessControlEntry(ace.getPrincipalId(), ace.getPermissions()));
+		}
+
+		return pof.createAccessControlList(providerAces);
+	}
+
+	// policies
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.api.repository.ObjectFactory#convertPolicies
+	 * (java.util.List)
+	 */
+	public List<String> convertPolicies(List<Policy> policies) {
+		if (policies == null) {
+			return null;
+		}
+
+		List<String> result = new ArrayList<String>();
+
+		for (Policy policy : policies) {
+			if ((policy != null) && (policy.getId() != null)) {
+				result.add(policy.getId());
+			}
+		}
+
+		return result;
+	}
+
+	// renditions
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.api.repository.ObjectFactory#convertRendition
+	 * (java.lang.String, org.apache.opencmis.commons.provider.RenditionData)
+	 */
+	public Rendition convertRendition(String objectId, RenditionData rendition) {
+		if (rendition == null) {
+			throw new IllegalArgumentException("Rendition must be set!");
+		}
+
+		// TODO: what should happen if the length is not set?
+		long length = (rendition.getBigLength() == null ? -1 : rendition.getBigLength().longValue());
+		int height = (rendition.getBigHeight() == null ? -1 : rendition.getBigHeight().intValue());
+		int width = (rendition.getBigWidth() == null ? -1 : rendition.getBigWidth().intValue());
+
+		return new RenditionImpl(this.session, objectId, rendition.getStreamId(), rendition.getRenditionDocumentId(),
+				rendition.getKind(), length, rendition.getMimeType(), rendition.getTitle(), height, width);
+	}
+
+	// content stream
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.api.repository.ObjectFactory#createContentStream
+	 * (java.lang.String, long, java.lang.String, java.io.InputStream)
+	 */
+	public ContentStream createContentStream(String filename, long length, String mimetype, InputStream stream) {
+		return new ContentStreamImpl(filename, BigInteger.valueOf(length), mimetype, stream);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.api.repository.ObjectFactory#convertContentStream
+	 * (org.apache.opencmis .client.api.ContentStream)
+	 */
+	public ContentStream convertContentStream(ContentStream contentStream) {
+		if (contentStream == null) {
+			return null;
+		}
+
+		BigInteger length = (contentStream.getLength() < 0 ? null : BigInteger.valueOf(contentStream.getLength()));
+
+		return getProviderObjectFactory().createContentStream(contentStream.getFileName(), length,
+				contentStream.getMimeType(), contentStream.getStream());
+	}
+
+	// types
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.api.repository.ObjectFactory#convertTypeDefinition
+	 * (org.apache.opencmis .commons.api.TypeDefinition)
+	 */
+	public ObjectType convertTypeDefinition(TypeDefinition typeDefinition) {
+		if (typeDefinition instanceof DocumentTypeDefinition) {
+			return new DocumentTypeImpl(this.session, (DocumentTypeDefinition) typeDefinition);
+		} else if (typeDefinition instanceof FolderTypeDefinition) {
+			return new FolderTypeImpl(this.session, (FolderTypeDefinition) typeDefinition);
+		} else if (typeDefinition instanceof RelationshipTypeDefinition) {
+			return new RelationshipTypeImpl(this.session, (RelationshipTypeDefinition) typeDefinition);
+		} else if (typeDefinition instanceof PolicyTypeDefinition) {
+			return new PolicyTypeImpl(this.session, (PolicyTypeDefinition) typeDefinition);
+		} else {
+			throw new CmisRuntimeException("Unknown base type!");
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.api.repository.ObjectFactory#getTypeFromObjectData
+	 * (org.apache.opencmis .commons.provider.ObjectData)
+	 */
+	public ObjectType getTypeFromObjectData(ObjectData objectData) {
+		if ((objectData == null) || (objectData.getProperties() == null)
+				|| (objectData.getProperties().getProperties() == null)) {
+			return null;
+		}
+
+		PropertyData<?> typeProperty = objectData.getProperties().getProperties().get(PropertyIds.OBJECT_TYPE_ID);
+		if (!(typeProperty instanceof PropertyId)) {
+			return null;
+		}
+
+		return this.session.getTypeDefinition((String) typeProperty.getFirstValue());
+	}
+
+	// properties
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.api.repository.ObjectFactory#createProperty
+	 * (org.apache.opencmis. commons.api.PropertyDefinition, java.lang.Object)
+	 */
+	public <T> Property<T> createProperty(PropertyDefinition<?> type, T value) {
+		return new PersistentPropertyImpl<T>(type, value);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.apache.opencmis.client.api.repository.ObjectFactory#
+	 * createPropertyMultivalue(org.apache
+	 * .opencmis.commons.api.PropertyDefinition, java.util.List)
+	 */
+	public <T> Property<T> createPropertyMultivalue(PropertyDefinition<?> type, List<T> values) {
+		return new PersistentPropertyImpl<T>(type, values);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.api.repository.ObjectFactory#convertProperties
+	 * (org.apache.opencmis .client.api.objecttype.ObjectType,
+	 * org.apache.opencmis.commons.provider.PropertiesData)
+	 */
+	@SuppressWarnings("unchecked")
+	public Map<String, Property<?>> convertProperties(ObjectType objectType, Properties properties) {
+		// check input
+		if (objectType == null) {
+			throw new IllegalArgumentException("Object type must set!");
+		}
+
+		if (objectType.getPropertyDefinitions() == null) {
+			throw new IllegalArgumentException("Object type has no property defintions!");
+		}
+
+		if ((properties == null) || (properties.getProperties() == null)) {
+			throw new IllegalArgumentException("Properties must be set!");
+		}
+
+		// iterate through properties and convert them
+		Map<String, Property<?>> result = new LinkedHashMap<String, Property<?>>();
+		for (Map.Entry<String, PropertyData<?>> property : properties.getProperties().entrySet()) {
+			// find property definition
+			PropertyDefinition<?> definition = objectType.getPropertyDefinitions().get(property.getKey());
+			if (definition == null) {
+				// property without definition
+				throw new CmisRuntimeException("Property '" + property.getKey() + "' doesn't exist!");
+			}
+
+			Property<?> apiProperty = null;
+
+			if (definition instanceof PropertyStringDefinition) {
+				apiProperty = createPropertyMultivalue((PropertyStringDefinition) definition, (List<String>) property
+						.getValue().getValues());
+			} else if (definition instanceof PropertyIdDefinition) {
+				apiProperty = createPropertyMultivalue((PropertyIdDefinition) definition, (List<String>) property
+						.getValue().getValues());
+			} else if (definition instanceof PropertyHtmlDefinition) {
+				apiProperty = createPropertyMultivalue((PropertyHtmlDefinition) definition, (List<String>) property
+						.getValue().getValues());
+			} else if (definition instanceof PropertyUriDefinition) {
+				apiProperty = createPropertyMultivalue((PropertyUriDefinition) definition, (List<String>) property
+						.getValue().getValues());
+			} else if (definition instanceof PropertyIntegerDefinition) {
+				apiProperty = createPropertyMultivalue((PropertyIntegerDefinition) definition,
+						(List<BigInteger>) property.getValue().getValues());
+			} else if (definition instanceof PropertyBooleanDefinition) {
+				apiProperty = createPropertyMultivalue((PropertyBooleanDefinition) definition, (List<Boolean>) property
+						.getValue().getValues());
+			} else if (definition instanceof PropertyDecimalDefinition) {
+				apiProperty = createPropertyMultivalue((PropertyDecimalDefinition) definition,
+						(List<BigDecimal>) property.getValue().getValues());
+			} else if (definition instanceof PropertyDateTimeDefinition) {
+				apiProperty = createPropertyMultivalue((PropertyDateTimeDefinition) definition,
+						(List<GregorianCalendar>) property.getValue().getValues());
+			}
+
+			result.put(property.getKey(), apiProperty);
+		}
+
+		return result;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.api.repository.ObjectFactory#convertProperties
+	 * (java.util.Map, org.apache.opencmis.client.api.objecttype.ObjectType,
+	 * java.util.Set)
+	 */
+	@SuppressWarnings("unchecked")
+	public Properties convertProperties(Map<String, ?> properties, ObjectType type, Set<Updatability> updatabilityFilter) {
+		// check input
+		if (properties == null) {
+			throw new IllegalArgumentException("Properties must be set!");
+		}
+
+		// get the type
+		if (type == null) {
+			Object typeId = properties.get(PropertyIds.OBJECT_TYPE_ID);
+			if (!(typeId instanceof String)) {
+				throw new IllegalArgumentException("Type or type property must be set!");
+			}
+
+			type = session.getTypeDefinition(typeId.toString());
+		}
+
+		// some preparation
+		BindingsObjectFactory pof = getProviderObjectFactory();
+		List<PropertyData<?>> propertyList = new ArrayList<PropertyData<?>>();
+
+		// the big loop
+		for (Map.Entry<String, ?> property : properties.entrySet()) {
+			if ((property == null) || (property.getKey() == null)) {
+				continue;
+			}
+
+			String id = property.getKey();
+			Object value = property.getValue();
+
+			if (value instanceof Property<?>) {
+				Property<?> p = (Property<?>) value;
+				if (!id.equals(p.getId())) {
+					throw new IllegalArgumentException("Property id mismatch: '" + id + "' != '" + p.getId() + "'!");
+				}
+				value = (p.getDefinition().getCardinality() == Cardinality.SINGLE ? p.getFirstValue() : p.getValues());
+			}
+
+			// get the property definition
+			PropertyDefinition<?> definition = type.getPropertyDefinitions().get(id);
+			if (definition == null) {
+				throw new IllegalArgumentException("Property +'" + id + "' is not valid for this type!");
+			}
+
+			// check updatability
+			if (updatabilityFilter != null) {
+				if (!updatabilityFilter.contains(definition.getUpdatability())) {
+					continue;
+				}
+			}
+
+			// single and multi value check
+			List<?> values;
+			if (value == null) {
+				values = null;
+			} else if (value instanceof List<?>) {
+				if (definition.getCardinality() != Cardinality.MULTI) {
+					throw new IllegalArgumentException("Property '" + id + "' is not a multi value property!");
+				}
+				values = (List<?>) value;
+
+				// check if the list is homogeneous and does not contain null
+				// values
+				Class<?> valueClazz = null;
+				for (Object o : values) {
+					if (o == null) {
+						throw new IllegalArgumentException("Property '" + id + "' contains null values!");
+					}
+					if (valueClazz == null) {
+						valueClazz = o.getClass();
+					} else {
+						if (!valueClazz.isInstance(o)) {
+							throw new IllegalArgumentException("Property '" + id + "' is inhomogeneous!");
+						}
+					}
+				}
+			} else {
+				if (definition.getCardinality() != Cardinality.SINGLE) {
+					throw new IllegalArgumentException("Property '" + id + "' is not a single value property!");
+				}
+				values = Collections.singletonList(value);
+			}
+
+			// assemble property
+			PropertyData<?> propertyData = null;
+			Object firstValue = (values == null ? null : values.get(0));
+
+			if (definition instanceof PropertyStringDefinition) {
+				if (firstValue == null) {
+					propertyData = pof.createPropertyStringData(id, (List<String>) null);
+				} else if (firstValue instanceof String) {
+					propertyData = pof.createPropertyStringData(id, (List<String>) values);
+				} else {
+					throw new IllegalArgumentException("Property '" + id + "' is a String property!");
+				}
+			} else if (definition instanceof PropertyIdDefinition) {
+				if (firstValue == null) {
+					propertyData = pof.createPropertyIdData(id, (List<String>) null);
+				} else if (firstValue instanceof String) {
+					propertyData = pof.createPropertyIdData(id, (List<String>) values);
+				} else {
+					throw new IllegalArgumentException("Property '" + id + "' is an Id property!");
+				}
+			} else if (definition instanceof PropertyHtmlDefinition) {
+				if (firstValue == null) {
+					propertyData = pof.createPropertyHtmlData(id, (List<String>) values);
+				} else if (firstValue instanceof String) {
+					propertyData = pof.createPropertyHtmlData(id, (List<String>) values);
+				} else {
+					throw new IllegalArgumentException("Property '" + id + "' is a HTML property!");
+				}
+			} else if (definition instanceof PropertyUriDefinition) {
+				if (firstValue == null) {
+					propertyData = pof.createPropertyUriData(id, (List<String>) null);
+				} else if (firstValue instanceof String) {
+					propertyData = pof.createPropertyUriData(id, (List<String>) values);
+				} else {
+					throw new IllegalArgumentException("Property '" + id + "' is an URI property!");
+				}
+			} else if (definition instanceof PropertyIntegerDefinition) {
+				if (firstValue == null) {
+					propertyData = pof.createPropertyIntegerData(id, (List<BigInteger>) null);
+				} else if (firstValue instanceof BigInteger) {
+					propertyData = pof.createPropertyIntegerData(id, (List<BigInteger>) values);
+				} else if ((firstValue instanceof Byte) || (firstValue instanceof Short)
+						|| (firstValue instanceof Integer) || (firstValue instanceof Long)) {
+					// we accept all kinds of integers
+					List<BigInteger> list = new ArrayList<BigInteger>(values.size());
+					for (Object v : values) {
+						list.add(BigInteger.valueOf(((Number) v).longValue()));
+					}
+
+					propertyData = pof.createPropertyIntegerData(id, list);
+				} else {
+					throw new IllegalArgumentException("Property '" + id + "' is an Integer property!");
+				}
+			} else if (definition instanceof PropertyBooleanDefinition) {
+				if (firstValue == null) {
+					propertyData = pof.createPropertyBooleanData(id, (List<Boolean>) null);
+				} else if (firstValue instanceof Boolean) {
+					propertyData = pof.createPropertyBooleanData(id, (List<Boolean>) values);
+				} else {
+					throw new IllegalArgumentException("Property '" + id + "' is a Boolean property!");
+				}
+			} else if (definition instanceof PropertyDecimalDefinition) {
+				if (firstValue == null) {
+					propertyData = pof.createPropertyDecimalData(id, (List<BigDecimal>) null);
+				} else if (firstValue instanceof BigDecimal) {
+					propertyData = pof.createPropertyDecimalData(id, (List<BigDecimal>) values);
+				} else {
+					throw new IllegalArgumentException("Property '" + id + "' is a Decimal property!");
+				}
+			} else if (definition instanceof PropertyDateTimeDefinition) {
+				if (firstValue == null) {
+					propertyData = pof.createPropertyDateTimeData(id, (List<GregorianCalendar>) null);
+				} else if (firstValue instanceof GregorianCalendar) {
+					propertyData = pof.createPropertyDateTimeData(id, (List<GregorianCalendar>) values);
+				} else {
+					throw new IllegalArgumentException("Property '" + id + "' is a Decimal property!");
+				}
+			}
+
+			// do we have something?
+			if (propertyData == null) {
+				throw new IllegalArgumentException("Property '" + id + "' doesn't match the property defintion!");
+			}
+
+			propertyList.add(propertyData);
+		}
+
+		return pof.createPropertiesData(propertyList);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.apache.opencmis.client.api.repository.ObjectFactory#
+	 * convertQueryProperties(org.apache.opencmis
+	 * .commons.provider.PropertiesData)
+	 */
+	@SuppressWarnings("unchecked")
+	public List<PropertyData<?>> convertQueryProperties(Properties properties) {
+		// check input
+		if ((properties == null) || (properties.getProperties() == null)) {
+			throw new IllegalArgumentException("Properties must be set!");
+		}
+		return new ArrayList<PropertyData<?>>(properties.getProperties().values());
+	}
+
+	// objects
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.api.repository.ObjectFactory#convertObject
+	 * (org.apache.opencmis.commons .provider.ObjectData,
+	 * org.apache.opencmis.client.api.OperationContext)
+	 */
+	public CmisObject convertObject(ObjectData objectData, OperationContext context) {
+		if (objectData == null) {
+			throw new IllegalArgumentException("Object data is null!");
+		}
+
+		ObjectType type = getTypeFromObjectData(objectData);
+
+		/* determine type */
+		switch (objectData.getBaseTypeId()) {
+		case CMIS_DOCUMENT:
+			return new PersistentDocumentImpl(this.session, type, objectData, context);
+		case CMIS_FOLDER:
+			return new PersistentFolderImpl(this.session, type, objectData, context);
+		case CMIS_POLICY:
+			return new PersistentPolicyImpl(this.session, type, objectData, context);
+		case CMIS_RELATIONSHIP:
+			return new PersistentRelationshipImpl(this.session, type, objectData, context);
+		default:
+			throw new CmisRuntimeException("unsupported type: " + objectData.getBaseTypeId());
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.api.repository.ObjectFactory#convertQueryResult
+	 * (org.apache.opencmis .commons.provider.ObjectData)
+	 */
+	public QueryResult convertQueryResult(ObjectData objectData) {
+		if (objectData == null) {
+			throw new IllegalArgumentException("Object data is null!");
+		}
 
-    return new QueryResultImpl(session, objectData);
-  }
+		return new QueryResultImpl(session, objectData);
+	}
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/RepositoryImpl.java?rev=934889&r1=934888&r2=934889&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/RepositoryImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/RepositoryImpl.java Fri Apr 16 14:07:11 2010
@@ -30,31 +30,30 @@ import org.apache.chemistry.opencmis.com
 
 public class RepositoryImpl extends RepositoryInfoImpl implements Repository {
 
-  private static final long serialVersionUID = 1L;
+	private static final long serialVersionUID = 1L;
 
-  private final Map<String, String> parameters;
-  private final SessionFactory sessionFactory;
+	private final Map<String, String> parameters;
+	private final SessionFactory sessionFactory;
 
-  /**
-   * Constructor.
-   */
-  public RepositoryImpl(RepositoryInfo data, Map<String, String> parameters,
-      SessionFactory sessionFactory) {
-    super(data);
-
-    this.parameters = new HashMap<String, String>(parameters);
-    this.parameters.put(SessionParameter.REPOSITORY_ID, getId());
-
-    this.sessionFactory = sessionFactory;
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.repository.Repository#createSession()
-   */
-  @SuppressWarnings("unchecked")
-  public <T extends Session> T createSession() {
-    return (T) sessionFactory.createSession(parameters);
-  }
+	/**
+	 * Constructor.
+	 */
+	public RepositoryImpl(RepositoryInfo data, Map<String, String> parameters, SessionFactory sessionFactory) {
+		super(data);
+
+		this.parameters = new HashMap<String, String>(parameters);
+		this.parameters.put(SessionParameter.REPOSITORY_ID, getId());
+
+		this.sessionFactory = sessionFactory;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.api.repository.Repository#createSession()
+	 */
+	@SuppressWarnings("unchecked")
+	public <T extends Session> T createSession() {
+		return (T) sessionFactory.createSession(parameters);
+	}
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/AbstractPageFetch.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/AbstractPageFetch.java?rev=934889&r1=934888&r2=934889&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/AbstractPageFetch.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/AbstractPageFetch.java Fri Apr 16 14:07:11 2010
@@ -21,47 +21,45 @@ package org.apache.chemistry.opencmis.cl
 import java.math.BigInteger;
 import java.util.List;
 
-
 /**
- * Abstract page fetch. 
- *
+ * Abstract page fetch.
+ * 
  * @param <T>
  */
 public abstract class AbstractPageFetch<T> {
 
-  /**
-   * Fetches the given page from the server.
-   * 
-   * @param pageNumber
-   *          number of the page (>= 0).
-   */
-  protected abstract PageFetchResult<T> fetchPage(long skipCount);
-
-  
-  // --- fetch result class ---
-
-  protected static class PageFetchResult<T> {
-    private List<T> page;
-    private BigInteger totalItems;
-    private Boolean hasMoreItems;
-
-    public PageFetchResult(List<T> page, BigInteger totalItems, Boolean hasMoreItems) {
-      this.page = page;
-      this.totalItems = totalItems;
-      this.hasMoreItems = hasMoreItems;
-    }
-
-    public List<T> getPage() {
-      return page;
-    }
-
-    public BigInteger getTotalItems() {
-      return totalItems;
-    }
-
-    public Boolean getHasMoreItems() {
-      return hasMoreItems;
-    }
-  }
+	/**
+	 * Fetches the given page from the server.
+	 * 
+	 * @param pageNumber
+	 *            number of the page (>= 0).
+	 */
+	protected abstract PageFetchResult<T> fetchPage(long skipCount);
+
+	// --- fetch result class ---
+
+	protected static class PageFetchResult<T> {
+		private List<T> page;
+		private BigInteger totalItems;
+		private Boolean hasMoreItems;
+
+		public PageFetchResult(List<T> page, BigInteger totalItems, Boolean hasMoreItems) {
+			this.page = page;
+			this.totalItems = totalItems;
+			this.hasMoreItems = hasMoreItems;
+		}
+
+		public List<T> getPage() {
+			return page;
+		}
+
+		public BigInteger getTotalItems() {
+			return totalItems;
+		}
+
+		public Boolean getHasMoreItems() {
+			return hasMoreItems;
+		}
+	}
 
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/AbstractPagingList.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/AbstractPagingList.java?rev=934889&r1=934888&r2=934889&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/AbstractPagingList.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/AbstractPagingList.java Fri Apr 16 14:07:11 2010
@@ -31,234 +31,231 @@ import org.apache.chemistry.opencmis.cli
  */
 public abstract class AbstractPagingList<T> implements PagingList<T> {
 
-  // number of item is unknown before the first fetch
-  private int numItems = -1;
+	// number of item is unknown before the first fetch
+	private int numItems = -1;
 
-  // cache is disabled by default
-  private int cacheSize = 0;
-  private LinkedHashMap<Integer, FetchResult> cache = null;
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see org.apache.opencmis.client.api.util.PagingList#setCacheSize(int)
-   */
-  public void setCacheSize(final int cacheSize) {
-    this.cacheSize = cacheSize;
-
-    if (cacheSize > 0) {
-      this.cache = new LinkedHashMap<Integer, FetchResult>(cacheSize + 1, 0.70f, true) {
-        private static final long serialVersionUID = 1L;
-
-        @Override
-        public boolean removeEldestEntry(Map.Entry<Integer, FetchResult> eldest) {
-          return size() > cacheSize;
-        }
-      };
-    }
-    else {
-      this.cache = null;
-    }
-  }
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see org.apache.opencmis.client.api.util.PagingList#get(int)
-   */
-  public List<T> get(int pageNumber) {
-    FetchResult fr = getInternal(pageNumber);
-    return (fr == null ? null : fr.getPage());
-  }
-
-  /**
-   * Retrieves a page or gets it from cache.
-   */
-  protected FetchResult getInternal(int pageNumber) {
-    if (pageNumber < 0) {
-      throw new IllegalArgumentException("pageNumber must be >= 0!");
-    }
-
-    FetchResult result = null;
-
-    if (cacheSize > 0) {
-      result = cache.get(pageNumber);
-      if (result == null) {
-        result = fetchPage(pageNumber);
-        cache.put(pageNumber, result);
-      }
-    }
-    else {
-      result = fetchPage(pageNumber);
-
-      // set number of items
-      if (result != null) {
-        if (result.getNumItems() != null) {
-          setNumItems(result.getNumItems().intValue());
-        }
-        else {
-          setNumItems(-1);
-        }
-      }
-    }
-
-    return result;
-  }
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see org.apache.opencmis.client.api.util.PagingList#getNumItems()
-   */
-  public int getNumItems() {
-    return numItems;
-  }
-
-  /**
-   * Sets the number of items.
-   */
-  protected void setNumItems(int numItems) {
-    this.numItems = numItems;
-  }
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see org.apache.opencmis.client.api.util.PagingList#size()
-   */
-  public int size() {
-    if (getNumItems() < 1) {
-      return -1;
-    }
-
-    if (getMaxItemsPerPage() < 1) {
-      return -1;
-    }
-
-    return (int) Math.ceil(((double) getNumItems() / (double) getMaxItemsPerPage()));
-  }
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see org.apache.opencmis.client.api.util.PagingList#isEmpty()
-   */
-  public boolean isEmpty() {
-    if (getNumItems() > 0) {
-      return false;
-    }
-
-    if (getNumItems() == 0) {
-      return true;
-    }
-
-    List<T> page = get(0);
-    if (page == null) {
-      return true;
-    }
-
-    return page.isEmpty();
-  }
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see java.lang.Iterable#iterator()
-   */
-  public Iterator<List<T>> iterator() {
-    return new PageIterator();
-  }
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see org.apache.opencmis.client.api.util.PagingList#getMaxItemsPerPage()
-   */
-  public abstract int getMaxItemsPerPage();
-
-  /**
-   * Fetches the given page from the server.
-   * 
-   * @param pageNumber
-   *          number of the page (>= 0).
-   */
-  protected abstract FetchResult fetchPage(int pageNumber);
-
-  // --- fetch result class ---
-
-  /**
-   * Fetch result.
-   */
-  protected class FetchResult {
-    private List<T> page;
-    private BigInteger numItems;
-    private Boolean hasMoreItems;
-
-    public FetchResult(List<T> page, BigInteger numItems, Boolean hasMoreItems) {
-      this.page = page;
-      this.numItems = numItems;
-      this.hasMoreItems = hasMoreItems;
-    }
-
-    public List<T> getPage() {
-      return page;
-    }
-
-    public BigInteger getNumItems() {
-      return numItems;
-    }
-
-    public Boolean getHasMoreItems() {
-      return hasMoreItems;
-    }
-  }
-
-  // --- iterator class ---
-
-  /**
-   * Page iterator.
-   */
-  class PageIterator implements Iterator<List<T>> {
-
-    private int currentPage = -1;
-    private boolean hasMoreItems = true;
-
-    public boolean hasNext() {
-      if (!hasMoreItems) {
-        return false;
-      }
-
-      int size = size();
-      if (size < 0) {
-        // we don't know better
-        return true;
-      }
-
-      return currentPage < size - 1;
-    }
-
-    public List<T> next() {
-      currentPage++;
-      FetchResult next = getInternal(currentPage);
-
-      if (next == null) {
-        hasMoreItems = false;
-        return null;
-      }
-
-      if ((next.getPage() == null) || (next.getPage().isEmpty())) {
-        hasMoreItems = false;
-      }
-
-      if (next.getHasMoreItems() != null) {
-        hasMoreItems = next.getHasMoreItems().booleanValue();
-      }
-
-      return next.getPage();
-    }
-
-    public void remove() {
-      throw new UnsupportedOperationException();
-    }
-  }
+	// cache is disabled by default
+	private int cacheSize = 0;
+	private LinkedHashMap<Integer, FetchResult> cache = null;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.api.util.PagingList#setCacheSize(int)
+	 */
+	public void setCacheSize(final int cacheSize) {
+		this.cacheSize = cacheSize;
+
+		if (cacheSize > 0) {
+			this.cache = new LinkedHashMap<Integer, FetchResult>(cacheSize + 1, 0.70f, true) {
+				private static final long serialVersionUID = 1L;
+
+				@Override
+				public boolean removeEldestEntry(Map.Entry<Integer, FetchResult> eldest) {
+					return size() > cacheSize;
+				}
+			};
+		} else {
+			this.cache = null;
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.api.util.PagingList#get(int)
+	 */
+	public List<T> get(int pageNumber) {
+		FetchResult fr = getInternal(pageNumber);
+		return (fr == null ? null : fr.getPage());
+	}
+
+	/**
+	 * Retrieves a page or gets it from cache.
+	 */
+	protected FetchResult getInternal(int pageNumber) {
+		if (pageNumber < 0) {
+			throw new IllegalArgumentException("pageNumber must be >= 0!");
+		}
+
+		FetchResult result = null;
+
+		if (cacheSize > 0) {
+			result = cache.get(pageNumber);
+			if (result == null) {
+				result = fetchPage(pageNumber);
+				cache.put(pageNumber, result);
+			}
+		} else {
+			result = fetchPage(pageNumber);
+
+			// set number of items
+			if (result != null) {
+				if (result.getNumItems() != null) {
+					setNumItems(result.getNumItems().intValue());
+				} else {
+					setNumItems(-1);
+				}
+			}
+		}
+
+		return result;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.api.util.PagingList#getNumItems()
+	 */
+	public int getNumItems() {
+		return numItems;
+	}
+
+	/**
+	 * Sets the number of items.
+	 */
+	protected void setNumItems(int numItems) {
+		this.numItems = numItems;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.api.util.PagingList#size()
+	 */
+	public int size() {
+		if (getNumItems() < 1) {
+			return -1;
+		}
+
+		if (getMaxItemsPerPage() < 1) {
+			return -1;
+		}
+
+		return (int) Math.ceil(((double) getNumItems() / (double) getMaxItemsPerPage()));
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.api.util.PagingList#isEmpty()
+	 */
+	public boolean isEmpty() {
+		if (getNumItems() > 0) {
+			return false;
+		}
+
+		if (getNumItems() == 0) {
+			return true;
+		}
+
+		List<T> page = get(0);
+		if (page == null) {
+			return true;
+		}
+
+		return page.isEmpty();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.lang.Iterable#iterator()
+	 */
+	public Iterator<List<T>> iterator() {
+		return new PageIterator();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.api.util.PagingList#getMaxItemsPerPage()
+	 */
+	public abstract int getMaxItemsPerPage();
+
+	/**
+	 * Fetches the given page from the server.
+	 * 
+	 * @param pageNumber
+	 *            number of the page (>= 0).
+	 */
+	protected abstract FetchResult fetchPage(int pageNumber);
+
+	// --- fetch result class ---
+
+	/**
+	 * Fetch result.
+	 */
+	protected class FetchResult {
+		private List<T> page;
+		private BigInteger numItems;
+		private Boolean hasMoreItems;
+
+		public FetchResult(List<T> page, BigInteger numItems, Boolean hasMoreItems) {
+			this.page = page;
+			this.numItems = numItems;
+			this.hasMoreItems = hasMoreItems;
+		}
+
+		public List<T> getPage() {
+			return page;
+		}
+
+		public BigInteger getNumItems() {
+			return numItems;
+		}
+
+		public Boolean getHasMoreItems() {
+			return hasMoreItems;
+		}
+	}
+
+	// --- iterator class ---
+
+	/**
+	 * Page iterator.
+	 */
+	class PageIterator implements Iterator<List<T>> {
+
+		private int currentPage = -1;
+		private boolean hasMoreItems = true;
+
+		public boolean hasNext() {
+			if (!hasMoreItems) {
+				return false;
+			}
+
+			int size = size();
+			if (size < 0) {
+				// we don't know better
+				return true;
+			}
+
+			return currentPage < size - 1;
+		}
+
+		public List<T> next() {
+			currentPage++;
+			FetchResult next = getInternal(currentPage);
+
+			if (next == null) {
+				hasMoreItems = false;
+				return null;
+			}
+
+			if ((next.getPage() == null) || (next.getPage().isEmpty())) {
+				hasMoreItems = false;
+			}
+
+			if (next.getHasMoreItems() != null) {
+				hasMoreItems = next.getHasMoreItems().booleanValue();
+			}
+
+			return next.getPage();
+		}
+
+		public void remove() {
+			throw new UnsupportedOperationException();
+		}
+	}
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/ContainerImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/ContainerImpl.java?rev=934889&r1=934888&r2=934889&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/ContainerImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/ContainerImpl.java Fri Apr 16 14:07:11 2010
@@ -24,33 +24,33 @@ import org.apache.chemistry.opencmis.cli
 
 public class ContainerImpl<T> implements Tree<T> {
 
-  private T item;
-  private List<Tree<T>> children;
+	private T item;
+	private List<Tree<T>> children;
 
-  public ContainerImpl(T item, List<Tree<T>> children) {
-    if (item == null) {
-      throw new IllegalArgumentException("Item must be set!");
-    }
-
-    this.item = item;
-    this.children = children;
-  }
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see org.apache.opencmis.client.api.util.Container#getItem()
-   */
-  public T getItem() {
-    return item;
-  }
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see org.apache.opencmis.client.api.util.Container#getChildren()
-   */
-  public List<Tree<T>> getChildren() {
-    return this.children;
-  }
+	public ContainerImpl(T item, List<Tree<T>> children) {
+		if (item == null) {
+			throw new IllegalArgumentException("Item must be set!");
+		}
+
+		this.item = item;
+		this.children = children;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.api.util.Container#getItem()
+	 */
+	public T getItem() {
+		return item;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.api.util.Container#getChildren()
+	 */
+	public List<Tree<T>> getChildren() {
+		return this.children;
+	}
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/DefaultPagingIterable.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/DefaultPagingIterable.java?rev=934889&r1=934888&r2=934889&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/DefaultPagingIterable.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/DefaultPagingIterable.java Fri Apr 16 14:07:11 2010
@@ -27,43 +27,46 @@ import org.apache.chemistry.opencmis.cli
  */
 public class DefaultPagingIterable<T> implements PagingIterable<T> {
 
-  private AbstractPageFetch<T> pageFetch;
-  private long skipCount;
-  
-  /**
-   * Construct
-   * 
-   * @param pageFetch
-   */
-  public DefaultPagingIterable(AbstractPageFetch<T> pageFetch) {
-    this(0, pageFetch);
-  }
-
-  /**
-   * Construct
-   * 
-   * @param position
-   * @param pageFetch
-   */
-  private DefaultPagingIterable(long position, AbstractPageFetch<T> pageFetch) {
-    this.pageFetch = pageFetch;
-    this.skipCount = position;
-  }
-
-  /*
-   * (non-Javadoc)
-   * @see java.lang.Iterable#iterator()
-   */
-  public Iterator<T> iterator() {
-    return new DefaultPagingIterator<T>(skipCount, pageFetch);
-  }
-
-  /*
-   * (non-Javadoc)
-   * @see org.apache.chemistry.opencmis.client.api.util.PagingIterable#skipTo(long)
-   */
-  public PagingIterable<T> skipTo(long position) {
-    return new DefaultPagingIterable<T>(position, pageFetch);
-  }
+	private AbstractPageFetch<T> pageFetch;
+	private long skipCount;
+
+	/**
+	 * Construct
+	 * 
+	 * @param pageFetch
+	 */
+	public DefaultPagingIterable(AbstractPageFetch<T> pageFetch) {
+		this(0, pageFetch);
+	}
+
+	/**
+	 * Construct
+	 * 
+	 * @param position
+	 * @param pageFetch
+	 */
+	private DefaultPagingIterable(long position, AbstractPageFetch<T> pageFetch) {
+		this.pageFetch = pageFetch;
+		this.skipCount = position;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.lang.Iterable#iterator()
+	 */
+	public Iterator<T> iterator() {
+		return new DefaultPagingIterator<T>(skipCount, pageFetch);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.chemistry.opencmis.client.api.util.PagingIterable#skipTo(long)
+	 */
+	public PagingIterable<T> skipTo(long position) {
+		return new DefaultPagingIterable<T>(position, pageFetch);
+	}
 
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/DefaultPagingIterator.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/DefaultPagingIterator.java?rev=934889&r1=934888&r2=934889&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/DefaultPagingIterator.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/DefaultPagingIterator.java Fri Apr 16 14:07:11 2010
@@ -23,135 +23,140 @@ import java.util.List;
 import org.apache.chemistry.opencmis.client.api.PagingIterator;
 import org.apache.chemistry.opencmis.client.runtime.util.AbstractPageFetch.PageFetchResult;
 
-
 /**
  * Base <code>PagingIterator</code> implementation.
- *
+ * 
  * @param <T>
  */
 public class DefaultPagingIterator<T> implements PagingIterator<T> {
 
-  private long skipCount;
-  private int skipOffset = 0;
+	private long skipCount;
+	private int skipOffset = 0;
+
+	private AbstractPageFetch<T> pageFetch;
+
+	private Long totalItems = null;
+	private PageFetchResult<T> page = null;
+
+	/**
+	 * Construct
+	 * 
+	 * @param skipCount
+	 * @param pageFetch
+	 */
+	public DefaultPagingIterator(long skipCount, AbstractPageFetch<T> pageFetch) {
+		this.skipCount = skipCount;
+		this.pageFetch = pageFetch;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.chemistry.opencmis.client.api.util.PagingIterator#getPosition
+	 * ()
+	 */
+	public long getPosition() {
+		return skipCount + skipOffset;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.chemistry.opencmis.client.api.util.PagingIterator#getTotalNumItems
+	 * ()
+	 */
+	public long getTotalNumItems() {
+		if (totalItems == null) {
+			PageFetchResult<T> page = getPage();
+			if (page != null) {
+				// set number of items
+				if (page.getTotalItems() != null) {
+					totalItems = page.getTotalItems().longValue();
+				} else {
+					totalItems = -1L;
+				}
+			}
+		}
+		return totalItems;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.util.Iterator#hasNext()
+	 */
+	public boolean hasNext() {
+		if (!hasMoreItems()) {
+			return false;
+		}
+
+		long totalItems = getTotalNumItems();
+		if (totalItems < 0) {
+			// we don't know better
+			return true;
+		}
+
+		return (skipCount + skipOffset) < totalItems - 1;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.util.Iterator#next()
+	 */
+	public T next() {
+		PageFetchResult<T> currentPage = getPage();
+		skipOffset++;
+
+		List<T> items = currentPage.getPage();
+		if (items == null || items.isEmpty()) {
+			return null;
+		}
+
+		if (skipOffset == items.size()) {
+			skipCount += skipOffset;
+			skipOffset = 0;
+			this.page = pageFetch.fetchPage(skipCount);
+			currentPage = this.page;
+			if (currentPage != null) {
+				items = currentPage.getPage();
+			}
+		}
+
+		if (items == null || items.isEmpty() || skipOffset == items.size()) {
+			return null;
+		}
+
+		return items.get(skipOffset);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.util.Iterator#remove()
+	 */
+	public void remove() {
+		throw new UnsupportedOperationException();
+	}
+
+	private boolean hasMoreItems() {
+		PageFetchResult<T> page = getPage();
+		if (page == null) {
+			return false;
+		}
+		if (page.getHasMoreItems() != null) {
+			return page.getHasMoreItems().booleanValue();
+		}
+		return false;
+	}
+
+	private PageFetchResult<T> getPage() {
+		if (page == null) {
+			page = pageFetch.fetchPage(skipCount);
+		}
+		return page;
+	}
 
-  private AbstractPageFetch<T> pageFetch;
-  
-  private Long totalItems = null;
-  private PageFetchResult<T> page = null;
-  
-  
-  /**
-   * Construct
-   * 
-   * @param skipCount
-   * @param pageFetch
-   */
-  public DefaultPagingIterator(long skipCount, AbstractPageFetch<T> pageFetch) {
-    this.skipCount = skipCount;
-    this.pageFetch = pageFetch;
-  }
-  
-  /*
-   * (non-Javadoc)
-   * @see org.apache.chemistry.opencmis.client.api.util.PagingIterator#getPosition()
-   */
-  public long getPosition() {
-    return skipCount + skipOffset;
-  }
-
-  /*
-   * (non-Javadoc)
-   * @see org.apache.chemistry.opencmis.client.api.util.PagingIterator#getTotalNumItems()
-   */
-  public long getTotalNumItems() {
-    if (totalItems == null) {
-      PageFetchResult<T> page = getPage();
-      if (page != null) {
-        // set number of items
-        if (page.getTotalItems() != null) {
-          totalItems = page.getTotalItems().longValue();
-        }
-        else {
-          totalItems = -1L;
-        }
-      }
-    }
-    return totalItems;
-  }
-
-  /*
-   * (non-Javadoc)
-   * @see java.util.Iterator#hasNext()
-   */
-  public boolean hasNext() {
-    if (!hasMoreItems()) {
-      return false;
-    }
-
-    long totalItems = getTotalNumItems();
-    if (totalItems < 0) {
-      // we don't know better
-      return true;
-    }
-
-    return (skipCount + skipOffset) < totalItems - 1;
-  }
-
-  /*
-   * (non-Javadoc)
-   * @see java.util.Iterator#next()
-   */
-  public T next() {
-    PageFetchResult<T> currentPage = getPage();
-    skipOffset++;
-    
-    List<T> items = currentPage.getPage();
-    if (items == null || items.isEmpty()) {
-      return null;
-    }
-    
-    if (skipOffset == items.size()) {
-      skipCount += skipOffset;
-      skipOffset = 0;
-      this.page = pageFetch.fetchPage(skipCount);
-      currentPage = this.page;
-      if (currentPage != null) {
-        items = currentPage.getPage();
-      }
-    }
-
-    if (items == null || items.isEmpty() || skipOffset == items.size())  {
-      return null;
-    }
-
-    return items.get(skipOffset);
-  }
-
-  /*
-   * (non-Javadoc)
-   * @see java.util.Iterator#remove()
-   */
-  public void remove() {
-    throw new UnsupportedOperationException();
-  }
-
-  private boolean hasMoreItems() {
-    PageFetchResult<T> page = getPage();
-    if (page == null) {
-      return false;
-    }
-    if (page.getHasMoreItems() != null) {
-      return page.getHasMoreItems().booleanValue();
-    }
-    return false;
-  }
-  
-  private PageFetchResult<T> getPage()
-  {
-    if (page == null) {
-      page = pageFetch.fetchPage(skipCount);
-    }
-    return page;
-  }
-  
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/CacheTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/CacheTest.java?rev=934889&r1=934888&r2=934889&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/CacheTest.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/CacheTest.java Fri Apr 16 14:07:11 2010
@@ -38,108 +38,108 @@ import com.sun.xml.ws.util.ByteArrayBuff
 
 public class CacheTest {
 
-  @Before
-  public void setup() {
-  }
-
-  @Test
-  public void cacheSingleObjectTest() {
-    Cache cache = CacheImpl.newInstance();
-
-    String id = "1";
-    // String path = "/1";
-    String cacheKey = "key";
-
-    // add object
-    CmisObject obj1 = this.createCmisObject(id);
-    cache.put(obj1, cacheKey);
-
-    // access object
-    Assert.assertTrue(cache.containsId(id, cacheKey));
-
-    // access object
-    CmisObject obj2 = cache.getById(id, cacheKey);
-    Assert.assertEquals(obj1, obj2);
-
-    // clear cache
-    cache.clear();
-
-    // access object (not found)
-    Assert.assertFalse(cache.containsId(id, cacheKey));
-
-    // access object (not found)
-    CmisObject obj4 = cache.getById(id, cacheKey);
-    Assert.assertNull(obj4);
-  }
-
-  @Test
-  public void cacheSizeTest() {
-    int cacheSize = 50000;
-    Cache cache = CacheImpl.newInstance(cacheSize);
-    Assert.assertEquals(cacheSize, cache.getCacheSize());
-  }
-
-  @Test
-  public void lruTest() {
-    int cacheSize = 3;
-    Cache cache = CacheImpl.newInstance(cacheSize);
-
-    String cacheKey = "key";
-
-    for (int i = 0; i < cacheSize + 1; i++) {
-      CmisObject obj = this.createCmisObject("id" + i);
-      cache.put(obj, cacheKey);
-    }
-
-    Assert.assertNull(cache.getById("id0", cacheKey)); // thrown out
-    Assert.assertNotNull(cache.getById("id1", cacheKey));
-    Assert.assertNotNull(cache.getById("id2", cacheKey));
-    Assert.assertNotNull(cache.getById("id3", cacheKey));
-  }
-
-  @Test
-  public void serializationTest() throws IOException, ClassNotFoundException {
-    int cacheSize = 10;
-    Cache cache = CacheImpl.newInstance(cacheSize);
-
-    String cacheKey = "key";
-
-    for (int i = 0; i < cacheSize; i++) {
-      CmisObject obj = this.createCmisObject("id" + i);
-      cache.put(obj, cacheKey);
-    }
-
-    ByteArrayBuffer buffer = new ByteArrayBuffer();
-    ObjectOutputStream out = new ObjectOutputStream(buffer);
-    out.writeObject(cache);
-    out.close();
-
-    ObjectInputStream in = new ObjectInputStream(buffer.newInputStream());
-    Cache cache2 = (Cache) in.readObject();
-    in.close();
-
-    for (int k = 0; k < cacheSize; k++) {
-      CmisObject o1 = cache.getById("id" + k, cacheKey);
-      CmisObject o2 = cache2.getById("id" + k, cacheKey);
-      Assert.assertEquals(o1.getId(), o2.getId());
-    }
-
-  }
-
-  /**
-   * Create a Mock for testing Cache is sufficient.
-   * 
-   * @param id
-   * @param path
-   * @return a mocked object
-   */
-  private CmisObject createCmisObject(String id) {
-    CmisObject obj = createNiceMock(CmisObject.class);
+	@Before
+	public void setup() {
+	}
+
+	@Test
+	public void cacheSingleObjectTest() {
+		Cache cache = CacheImpl.newInstance();
+
+		String id = "1";
+		// String path = "/1";
+		String cacheKey = "key";
+
+		// add object
+		CmisObject obj1 = this.createCmisObject(id);
+		cache.put(obj1, cacheKey);
+
+		// access object
+		Assert.assertTrue(cache.containsId(id, cacheKey));
+
+		// access object
+		CmisObject obj2 = cache.getById(id, cacheKey);
+		Assert.assertEquals(obj1, obj2);
+
+		// clear cache
+		cache.clear();
+
+		// access object (not found)
+		Assert.assertFalse(cache.containsId(id, cacheKey));
+
+		// access object (not found)
+		CmisObject obj4 = cache.getById(id, cacheKey);
+		Assert.assertNull(obj4);
+	}
+
+	@Test
+	public void cacheSizeTest() {
+		int cacheSize = 50000;
+		Cache cache = CacheImpl.newInstance(cacheSize);
+		Assert.assertEquals(cacheSize, cache.getCacheSize());
+	}
+
+	@Test
+	public void lruTest() {
+		int cacheSize = 3;
+		Cache cache = CacheImpl.newInstance(cacheSize);
+
+		String cacheKey = "key";
+
+		for (int i = 0; i < cacheSize + 1; i++) {
+			CmisObject obj = this.createCmisObject("id" + i);
+			cache.put(obj, cacheKey);
+		}
+
+		Assert.assertNull(cache.getById("id0", cacheKey)); // thrown out
+		Assert.assertNotNull(cache.getById("id1", cacheKey));
+		Assert.assertNotNull(cache.getById("id2", cacheKey));
+		Assert.assertNotNull(cache.getById("id3", cacheKey));
+	}
+
+	@Test
+	public void serializationTest() throws IOException, ClassNotFoundException {
+		int cacheSize = 10;
+		Cache cache = CacheImpl.newInstance(cacheSize);
+
+		String cacheKey = "key";
+
+		for (int i = 0; i < cacheSize; i++) {
+			CmisObject obj = this.createCmisObject("id" + i);
+			cache.put(obj, cacheKey);
+		}
+
+		ByteArrayBuffer buffer = new ByteArrayBuffer();
+		ObjectOutputStream out = new ObjectOutputStream(buffer);
+		out.writeObject(cache);
+		out.close();
+
+		ObjectInputStream in = new ObjectInputStream(buffer.newInputStream());
+		Cache cache2 = (Cache) in.readObject();
+		in.close();
+
+		for (int k = 0; k < cacheSize; k++) {
+			CmisObject o1 = cache.getById("id" + k, cacheKey);
+			CmisObject o2 = cache2.getById("id" + k, cacheKey);
+			Assert.assertEquals(o1.getId(), o2.getId());
+		}
+
+	}
+
+	/**
+	 * Create a Mock for testing Cache is sufficient.
+	 * 
+	 * @param id
+	 * @param path
+	 * @return a mocked object
+	 */
+	private CmisObject createCmisObject(String id) {
+		CmisObject obj = createNiceMock(CmisObject.class);
 
-    expect(obj.getId()).andReturn(id).anyTimes();
+		expect(obj.getId()).andReturn(id).anyTimes();
 
-    replay(obj);
+		replay(obj);
 
-    return obj;
-  }
+		return obj;
+	}
 }



Mime
View raw message