chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dcaru...@apache.org
Subject svn commit: r936922 [14/18] - in /incubator/chemistry/opencmis/trunk/chemistry-opencmis-client: chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/ chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/...
Date Thu, 22 Apr 2010 16:04:22 GMT
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadOnlyTests.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadOnlyTests.java?rev=936922&r1=936921&r2=936922&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadOnlyTests.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadOnlyTests.java Thu Apr 22 16:04:19 2010
@@ -30,26 +30,26 @@ import org.apache.chemistry.opencmis.com
  */
 public class SimpleReadOnlyTests extends AbstractSimpleReadOnlyTests {
 
-	private Set<String> fTests;
+    private Set<String> fTests;
 
-	public SimpleReadOnlyTests() {
-		fTests = new HashSet<String>();
-		fTests.add(TEST_REPOSITORY_INFO);
-		fTests.add(TEST_TYPES);
-		fTests.add(TEST_NAVIGATION);
-		fTests.add(TEST_CONTENT_STREAM);
-		fTests.add(TEST_QUERY);
-		fTests.add(TEST_CHECKEDOUT);
-		fTests.add(TEST_CONTENT_CHANGES);
-	}
+    public SimpleReadOnlyTests() {
+        fTests = new HashSet<String>();
+        fTests.add(TEST_REPOSITORY_INFO);
+        fTests.add(TEST_TYPES);
+        fTests.add(TEST_NAVIGATION);
+        fTests.add(TEST_CONTENT_STREAM);
+        fTests.add(TEST_QUERY);
+        fTests.add(TEST_CHECKEDOUT);
+        fTests.add(TEST_CONTENT_CHANGES);
+    }
 
-	@Override
-	protected CmisBinding createBinding() {
-		return WebServicesTestBindingFactory.createBinding(getWebServicesURL(), getUsername(), getPassword());
-	}
+    @Override
+    protected CmisBinding createBinding() {
+        return WebServicesTestBindingFactory.createBinding(getWebServicesURL(), getUsername(), getPassword());
+    }
 
-	@Override
-	protected Set<String> getEnabledTests() {
-		return fTests;
-	}
+    @Override
+    protected Set<String> getEnabledTests() {
+        return fTests;
+    }
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadWriteTests.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadWriteTests.java?rev=936922&r1=936921&r2=936922&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadWriteTests.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/SimpleReadWriteTests.java Thu Apr 22 16:04:19 2010
@@ -30,27 +30,27 @@ import org.apache.chemistry.opencmis.com
  */
 public class SimpleReadWriteTests extends AbstractSimpleReadWriteTests {
 
-	private Set<String> fTests;
+    private Set<String> fTests;
 
-	public SimpleReadWriteTests() {
-		fTests = new HashSet<String>();
-		fTests.add(TEST_CREATE_FOLDER);
-		fTests.add(TEST_CREATE_DOCUMENT);
-		fTests.add(TEST_CREATE_FROM_SOURCE);
-		fTests.add(TEST_SET_AND_DELETE_CONTENT);
-		fTests.add(TEST_UPDATE_PROPERTIES);
-		fTests.add(TEST_DELETE_TREE);
-		fTests.add(TEST_MOVE_OBJECT);
-		fTests.add(TEST_VERSIONING);
-	}
+    public SimpleReadWriteTests() {
+        fTests = new HashSet<String>();
+        fTests.add(TEST_CREATE_FOLDER);
+        fTests.add(TEST_CREATE_DOCUMENT);
+        fTests.add(TEST_CREATE_FROM_SOURCE);
+        fTests.add(TEST_SET_AND_DELETE_CONTENT);
+        fTests.add(TEST_UPDATE_PROPERTIES);
+        fTests.add(TEST_DELETE_TREE);
+        fTests.add(TEST_MOVE_OBJECT);
+        fTests.add(TEST_VERSIONING);
+    }
 
-	@Override
-	protected CmisBinding createBinding() {
-		return WebServicesTestBindingFactory.createBinding(getWebServicesURL(), getUsername(), getPassword());
-	}
+    @Override
+    protected CmisBinding createBinding() {
+        return WebServicesTestBindingFactory.createBinding(getWebServicesURL(), getUsername(), getPassword());
+    }
 
-	@Override
-	protected Set<String> getEnabledTests() {
-		return fTests;
-	}
+    @Override
+    protected Set<String> getEnabledTests() {
+        return fTests;
+    }
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/WebServicesTestBindingFactory.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/WebServicesTestBindingFactory.java?rev=936922&r1=936921&r2=936922&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/WebServicesTestBindingFactory.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/test/java/org/apache/chemistry/opencmis/client/bindings/webservices/WebServicesTestBindingFactory.java Thu Apr 22 16:04:19 2010
@@ -31,53 +31,53 @@ import org.apache.chemistry.opencmis.com
  */
 public class WebServicesTestBindingFactory {
 
-	public static CmisBinding createBinding(String url, String username, String password) {
-		boolean isPrefix = true;
-		String urlLower = url.toLowerCase();
-
-		if (urlLower.endsWith("?wsdl")) {
-			isPrefix = false;
-		} else if (urlLower.endsWith(".wsdl")) {
-			isPrefix = false;
-		} else if (urlLower.endsWith(".xml")) {
-			isPrefix = false;
-		}
-
-		return createBinding(url, isPrefix, username, password);
-	}
-
-	public static CmisBinding createBinding(String url, boolean isPrefix, String username, String password) {
-		// gather parameters
-		Map<String, String> parameters = new HashMap<String, String>();
-		parameters.put(SessionParameter.USER, username);
-		parameters.put(SessionParameter.PASSWORD, password);
-
-		if (!isPrefix) {
-			parameters.put(SessionParameter.WEBSERVICES_REPOSITORY_SERVICE, url);
-			parameters.put(SessionParameter.WEBSERVICES_NAVIGATION_SERVICE, url);
-			parameters.put(SessionParameter.WEBSERVICES_OBJECT_SERVICE, url);
-			parameters.put(SessionParameter.WEBSERVICES_VERSIONING_SERVICE, url);
-			parameters.put(SessionParameter.WEBSERVICES_DISCOVERY_SERVICE, url);
-			parameters.put(SessionParameter.WEBSERVICES_RELATIONSHIP_SERVICE, url);
-			parameters.put(SessionParameter.WEBSERVICES_MULTIFILING_SERVICE, url);
-			parameters.put(SessionParameter.WEBSERVICES_POLICY_SERVICE, url);
-			parameters.put(SessionParameter.WEBSERVICES_ACL_SERVICE, url);
-		} else {
-			parameters.put(SessionParameter.WEBSERVICES_REPOSITORY_SERVICE, url + "RepositoryService?wsdl");
-			parameters.put(SessionParameter.WEBSERVICES_NAVIGATION_SERVICE, url + "NavigationService?wsdl");
-			parameters.put(SessionParameter.WEBSERVICES_OBJECT_SERVICE, url + "ObjectService?wsdl");
-			parameters.put(SessionParameter.WEBSERVICES_VERSIONING_SERVICE, url + "VersioningService?wsdl");
-			parameters.put(SessionParameter.WEBSERVICES_DISCOVERY_SERVICE, url + "DiscoveryService?wsdl");
-			parameters.put(SessionParameter.WEBSERVICES_RELATIONSHIP_SERVICE, url + "RelationshipService?wsdl");
-			parameters.put(SessionParameter.WEBSERVICES_MULTIFILING_SERVICE, url + "MultiFilingService?wsdl");
-			parameters.put(SessionParameter.WEBSERVICES_POLICY_SERVICE, url + "PolicyService?wsdl");
-			parameters.put(SessionParameter.WEBSERVICES_ACL_SERVICE, url + "ACLService?wsdl");
-		}
-
-		// get factory and create provider
-		CmisBindingFactory factory = CmisBindingFactory.newInstance();
-		CmisBinding binding = factory.createCmisWebServicesBinding(parameters);
+    public static CmisBinding createBinding(String url, String username, String password) {
+        boolean isPrefix = true;
+        String urlLower = url.toLowerCase();
+
+        if (urlLower.endsWith("?wsdl")) {
+            isPrefix = false;
+        } else if (urlLower.endsWith(".wsdl")) {
+            isPrefix = false;
+        } else if (urlLower.endsWith(".xml")) {
+            isPrefix = false;
+        }
+
+        return createBinding(url, isPrefix, username, password);
+    }
+
+    public static CmisBinding createBinding(String url, boolean isPrefix, String username, String password) {
+        // gather parameters
+        Map<String, String> parameters = new HashMap<String, String>();
+        parameters.put(SessionParameter.USER, username);
+        parameters.put(SessionParameter.PASSWORD, password);
+
+        if (!isPrefix) {
+            parameters.put(SessionParameter.WEBSERVICES_REPOSITORY_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_NAVIGATION_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_OBJECT_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_VERSIONING_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_DISCOVERY_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_RELATIONSHIP_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_MULTIFILING_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_POLICY_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_ACL_SERVICE, url);
+        } else {
+            parameters.put(SessionParameter.WEBSERVICES_REPOSITORY_SERVICE, url + "RepositoryService?wsdl");
+            parameters.put(SessionParameter.WEBSERVICES_NAVIGATION_SERVICE, url + "NavigationService?wsdl");
+            parameters.put(SessionParameter.WEBSERVICES_OBJECT_SERVICE, url + "ObjectService?wsdl");
+            parameters.put(SessionParameter.WEBSERVICES_VERSIONING_SERVICE, url + "VersioningService?wsdl");
+            parameters.put(SessionParameter.WEBSERVICES_DISCOVERY_SERVICE, url + "DiscoveryService?wsdl");
+            parameters.put(SessionParameter.WEBSERVICES_RELATIONSHIP_SERVICE, url + "RelationshipService?wsdl");
+            parameters.put(SessionParameter.WEBSERVICES_MULTIFILING_SERVICE, url + "MultiFilingService?wsdl");
+            parameters.put(SessionParameter.WEBSERVICES_POLICY_SERVICE, url + "PolicyService?wsdl");
+            parameters.put(SessionParameter.WEBSERVICES_ACL_SERVICE, url + "ACLService?wsdl");
+        }
+
+        // get factory and create provider
+        CmisBindingFactory factory = CmisBindingFactory.newInstance();
+        CmisBinding binding = factory.createCmisWebServicesBinding(parameters);
 
-		return binding;
-	}
+        return binding;
+    }
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/SessionFactoryImpl.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/SessionFactoryImpl.java?rev=936922&r1=936921&r2=936922&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/SessionFactoryImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/SessionFactoryImpl.java Thu Apr 22 16:04:19 2010
@@ -53,67 +53,67 @@ import org.apache.chemistry.opencmis.com
  */
 public class SessionFactoryImpl implements SessionFactory {
 
-	protected SessionFactoryImpl() {
+    protected SessionFactoryImpl() {
 
-	}
+    }
 
-	public static SessionFactory newInstance() {
-		return new SessionFactoryImpl();
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.SessionFactory#createSession(java.util
-	 * .Map)
-	 */
-	@SuppressWarnings("unchecked")
-	public <T extends Session> T createSession(Map<String, String> parameters) {
-		Session s = null;
-		SessionType t = null;
-
-		// determine session type
-		if (parameters.containsKey(SessionParameter.SESSION_TYPE)) {
-			t = SessionType.fromValue(parameters.get(SessionParameter.SESSION_TYPE));
-		} else {
-			// default session type if type is not set
-			t = SessionType.PERSISTENT;
-		}
-
-		switch (t) {
-		case PERSISTENT:
-			PersistentSessionImpl ps = new PersistentSessionImpl(parameters);
-			ps.connect(); // connect session with provider
-			s = ps;
-			break;
-		case TRANSIENT:
-			throw new CmisNotSupportedException("SessionType " + t + "not implemented!");
-		default:
-			throw new CmisRuntimeException("SessionType " + t + "not known!");
-		}
-
-		return (T) s;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.SessionFactory#getRepositories(java.util
-	 * .Map)
-	 */
-	public List<Repository> getRepositories(Map<String, String> parameters) {
-		CmisBinding binding = CmisBindingHelper.createProvider(parameters);
-
-		List<RepositoryInfo> repositoryInfos = binding.getRepositoryService().getRepositoryInfos(null);
-
-		List<Repository> result = new ArrayList<Repository>();
-		for (RepositoryInfo data : repositoryInfos) {
-			result.add(new RepositoryImpl(data, parameters, this));
-		}
+    public static SessionFactory newInstance() {
+        return new SessionFactoryImpl();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.SessionFactory#createSession(java.util
+     * .Map)
+     */
+    @SuppressWarnings("unchecked")
+    public <T extends Session> T createSession(Map<String, String> parameters) {
+        Session s = null;
+        SessionType t = null;
+
+        // determine session type
+        if (parameters.containsKey(SessionParameter.SESSION_TYPE)) {
+            t = SessionType.fromValue(parameters.get(SessionParameter.SESSION_TYPE));
+        } else {
+            // default session type if type is not set
+            t = SessionType.PERSISTENT;
+        }
+
+        switch (t) {
+        case PERSISTENT:
+            PersistentSessionImpl ps = new PersistentSessionImpl(parameters);
+            ps.connect(); // connect session with provider
+            s = ps;
+            break;
+        case TRANSIENT:
+            throw new CmisNotSupportedException("SessionType " + t + "not implemented!");
+        default:
+            throw new CmisRuntimeException("SessionType " + t + "not known!");
+        }
+
+        return (T) s;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.SessionFactory#getRepositories(java.util
+     * .Map)
+     */
+    public List<Repository> getRepositories(Map<String, String> parameters) {
+        CmisBinding binding = CmisBindingHelper.createProvider(parameters);
+
+        List<RepositoryInfo> repositoryInfos = binding.getRepositoryService().getRepositoryInfos(null);
+
+        List<Repository> result = new ArrayList<Repository>();
+        for (RepositoryInfo data : repositoryInfos) {
+            result.add(new RepositoryImpl(data, parameters, this));
+        }
 
-		return result;
-	}
+        return result;
+    }
 
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractPersistentCmisObject.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/AbstractPersistentCmisObject.java?rev=936922&r1=936921&r2=936922&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractPersistentCmisObject.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractPersistentCmisObject.java Thu Apr 22 16:04:19 2010
@@ -59,874 +59,882 @@ import org.apache.chemistry.opencmis.com
  */
 public abstract class AbstractPersistentCmisObject implements CmisObject {
 
-	private PersistentSessionImpl session;
-	private ObjectType objectType;
-	private Map<String, Property<?>> properties;
-	private AllowableActions allowableActions;
-	private List<Rendition> renditions;
-	private Acl acl;
-	private List<Policy> policies;
-	private List<Relationship> relationships;
-	private OperationContext creationContext;
-	private boolean isChanged = false;
-	private long refreshTimestamp;
-
-	private final ReentrantReadWriteLock fLock = new ReentrantReadWriteLock();
-
-	/**
-	 * Initializes the object.
-	 */
-	protected void initialize(PersistentSessionImpl session, ObjectType objectType, ObjectData objectData,
-			OperationContext context) {
-		if (session == null) {
-			throw new IllegalArgumentException("Session must be set!");
-		}
-
-		if (objectType == null) {
-			throw new IllegalArgumentException("Object type must be set!");
-		}
-
-		if (objectType.getPropertyDefinitions().size() < 9) {
-			// there must be at least the 9 standard properties that all objects
-			// have
-			throw new IllegalArgumentException("Object type must have property defintions!");
-		}
-
-		this.session = session;
-		this.objectType = objectType;
-		this.creationContext = new OperationContextImpl(context);
-		this.refreshTimestamp = System.currentTimeMillis();
-
-		ObjectFactory of = getObjectFactory();
-
-		if (objectData != null) {
-			// handle properties
-			if (objectData.getProperties() != null) {
-				this.properties = of.convertProperties(objectType, objectData.getProperties());
-			}
-
-			// handle allowable actions
-			if (objectData.getAllowableActions() != null) {
-				this.allowableActions = objectData.getAllowableActions();
-			}
-
-			// handle renditions
-			if (objectData.getRenditions() != null) {
-				this.renditions = new ArrayList<Rendition>();
-				for (RenditionData rd : objectData.getRenditions()) {
-					this.renditions.add(of.convertRendition(getId(), rd));
-				}
-			}
-
-			// handle ACL
-			if (objectData.getAcl() != null) {
-				acl = objectData.getAcl();
-			}
-
-			// handle policies
-			if ((objectData.getPolicyIds() != null) && (objectData.getPolicyIds().getPolicyIds() != null)) {
-				policies = new ArrayList<Policy>();
-				for (String pid : objectData.getPolicyIds().getPolicyIds()) {
-					CmisObject policy = session.getObject(getSession().createObjectId(pid));
-					if (policy instanceof Policy) {
-						policies.add((Policy) policy);
-					}
-				}
-			}
-
-			// handle relationships
-			if (objectData.getRelationships() != null) {
-				relationships = new ArrayList<Relationship>();
-				for (ObjectData rod : objectData.getRelationships()) {
-					CmisObject relationship = of.convertObject(rod, this.creationContext);
-					if (relationship instanceof Relationship) {
-						relationships.add((Relationship) relationship);
-					}
-				}
-			}
-		}
-
-		isChanged = false;
-	}
-
-	/**
-	 * Acquires a write lock.
-	 */
-	protected void writeLock() {
-		fLock.writeLock().lock();
-	}
-
-	/**
-	 * Releases a write lock.
-	 */
-	protected void writeUnlock() {
-		fLock.writeLock().unlock();
-	}
-
-	/**
-	 * Acquires a read lock.
-	 */
-	protected void readLock() {
-		fLock.readLock().lock();
-	}
-
-	/**
-	 * Releases a read lock.
-	 */
-	protected void readUnlock() {
-		fLock.readLock().unlock();
-	}
-
-	/**
-	 * Returns the session object.
-	 */
-	protected PersistentSessionImpl getSession() {
-		return this.session;
-	}
-
-	/**
-	 * Returns the repository id.
-	 */
-	protected String getRepositoryId() {
-		return getSession().getRepositoryId();
-	}
-
-	/**
-	 * Returns the object type.
-	 */
-	protected ObjectType getObjectType() {
-		readLock();
-		try {
-			return this.objectType;
-		} finally {
-			readUnlock();
-		}
-	}
-
-	/**
-	 * Returns the binding object.
-	 */
-	protected CmisBinding getBinding() {
-		return getSession().getBinding();
-	}
-
-	/**
-	 * Returns the object factory.
-	 */
-	protected ObjectFactory getObjectFactory() {
-		return getSession().getObjectFactory();
-	}
-
-	/**
-	 * Returns the id of this object or throws an exception if the id is
-	 * unknown.
-	 */
-	protected String getObjectId() {
-		String objectId = getId();
-		if (objectId == null) {
-			throw new IllegalStateException("Object Id is unknown!");
-		}
-
-		return objectId;
-	}
-
-	// --- operations ---
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.CmisObject#delete(boolean)
-	 */
-	public void delete(boolean allVersions) {
-		String objectId = getObjectId();
-		getBinding().getObjectService().deleteObject(getRepositoryId(), objectId, allVersions, null);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.CmisObject#updateProperties()
-	 */
-	public ObjectId updateProperties() {
-		readLock();
-		try {
-			String objectId = getObjectId();
-			Holder<String> objectIdHolder = new Holder<String>(objectId);
-
-			String changeToken = getChangeToken();
-			Holder<String> changeTokenHolder = new Holder<String>(changeToken);
-
-			Set<Updatability> updatebility = new HashSet<Updatability>();
-			updatebility.add(Updatability.READWRITE);
-
-			// check if checked out
-			Boolean isCheckedOut = getPropertyValue(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT);
-			if ((isCheckedOut != null) && isCheckedOut.booleanValue()) {
-				updatebility.add(Updatability.WHENCHECKEDOUT);
-			}
-
-			// it's time to update
-			getBinding().getObjectService().updateProperties(getRepositoryId(), objectIdHolder, changeTokenHolder,
-					getObjectFactory().convertProperties(this.properties, this.objectType, updatebility), null);
-
-			if (objectIdHolder.getValue() == null) {
-				return null;
-			}
-
-			return getSession().createObjectId(objectIdHolder.getValue());
-		} finally {
-			readUnlock();
-		}
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.CmisObject#updateProperties(java.util.Map)
-	 */
-	public ObjectId updateProperties(Map<String, ?> properties) {
-		if ((properties == null) || (properties.isEmpty())) {
-			throw new IllegalArgumentException("Properties must not be empty!");
-		}
-
-		readLock();
-		try {
-			String objectId = getObjectId();
-			Holder<String> objectIdHolder = new Holder<String>(objectId);
-
-			String changeToken = getChangeToken();
-			Holder<String> changeTokenHolder = new Holder<String>(changeToken);
-
-			Set<Updatability> updatebility = new HashSet<Updatability>();
-			updatebility.add(Updatability.READWRITE);
-
-			// check if checked out
-			Boolean isCheckedOut = getPropertyValue(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT);
-			if ((isCheckedOut != null) && isCheckedOut.booleanValue()) {
-				updatebility.add(Updatability.WHENCHECKEDOUT);
-			}
-
-			// it's time to update
-			getBinding().getObjectService().updateProperties(getRepositoryId(), objectIdHolder, changeTokenHolder,
-					getObjectFactory().convertProperties(properties, this.objectType, updatebility), null);
-
-			if (objectIdHolder.getValue() == null) {
-				return null;
-			}
-
-			return getSession().createObjectId(objectIdHolder.getValue());
-		} finally {
-			readUnlock();
-		}
-	}
-
-	// --- properties ---
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.CmisObject#getBaseType()
-	 */
-	public ObjectType getBaseType() {
-		BaseTypeId baseTypeId = getBaseTypeId();
-		if (baseTypeId == null) {
-			return null;
-		}
-
-		return getSession().getTypeDefinition(baseTypeId.value());
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.CmisObject#getBaseTypeId()
-	 */
-	public BaseTypeId getBaseTypeId() {
-		String baseType = getPropertyValue(PropertyIds.BASE_TYPE_ID);
-		if (baseType == null) {
-			return null;
-		}
-
-		return BaseTypeId.fromValue(baseType);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.CmisObject#getChangeToken()
-	 */
-	public String getChangeToken() {
-		return getPropertyValue(PropertyIds.CHANGE_TOKEN);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.CmisObject#getCreatedBy()
-	 */
-	public String getCreatedBy() {
-		return getPropertyValue(PropertyIds.CREATED_BY);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.CmisObject#getCreationDate()
-	 */
-	public GregorianCalendar getCreationDate() {
-		return getPropertyValue(PropertyIds.CREATION_DATE);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.CmisObject#getId()
-	 */
-	public String getId() {
-		return getPropertyValue(PropertyIds.OBJECT_ID);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.CmisObject#getLastModificationDate()
-	 */
-	public GregorianCalendar getLastModificationDate() {
-		return getPropertyValue(PropertyIds.LAST_MODIFICATION_DATE);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.CmisObject#getLastModifiedBy()
-	 */
-	public String getLastModifiedBy() {
-		return getPropertyValue(PropertyIds.LAST_MODIFIED_BY);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.CmisObject#getName()
-	 */
-	public String getName() {
-		return getPropertyValue(PropertyIds.NAME);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.CmisObject#getProperties()
-	 */
-	public List<Property<?>> getProperties() {
-		readLock();
-		try {
-			return new ArrayList<Property<?>>(this.properties.values());
-		} finally {
-			readUnlock();
-		}
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.CmisObject#getProperty(java.lang.String)
-	 */
-	@SuppressWarnings("unchecked")
-	public <T> Property<T> getProperty(String id) {
-		readLock();
-		try {
-			return (Property<T>) this.properties.get(id);
-		} finally {
-			readUnlock();
-		}
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.CmisObject#getPropertyMultivalue(java.
-	 * lang.String)
-	 */
-	public <T> List<T> getPropertyMultivalue(String id) {
-		Property<T> property = getProperty(id);
-		if (property == null) {
-			return null;
-		}
-
-		return property.getValues();
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.CmisObject#getPropertyValue(java.lang.
-	 * String)
-	 */
-	public <T> T getPropertyValue(String id) {
-		Property<T> property = getProperty(id);
-		if (property == null) {
-			return null;
-		}
-
-		return property.getFirstValue();
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.CmisObject#setName(java.lang.String)
-	 */
-	public void setName(String name) {
-		setProperty(PropertyIds.NAME, name);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.CmisObject#setProperty(java.lang.String,
-	 * java.lang.Object)
-	 */
-	@SuppressWarnings("unchecked")
-	public <T> void setProperty(String id, T value) {
-		PropertyDefinition<?> propertyDefinition = checkProperty(id, value);
-
-		// check updatability
-		if (propertyDefinition.getUpdatability() == Updatability.READONLY) {
-			throw new IllegalArgumentException("Property is read-only!");
-		}
-
-		// create property
-		Property<T> newProperty = (Property<T>) getObjectFactory().createProperty(
-				(PropertyDefinition<T>) propertyDefinition, value);
-
-		writeLock();
-		try {
-			setChanged();
-			this.properties.put(id, newProperty);
-		} finally {
-			writeUnlock();
-		}
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.CmisObject#setPropertyMultivalue(java.
-	 * lang.String, java.util.List)
-	 */
-	@SuppressWarnings("unchecked")
-	public <T> void setPropertyMultivalue(String id, List<T> value) {
-		PropertyDefinition<?> propertyDefinition = checkProperty(id, value);
-
-		// check updatability
-		if (propertyDefinition.getUpdatability() == Updatability.READONLY) {
-			throw new IllegalArgumentException("Property is read-only!");
-		}
-
-		// create property
-		Property<T> newProperty = (Property<T>) getObjectFactory().createPropertyMultivalue(
-				(PropertyDefinition<T>) propertyDefinition, value);
-
-		writeLock();
-		try {
-			setChanged();
-			this.properties.put(id, newProperty);
-		} finally {
-			writeUnlock();
-		}
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.CmisObject#getType()
-	 */
-	public ObjectType getType() {
-		readLock();
-		try {
-			return this.objectType;
-		} finally {
-			readUnlock();
-		}
-	}
-
-	// --- allowable actions ---
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.CmisObject#getAllowableActions()
-	 */
-	public AllowableActions getAllowableActions() {
-		readLock();
-		try {
-			return this.allowableActions;
-		} finally {
-			readUnlock();
-		}
-	}
-
-	// --- renditions ---
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.CmisObject#getRenditions()
-	 */
-	public List<Rendition> getRenditions() {
-		readLock();
-		try {
-			return this.renditions;
-		} finally {
-			readUnlock();
-		}
-	}
-
-	// --- ACL ---
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.CmisObject#getAcl(boolean)
-	 */
-	public Acl getAcl(boolean onlyBasicPermissions) {
-		String objectId = getObjectId();
-		return getBinding().getAclService().getAcl(getRepositoryId(), objectId, onlyBasicPermissions, null);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.CmisObject#applyAcl(java.util.List,
-	 * java.util.List, org.apache.opencmis.commons.enums.AclPropagation)
-	 */
-	public Acl applyAcl(List<Ace> addAces, List<Ace> removeAces, AclPropagation aclPropagation) {
-		String objectId = getObjectId();
-
-		ObjectFactory of = getObjectFactory();
-
-		return getBinding().getAclService().applyAcl(getRepositoryId(), objectId, of.convertAces(addAces),
-				of.convertAces(removeAces), aclPropagation, null);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.CmisObject#addAcl(java.util.List,
-	 * org.apache.opencmis.commons.enums.AclPropagation)
-	 */
-	public void addAcl(List<Ace> addAces, AclPropagation aclPropagation) {
-		applyAcl(addAces, null, aclPropagation);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.CmisObject#removeAcl(java.util.List,
-	 * org.apache.opencmis.commons.enums.AclPropagation)
-	 */
-	public void removeAcl(List<Ace> removeAces, AclPropagation aclPropagation) {
-		applyAcl(null, removeAces, aclPropagation);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.CmisObject#getAcl()
-	 */
-	public Acl getAcl() {
-		readLock();
-		try {
-			return this.acl;
-		} finally {
-			readUnlock();
-		}
-	}
-
-	// --- policies ---
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.CmisObject#applyPolicy(org.apache.opencmis
-	 * .client.api.ObjectId)
-	 */
-	public void applyPolicy(ObjectId policyId) {
-		if ((policyId == null) || (policyId.getId() == null)) {
-			throw new IllegalArgumentException("Policy Id is not set!");
-		}
-
-		String objectId = getObjectId();
-		getBinding().getPolicyService().applyPolicy(getRepositoryId(), policyId.getId(), objectId, null);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.CmisObject#removePolicy(org.apache.opencmis
-	 * .client.api.ObjectId)
-	 */
-	public void removePolicy(ObjectId policyId) {
-		if ((policyId == null) || (policyId.getId() == null)) {
-			throw new IllegalArgumentException("Policy Id is not set!");
-		}
-
-		String objectId = getObjectId();
-		getBinding().getPolicyService().removePolicy(getRepositoryId(), policyId.getId(), objectId, null);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.CmisObject#getPolicies()
-	 */
-	public List<Policy> getPolicies() {
-		readLock();
-		try {
-			return this.policies;
-		} finally {
-			readUnlock();
-		}
-	}
-
-	// --- relationships ---
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.CmisObject#getRelationships()
-	 */
-	public List<Relationship> getRelationships() {
-		readLock();
-		try {
-			return this.relationships;
-		} finally {
-			readUnlock();
-		}
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.CmisObject#getRelationships(boolean,
-	 * org.apache.opencmis.commons.enums.RelationshipDirection,
-	 * org.apache.opencmis.client.api.objecttype.ObjectType,
-	 * org.apache.opencmis.client.api.OperationContext, int)
-	 */
-	public PagingIterable<Relationship> getRelationships(final boolean includeSubRelationshipTypes,
-			final RelationshipDirection relationshipDirection, ObjectType type, OperationContext context,
-			final int itemsPerPage) {
-//		if (itemsPerPage < 1) {
-//			throw new IllegalArgumentException("itemsPerPage must be > 0!");
-//		}
-//
-//		final String objectId = getObjectId();
-//		final String typeId = (type == null ? null : type.getId());
-//		final RelationshipService relationshipService = getBinding().getRelationshipService();
-//		final OperationContext ctxt = (context != null ? context : new OperationContextImpl(getSession()
-//				.getDefaultContext()));
-//
-//		return new AbstractPagingList<Relationship>() {
-//
-//			@Override
-//			protected FetchResult fetchPage(int pageNumber) {
-//				int skipCount = pageNumber * getMaxItemsPerPage();
-//
-//				// fetch the relationships
-//				ObjectList relList = relationshipService.getObjectRelationships(getRepositoryId(), objectId,
-//						includeSubRelationshipTypes, relationshipDirection, typeId, ctxt.getFilterString(), ctxt
-//								.isIncludeAllowableActions(), BigInteger.valueOf(getMaxItemsPerPage()), BigInteger
-//								.valueOf(skipCount), null);
-//
-//				// convert relationship objects
-//				List<Relationship> page = new ArrayList<Relationship>();
-//				if (relList.getObjects() != null) {
-//					for (ObjectData rod : relList.getObjects()) {
-//						Relationship relationship = new PersistentRelationshipImpl(getSession(), getObjectFactory()
-//								.getTypeFromObjectData(rod), rod, ctxt);
-//
-//						page.add(relationship);
-//					}
-//				}
-//
-//				return new FetchResult(page, relList.getNumItems(), relList.hasMoreItems());
-//			}
-//
-//			@Override
-//			public int getMaxItemsPerPage() {
-//				return itemsPerPage;
-//			}
-//		};
-			return null;
-}
-
-	// --- other ---
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.CmisObject#isChanged()
-	 */
-	public boolean isChanged() {
-		readLock();
-		try {
-			return isChanged;
-		} finally {
-			readUnlock();
-		}
-	}
-
-	/**
-	 * Sets the isChanged flag to <code>true</code>
-	 */
-	protected void setChanged() {
-		writeLock();
-		try {
-			isChanged = true;
-		} finally {
-			writeUnlock();
-		}
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.CmisObject#getRefreshTimestamp()
-	 */
-	public long getRefreshTimestamp() {
-		readLock();
-		try {
-			return this.refreshTimestamp;
-		} finally {
-			readUnlock();
-		}
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.CmisObject#refresh(org.apache.opencmis
-	 * .client.api.OperationContext )
-	 */
-	public void refresh() {
-		writeLock();
-		try {
-			String objectId = getObjectId();
-
-			// get the latest data from the repository
-			ObjectData objectData = getSession().getBinding().getObjectService().getObject(getRepositoryId(), objectId,
-					creationContext.getFilterString(), creationContext.isIncludeAllowableActions(),
-					creationContext.getIncludeRelationships(), creationContext.getRenditionFilterString(),
-					creationContext.isIncludePolicies(), creationContext.isIncludeAcls(), null);
-
-			// reset this object
-			initialize(getSession(), getObjectType(), objectData, this.creationContext);
-		} finally {
-			writeUnlock();
-		}
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.CmisObject#refreshIfOld(long)
-	 */
-	public void refreshIfOld(long durationInMillis) {
-		writeLock();
-		try {
-			if (this.refreshTimestamp < System.currentTimeMillis() - durationInMillis) {
-				refresh();
-			}
-		} finally {
-			writeUnlock();
-		}
-	}
-
-	// --- internal ---
-
-	/**
-	 * Checks if a value matches a property definition.
-	 */
-	private PropertyDefinition<?> checkProperty(String id, Object value) {
-		PropertyDefinition<?> propertyDefinition = getObjectType().getPropertyDefinitions().get(id);
-		if (propertyDefinition == null) {
-			throw new IllegalArgumentException("Unknown property '" + id + "'!");
-		}
-
-		// null values are ok for updates
-		if (value == null) {
-			return propertyDefinition;
-		}
-
-		// single and multi value check
-		List<?> values = null;
-		if (value instanceof List<?>) {
-			if (propertyDefinition.getCardinality() != Cardinality.MULTI) {
-				throw new IllegalArgumentException("Property '" + propertyDefinition.getId()
-						+ "' is not a multi value property!");
-			}
-
-			values = (List<?>) value;
-			if (values.isEmpty()) {
-				return propertyDefinition;
-			}
-		} else {
-			if (propertyDefinition.getCardinality() != Cardinality.SINGLE) {
-				throw new IllegalArgumentException("Property '" + propertyDefinition.getId()
-						+ "' is not a single value property!");
-			}
-
-			values = Collections.singletonList(value);
-		}
-
-		// check if list contains null values
-		for (Object o : values) {
-			if (o == null) {
-				throw new IllegalArgumentException("Property '" + propertyDefinition.getId()
-						+ "' contains null values!");
-			}
-		}
-
-		// take a sample and test the data type
-		boolean typeMatch = false;
-		Object firstValue = values.get(0);
-
-		switch (propertyDefinition.getPropertyType()) {
-		case STRING:
-		case ID:
-		case URI:
-		case HTML:
-			typeMatch = (firstValue instanceof String);
-			break;
-		case INTEGER:
-			typeMatch = (firstValue instanceof BigInteger);
-			break;
-		case DECIMAL:
-			typeMatch = (firstValue instanceof BigDecimal);
-			break;
-		case BOOLEAN:
-			typeMatch = (firstValue instanceof Boolean);
-			break;
-		case DATETIME:
-			typeMatch = (firstValue instanceof GregorianCalendar);
-			break;
-		}
-
-		if (!typeMatch) {
-			throw new IllegalArgumentException("Value of property '" + propertyDefinition.getId()
-					+ "' does not match property type!");
-		}
+    private PersistentSessionImpl session;
+    private ObjectType objectType;
+    private Map<String, Property<?>> properties;
+    private AllowableActions allowableActions;
+    private List<Rendition> renditions;
+    private Acl acl;
+    private List<Policy> policies;
+    private List<Relationship> relationships;
+    private OperationContext creationContext;
+    private boolean isChanged = false;
+    private long refreshTimestamp;
+
+    private final ReentrantReadWriteLock fLock = new ReentrantReadWriteLock();
+
+    /**
+     * Initializes the object.
+     */
+    protected void initialize(PersistentSessionImpl session, ObjectType objectType, ObjectData objectData,
+            OperationContext context) {
+        if (session == null) {
+            throw new IllegalArgumentException("Session must be set!");
+        }
+
+        if (objectType == null) {
+            throw new IllegalArgumentException("Object type must be set!");
+        }
+
+        if (objectType.getPropertyDefinitions().size() < 9) {
+            // there must be at least the 9 standard properties that all objects
+            // have
+            throw new IllegalArgumentException("Object type must have property defintions!");
+        }
+
+        this.session = session;
+        this.objectType = objectType;
+        this.creationContext = new OperationContextImpl(context);
+        this.refreshTimestamp = System.currentTimeMillis();
+
+        ObjectFactory of = getObjectFactory();
+
+        if (objectData != null) {
+            // handle properties
+            if (objectData.getProperties() != null) {
+                this.properties = of.convertProperties(objectType, objectData.getProperties());
+            }
+
+            // handle allowable actions
+            if (objectData.getAllowableActions() != null) {
+                this.allowableActions = objectData.getAllowableActions();
+            }
+
+            // handle renditions
+            if (objectData.getRenditions() != null) {
+                this.renditions = new ArrayList<Rendition>();
+                for (RenditionData rd : objectData.getRenditions()) {
+                    this.renditions.add(of.convertRendition(getId(), rd));
+                }
+            }
+
+            // handle ACL
+            if (objectData.getAcl() != null) {
+                acl = objectData.getAcl();
+            }
+
+            // handle policies
+            if ((objectData.getPolicyIds() != null) && (objectData.getPolicyIds().getPolicyIds() != null)) {
+                policies = new ArrayList<Policy>();
+                for (String pid : objectData.getPolicyIds().getPolicyIds()) {
+                    CmisObject policy = session.getObject(getSession().createObjectId(pid));
+                    if (policy instanceof Policy) {
+                        policies.add((Policy) policy);
+                    }
+                }
+            }
+
+            // handle relationships
+            if (objectData.getRelationships() != null) {
+                relationships = new ArrayList<Relationship>();
+                for (ObjectData rod : objectData.getRelationships()) {
+                    CmisObject relationship = of.convertObject(rod, this.creationContext);
+                    if (relationship instanceof Relationship) {
+                        relationships.add((Relationship) relationship);
+                    }
+                }
+            }
+        }
+
+        isChanged = false;
+    }
+
+    /**
+     * Acquires a write lock.
+     */
+    protected void writeLock() {
+        fLock.writeLock().lock();
+    }
+
+    /**
+     * Releases a write lock.
+     */
+    protected void writeUnlock() {
+        fLock.writeLock().unlock();
+    }
+
+    /**
+     * Acquires a read lock.
+     */
+    protected void readLock() {
+        fLock.readLock().lock();
+    }
+
+    /**
+     * Releases a read lock.
+     */
+    protected void readUnlock() {
+        fLock.readLock().unlock();
+    }
+
+    /**
+     * Returns the session object.
+     */
+    protected PersistentSessionImpl getSession() {
+        return this.session;
+    }
+
+    /**
+     * Returns the repository id.
+     */
+    protected String getRepositoryId() {
+        return getSession().getRepositoryId();
+    }
+
+    /**
+     * Returns the object type.
+     */
+    protected ObjectType getObjectType() {
+        readLock();
+        try {
+            return this.objectType;
+        } finally {
+            readUnlock();
+        }
+    }
+
+    /**
+     * Returns the binding object.
+     */
+    protected CmisBinding getBinding() {
+        return getSession().getBinding();
+    }
+
+    /**
+     * Returns the object factory.
+     */
+    protected ObjectFactory getObjectFactory() {
+        return getSession().getObjectFactory();
+    }
+
+    /**
+     * Returns the id of this object or throws an exception if the id is
+     * unknown.
+     */
+    protected String getObjectId() {
+        String objectId = getId();
+        if (objectId == null) {
+            throw new IllegalStateException("Object Id is unknown!");
+        }
+
+        return objectId;
+    }
+
+    // --- operations ---
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.CmisObject#delete(boolean)
+     */
+    public void delete(boolean allVersions) {
+        String objectId = getObjectId();
+        getBinding().getObjectService().deleteObject(getRepositoryId(), objectId, allVersions, null);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.CmisObject#updateProperties()
+     */
+    public ObjectId updateProperties() {
+        readLock();
+        try {
+            String objectId = getObjectId();
+            Holder<String> objectIdHolder = new Holder<String>(objectId);
+
+            String changeToken = getChangeToken();
+            Holder<String> changeTokenHolder = new Holder<String>(changeToken);
+
+            Set<Updatability> updatebility = new HashSet<Updatability>();
+            updatebility.add(Updatability.READWRITE);
+
+            // check if checked out
+            Boolean isCheckedOut = getPropertyValue(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT);
+            if ((isCheckedOut != null) && isCheckedOut.booleanValue()) {
+                updatebility.add(Updatability.WHENCHECKEDOUT);
+            }
+
+            // it's time to update
+            getBinding().getObjectService().updateProperties(getRepositoryId(), objectIdHolder, changeTokenHolder,
+                    getObjectFactory().convertProperties(this.properties, this.objectType, updatebility), null);
+
+            if (objectIdHolder.getValue() == null) {
+                return null;
+            }
+
+            return getSession().createObjectId(objectIdHolder.getValue());
+        } finally {
+            readUnlock();
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.CmisObject#updateProperties(java.util.Map)
+     */
+    public ObjectId updateProperties(Map<String, ?> properties) {
+        if ((properties == null) || (properties.isEmpty())) {
+            throw new IllegalArgumentException("Properties must not be empty!");
+        }
+
+        readLock();
+        try {
+            String objectId = getObjectId();
+            Holder<String> objectIdHolder = new Holder<String>(objectId);
+
+            String changeToken = getChangeToken();
+            Holder<String> changeTokenHolder = new Holder<String>(changeToken);
+
+            Set<Updatability> updatebility = new HashSet<Updatability>();
+            updatebility.add(Updatability.READWRITE);
+
+            // check if checked out
+            Boolean isCheckedOut = getPropertyValue(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT);
+            if ((isCheckedOut != null) && isCheckedOut.booleanValue()) {
+                updatebility.add(Updatability.WHENCHECKEDOUT);
+            }
+
+            // it's time to update
+            getBinding().getObjectService().updateProperties(getRepositoryId(), objectIdHolder, changeTokenHolder,
+                    getObjectFactory().convertProperties(properties, this.objectType, updatebility), null);
+
+            if (objectIdHolder.getValue() == null) {
+                return null;
+            }
+
+            return getSession().createObjectId(objectIdHolder.getValue());
+        } finally {
+            readUnlock();
+        }
+    }
+
+    // --- properties ---
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.CmisObject#getBaseType()
+     */
+    public ObjectType getBaseType() {
+        BaseTypeId baseTypeId = getBaseTypeId();
+        if (baseTypeId == null) {
+            return null;
+        }
+
+        return getSession().getTypeDefinition(baseTypeId.value());
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.CmisObject#getBaseTypeId()
+     */
+    public BaseTypeId getBaseTypeId() {
+        String baseType = getPropertyValue(PropertyIds.BASE_TYPE_ID);
+        if (baseType == null) {
+            return null;
+        }
+
+        return BaseTypeId.fromValue(baseType);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.CmisObject#getChangeToken()
+     */
+    public String getChangeToken() {
+        return getPropertyValue(PropertyIds.CHANGE_TOKEN);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.CmisObject#getCreatedBy()
+     */
+    public String getCreatedBy() {
+        return getPropertyValue(PropertyIds.CREATED_BY);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.CmisObject#getCreationDate()
+     */
+    public GregorianCalendar getCreationDate() {
+        return getPropertyValue(PropertyIds.CREATION_DATE);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.CmisObject#getId()
+     */
+    public String getId() {
+        return getPropertyValue(PropertyIds.OBJECT_ID);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.CmisObject#getLastModificationDate()
+     */
+    public GregorianCalendar getLastModificationDate() {
+        return getPropertyValue(PropertyIds.LAST_MODIFICATION_DATE);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.CmisObject#getLastModifiedBy()
+     */
+    public String getLastModifiedBy() {
+        return getPropertyValue(PropertyIds.LAST_MODIFIED_BY);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.CmisObject#getName()
+     */
+    public String getName() {
+        return getPropertyValue(PropertyIds.NAME);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.CmisObject#getProperties()
+     */
+    public List<Property<?>> getProperties() {
+        readLock();
+        try {
+            return new ArrayList<Property<?>>(this.properties.values());
+        } finally {
+            readUnlock();
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.CmisObject#getProperty(java.lang.String)
+     */
+    @SuppressWarnings("unchecked")
+    public <T> Property<T> getProperty(String id) {
+        readLock();
+        try {
+            return (Property<T>) this.properties.get(id);
+        } finally {
+            readUnlock();
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.CmisObject#getPropertyMultivalue(java.
+     * lang.String)
+     */
+    public <T> List<T> getPropertyMultivalue(String id) {
+        Property<T> property = getProperty(id);
+        if (property == null) {
+            return null;
+        }
+
+        return property.getValues();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.CmisObject#getPropertyValue(java.lang.
+     * String)
+     */
+    public <T> T getPropertyValue(String id) {
+        Property<T> property = getProperty(id);
+        if (property == null) {
+            return null;
+        }
+
+        return property.getFirstValue();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.CmisObject#setName(java.lang.String)
+     */
+    public void setName(String name) {
+        setProperty(PropertyIds.NAME, name);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.CmisObject#setProperty(java.lang.String,
+     * java.lang.Object)
+     */
+    @SuppressWarnings("unchecked")
+    public <T> void setProperty(String id, T value) {
+        PropertyDefinition<?> propertyDefinition = checkProperty(id, value);
+
+        // check updatability
+        if (propertyDefinition.getUpdatability() == Updatability.READONLY) {
+            throw new IllegalArgumentException("Property is read-only!");
+        }
+
+        // create property
+        Property<T> newProperty = (Property<T>) getObjectFactory().createProperty(
+                (PropertyDefinition<T>) propertyDefinition, value);
+
+        writeLock();
+        try {
+            setChanged();
+            this.properties.put(id, newProperty);
+        } finally {
+            writeUnlock();
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.CmisObject#setPropertyMultivalue(java.
+     * lang.String, java.util.List)
+     */
+    @SuppressWarnings("unchecked")
+    public <T> void setPropertyMultivalue(String id, List<T> value) {
+        PropertyDefinition<?> propertyDefinition = checkProperty(id, value);
+
+        // check updatability
+        if (propertyDefinition.getUpdatability() == Updatability.READONLY) {
+            throw new IllegalArgumentException("Property is read-only!");
+        }
+
+        // create property
+        Property<T> newProperty = (Property<T>) getObjectFactory().createPropertyMultivalue(
+                (PropertyDefinition<T>) propertyDefinition, value);
+
+        writeLock();
+        try {
+            setChanged();
+            this.properties.put(id, newProperty);
+        } finally {
+            writeUnlock();
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.CmisObject#getType()
+     */
+    public ObjectType getType() {
+        readLock();
+        try {
+            return this.objectType;
+        } finally {
+            readUnlock();
+        }
+    }
+
+    // --- allowable actions ---
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.CmisObject#getAllowableActions()
+     */
+    public AllowableActions getAllowableActions() {
+        readLock();
+        try {
+            return this.allowableActions;
+        } finally {
+            readUnlock();
+        }
+    }
+
+    // --- renditions ---
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.CmisObject#getRenditions()
+     */
+    public List<Rendition> getRenditions() {
+        readLock();
+        try {
+            return this.renditions;
+        } finally {
+            readUnlock();
+        }
+    }
+
+    // --- ACL ---
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.CmisObject#getAcl(boolean)
+     */
+    public Acl getAcl(boolean onlyBasicPermissions) {
+        String objectId = getObjectId();
+        return getBinding().getAclService().getAcl(getRepositoryId(), objectId, onlyBasicPermissions, null);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.CmisObject#applyAcl(java.util.List,
+     * java.util.List, org.apache.opencmis.commons.enums.AclPropagation)
+     */
+    public Acl applyAcl(List<Ace> addAces, List<Ace> removeAces, AclPropagation aclPropagation) {
+        String objectId = getObjectId();
+
+        ObjectFactory of = getObjectFactory();
+
+        return getBinding().getAclService().applyAcl(getRepositoryId(), objectId, of.convertAces(addAces),
+                of.convertAces(removeAces), aclPropagation, null);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.CmisObject#addAcl(java.util.List,
+     * org.apache.opencmis.commons.enums.AclPropagation)
+     */
+    public void addAcl(List<Ace> addAces, AclPropagation aclPropagation) {
+        applyAcl(addAces, null, aclPropagation);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.CmisObject#removeAcl(java.util.List,
+     * org.apache.opencmis.commons.enums.AclPropagation)
+     */
+    public void removeAcl(List<Ace> removeAces, AclPropagation aclPropagation) {
+        applyAcl(null, removeAces, aclPropagation);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.CmisObject#getAcl()
+     */
+    public Acl getAcl() {
+        readLock();
+        try {
+            return this.acl;
+        } finally {
+            readUnlock();
+        }
+    }
+
+    // --- policies ---
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.CmisObject#applyPolicy(org.apache.opencmis
+     * .client.api.ObjectId)
+     */
+    public void applyPolicy(ObjectId policyId) {
+        if ((policyId == null) || (policyId.getId() == null)) {
+            throw new IllegalArgumentException("Policy Id is not set!");
+        }
+
+        String objectId = getObjectId();
+        getBinding().getPolicyService().applyPolicy(getRepositoryId(), policyId.getId(), objectId, null);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.CmisObject#removePolicy(org.apache.opencmis
+     * .client.api.ObjectId)
+     */
+    public void removePolicy(ObjectId policyId) {
+        if ((policyId == null) || (policyId.getId() == null)) {
+            throw new IllegalArgumentException("Policy Id is not set!");
+        }
+
+        String objectId = getObjectId();
+        getBinding().getPolicyService().removePolicy(getRepositoryId(), policyId.getId(), objectId, null);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.CmisObject#getPolicies()
+     */
+    public List<Policy> getPolicies() {
+        readLock();
+        try {
+            return this.policies;
+        } finally {
+            readUnlock();
+        }
+    }
+
+    // --- relationships ---
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.CmisObject#getRelationships()
+     */
+    public List<Relationship> getRelationships() {
+        readLock();
+        try {
+            return this.relationships;
+        } finally {
+            readUnlock();
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.CmisObject#getRelationships(boolean,
+     * org.apache.opencmis.commons.enums.RelationshipDirection,
+     * org.apache.opencmis.client.api.objecttype.ObjectType,
+     * org.apache.opencmis.client.api.OperationContext, int)
+     */
+    public PagingIterable<Relationship> getRelationships(final boolean includeSubRelationshipTypes,
+            final RelationshipDirection relationshipDirection, ObjectType type, OperationContext context,
+            final int itemsPerPage) {
+        // if (itemsPerPage < 1) {
+        // throw new IllegalArgumentException("itemsPerPage must be > 0!");
+        // }
+        //
+        // final String objectId = getObjectId();
+        // final String typeId = (type == null ? null : type.getId());
+        // final RelationshipService relationshipService =
+        // getBinding().getRelationshipService();
+        // final OperationContext ctxt = (context != null ? context : new
+        // OperationContextImpl(getSession()
+        // .getDefaultContext()));
+        //
+        // return new AbstractPagingList<Relationship>() {
+        //
+        // @Override
+        // protected FetchResult fetchPage(int pageNumber) {
+        // int skipCount = pageNumber * getMaxItemsPerPage();
+        //
+        // // fetch the relationships
+        // ObjectList relList =
+        // relationshipService.getObjectRelationships(getRepositoryId(),
+        // objectId,
+        // includeSubRelationshipTypes, relationshipDirection, typeId,
+        // ctxt.getFilterString(), ctxt
+        // .isIncludeAllowableActions(),
+        // BigInteger.valueOf(getMaxItemsPerPage()), BigInteger
+        // .valueOf(skipCount), null);
+        //
+        // // convert relationship objects
+        // List<Relationship> page = new ArrayList<Relationship>();
+        // if (relList.getObjects() != null) {
+        // for (ObjectData rod : relList.getObjects()) {
+        // Relationship relationship = new
+        // PersistentRelationshipImpl(getSession(), getObjectFactory()
+        // .getTypeFromObjectData(rod), rod, ctxt);
+        //
+        // page.add(relationship);
+        // }
+        // }
+        //
+        // return new FetchResult(page, relList.getNumItems(),
+        // relList.hasMoreItems());
+        // }
+        //
+        // @Override
+        // public int getMaxItemsPerPage() {
+        // return itemsPerPage;
+        // }
+        // };
+        return null;
+    }
+
+    // --- other ---
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.CmisObject#isChanged()
+     */
+    public boolean isChanged() {
+        readLock();
+        try {
+            return isChanged;
+        } finally {
+            readUnlock();
+        }
+    }
+
+    /**
+     * Sets the isChanged flag to <code>true</code>
+     */
+    protected void setChanged() {
+        writeLock();
+        try {
+            isChanged = true;
+        } finally {
+            writeUnlock();
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.CmisObject#getRefreshTimestamp()
+     */
+    public long getRefreshTimestamp() {
+        readLock();
+        try {
+            return this.refreshTimestamp;
+        } finally {
+            readUnlock();
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.CmisObject#refresh(org.apache.opencmis
+     * .client.api.OperationContext )
+     */
+    public void refresh() {
+        writeLock();
+        try {
+            String objectId = getObjectId();
+
+            // get the latest data from the repository
+            ObjectData objectData = getSession().getBinding().getObjectService().getObject(getRepositoryId(), objectId,
+                    creationContext.getFilterString(), creationContext.isIncludeAllowableActions(),
+                    creationContext.getIncludeRelationships(), creationContext.getRenditionFilterString(),
+                    creationContext.isIncludePolicies(), creationContext.isIncludeAcls(), null);
+
+            // reset this object
+            initialize(getSession(), getObjectType(), objectData, this.creationContext);
+        } finally {
+            writeUnlock();
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.CmisObject#refreshIfOld(long)
+     */
+    public void refreshIfOld(long durationInMillis) {
+        writeLock();
+        try {
+            if (this.refreshTimestamp < System.currentTimeMillis() - durationInMillis) {
+                refresh();
+            }
+        } finally {
+            writeUnlock();
+        }
+    }
+
+    // --- internal ---
+
+    /**
+     * Checks if a value matches a property definition.
+     */
+    private PropertyDefinition<?> checkProperty(String id, Object value) {
+        PropertyDefinition<?> propertyDefinition = getObjectType().getPropertyDefinitions().get(id);
+        if (propertyDefinition == null) {
+            throw new IllegalArgumentException("Unknown property '" + id + "'!");
+        }
+
+        // null values are ok for updates
+        if (value == null) {
+            return propertyDefinition;
+        }
+
+        // single and multi value check
+        List<?> values = null;
+        if (value instanceof List<?>) {
+            if (propertyDefinition.getCardinality() != Cardinality.MULTI) {
+                throw new IllegalArgumentException("Property '" + propertyDefinition.getId()
+                        + "' is not a multi value property!");
+            }
+
+            values = (List<?>) value;
+            if (values.isEmpty()) {
+                return propertyDefinition;
+            }
+        } else {
+            if (propertyDefinition.getCardinality() != Cardinality.SINGLE) {
+                throw new IllegalArgumentException("Property '" + propertyDefinition.getId()
+                        + "' is not a single value property!");
+            }
+
+            values = Collections.singletonList(value);
+        }
+
+        // check if list contains null values
+        for (Object o : values) {
+            if (o == null) {
+                throw new IllegalArgumentException("Property '" + propertyDefinition.getId()
+                        + "' contains null values!");
+            }
+        }
+
+        // take a sample and test the data type
+        boolean typeMatch = false;
+        Object firstValue = values.get(0);
+
+        switch (propertyDefinition.getPropertyType()) {
+        case STRING:
+        case ID:
+        case URI:
+        case HTML:
+            typeMatch = (firstValue instanceof String);
+            break;
+        case INTEGER:
+            typeMatch = (firstValue instanceof BigInteger);
+            break;
+        case DECIMAL:
+            typeMatch = (firstValue instanceof BigDecimal);
+            break;
+        case BOOLEAN:
+            typeMatch = (firstValue instanceof Boolean);
+            break;
+        case DATETIME:
+            typeMatch = (firstValue instanceof GregorianCalendar);
+            break;
+        }
+
+        if (!typeMatch) {
+            throw new IllegalArgumentException("Value of property '" + propertyDefinition.getId()
+                    + "' does not match property type!");
+        }
 
-		return propertyDefinition;
-	}
+        return propertyDefinition;
+    }
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractPersistentFilableCmisObject.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/AbstractPersistentFilableCmisObject.java?rev=936922&r1=936921&r2=936922&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractPersistentFilableCmisObject.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/AbstractPersistentFilableCmisObject.java Thu Apr 22 16:04:19 2010
@@ -38,156 +38,156 @@ import org.apache.chemistry.opencmis.com
  * Base class for all filable persistent session object impl classes.
  */
 public abstract class AbstractPersistentFilableCmisObject extends AbstractPersistentCmisObject implements
-		FileableCmisObject {
+        FileableCmisObject {
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.FileableCmisObject#getParents()
-	 */
-	public List<Folder> getParents() {
-		String objectId = getObjectId();
-
-		// get object ids of the parent folders
-		List<ObjectParentData> providerParents = getBinding().getNavigationService()
-				.getObjectParents(getRepositoryId(), objectId, PropertyIds.OBJECT_ID, false, IncludeRelationships.NONE,
-						null, false, null);
-
-		List<Folder> parents = new ArrayList<Folder>();
-
-		for (ObjectParentData p : providerParents) {
-			if ((p == null) || (p.getObject() == null) || (p.getObject().getProperties() == null)) {
-				// should not happen...
-				throw new CmisRuntimeException("Repository sent invalid data!");
-			}
-
-			// get id property
-			PropertyData<?> idProperty = p.getObject().getProperties().getProperties().get(PropertyIds.OBJECT_ID);
-			if (!(idProperty instanceof PropertyId)) {
-				// the repository sent an object without a valid object id...
-				throw new CmisRuntimeException("Repository sent invalid data! No object id!");
-			}
-
-			// fetch the object and make sure it is a folder
-			ObjectId parentId = getSession().createObjectId((String) idProperty.getFirstValue());
-			CmisObject parentFolder = getSession().getObject(parentId);
-			if (!(parentFolder instanceof Folder)) {
-				// the repository sent an object that is not a folder...
-				throw new CmisRuntimeException("Repository sent invalid data! Object is not a folder!");
-			}
-
-			parents.add((Folder) parentFolder);
-		}
-
-		return parents;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.FileableCmisObject#getPaths()
-	 */
-	public List<String> getPaths() {
-		String objectId = getObjectId();
-
-		// get object paths of the parent folders
-		List<ObjectParentData> providerParents = getBinding().getNavigationService().getObjectParents(
-				getRepositoryId(), objectId, PropertyIds.PATH, false, IncludeRelationships.NONE, null, true, null);
-
-		List<String> paths = new ArrayList<String>();
-
-		for (ObjectParentData p : providerParents) {
-			if ((p == null) || (p.getObject() == null) || (p.getObject().getProperties() == null)) {
-				// should not happen...
-				throw new CmisRuntimeException("Repository sent invalid data!");
-			}
-
-			// get path property
-			PropertyData<?> pathProperty = p.getObject().getProperties().getProperties().get(PropertyIds.PATH);
-			if (!(pathProperty instanceof PropertyString)) {
-				// the repository sent a folder without a valid path...
-				throw new CmisRuntimeException("Repository sent invalid data! No path property!");
-			}
-
-			if (p.getRelativePathSegment() == null) {
-				// the repository didn't send a relative path segment
-				throw new CmisRuntimeException("Repository sent invalid data! No relative path segement!");
-			}
-
-			String folderPath = ((String) pathProperty.getFirstValue());
-			paths.add(folderPath + (folderPath.endsWith("/") ? "" : "/") + p.getRelativePathSegment());
-		}
-
-		return paths;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.FileableCmisObject#move(org.apache.opencmis
-	 * .client.api.ObjectId, org.apache.opencmis.client.api.ObjectId)
-	 */
-	public FileableCmisObject move(ObjectId sourceFolderId, ObjectId targetFolderId) {
-		String objectId = getObjectId();
-		Holder<String> objectIdHolder = new Holder<String>(objectId);
-
-		if ((sourceFolderId == null) || (sourceFolderId.getId() == null)) {
-			throw new IllegalArgumentException("Source folder id must be set!");
-		}
-
-		if ((targetFolderId == null) || (targetFolderId.getId() == null)) {
-			throw new IllegalArgumentException("Target folder id must be set!");
-		}
-
-		getBinding().getObjectService().moveObject(getRepositoryId(), objectIdHolder, targetFolderId.getId(),
-				sourceFolderId.getId(), null);
-
-		if (objectIdHolder.getValue() == null) {
-			return null;
-		}
-
-		CmisObject movedObject = getSession().getObject(getSession().createObjectId(objectIdHolder.getValue()));
-		if (!(movedObject instanceof FileableCmisObject)) {
-			throw new CmisRuntimeException("Moved object is invalid!");
-		}
-
-		return (FileableCmisObject) movedObject;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.FileableCmisObject#addToFolder(org.apache
-	 * .opencmis.client.api .ObjectId, boolean)
-	 */
-	public void addToFolder(ObjectId folderId, boolean allVersions) {
-		String objectId = getObjectId();
-
-		if ((folderId == null) || (folderId.getId() == null)) {
-			throw new IllegalArgumentException("Folder Id must be set!");
-		}
-
-		getBinding().getMultiFilingService().addObjectToFolder(getRepositoryId(), objectId, folderId.getId(),
-				allVersions, null);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.FileableCmisObject#removeFromFolder(org
-	 * .apache.opencmis.client .api.ObjectId)
-	 */
-	public void removeFromFolder(ObjectId folderId) {
-		String objectId = getObjectId();
-
-		if ((folderId == null) || (folderId.getId() == null)) {
-			throw new IllegalArgumentException("Folder Id must be set!");
-		}
-
-		getBinding().getMultiFilingService()
-				.removeObjectFromFolder(getRepositoryId(), objectId, folderId.getId(), null);
-	}
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.FileableCmisObject#getParents()
+     */
+    public List<Folder> getParents() {
+        String objectId = getObjectId();
+
+        // get object ids of the parent folders
+        List<ObjectParentData> providerParents = getBinding().getNavigationService()
+                .getObjectParents(getRepositoryId(), objectId, PropertyIds.OBJECT_ID, false, IncludeRelationships.NONE,
+                        null, false, null);
+
+        List<Folder> parents = new ArrayList<Folder>();
+
+        for (ObjectParentData p : providerParents) {
+            if ((p == null) || (p.getObject() == null) || (p.getObject().getProperties() == null)) {
+                // should not happen...
+                throw new CmisRuntimeException("Repository sent invalid data!");
+            }
+
+            // get id property
+            PropertyData<?> idProperty = p.getObject().getProperties().getProperties().get(PropertyIds.OBJECT_ID);
+            if (!(idProperty instanceof PropertyId)) {
+                // the repository sent an object without a valid object id...
+                throw new CmisRuntimeException("Repository sent invalid data! No object id!");
+            }
+
+            // fetch the object and make sure it is a folder
+            ObjectId parentId = getSession().createObjectId((String) idProperty.getFirstValue());
+            CmisObject parentFolder = getSession().getObject(parentId);
+            if (!(parentFolder instanceof Folder)) {
+                // the repository sent an object that is not a folder...
+                throw new CmisRuntimeException("Repository sent invalid data! Object is not a folder!");
+            }
+
+            parents.add((Folder) parentFolder);
+        }
+
+        return parents;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.FileableCmisObject#getPaths()
+     */
+    public List<String> getPaths() {
+        String objectId = getObjectId();
+
+        // get object paths of the parent folders
+        List<ObjectParentData> providerParents = getBinding().getNavigationService().getObjectParents(
+                getRepositoryId(), objectId, PropertyIds.PATH, false, IncludeRelationships.NONE, null, true, null);
+
+        List<String> paths = new ArrayList<String>();
+
+        for (ObjectParentData p : providerParents) {
+            if ((p == null) || (p.getObject() == null) || (p.getObject().getProperties() == null)) {
+                // should not happen...
+                throw new CmisRuntimeException("Repository sent invalid data!");
+            }
+
+            // get path property
+            PropertyData<?> pathProperty = p.getObject().getProperties().getProperties().get(PropertyIds.PATH);
+            if (!(pathProperty instanceof PropertyString)) {
+                // the repository sent a folder without a valid path...
+                throw new CmisRuntimeException("Repository sent invalid data! No path property!");
+            }
+
+            if (p.getRelativePathSegment() == null) {
+                // the repository didn't send a relative path segment
+                throw new CmisRuntimeException("Repository sent invalid data! No relative path segement!");
+            }
+
+            String folderPath = ((String) pathProperty.getFirstValue());
+            paths.add(folderPath + (folderPath.endsWith("/") ? "" : "/") + p.getRelativePathSegment());
+        }
+
+        return paths;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.FileableCmisObject#move(org.apache.opencmis
+     * .client.api.ObjectId, org.apache.opencmis.client.api.ObjectId)
+     */
+    public FileableCmisObject move(ObjectId sourceFolderId, ObjectId targetFolderId) {
+        String objectId = getObjectId();
+        Holder<String> objectIdHolder = new Holder<String>(objectId);
+
+        if ((sourceFolderId == null) || (sourceFolderId.getId() == null)) {
+            throw new IllegalArgumentException("Source folder id must be set!");
+        }
+
+        if ((targetFolderId == null) || (targetFolderId.getId() == null)) {
+            throw new IllegalArgumentException("Target folder id must be set!");
+        }
+
+        getBinding().getObjectService().moveObject(getRepositoryId(), objectIdHolder, targetFolderId.getId(),
+                sourceFolderId.getId(), null);
+
+        if (objectIdHolder.getValue() == null) {
+            return null;
+        }
+
+        CmisObject movedObject = getSession().getObject(getSession().createObjectId(objectIdHolder.getValue()));
+        if (!(movedObject instanceof FileableCmisObject)) {
+            throw new CmisRuntimeException("Moved object is invalid!");
+        }
+
+        return (FileableCmisObject) movedObject;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.FileableCmisObject#addToFolder(org.apache
+     * .opencmis.client.api .ObjectId, boolean)
+     */
+    public void addToFolder(ObjectId folderId, boolean allVersions) {
+        String objectId = getObjectId();
+
+        if ((folderId == null) || (folderId.getId() == null)) {
+            throw new IllegalArgumentException("Folder Id must be set!");
+        }
+
+        getBinding().getMultiFilingService().addObjectToFolder(getRepositoryId(), objectId, folderId.getId(),
+                allVersions, null);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.FileableCmisObject#removeFromFolder(org
+     * .apache.opencmis.client .api.ObjectId)
+     */
+    public void removeFromFolder(ObjectId folderId) {
+        String objectId = getObjectId();
+
+        if ((folderId == null) || (folderId.getId() == null)) {
+            throw new IllegalArgumentException("Folder Id must be set!");
+        }
+
+        getBinding().getMultiFilingService()
+                .removeObjectFromFolder(getRepositoryId(), objectId, folderId.getId(), null);
+    }
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/CmisBindingHelper.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/CmisBindingHelper.java?rev=936922&r1=936921&r2=936922&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/CmisBindingHelper.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/CmisBindingHelper.java Thu Apr 22 16:04:19 2010
@@ -30,59 +30,59 @@ import org.apache.chemistry.opencmis.com
  * Helper methods for binding handling.
  */
 public class CmisBindingHelper {
-	/**
-	 * Creates a {@link CmisProvider} object.
-	 */
-	public static CmisBinding createProvider(Map<String, String> parameters) {
-		if (parameters == null || parameters.isEmpty()) {
-			throw new CmisRuntimeException("Session parameter not set!");
-		}
-
-		if (!parameters.containsKey(SessionParameter.BINDING_TYPE)) {
-			parameters.put(SessionParameter.BINDING_TYPE, BindingType.CUSTOM.value());
-		}
-
-		BindingType bt = BindingType.fromValue(parameters.get(SessionParameter.BINDING_TYPE));
-
-		switch (bt) {
-		case ATOMPUB:
-			return createAtomPubBinding(parameters);
-		case WEBSERVICES:
-			return createWebServiceBinding(parameters);
-		case CUSTOM:
-			return createCustomBinding(parameters);
-		default:
-			throw new CmisRuntimeException("Ambiguous session parameter: " + parameters);
-		}
-	}
-
-	/**
-	 * Creates a provider with custom parameters.
-	 */
-	private static CmisBinding createCustomBinding(Map<String, String> parameters) {
-		CmisBindingFactory factory = CmisBindingFactory.newInstance();
-		CmisBinding binding = factory.createCmisBinding(parameters);
-
-		return binding;
-	}
-
-	/**
-	 * Creates a Web Services provider.
-	 */
-	private static CmisBinding createWebServiceBinding(Map<String, String> parameters) {
-		CmisBindingFactory factory = CmisBindingFactory.newInstance();
-		CmisBinding binding = factory.createCmisWebServicesBinding(parameters);
-
-		return binding;
-	}
-
-	/**
-	 * Creates an AtomPub provider.
-	 */
-	private static CmisBinding createAtomPubBinding(Map<String, String> parameters) {
-		CmisBindingFactory factory = CmisBindingFactory.newInstance();
-		CmisBinding binding = factory.createCmisAtomPubBinding(parameters);
+    /**
+     * Creates a {@link CmisProvider} object.
+     */
+    public static CmisBinding createProvider(Map<String, String> parameters) {
+        if (parameters == null || parameters.isEmpty()) {
+            throw new CmisRuntimeException("Session parameter not set!");
+        }
+
+        if (!parameters.containsKey(SessionParameter.BINDING_TYPE)) {
+            parameters.put(SessionParameter.BINDING_TYPE, BindingType.CUSTOM.value());
+        }
+
+        BindingType bt = BindingType.fromValue(parameters.get(SessionParameter.BINDING_TYPE));
+
+        switch (bt) {
+        case ATOMPUB:
+            return createAtomPubBinding(parameters);
+        case WEBSERVICES:
+            return createWebServiceBinding(parameters);
+        case CUSTOM:
+            return createCustomBinding(parameters);
+        default:
+            throw new CmisRuntimeException("Ambiguous session parameter: " + parameters);
+        }
+    }
+
+    /**
+     * Creates a provider with custom parameters.
+     */
+    private static CmisBinding createCustomBinding(Map<String, String> parameters) {
+        CmisBindingFactory factory = CmisBindingFactory.newInstance();
+        CmisBinding binding = factory.createCmisBinding(parameters);
+
+        return binding;
+    }
+
+    /**
+     * Creates a Web Services provider.
+     */
+    private static CmisBinding createWebServiceBinding(Map<String, String> parameters) {
+        CmisBindingFactory factory = CmisBindingFactory.newInstance();
+        CmisBinding binding = factory.createCmisWebServicesBinding(parameters);
+
+        return binding;
+    }
+
+    /**
+     * Creates an AtomPub provider.
+     */
+    private static CmisBinding createAtomPubBinding(Map<String, String> parameters) {
+        CmisBindingFactory factory = CmisBindingFactory.newInstance();
+        CmisBinding binding = factory.createCmisAtomPubBinding(parameters);
 
-		return binding;
-	}
+        return binding;
+    }
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/ObjectIdImpl.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/ObjectIdImpl.java?rev=936922&r1=936921&r2=936922&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/ObjectIdImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/ObjectIdImpl.java Thu Apr 22 16:04:19 2010
@@ -25,32 +25,32 @@ import org.apache.chemistry.opencmis.cli
  */
 public class ObjectIdImpl implements ObjectId {
 
-	private String id;
+    private String id;
 
-	/**
-	 * Constructor.
-	 */
-	public ObjectIdImpl(String id) {
-		setId(id);
-	}
+    /**
+     * Constructor.
+     */
+    public ObjectIdImpl(String id) {
+        setId(id);
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.ObjectId#getId()
-	 */
-	public String getId() {
-		return id;
-	}
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.ObjectId#getId()
+     */
+    public String getId() {
+        return id;
+    }
 
-	/**
-	 * Sets the id.
-	 */
-	public void setId(String id) {
-		if ((id == null) || (id.length() == 0)) {
-			throw new IllegalArgumentException("Id must be set!");
-		}
+    /**
+     * Sets the id.
+     */
+    public void setId(String id) {
+        if ((id == null) || (id.length() == 0)) {
+            throw new IllegalArgumentException("Id must be set!");
+        }
 
-		this.id = id;
-	}
+        this.id = id;
+    }
 }



Mime
View raw message