You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by dc...@apache.org on 2010/04/22 18:04:22 UTC

svn commit: r936922 [15/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/...

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/OperationContextImpl.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/OperationContextImpl.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/OperationContextImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/OperationContextImpl.java Thu Apr 22 16:04:19 2010
@@ -32,456 +32,456 @@ import org.apache.chemistry.opencmis.com
  */
 public class OperationContextImpl implements OperationContext, Serializable {
 
-	public static final String PROPERTIES_STAR = "*";
-	public static final String RENDITION_NONE = "cmis:none";
+    public static final String PROPERTIES_STAR = "*";
+    public static final String RENDITION_NONE = "cmis:none";
 
-	private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 1L;
 
-	private TreeSet<String> filter;
-	private boolean includeAcls;
-	private boolean includeAllowableActions;
-	private boolean includePolicies;
-	private IncludeRelationships includeRelationships;
-	private TreeSet<String> renditionFilter;
-	private boolean includePathSegments;
-	private String orderBy;
-	private boolean cacheEnabled;
-	private String cacheKey;
-
-	/**
-	 * Default constructor.
-	 */
-	public OperationContextImpl() {
-		setFilter(null);
-		setIncludeAcls(false);
-		setIncludeAllowableActions(true);
-		setIncludePolicies(false);
-		setIncludeRelationships(IncludeRelationships.NONE);
-		setRenditionFilter(null);
-		setIncludePathSegments(true);
-		setOrderBy(null);
-		setCacheEnabled(false);
-		generateCacheKey();
-	}
-
-	/**
-	 * Copy constructor.
-	 */
-	public OperationContextImpl(OperationContext source) {
-		setFilter(source.getFilter());
-		setIncludeAcls(source.isIncludeAcls());
-		setIncludeAllowableActions(source.isIncludeAllowableActions());
-		setIncludePolicies(source.isIncludePolicies());
-		setIncludeRelationships(source.getIncludeRelationships());
-		setRenditionFilter(source.getRenditionFilter());
-		setIncludePathSegments(source.isIncludePathSegments());
-		setOrderBy(source.getOrderBy());
-		setCacheEnabled(source.isCacheEnabled());
-		generateCacheKey();
-	}
-
-	/**
-	 * Constructor with parameters.
-	 */
-	public OperationContextImpl(Set<String> propertyFilter, boolean includeAcls, boolean includeAllowableActions,
-			boolean includePolicies, IncludeRelationships includeRelationships, Set<String> renditionFilter,
-			boolean includePathSegments, String orderBy, boolean cacheEnabled) {
-		setFilter(propertyFilter);
-		setIncludeAcls(includeAcls);
-		setIncludeAllowableActions(includeAllowableActions);
-		setIncludePolicies(includePolicies);
-		setIncludeRelationships(includeRelationships);
-		setRenditionFilter(renditionFilter);
-		setIncludePathSegments(includePathSegments);
-		setOrderBy(orderBy);
-		setCacheEnabled(cacheEnabled);
-		generateCacheKey();
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.OperationContext#getFilter()
-	 */
-	public Set<String> getFilter() {
-		if (this.filter == null) {
-			return null;
-		}
-
-		return Collections.unmodifiableSet(this.filter);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.OperationContext#setFilter(java.util.Set)
-	 */
-	public void setFilter(Set<String> propertyFilter) {
-		if (propertyFilter != null) {
-			TreeSet<String> tempSet = new TreeSet<String>();
-
-			for (String oid : propertyFilter) {
-				if (oid == null) {
-					continue;
-				}
-
-				String toid = oid.trim();
-				if (toid.length() == 0) {
-					continue;
-				}
-				if (toid.equals(PROPERTIES_STAR)) {
-					tempSet = new TreeSet<String>();
-					tempSet.add(PROPERTIES_STAR);
-					break;
-				}
-				if (toid.indexOf(',') > -1) {
-					throw new IllegalArgumentException("Property id must not contain a comma!");
-				}
-
-				tempSet.add(toid);
-			}
-
-			if (tempSet.size() == 0) {
-				this.filter = null;
-			} else {
-				this.filter = tempSet;
-			}
-		} else {
-			this.filter = null;
-		}
-
-		generateCacheKey();
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.OperationContext#setFilter(java.lang.String
-	 * )
-	 */
-	public void setFilterString(String propertyFilter) {
-		if (propertyFilter == null) {
-			setFilter(null);
-			return;
-		}
-
-		String[] propertyIds = propertyFilter.split(",");
-		TreeSet<String> tempSet = new TreeSet<String>();
-		for (String pid : propertyIds) {
-			tempSet.add(pid);
-		}
-
-		setFilter(tempSet);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.OperationContext#getFilterString()
-	 */
-	public String getFilterString() {
-		if (this.filter == null) {
-			return null;
-		}
-
-		if (this.filter.contains(PROPERTIES_STAR)) {
-			return PROPERTIES_STAR;
-		}
-
-		this.filter.add(PropertyIds.OBJECT_ID);
-		this.filter.add(PropertyIds.BASE_TYPE_ID);
-		this.filter.add(PropertyIds.OBJECT_TYPE_ID);
-
-		StringBuilder sb = new StringBuilder();
-
-		for (String oid : this.filter) {
-			if (sb.length() > 0) {
-				sb.append(",");
-			}
-
-			sb.append(oid);
-		}
-
-		return sb.toString();
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.OperationContext#isIncludeAcls()
-	 */
-	public boolean isIncludeAcls() {
-		return includeAcls;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.OperationContext#setIncludeAcls(boolean)
-	 */
-	public void setIncludeAcls(boolean include) {
-		this.includeAcls = include;
-		generateCacheKey();
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.OperationContext#isIncludeAllowableActions
-	 * ()
-	 */
-	public boolean isIncludeAllowableActions() {
-		return this.includeAllowableActions;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.OperationContext#setIncludeAllowableActions
-	 * (boolean)
-	 */
-	public void setIncludeAllowableActions(boolean include) {
-		this.includeAllowableActions = include;
-		generateCacheKey();
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.OperationContext#isIncludePolicies()
-	 */
-	public boolean isIncludePolicies() {
-		return this.includePolicies;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.OperationContext#setIncludePolicies(boolean
-	 * )
-	 */
-	public void setIncludePolicies(boolean include) {
-		this.includePolicies = include;
-		generateCacheKey();
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.OperationContext#getIncludeRelationships()
-	 */
-	public IncludeRelationships getIncludeRelationships() {
-		return this.includeRelationships;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.OperationContext#setIncludeRelationships
-	 * (org.apache.opencmis .commons.enums.IncludeRelationships)
-	 */
-	public void setIncludeRelationships(IncludeRelationships include) {
-		this.includeRelationships = include;
-		generateCacheKey();
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.OperationContext#getRenditionFilter()
-	 */
-	public Set<String> getRenditionFilter() {
-		if (this.renditionFilter == null) {
-			return null;
-		}
-
-		return Collections.unmodifiableSet(this.renditionFilter);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.OperationContext#setRenditionFilter(java
-	 * .util.Set)
-	 */
-	public void setRenditionFilter(Set<String> renditionFilter) {
-		TreeSet<String> tempSet = new TreeSet<String>();
-
-		if (renditionFilter != null) {
-			for (String rf : renditionFilter) {
-				if (rf == null) {
-					continue;
-				}
-
-				String trf = rf.trim();
-				if (trf.length() == 0) {
-					continue;
-				}
-				if (trf.indexOf(',') > -1) {
-					throw new IllegalArgumentException("Rendition must not contain a comma!");
-				}
-
-				tempSet.add(trf);
-			}
-
-			if (tempSet.size() == 0) {
-				tempSet.add(RENDITION_NONE);
-			}
-		} else {
-			tempSet.add(RENDITION_NONE);
-		}
-
-		this.renditionFilter = tempSet;
-		generateCacheKey();
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.OperationContext#setRenditionFilterString
-	 * (java.lang.String)
-	 */
-	public void setRenditionFilterString(String renditionFilter) {
-		if (renditionFilter == null) {
-			setRenditionFilter(null);
-			return;
-		}
-
-		String[] renditions = renditionFilter.split(",");
-		TreeSet<String> tempSet = new TreeSet<String>();
-		for (String rend : renditions) {
-			tempSet.add(rend);
-		}
-
-		setRenditionFilter(tempSet);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.OperationContext#getRenditionFilterString
-	 * ()
-	 */
-	public String getRenditionFilterString() {
-		if (this.renditionFilter == null) {
-			return null;
-		}
-
-		StringBuilder sb = new StringBuilder();
-
-		for (String rf : this.renditionFilter) {
-			if (sb.length() > 0) {
-				sb.append(",");
-			}
-
-			sb.append(rf);
-		}
-
-		return sb.toString();
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.OperationContext#isIncludePathSegments()
-	 */
-	public boolean isIncludePathSegments() {
-		return includePathSegments;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.OperationContext#setIncludePathSegments
-	 * (boolean)
-	 */
-	public void setIncludePathSegments(boolean include) {
-		this.includePathSegments = include;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.OperationContext#getOrderBy()
-	 */
-	public String getOrderBy() {
-		return this.orderBy;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.OperationContext#setOrderBy(java.lang.
-	 * String)
-	 */
-	public void setOrderBy(String orderBy) {
-		this.orderBy = orderBy;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.OperationContext#isCacheEnabled()
-	 */
-	public boolean isCacheEnabled() {
-		return cacheEnabled;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.OperationContext#setCacheEnabled(boolean)
-	 */
-	public void setCacheEnabled(boolean cacheEnabled) {
-		this.cacheEnabled = cacheEnabled;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.OperationContext#getCacheKey()
-	 */
-	public String getCacheKey() {
-		return cacheKey;
-	}
-
-	/**
-	 * Generates a new cache key from all parameters that are relevant for
-	 * caching.
-	 */
-	protected void generateCacheKey() {
-		if (!cacheEnabled) {
-			cacheKey = null;
-		}
-
-		StringBuilder sb = new StringBuilder();
-
-		sb.append(includeAcls ? "1" : "0");
-		sb.append(includeAllowableActions ? "1" : "0");
-		sb.append(includePolicies ? "1" : "0");
-		sb.append("|");
-		sb.append(filter == null ? "" : getFilterString());
-		sb.append("|");
-		sb.append(includeRelationships == null ? "" : includeRelationships.value());
+    private TreeSet<String> filter;
+    private boolean includeAcls;
+    private boolean includeAllowableActions;
+    private boolean includePolicies;
+    private IncludeRelationships includeRelationships;
+    private TreeSet<String> renditionFilter;
+    private boolean includePathSegments;
+    private String orderBy;
+    private boolean cacheEnabled;
+    private String cacheKey;
+
+    /**
+     * Default constructor.
+     */
+    public OperationContextImpl() {
+        setFilter(null);
+        setIncludeAcls(false);
+        setIncludeAllowableActions(true);
+        setIncludePolicies(false);
+        setIncludeRelationships(IncludeRelationships.NONE);
+        setRenditionFilter(null);
+        setIncludePathSegments(true);
+        setOrderBy(null);
+        setCacheEnabled(false);
+        generateCacheKey();
+    }
+
+    /**
+     * Copy constructor.
+     */
+    public OperationContextImpl(OperationContext source) {
+        setFilter(source.getFilter());
+        setIncludeAcls(source.isIncludeAcls());
+        setIncludeAllowableActions(source.isIncludeAllowableActions());
+        setIncludePolicies(source.isIncludePolicies());
+        setIncludeRelationships(source.getIncludeRelationships());
+        setRenditionFilter(source.getRenditionFilter());
+        setIncludePathSegments(source.isIncludePathSegments());
+        setOrderBy(source.getOrderBy());
+        setCacheEnabled(source.isCacheEnabled());
+        generateCacheKey();
+    }
+
+    /**
+     * Constructor with parameters.
+     */
+    public OperationContextImpl(Set<String> propertyFilter, boolean includeAcls, boolean includeAllowableActions,
+            boolean includePolicies, IncludeRelationships includeRelationships, Set<String> renditionFilter,
+            boolean includePathSegments, String orderBy, boolean cacheEnabled) {
+        setFilter(propertyFilter);
+        setIncludeAcls(includeAcls);
+        setIncludeAllowableActions(includeAllowableActions);
+        setIncludePolicies(includePolicies);
+        setIncludeRelationships(includeRelationships);
+        setRenditionFilter(renditionFilter);
+        setIncludePathSegments(includePathSegments);
+        setOrderBy(orderBy);
+        setCacheEnabled(cacheEnabled);
+        generateCacheKey();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.OperationContext#getFilter()
+     */
+    public Set<String> getFilter() {
+        if (this.filter == null) {
+            return null;
+        }
+
+        return Collections.unmodifiableSet(this.filter);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.OperationContext#setFilter(java.util.Set)
+     */
+    public void setFilter(Set<String> propertyFilter) {
+        if (propertyFilter != null) {
+            TreeSet<String> tempSet = new TreeSet<String>();
+
+            for (String oid : propertyFilter) {
+                if (oid == null) {
+                    continue;
+                }
+
+                String toid = oid.trim();
+                if (toid.length() == 0) {
+                    continue;
+                }
+                if (toid.equals(PROPERTIES_STAR)) {
+                    tempSet = new TreeSet<String>();
+                    tempSet.add(PROPERTIES_STAR);
+                    break;
+                }
+                if (toid.indexOf(',') > -1) {
+                    throw new IllegalArgumentException("Property id must not contain a comma!");
+                }
+
+                tempSet.add(toid);
+            }
+
+            if (tempSet.size() == 0) {
+                this.filter = null;
+            } else {
+                this.filter = tempSet;
+            }
+        } else {
+            this.filter = null;
+        }
+
+        generateCacheKey();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.OperationContext#setFilter(java.lang.String
+     * )
+     */
+    public void setFilterString(String propertyFilter) {
+        if (propertyFilter == null) {
+            setFilter(null);
+            return;
+        }
+
+        String[] propertyIds = propertyFilter.split(",");
+        TreeSet<String> tempSet = new TreeSet<String>();
+        for (String pid : propertyIds) {
+            tempSet.add(pid);
+        }
+
+        setFilter(tempSet);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.OperationContext#getFilterString()
+     */
+    public String getFilterString() {
+        if (this.filter == null) {
+            return null;
+        }
+
+        if (this.filter.contains(PROPERTIES_STAR)) {
+            return PROPERTIES_STAR;
+        }
+
+        this.filter.add(PropertyIds.OBJECT_ID);
+        this.filter.add(PropertyIds.BASE_TYPE_ID);
+        this.filter.add(PropertyIds.OBJECT_TYPE_ID);
+
+        StringBuilder sb = new StringBuilder();
+
+        for (String oid : this.filter) {
+            if (sb.length() > 0) {
+                sb.append(",");
+            }
+
+            sb.append(oid);
+        }
+
+        return sb.toString();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.OperationContext#isIncludeAcls()
+     */
+    public boolean isIncludeAcls() {
+        return includeAcls;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.OperationContext#setIncludeAcls(boolean)
+     */
+    public void setIncludeAcls(boolean include) {
+        this.includeAcls = include;
+        generateCacheKey();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.OperationContext#isIncludeAllowableActions
+     * ()
+     */
+    public boolean isIncludeAllowableActions() {
+        return this.includeAllowableActions;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.OperationContext#setIncludeAllowableActions
+     * (boolean)
+     */
+    public void setIncludeAllowableActions(boolean include) {
+        this.includeAllowableActions = include;
+        generateCacheKey();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.OperationContext#isIncludePolicies()
+     */
+    public boolean isIncludePolicies() {
+        return this.includePolicies;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.OperationContext#setIncludePolicies(boolean
+     * )
+     */
+    public void setIncludePolicies(boolean include) {
+        this.includePolicies = include;
+        generateCacheKey();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.OperationContext#getIncludeRelationships()
+     */
+    public IncludeRelationships getIncludeRelationships() {
+        return this.includeRelationships;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.OperationContext#setIncludeRelationships
+     * (org.apache.opencmis .commons.enums.IncludeRelationships)
+     */
+    public void setIncludeRelationships(IncludeRelationships include) {
+        this.includeRelationships = include;
+        generateCacheKey();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.OperationContext#getRenditionFilter()
+     */
+    public Set<String> getRenditionFilter() {
+        if (this.renditionFilter == null) {
+            return null;
+        }
+
+        return Collections.unmodifiableSet(this.renditionFilter);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.OperationContext#setRenditionFilter(java
+     * .util.Set)
+     */
+    public void setRenditionFilter(Set<String> renditionFilter) {
+        TreeSet<String> tempSet = new TreeSet<String>();
+
+        if (renditionFilter != null) {
+            for (String rf : renditionFilter) {
+                if (rf == null) {
+                    continue;
+                }
+
+                String trf = rf.trim();
+                if (trf.length() == 0) {
+                    continue;
+                }
+                if (trf.indexOf(',') > -1) {
+                    throw new IllegalArgumentException("Rendition must not contain a comma!");
+                }
+
+                tempSet.add(trf);
+            }
+
+            if (tempSet.size() == 0) {
+                tempSet.add(RENDITION_NONE);
+            }
+        } else {
+            tempSet.add(RENDITION_NONE);
+        }
+
+        this.renditionFilter = tempSet;
+        generateCacheKey();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.OperationContext#setRenditionFilterString
+     * (java.lang.String)
+     */
+    public void setRenditionFilterString(String renditionFilter) {
+        if (renditionFilter == null) {
+            setRenditionFilter(null);
+            return;
+        }
+
+        String[] renditions = renditionFilter.split(",");
+        TreeSet<String> tempSet = new TreeSet<String>();
+        for (String rend : renditions) {
+            tempSet.add(rend);
+        }
+
+        setRenditionFilter(tempSet);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.OperationContext#getRenditionFilterString
+     * ()
+     */
+    public String getRenditionFilterString() {
+        if (this.renditionFilter == null) {
+            return null;
+        }
+
+        StringBuilder sb = new StringBuilder();
+
+        for (String rf : this.renditionFilter) {
+            if (sb.length() > 0) {
+                sb.append(",");
+            }
+
+            sb.append(rf);
+        }
+
+        return sb.toString();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.OperationContext#isIncludePathSegments()
+     */
+    public boolean isIncludePathSegments() {
+        return includePathSegments;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.OperationContext#setIncludePathSegments
+     * (boolean)
+     */
+    public void setIncludePathSegments(boolean include) {
+        this.includePathSegments = include;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.OperationContext#getOrderBy()
+     */
+    public String getOrderBy() {
+        return this.orderBy;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.OperationContext#setOrderBy(java.lang.
+     * String)
+     */
+    public void setOrderBy(String orderBy) {
+        this.orderBy = orderBy;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.OperationContext#isCacheEnabled()
+     */
+    public boolean isCacheEnabled() {
+        return cacheEnabled;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.OperationContext#setCacheEnabled(boolean)
+     */
+    public void setCacheEnabled(boolean cacheEnabled) {
+        this.cacheEnabled = cacheEnabled;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.OperationContext#getCacheKey()
+     */
+    public String getCacheKey() {
+        return cacheKey;
+    }
+
+    /**
+     * Generates a new cache key from all parameters that are relevant for
+     * caching.
+     */
+    protected void generateCacheKey() {
+        if (!cacheEnabled) {
+            cacheKey = null;
+        }
+
+        StringBuilder sb = new StringBuilder();
+
+        sb.append(includeAcls ? "1" : "0");
+        sb.append(includeAllowableActions ? "1" : "0");
+        sb.append(includePolicies ? "1" : "0");
+        sb.append("|");
+        sb.append(filter == null ? "" : getFilterString());
+        sb.append("|");
+        sb.append(includeRelationships == null ? "" : includeRelationships.value());
 
-		sb.append("|");
-		sb.append(renditionFilter == null ? "" : getRenditionFilterString());
+        sb.append("|");
+        sb.append(renditionFilter == null ? "" : getRenditionFilterString());
 
-		cacheKey = sb.toString();
-	}
+        cacheKey = sb.toString();
+    }
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentDocumentImpl.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/PersistentDocumentImpl.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/PersistentDocumentImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentDocumentImpl.java Thu Apr 22 16:04:19 2010
@@ -44,337 +44,337 @@ import org.apache.chemistry.opencmis.com
 
 public class PersistentDocumentImpl extends AbstractPersistentFilableCmisObject implements Document {
 
-	/**
-	 * Constructor.
-	 */
-	public PersistentDocumentImpl(PersistentSessionImpl session, ObjectType objectType, ObjectData objectData,
-			OperationContext context) {
-		initialize(session, objectType, objectData, context);
-	}
-
-	// properties
-
-	public String getCheckinComment() {
-		return getPropertyValue(PropertyIds.CHECKIN_COMMENT);
-	}
-
-	public String getVersionLabel() {
-		return getPropertyValue(PropertyIds.VERSION_LABEL);
-	}
-
-	public String getVersionSeriesId() {
-		return getPropertyValue(PropertyIds.VERSION_SERIES_ID);
-	}
-
-	public String getVersionSeriesCheckedOutId() {
-		return getPropertyValue(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID);
-	}
-
-	public String getVersionSeriesCheckedOutBy() {
-		return getPropertyValue(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY);
-	}
-
-	public Boolean isImmutable() {
-		return getPropertyValue(PropertyIds.IS_IMMUTABLE);
-	}
-
-	public Boolean isLatestMajorVersion() {
-		return getPropertyValue(PropertyIds.IS_LATEST_MAJOR_VERSION);
-	}
-
-	public Boolean isLatestVersion() {
-		return getPropertyValue(PropertyIds.IS_LATEST_VERSION);
-	}
-
-	public Boolean isMajorVersion() {
-		return getPropertyValue(PropertyIds.IS_MAJOR_VERSION);
-	}
-
-	public Boolean isVersionSeriesCheckedOut() {
-		return getPropertyValue(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT);
-	}
-
-	public long getContentStreamLength() {
-		BigInteger bigInt = getPropertyValue(PropertyIds.CONTENT_STREAM_LENGTH);
-		return (bigInt == null) ? (long) -1 : bigInt.longValue();
-	}
-
-	public String getContentStreamMimeType() {
-		return getPropertyValue(PropertyIds.CONTENT_STREAM_MIME_TYPE);
-	}
-
-	public String getContentStreamFileName() {
-		return getPropertyValue(PropertyIds.CONTENT_STREAM_FILE_NAME);
-	}
-
-	public String getContentStreamId() {
-		return getPropertyValue(PropertyIds.CONTENT_STREAM_ID);
-	}
-
-	// operations
-
-	public Document copy(List<Property<?>> properties, VersioningState versioningState, List<Policy> policies,
-			List<Ace> addACEs, List<Ace> removeACEs) {
-		throw new CmisRuntimeException("not implemented");
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.Document#deleteAllVersions()
-	 */
-	public void deleteAllVersions() {
-		delete(true);
-	}
-
-	// versioning
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.Document#checkOut()
-	 */
-	public ObjectId checkOut() {
-		String objectId = getObjectId();
-		Holder<String> objectIdHolder = new Holder<String>(objectId);
-
-		getBinding().getVersioningService().checkOut(getRepositoryId(), objectIdHolder, null, null);
-
-		if (objectIdHolder.getValue() == null) {
-			return null;
-		}
-
-		return getSession().createObjectId(objectIdHolder.getValue());
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.Document#cancelCheckOut()
-	 */
-	public void cancelCheckOut() {
-		String objectId = getObjectId();
-
-		getBinding().getVersioningService().cancelCheckOut(getRepositoryId(), objectId, null);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.Document#checkIn(boolean,
-	 * java.util.Map, org.apache.opencmis.client.api.ContentStream,
-	 * java.lang.String, java.util.List, java.util.List, java.util.List)
-	 */
-	public ObjectId checkIn(boolean major, Map<String, ?> properties, ContentStream contentStream,
-			String checkinComment, List<Policy> policies, List<Ace> addAces, List<Ace> removeAces) {
-		String objectId;
-		ObjectType type;
-		readLock();
-		try {
-			objectId = getObjectId();
-			type = getType();
-		} finally {
-			readUnlock();
-		}
-
-		Holder<String> objectIdHolder = new Holder<String>(objectId);
-
-		ObjectFactory of = getObjectFactory();
-
-		Set<Updatability> updatebility = new HashSet<Updatability>();
-		updatebility.add(Updatability.READWRITE);
-		updatebility.add(Updatability.WHENCHECKEDOUT);
-
-		getBinding().getVersioningService()
-				.checkIn(getRepositoryId(), objectIdHolder, major,
-						of.convertProperties(properties, type, updatebility), of.convertContentStream(contentStream),
-						checkinComment, of.convertPolicies(policies), of.convertAces(addAces),
-						of.convertAces(removeAces), null);
-
-		if (objectIdHolder.getValue() == null) {
-			return null;
-		}
-
-		return getSession().createObjectId(objectIdHolder.getValue());
-
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.Document#getAllVersions()
-	 */
-	public List<Document> getAllVersions() {
-		return getAllVersions(getSession().getDefaultContext());
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @seeorg.apache.opencmis.client.api.Document#getAllVersions(org.apache.
-	 * opencmis.client.api. OperationContext)
-	 */
-	public List<Document> getAllVersions(OperationContext context) {
-		String objectId;
-		String versionSeriesId;
-
-		readLock();
-		try {
-			objectId = getObjectId();
-			versionSeriesId = getVersionSeriesId();
-		} finally {
-			readUnlock();
-		}
-
-		List<ObjectData> versions = getBinding().getVersioningService().getAllVersions(getRepositoryId(), objectId,
-				versionSeriesId, context.getFilterString(), context.isIncludeAllowableActions(), null);
-
-		ObjectFactory objectFactory = getSession().getObjectFactory();
-
-		List<Document> result = new ArrayList<Document>();
-		if (versions != null) {
-			for (ObjectData objectData : versions) {
-				CmisObject doc = objectFactory.convertObject(objectData, context);
-				if (!(doc instanceof Document)) {
-					// should not happen...
-					continue;
-				}
-
-				result.add((Document) doc);
-			}
-		}
-
-		return result;
-
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.Document#getObjectOfLatestVersion(boolean)
-	 */
-	public Document getObjectOfLatestVersion(boolean major) {
-		return getObjectOfLatestVersion(major, null);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.Document#getObjectOfLatestVersion(boolean,
-	 * org.apache.opencmis.client.api.OperationContext)
-	 */
-	public Document getObjectOfLatestVersion(boolean major, OperationContext context) {
-		String objectId;
-		String versionSeriesId;
-
-		readLock();
-		try {
-			objectId = getObjectId();
-			versionSeriesId = getVersionSeriesId();
-		} finally {
-			readUnlock();
-		}
-
-		if (versionSeriesId == null) {
-			throw new CmisRuntimeException("Version series id is unknown!");
-		}
-
-		ObjectData objectData = getBinding().getVersioningService().getObjectOfLatestVersion(getRepositoryId(),
-				objectId, versionSeriesId, major, context.getFilterString(), context.isIncludeAllowableActions(),
-				context.getIncludeRelationships(), context.getRenditionFilterString(), context.isIncludePolicies(),
-				context.isIncludeAcls(), null);
-
-		ObjectFactory objectFactory = getSession().getObjectFactory();
-
-		CmisObject result = objectFactory.convertObject(objectData, context);
-		if (!(result instanceof Document)) {
-			throw new CmisRuntimeException("Latest version is not a document!");
-		}
-
-		return (Document) result;
-	}
-
-	// content operations
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.Document#getContentStream()
-	 */
-	public ContentStream getContentStream() {
-		String objectId = getObjectId();
-
-		// get the stream
-		ContentStream contentStream = getBinding().getObjectService().getContentStream(getRepositoryId(), objectId,
-				null, null, null, null);
-
-		// TODO: what should happen if the length is not set?
-		long length = (contentStream.getBigLength() == null ? -1 : contentStream.getBigLength().longValue());
-
-		// convert and return stream object
-		return getSession().getObjectFactory().createContentStream(contentStream.getFileName(), length,
-				contentStream.getMimeType(), contentStream.getStream());
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.Document#setContentStream(boolean,
-	 * org.apache.opencmis.client.api.ContentStream)
-	 */
-	public ObjectId setContentStream(ContentStream contentStream, boolean overwrite) {
-		String objectId;
-		String changeToken;
-
-		readLock();
-		try {
-			objectId = getObjectId();
-			changeToken = getPropertyValue(PropertyIds.CHANGE_TOKEN);
-		} finally {
-			readUnlock();
-		}
-
-		Holder<String> objectIdHolder = new Holder<String>(objectId);
-		Holder<String> changeTokenHolder = new Holder<String>(changeToken);
-
-		getBinding().getObjectService().setContentStream(getRepositoryId(), objectIdHolder, overwrite,
-				changeTokenHolder, getObjectFactory().convertContentStream(contentStream), null);
-
-		if (objectIdHolder.getValue() == null) {
-			return null;
-		}
-
-		return getSession().createObjectId(objectIdHolder.getValue());
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.Document#deleteContentStream()
-	 */
-	public ObjectId deleteContentStream() {
-		String objectId;
-		String changeToken;
-
-		readLock();
-		try {
-			objectId = getObjectId();
-			changeToken = getPropertyValue(PropertyIds.CHANGE_TOKEN);
-		} finally {
-			readUnlock();
-		}
-
-		Holder<String> objectIdHolder = new Holder<String>(objectId);
-		Holder<String> changeTokenHolder = new Holder<String>(changeToken);
-
-		getBinding().getObjectService().deleteContentStream(getRepositoryId(), objectIdHolder, changeTokenHolder, null);
-
-		if (objectIdHolder.getValue() == null) {
-			return null;
-		}
+    /**
+     * Constructor.
+     */
+    public PersistentDocumentImpl(PersistentSessionImpl session, ObjectType objectType, ObjectData objectData,
+            OperationContext context) {
+        initialize(session, objectType, objectData, context);
+    }
+
+    // properties
+
+    public String getCheckinComment() {
+        return getPropertyValue(PropertyIds.CHECKIN_COMMENT);
+    }
+
+    public String getVersionLabel() {
+        return getPropertyValue(PropertyIds.VERSION_LABEL);
+    }
+
+    public String getVersionSeriesId() {
+        return getPropertyValue(PropertyIds.VERSION_SERIES_ID);
+    }
+
+    public String getVersionSeriesCheckedOutId() {
+        return getPropertyValue(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID);
+    }
+
+    public String getVersionSeriesCheckedOutBy() {
+        return getPropertyValue(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY);
+    }
+
+    public Boolean isImmutable() {
+        return getPropertyValue(PropertyIds.IS_IMMUTABLE);
+    }
+
+    public Boolean isLatestMajorVersion() {
+        return getPropertyValue(PropertyIds.IS_LATEST_MAJOR_VERSION);
+    }
+
+    public Boolean isLatestVersion() {
+        return getPropertyValue(PropertyIds.IS_LATEST_VERSION);
+    }
+
+    public Boolean isMajorVersion() {
+        return getPropertyValue(PropertyIds.IS_MAJOR_VERSION);
+    }
+
+    public Boolean isVersionSeriesCheckedOut() {
+        return getPropertyValue(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT);
+    }
+
+    public long getContentStreamLength() {
+        BigInteger bigInt = getPropertyValue(PropertyIds.CONTENT_STREAM_LENGTH);
+        return (bigInt == null) ? (long) -1 : bigInt.longValue();
+    }
+
+    public String getContentStreamMimeType() {
+        return getPropertyValue(PropertyIds.CONTENT_STREAM_MIME_TYPE);
+    }
+
+    public String getContentStreamFileName() {
+        return getPropertyValue(PropertyIds.CONTENT_STREAM_FILE_NAME);
+    }
+
+    public String getContentStreamId() {
+        return getPropertyValue(PropertyIds.CONTENT_STREAM_ID);
+    }
+
+    // operations
+
+    public Document copy(List<Property<?>> properties, VersioningState versioningState, List<Policy> policies,
+            List<Ace> addACEs, List<Ace> removeACEs) {
+        throw new CmisRuntimeException("not implemented");
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.Document#deleteAllVersions()
+     */
+    public void deleteAllVersions() {
+        delete(true);
+    }
+
+    // versioning
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.Document#checkOut()
+     */
+    public ObjectId checkOut() {
+        String objectId = getObjectId();
+        Holder<String> objectIdHolder = new Holder<String>(objectId);
+
+        getBinding().getVersioningService().checkOut(getRepositoryId(), objectIdHolder, null, null);
+
+        if (objectIdHolder.getValue() == null) {
+            return null;
+        }
+
+        return getSession().createObjectId(objectIdHolder.getValue());
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.Document#cancelCheckOut()
+     */
+    public void cancelCheckOut() {
+        String objectId = getObjectId();
+
+        getBinding().getVersioningService().cancelCheckOut(getRepositoryId(), objectId, null);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.Document#checkIn(boolean,
+     * java.util.Map, org.apache.opencmis.client.api.ContentStream,
+     * java.lang.String, java.util.List, java.util.List, java.util.List)
+     */
+    public ObjectId checkIn(boolean major, Map<String, ?> properties, ContentStream contentStream,
+            String checkinComment, List<Policy> policies, List<Ace> addAces, List<Ace> removeAces) {
+        String objectId;
+        ObjectType type;
+        readLock();
+        try {
+            objectId = getObjectId();
+            type = getType();
+        } finally {
+            readUnlock();
+        }
+
+        Holder<String> objectIdHolder = new Holder<String>(objectId);
+
+        ObjectFactory of = getObjectFactory();
+
+        Set<Updatability> updatebility = new HashSet<Updatability>();
+        updatebility.add(Updatability.READWRITE);
+        updatebility.add(Updatability.WHENCHECKEDOUT);
+
+        getBinding().getVersioningService()
+                .checkIn(getRepositoryId(), objectIdHolder, major,
+                        of.convertProperties(properties, type, updatebility), of.convertContentStream(contentStream),
+                        checkinComment, of.convertPolicies(policies), of.convertAces(addAces),
+                        of.convertAces(removeAces), null);
+
+        if (objectIdHolder.getValue() == null) {
+            return null;
+        }
+
+        return getSession().createObjectId(objectIdHolder.getValue());
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.Document#getAllVersions()
+     */
+    public List<Document> getAllVersions() {
+        return getAllVersions(getSession().getDefaultContext());
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @seeorg.apache.opencmis.client.api.Document#getAllVersions(org.apache.
+     * opencmis.client.api. OperationContext)
+     */
+    public List<Document> getAllVersions(OperationContext context) {
+        String objectId;
+        String versionSeriesId;
+
+        readLock();
+        try {
+            objectId = getObjectId();
+            versionSeriesId = getVersionSeriesId();
+        } finally {
+            readUnlock();
+        }
+
+        List<ObjectData> versions = getBinding().getVersioningService().getAllVersions(getRepositoryId(), objectId,
+                versionSeriesId, context.getFilterString(), context.isIncludeAllowableActions(), null);
+
+        ObjectFactory objectFactory = getSession().getObjectFactory();
+
+        List<Document> result = new ArrayList<Document>();
+        if (versions != null) {
+            for (ObjectData objectData : versions) {
+                CmisObject doc = objectFactory.convertObject(objectData, context);
+                if (!(doc instanceof Document)) {
+                    // should not happen...
+                    continue;
+                }
+
+                result.add((Document) doc);
+            }
+        }
+
+        return result;
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.Document#getObjectOfLatestVersion(boolean)
+     */
+    public Document getObjectOfLatestVersion(boolean major) {
+        return getObjectOfLatestVersion(major, null);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.Document#getObjectOfLatestVersion(boolean,
+     * org.apache.opencmis.client.api.OperationContext)
+     */
+    public Document getObjectOfLatestVersion(boolean major, OperationContext context) {
+        String objectId;
+        String versionSeriesId;
+
+        readLock();
+        try {
+            objectId = getObjectId();
+            versionSeriesId = getVersionSeriesId();
+        } finally {
+            readUnlock();
+        }
+
+        if (versionSeriesId == null) {
+            throw new CmisRuntimeException("Version series id is unknown!");
+        }
+
+        ObjectData objectData = getBinding().getVersioningService().getObjectOfLatestVersion(getRepositoryId(),
+                objectId, versionSeriesId, major, context.getFilterString(), context.isIncludeAllowableActions(),
+                context.getIncludeRelationships(), context.getRenditionFilterString(), context.isIncludePolicies(),
+                context.isIncludeAcls(), null);
+
+        ObjectFactory objectFactory = getSession().getObjectFactory();
+
+        CmisObject result = objectFactory.convertObject(objectData, context);
+        if (!(result instanceof Document)) {
+            throw new CmisRuntimeException("Latest version is not a document!");
+        }
+
+        return (Document) result;
+    }
+
+    // content operations
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.Document#getContentStream()
+     */
+    public ContentStream getContentStream() {
+        String objectId = getObjectId();
+
+        // get the stream
+        ContentStream contentStream = getBinding().getObjectService().getContentStream(getRepositoryId(), objectId,
+                null, null, null, null);
+
+        // TODO: what should happen if the length is not set?
+        long length = (contentStream.getBigLength() == null ? -1 : contentStream.getBigLength().longValue());
+
+        // convert and return stream object
+        return getSession().getObjectFactory().createContentStream(contentStream.getFileName(), length,
+                contentStream.getMimeType(), contentStream.getStream());
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.Document#setContentStream(boolean,
+     * org.apache.opencmis.client.api.ContentStream)
+     */
+    public ObjectId setContentStream(ContentStream contentStream, boolean overwrite) {
+        String objectId;
+        String changeToken;
+
+        readLock();
+        try {
+            objectId = getObjectId();
+            changeToken = getPropertyValue(PropertyIds.CHANGE_TOKEN);
+        } finally {
+            readUnlock();
+        }
+
+        Holder<String> objectIdHolder = new Holder<String>(objectId);
+        Holder<String> changeTokenHolder = new Holder<String>(changeToken);
+
+        getBinding().getObjectService().setContentStream(getRepositoryId(), objectIdHolder, overwrite,
+                changeTokenHolder, getObjectFactory().convertContentStream(contentStream), null);
+
+        if (objectIdHolder.getValue() == null) {
+            return null;
+        }
+
+        return getSession().createObjectId(objectIdHolder.getValue());
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.Document#deleteContentStream()
+     */
+    public ObjectId deleteContentStream() {
+        String objectId;
+        String changeToken;
+
+        readLock();
+        try {
+            objectId = getObjectId();
+            changeToken = getPropertyValue(PropertyIds.CHANGE_TOKEN);
+        } finally {
+            readUnlock();
+        }
+
+        Holder<String> objectIdHolder = new Holder<String>(objectId);
+        Holder<String> changeTokenHolder = new Holder<String>(changeToken);
+
+        getBinding().getObjectService().deleteContentStream(getRepositoryId(), objectIdHolder, changeTokenHolder, null);
+
+        if (objectIdHolder.getValue() == null) {
+            return null;
+        }
 
-		return getSession().createObjectId(objectIdHolder.getValue());
-	}
+        return getSession().createObjectId(objectIdHolder.getValue());
+    }
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentFolderImpl.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/PersistentFolderImpl.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/PersistentFolderImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentFolderImpl.java Thu Apr 22 16:04:19 2010
@@ -58,566 +58,506 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.enums.VersioningState;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
 
-public class PersistentFolderImpl extends AbstractPersistentFilableCmisObject
-		implements Folder {
+public class PersistentFolderImpl extends AbstractPersistentFilableCmisObject implements Folder {
 
-	private static final Set<Updatability> CREATE_UPDATABILITY = new HashSet<Updatability>();
-	static {
-		CREATE_UPDATABILITY.add(Updatability.ONCREATE);
-		CREATE_UPDATABILITY.add(Updatability.READWRITE);
-	}
-
-	/**
-	 * Constructor.
-	 */
-	public PersistentFolderImpl(PersistentSessionImpl session,
-			ObjectType objectType, ObjectData objectData,
-			OperationContext context) {
-		initialize(session, objectType, objectData, context);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.Folder#createDocument(java.util.Map,
-	 * org.apache.opencmis.client.api.ContentStream,
-	 * org.apache.opencmis.commons.enums.VersioningState, java.util.List,
-	 * java.util.List, java.util.List,
-	 * org.apache.opencmis.client.api.OperationContext)
-	 */
-	public Document createDocument(Map<String, ?> properties,
-			ContentStream contentStream, VersioningState versioningState,
-			List<Policy> policies, List<Ace> addAces, List<Ace> removeAces,
-			OperationContext context) {
-		String objectId = getObjectId();
-
-		ObjectFactory of = getObjectFactory();
-
-		String newId = getBinding().getObjectService().createDocument(
-				getRepositoryId(),
-				of.convertProperties(properties, null, CREATE_UPDATABILITY),
-				objectId, of.convertContentStream(contentStream),
-				versioningState, of.convertPolicies(policies),
-				of.convertAces(addAces), of.convertAces(removeAces), null);
-
-		// if no context is provided the object will not be fetched
-		if ((context == null) || (newId == null)) {
-			return null;
-		}
-
-		// get the new object
-		CmisObject object = getSession().getObject(
-				getSession().createObjectId(newId), context);
-		if (!(object instanceof Document)) {
-			throw new CmisRuntimeException(
-					"Newly created object is not a document! New id: " + newId);
-		}
-
-		return (Document) object;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.Folder#createDocumentFromSource(org.apache
-	 * .opencmis.client.api .ObjectId, java.util.Map,
-	 * org.apache.opencmis.commons.enums.VersioningState, java.util.List,
-	 * java.util.List, java.util.List,
-	 * org.apache.opencmis.client.api.OperationContext)
-	 */
-	public Document createDocumentFromSource(ObjectId source,
-			Map<String, ?> properties, VersioningState versioningState,
-			List<Policy> policies, List<Ace> addAces, List<Ace> removeAces,
-			OperationContext context) {
-		if ((source == null) || (source.getId() == null)) {
-			throw new IllegalArgumentException("Source must be set!");
-		}
-
-		String objectId = getObjectId();
-
-		// get the type of the source document
-		ObjectType type = null;
-		if (source instanceof CmisObject) {
-			type = ((CmisObject) source).getBaseType();
-		} else {
-			CmisObject sourceObj = getSession().getObject(source);
-			type = sourceObj.getType();
-		}
-
-		if (type.getBaseTypeId() != BaseTypeId.CMIS_DOCUMENT) {
-			throw new IllegalArgumentException(
-					"Source object must be a document!");
-		}
-
-		ObjectFactory of = getObjectFactory();
-
-		Set<Updatability> updatebility = new HashSet<Updatability>();
-		updatebility.add(Updatability.READWRITE);
-
-		String newId = getBinding().getObjectService()
-				.createDocumentFromSource(getRepositoryId(), source.getId(),
-						of.convertProperties(properties, type, updatebility),
-						objectId, versioningState,
-						of.convertPolicies(policies), of.convertAces(addAces),
-						of.convertAces(removeAces), null);
-
-		// if no context is provided the object will not be fetched
-		if ((context == null) || (newId == null)) {
-			return null;
-		}
-
-		// get the new object
-		CmisObject object = getSession().getObject(
-				getSession().createObjectId(newId), context);
-		if (!(object instanceof Document)) {
-			throw new CmisRuntimeException(
-					"Newly created object is not a document! New id: " + newId);
-		}
-
-		return (Document) object;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.Folder#createFolder(java.util.Map,
-	 * java.util.List, java.util.List, java.util.List,
-	 * org.apache.opencmis.client.api.OperationContext)
-	 */
-	public Folder createFolder(Map<String, ?> properties,
-			List<Policy> policies, List<Ace> addAces, List<Ace> removeAces,
-			OperationContext context) {
-		String objectId = getObjectId();
-
-		ObjectFactory of = getObjectFactory();
-
-		String newId = getBinding().getObjectService().createFolder(
-				getRepositoryId(),
-				of.convertProperties(properties, null, CREATE_UPDATABILITY),
-				objectId, of.convertPolicies(policies),
-				of.convertAces(addAces), of.convertAces(removeAces), null);
-
-		// if no context is provided the object will not be fetched
-		if ((context == null) || (newId == null)) {
-			return null;
-		}
-
-		// get the new object
-		CmisObject object = getSession().getObject(
-				getSession().createObjectId(newId), context);
-		if (!(object instanceof Folder)) {
-			throw new CmisRuntimeException(
-					"Newly created object is not a folder! New id: " + newId);
-		}
-
-		return (Folder) object;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.Folder#createPolicy(java.util.Map,
-	 * java.util.List, java.util.List, java.util.List,
-	 * org.apache.opencmis.client.api.OperationContext)
-	 */
-	public Policy createPolicy(Map<String, ?> properties,
-			List<Policy> policies, List<Ace> addAces, List<Ace> removeAces,
-			OperationContext context) {
-		String objectId = getObjectId();
-
-		ObjectFactory of = getObjectFactory();
-
-		String newId = getBinding().getObjectService().createPolicy(
-				getRepositoryId(),
-				of.convertProperties(properties, null, CREATE_UPDATABILITY),
-				objectId, of.convertPolicies(policies),
-				of.convertAces(addAces), of.convertAces(removeAces), null);
-
-		// if no context is provided the object will not be fetched
-		if ((context == null) || (newId == null)) {
-			return null;
-		}
-
-		// get the new object
-		CmisObject object = getSession().getObject(
-				getSession().createObjectId(newId), context);
-		if (!(object instanceof Policy)) {
-			throw new CmisRuntimeException(
-					"Newly created object is not a policy! New id: " + newId);
-		}
-
-		return (Policy) object;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.Folder#deleteTree(boolean,
-	 * org.apache.opencmis.commons.enums.UnfileObjects, boolean)
-	 */
-	public List<String> deleteTree(boolean allVersions, UnfileObject unfile,
-			boolean continueOnFailure) {
-		String repositoryId = getRepositoryId();
-		String objectId = getObjectId();
-
-		FailedToDeleteData failed = getBinding().getObjectService().deleteTree(
-				repositoryId, objectId, allVersions, unfile, continueOnFailure,
-				null);
-
-		return failed.getIds();
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.Folder#getAllowedChildObjectTypes()
-	 */
-	public List<ObjectType> getAllowedChildObjectTypes() {
-		List<ObjectType> result = new ArrayList<ObjectType>();
-
-		readLock();
-		try {
-			List<String> otids = getPropertyMultivalue(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS);
-			if (otids == null) {
-				return result;
-			}
-
-			for (String otid : otids) {
-				result.add(getSession().getTypeDefinition(otid));
-			}
-		} finally {
-			readUnlock();
-		}
-
-		return result;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.Folder#getCheckedOutDocs(int)
-	 */
-	public PagingIterable<Document> getCheckedOutDocs(int itemsPerPage) {
-		return getCheckedOutDocs(getSession().getDefaultContext(), itemsPerPage);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @seeorg.apache.opencmis.client.api.Folder#getCheckedOutDocs(org.apache.
-	 * opencmis.client.api. OperationContext, int)
-	 */
-	public PagingIterable<Document> getCheckedOutDocs(OperationContext context,
-			final int itemsPerPage) {
-		// if (itemsPerPage < 1) {
-		// throw new IllegalArgumentException("itemsPerPage must be > 0!");
-		// }
-		//
-		// final String objectId = getObjectId();
-		// final NavigationService nagivationService =
-		// getBinding().getNavigationService();
-		// final ObjectFactory objectFactory = getSession().getObjectFactory();
-		// final OperationContext ctxt = new OperationContextImpl(context);
-		//
-		// return new AbstractPagingList<Document>() {
-		//
-		// @Override
-		// protected FetchResult fetchPage(int pageNumber) {
-		// int skipCount = pageNumber * getMaxItemsPerPage();
-		//
-		// // get checked out documents for this folder
-		// ObjectList checkedOutDocs =
-		// nagivationService.getCheckedOutDocs(getRepositoryId(), objectId, ctxt
-		// .getFilterString(), ctxt.getOrderBy(),
-		// ctxt.isIncludeAllowableActions(), ctxt
-		// .getIncludeRelationships(), ctxt.getRenditionFilterString(),
-		// BigInteger
-		// .valueOf(getMaxItemsPerPage()), BigInteger.valueOf(skipCount), null);
-		//
-		// // convert objects
-		// List<Document> page = new ArrayList<Document>();
-		// if (checkedOutDocs.getObjects() != null) {
-		// for (ObjectData objectData : checkedOutDocs.getObjects()) {
-		// CmisObject doc = objectFactory.convertObject(objectData, ctxt);
-		// if (!(doc instanceof Document)) {
-		// // should not happen...
-		// continue;
-		// }
-		//
-		// page.add((Document) doc);
-		// }
-		// }
-		//
-		// return new FetchResult(page, checkedOutDocs.getNumItems(),
-		// checkedOutDocs.hasMoreItems());
-		// }
-		//
-		// @Override
-		// public int getMaxItemsPerPage() {
-		// return itemsPerPage;
-		// }
-		// };
-		return null;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.Folder#getChildren(int)
-	 */
-	public PagingIterable<CmisObject> getChildren(int itemsPerPage) {
-		return getChildren(getSession().getDefaultContext(), itemsPerPage);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.api.Folder#getChildren(org.apache.opencmis
-	 * .client.api.OperationContext , int)
-	 */
-	public PagingIterable<CmisObject> getChildren(OperationContext context,
-			final int itemsPerPage) {
-
-		if (itemsPerPage < 1) {
-			throw new IllegalArgumentException("itemsPerPage must be > 0!");
-		}
-
-		final String objectId = getObjectId();
-		final NavigationService navigationService = getBinding()
-				.getNavigationService();
-		final ObjectFactory objectFactory = getSession().getObjectFactory();
-		final OperationContext ctxt = new OperationContextImpl(context);
-
-		return new DefaultPagingIterable<CmisObject>(
-				new AbstractPageFetch<CmisObject>() {
-
-					@Override
-					protected AbstractPageFetch.PageFetchResult<CmisObject> fetchPage(
-							long skipCount) {
-
-						// get the children
-						ObjectInFolderList children = navigationService
-								.getChildren(getRepositoryId(), objectId, ctxt
-										.getFilterString(), ctxt.getOrderBy(),
-										ctxt.isIncludeAllowableActions(), ctxt
-												.getIncludeRelationships(),
-										ctxt.getRenditionFilterString(), ctxt
-												.isIncludePathSegments(),
-										BigInteger.valueOf(itemsPerPage),
-										BigInteger.valueOf(skipCount), null);
-
-						// convert objects
-						List<CmisObject> page = new ArrayList<CmisObject>();
-						List<ObjectInFolderData> childObjects = children
-								.getObjects();
-						if (childObjects != null) {
-							for (ObjectInFolderData objectData : childObjects) {
-								if (objectData.getObject() != null) {
-									page.add(objectFactory.convertObject(
-											objectData.getObject(), ctxt));
-								}
-							}
-						}
-
-						return new AbstractPageFetch.PageFetchResult<CmisObject>(
-								page, children.getNumItems(), children.hasMoreItems()) {
-						};
-					}
-				});
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.Folder#getDescendants(int)
-	 */
-	public List<Tree<FileableCmisObject>> getDescendants(int depth) {
-		return getDescendants(depth, getSession().getDefaultContext());
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.Folder#getDescendants(int,
-	 * org.apache.opencmis.client.api.OperationContext)
-	 */
-	public List<Tree<FileableCmisObject>> getDescendants(int depth,
-			OperationContext context) {
-		String objectId = getObjectId();
-
-		// get the descendants
-		List<ObjectInFolderContainer> providerContainerList = getBinding()
-				.getNavigationService().getDescendants(getRepositoryId(),
-						objectId, BigInteger.valueOf(depth),
-						context.getFilterString(),
-						context.isIncludeAllowableActions(),
-						context.getIncludeRelationships(),
-						context.getRenditionFilterString(),
-						context.isIncludePathSegments(), null);
-
-		return convertProviderContainer(providerContainerList, context);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.Folder#getFolderTree(int)
-	 */
-	public List<Tree<FileableCmisObject>> getFolderTree(int depth) {
-		return getFolderTree(depth, getSession().getDefaultContext());
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.Folder#getFolderTree(int,
-	 * org.apache.opencmis.client.api.OperationContext)
-	 */
-	public List<Tree<FileableCmisObject>> getFolderTree(int depth,
-			OperationContext context) {
-		String objectId = getObjectId();
-
-		// get the folder tree
-		List<ObjectInFolderContainer> providerContainerList = getBinding()
-				.getNavigationService().getFolderTree(getRepositoryId(),
-						objectId, BigInteger.valueOf(depth),
-						context.getFilterString(),
-						context.isIncludeAllowableActions(),
-						context.getIncludeRelationships(),
-						context.getRenditionFilterString(),
-						context.isIncludePathSegments(), null);
-
-		return convertProviderContainer(providerContainerList, context);
-	}
-
-	/**
-	 * Converts a provider container into an API container.
-	 */
-	private List<Tree<FileableCmisObject>> convertProviderContainer(
-			List<ObjectInFolderContainer> providerContainerList,
-			OperationContext context) {
-		if (providerContainerList == null) {
-			return null;
-		}
-
-		ObjectFactory of = getSession().getObjectFactory();
-
-		List<Tree<FileableCmisObject>> result = new ArrayList<Tree<FileableCmisObject>>();
-		for (ObjectInFolderContainer oifc : providerContainerList) {
-			if ((oifc.getObject() == null)
-					|| (oifc.getObject().getObject() == null)) {
-				// shouldn't happen ...
-				continue;
-			}
-
-			// convert the object
-			CmisObject object = of.convertObject(oifc.getObject().getObject(),
-					context);
-			if (!(object instanceof FileableCmisObject)) {
-				// the repository must not return objects that are not fileable,
-				// but you never know...
-				continue;
-			}
-
-			// convert the children
-			List<Tree<FileableCmisObject>> children = convertProviderContainer(
-					oifc.getChildren(), context);
-
-			// add both to current container
-			result.add(new ContainerImpl<FileableCmisObject>(
-					(FileableCmisObject) object, children));
-		}
-
-		return result;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.Folder#isRootFolder()
-	 */
-	public boolean isRootFolder() {
-		String objectId = getObjectId();
-		String rootFolderId = getSession().getRepositoryInfo()
-				.getRootFolderId();
-
-		return objectId.equals(rootFolderId);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.Folder#getFolderParent()
-	 */
-	public Folder getFolderParent() {
-		if (isRootFolder()) {
-			return null;
-		}
-
-		List<Folder> parents = super.getParents();
-		if ((parents == null) || (parents.isEmpty())) {
-			return null;
-		}
-
-		return parents.get(0);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.opencmis.client.api.Folder#getPath()
-	 */
-	public String getPath() {
-		String path;
-
-		readLock();
-		try {
-			// get the path property
-			path = getPropertyValue(PropertyIds.PATH);
-
-			// if the path property isn't set, get it
-			if (path == null) {
-				String objectId = getObjectId();
-				ObjectData objectData = getBinding().getObjectService()
-						.getObject(getRepositoryId(), objectId,
-								PropertyIds.PATH, false,
-								IncludeRelationships.NONE, "cmis:none", false,
-								false, null);
-
-				if ((objectData.getProperties() != null)
-						&& (objectData.getProperties().getProperties() != null)) {
-					PropertyData<?> pathProperty = objectData.getProperties()
-							.getProperties().get(PropertyIds.PATH);
-
-					if (pathProperty instanceof PropertyString) {
-						path = ((PropertyString) pathProperty).getFirstValue();
-					}
-				}
-			}
-		} finally {
-			readUnlock();
-		}
-
-		// we still don't know the path ... it's not a CMIS compliant repository
-		if (path == null) {
-			throw new CmisRuntimeException("Repository didn't return "
-					+ PropertyIds.PATH + "!");
-		}
-
-		return path;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.apache.opencmis.client.runtime.AbstractPersistentFilableCmisObject
-	 * #getPaths()
-	 */
-	@Override
-	public List<String> getPaths() {
-		return Collections.singletonList(getPath());
-	}
+    private static final Set<Updatability> CREATE_UPDATABILITY = new HashSet<Updatability>();
+    static {
+        CREATE_UPDATABILITY.add(Updatability.ONCREATE);
+        CREATE_UPDATABILITY.add(Updatability.READWRITE);
+    }
+
+    /**
+     * Constructor.
+     */
+    public PersistentFolderImpl(PersistentSessionImpl session, ObjectType objectType, ObjectData objectData,
+            OperationContext context) {
+        initialize(session, objectType, objectData, context);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.Folder#createDocument(java.util.Map,
+     * org.apache.opencmis.client.api.ContentStream,
+     * org.apache.opencmis.commons.enums.VersioningState, java.util.List,
+     * java.util.List, java.util.List,
+     * org.apache.opencmis.client.api.OperationContext)
+     */
+    public Document createDocument(Map<String, ?> properties, ContentStream contentStream,
+            VersioningState versioningState, List<Policy> policies, List<Ace> addAces, List<Ace> removeAces,
+            OperationContext context) {
+        String objectId = getObjectId();
+
+        ObjectFactory of = getObjectFactory();
+
+        String newId = getBinding().getObjectService().createDocument(getRepositoryId(),
+                of.convertProperties(properties, null, CREATE_UPDATABILITY), objectId,
+                of.convertContentStream(contentStream), versioningState, of.convertPolicies(policies),
+                of.convertAces(addAces), of.convertAces(removeAces), null);
+
+        // if no context is provided the object will not be fetched
+        if ((context == null) || (newId == null)) {
+            return null;
+        }
+
+        // get the new object
+        CmisObject object = getSession().getObject(getSession().createObjectId(newId), context);
+        if (!(object instanceof Document)) {
+            throw new CmisRuntimeException("Newly created object is not a document! New id: " + newId);
+        }
+
+        return (Document) object;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.Folder#createDocumentFromSource(org.apache
+     * .opencmis.client.api .ObjectId, java.util.Map,
+     * org.apache.opencmis.commons.enums.VersioningState, java.util.List,
+     * java.util.List, java.util.List,
+     * org.apache.opencmis.client.api.OperationContext)
+     */
+    public Document createDocumentFromSource(ObjectId source, Map<String, ?> properties,
+            VersioningState versioningState, List<Policy> policies, List<Ace> addAces, List<Ace> removeAces,
+            OperationContext context) {
+        if ((source == null) || (source.getId() == null)) {
+            throw new IllegalArgumentException("Source must be set!");
+        }
+
+        String objectId = getObjectId();
+
+        // get the type of the source document
+        ObjectType type = null;
+        if (source instanceof CmisObject) {
+            type = ((CmisObject) source).getBaseType();
+        } else {
+            CmisObject sourceObj = getSession().getObject(source);
+            type = sourceObj.getType();
+        }
+
+        if (type.getBaseTypeId() != BaseTypeId.CMIS_DOCUMENT) {
+            throw new IllegalArgumentException("Source object must be a document!");
+        }
+
+        ObjectFactory of = getObjectFactory();
+
+        Set<Updatability> updatebility = new HashSet<Updatability>();
+        updatebility.add(Updatability.READWRITE);
+
+        String newId = getBinding().getObjectService().createDocumentFromSource(getRepositoryId(), source.getId(),
+                of.convertProperties(properties, type, updatebility), objectId, versioningState,
+                of.convertPolicies(policies), of.convertAces(addAces), of.convertAces(removeAces), null);
+
+        // if no context is provided the object will not be fetched
+        if ((context == null) || (newId == null)) {
+            return null;
+        }
+
+        // get the new object
+        CmisObject object = getSession().getObject(getSession().createObjectId(newId), context);
+        if (!(object instanceof Document)) {
+            throw new CmisRuntimeException("Newly created object is not a document! New id: " + newId);
+        }
+
+        return (Document) object;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.Folder#createFolder(java.util.Map,
+     * java.util.List, java.util.List, java.util.List,
+     * org.apache.opencmis.client.api.OperationContext)
+     */
+    public Folder createFolder(Map<String, ?> properties, List<Policy> policies, List<Ace> addAces,
+            List<Ace> removeAces, OperationContext context) {
+        String objectId = getObjectId();
+
+        ObjectFactory of = getObjectFactory();
+
+        String newId = getBinding().getObjectService().createFolder(getRepositoryId(),
+                of.convertProperties(properties, null, CREATE_UPDATABILITY), objectId, of.convertPolicies(policies),
+                of.convertAces(addAces), of.convertAces(removeAces), null);
+
+        // if no context is provided the object will not be fetched
+        if ((context == null) || (newId == null)) {
+            return null;
+        }
+
+        // get the new object
+        CmisObject object = getSession().getObject(getSession().createObjectId(newId), context);
+        if (!(object instanceof Folder)) {
+            throw new CmisRuntimeException("Newly created object is not a folder! New id: " + newId);
+        }
+
+        return (Folder) object;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.Folder#createPolicy(java.util.Map,
+     * java.util.List, java.util.List, java.util.List,
+     * org.apache.opencmis.client.api.OperationContext)
+     */
+    public Policy createPolicy(Map<String, ?> properties, List<Policy> policies, List<Ace> addAces,
+            List<Ace> removeAces, OperationContext context) {
+        String objectId = getObjectId();
+
+        ObjectFactory of = getObjectFactory();
+
+        String newId = getBinding().getObjectService().createPolicy(getRepositoryId(),
+                of.convertProperties(properties, null, CREATE_UPDATABILITY), objectId, of.convertPolicies(policies),
+                of.convertAces(addAces), of.convertAces(removeAces), null);
+
+        // if no context is provided the object will not be fetched
+        if ((context == null) || (newId == null)) {
+            return null;
+        }
+
+        // get the new object
+        CmisObject object = getSession().getObject(getSession().createObjectId(newId), context);
+        if (!(object instanceof Policy)) {
+            throw new CmisRuntimeException("Newly created object is not a policy! New id: " + newId);
+        }
+
+        return (Policy) object;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.Folder#deleteTree(boolean,
+     * org.apache.opencmis.commons.enums.UnfileObjects, boolean)
+     */
+    public List<String> deleteTree(boolean allVersions, UnfileObject unfile, boolean continueOnFailure) {
+        String repositoryId = getRepositoryId();
+        String objectId = getObjectId();
+
+        FailedToDeleteData failed = getBinding().getObjectService().deleteTree(repositoryId, objectId, allVersions,
+                unfile, continueOnFailure, null);
+
+        return failed.getIds();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.Folder#getAllowedChildObjectTypes()
+     */
+    public List<ObjectType> getAllowedChildObjectTypes() {
+        List<ObjectType> result = new ArrayList<ObjectType>();
+
+        readLock();
+        try {
+            List<String> otids = getPropertyMultivalue(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS);
+            if (otids == null) {
+                return result;
+            }
+
+            for (String otid : otids) {
+                result.add(getSession().getTypeDefinition(otid));
+            }
+        } finally {
+            readUnlock();
+        }
+
+        return result;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.Folder#getCheckedOutDocs(int)
+     */
+    public PagingIterable<Document> getCheckedOutDocs(int itemsPerPage) {
+        return getCheckedOutDocs(getSession().getDefaultContext(), itemsPerPage);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @seeorg.apache.opencmis.client.api.Folder#getCheckedOutDocs(org.apache.
+     * opencmis.client.api. OperationContext, int)
+     */
+    public PagingIterable<Document> getCheckedOutDocs(OperationContext context, final int itemsPerPage) {
+        // if (itemsPerPage < 1) {
+        // throw new IllegalArgumentException("itemsPerPage must be > 0!");
+        // }
+        //
+        // final String objectId = getObjectId();
+        // final NavigationService nagivationService =
+        // getBinding().getNavigationService();
+        // final ObjectFactory objectFactory = getSession().getObjectFactory();
+        // final OperationContext ctxt = new OperationContextImpl(context);
+        //
+        // return new AbstractPagingList<Document>() {
+        //
+        // @Override
+        // protected FetchResult fetchPage(int pageNumber) {
+        // int skipCount = pageNumber * getMaxItemsPerPage();
+        //
+        // // get checked out documents for this folder
+        // ObjectList checkedOutDocs =
+        // nagivationService.getCheckedOutDocs(getRepositoryId(), objectId, ctxt
+        // .getFilterString(), ctxt.getOrderBy(),
+        // ctxt.isIncludeAllowableActions(), ctxt
+        // .getIncludeRelationships(), ctxt.getRenditionFilterString(),
+        // BigInteger
+        // .valueOf(getMaxItemsPerPage()), BigInteger.valueOf(skipCount), null);
+        //
+        // // convert objects
+        // List<Document> page = new ArrayList<Document>();
+        // if (checkedOutDocs.getObjects() != null) {
+        // for (ObjectData objectData : checkedOutDocs.getObjects()) {
+        // CmisObject doc = objectFactory.convertObject(objectData, ctxt);
+        // if (!(doc instanceof Document)) {
+        // // should not happen...
+        // continue;
+        // }
+        //
+        // page.add((Document) doc);
+        // }
+        // }
+        //
+        // return new FetchResult(page, checkedOutDocs.getNumItems(),
+        // checkedOutDocs.hasMoreItems());
+        // }
+        //
+        // @Override
+        // public int getMaxItemsPerPage() {
+        // return itemsPerPage;
+        // }
+        // };
+        return null;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.Folder#getChildren(int)
+     */
+    public PagingIterable<CmisObject> getChildren(int itemsPerPage) {
+        return getChildren(getSession().getDefaultContext(), itemsPerPage);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.api.Folder#getChildren(org.apache.opencmis
+     * .client.api.OperationContext , int)
+     */
+    public PagingIterable<CmisObject> getChildren(OperationContext context, final int itemsPerPage) {
+
+        if (itemsPerPage < 1) {
+            throw new IllegalArgumentException("itemsPerPage must be > 0!");
+        }
+
+        final String objectId = getObjectId();
+        final NavigationService navigationService = getBinding().getNavigationService();
+        final ObjectFactory objectFactory = getSession().getObjectFactory();
+        final OperationContext ctxt = new OperationContextImpl(context);
+
+        return new DefaultPagingIterable<CmisObject>(new AbstractPageFetch<CmisObject>() {
+
+            @Override
+            protected AbstractPageFetch.PageFetchResult<CmisObject> fetchPage(long skipCount) {
+
+                // get the children
+                ObjectInFolderList children = navigationService.getChildren(getRepositoryId(), objectId, ctxt
+                        .getFilterString(), ctxt.getOrderBy(), ctxt.isIncludeAllowableActions(), ctxt
+                        .getIncludeRelationships(), ctxt.getRenditionFilterString(), ctxt.isIncludePathSegments(),
+                        BigInteger.valueOf(itemsPerPage), BigInteger.valueOf(skipCount), null);
+
+                // convert objects
+                List<CmisObject> page = new ArrayList<CmisObject>();
+                List<ObjectInFolderData> childObjects = children.getObjects();
+                if (childObjects != null) {
+                    for (ObjectInFolderData objectData : childObjects) {
+                        if (objectData.getObject() != null) {
+                            page.add(objectFactory.convertObject(objectData.getObject(), ctxt));
+                        }
+                    }
+                }
+
+                return new AbstractPageFetch.PageFetchResult<CmisObject>(page, children.getNumItems(), children
+                        .hasMoreItems()) {
+                };
+            }
+        });
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.Folder#getDescendants(int)
+     */
+    public List<Tree<FileableCmisObject>> getDescendants(int depth) {
+        return getDescendants(depth, getSession().getDefaultContext());
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.Folder#getDescendants(int,
+     * org.apache.opencmis.client.api.OperationContext)
+     */
+    public List<Tree<FileableCmisObject>> getDescendants(int depth, OperationContext context) {
+        String objectId = getObjectId();
+
+        // get the descendants
+        List<ObjectInFolderContainer> providerContainerList = getBinding().getNavigationService().getDescendants(
+                getRepositoryId(), objectId, BigInteger.valueOf(depth), context.getFilterString(),
+                context.isIncludeAllowableActions(), context.getIncludeRelationships(),
+                context.getRenditionFilterString(), context.isIncludePathSegments(), null);
+
+        return convertProviderContainer(providerContainerList, context);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.Folder#getFolderTree(int)
+     */
+    public List<Tree<FileableCmisObject>> getFolderTree(int depth) {
+        return getFolderTree(depth, getSession().getDefaultContext());
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.Folder#getFolderTree(int,
+     * org.apache.opencmis.client.api.OperationContext)
+     */
+    public List<Tree<FileableCmisObject>> getFolderTree(int depth, OperationContext context) {
+        String objectId = getObjectId();
+
+        // get the folder tree
+        List<ObjectInFolderContainer> providerContainerList = getBinding().getNavigationService().getFolderTree(
+                getRepositoryId(), objectId, BigInteger.valueOf(depth), context.getFilterString(),
+                context.isIncludeAllowableActions(), context.getIncludeRelationships(),
+                context.getRenditionFilterString(), context.isIncludePathSegments(), null);
+
+        return convertProviderContainer(providerContainerList, context);
+    }
+
+    /**
+     * Converts a provider container into an API container.
+     */
+    private List<Tree<FileableCmisObject>> convertProviderContainer(
+            List<ObjectInFolderContainer> providerContainerList, OperationContext context) {
+        if (providerContainerList == null) {
+            return null;
+        }
+
+        ObjectFactory of = getSession().getObjectFactory();
+
+        List<Tree<FileableCmisObject>> result = new ArrayList<Tree<FileableCmisObject>>();
+        for (ObjectInFolderContainer oifc : providerContainerList) {
+            if ((oifc.getObject() == null) || (oifc.getObject().getObject() == null)) {
+                // shouldn't happen ...
+                continue;
+            }
+
+            // convert the object
+            CmisObject object = of.convertObject(oifc.getObject().getObject(), context);
+            if (!(object instanceof FileableCmisObject)) {
+                // the repository must not return objects that are not fileable,
+                // but you never know...
+                continue;
+            }
+
+            // convert the children
+            List<Tree<FileableCmisObject>> children = convertProviderContainer(oifc.getChildren(), context);
+
+            // add both to current container
+            result.add(new ContainerImpl<FileableCmisObject>((FileableCmisObject) object, children));
+        }
+
+        return result;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.Folder#isRootFolder()
+     */
+    public boolean isRootFolder() {
+        String objectId = getObjectId();
+        String rootFolderId = getSession().getRepositoryInfo().getRootFolderId();
+
+        return objectId.equals(rootFolderId);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.Folder#getFolderParent()
+     */
+    public Folder getFolderParent() {
+        if (isRootFolder()) {
+            return null;
+        }
+
+        List<Folder> parents = super.getParents();
+        if ((parents == null) || (parents.isEmpty())) {
+            return null;
+        }
+
+        return parents.get(0);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.opencmis.client.api.Folder#getPath()
+     */
+    public String getPath() {
+        String path;
+
+        readLock();
+        try {
+            // get the path property
+            path = getPropertyValue(PropertyIds.PATH);
+
+            // if the path property isn't set, get it
+            if (path == null) {
+                String objectId = getObjectId();
+                ObjectData objectData = getBinding().getObjectService().getObject(getRepositoryId(), objectId,
+                        PropertyIds.PATH, false, IncludeRelationships.NONE, "cmis:none", false, false, null);
+
+                if ((objectData.getProperties() != null) && (objectData.getProperties().getProperties() != null)) {
+                    PropertyData<?> pathProperty = objectData.getProperties().getProperties().get(PropertyIds.PATH);
+
+                    if (pathProperty instanceof PropertyString) {
+                        path = ((PropertyString) pathProperty).getFirstValue();
+                    }
+                }
+            }
+        } finally {
+            readUnlock();
+        }
+
+        // we still don't know the path ... it's not a CMIS compliant repository
+        if (path == null) {
+            throw new CmisRuntimeException("Repository didn't return " + PropertyIds.PATH + "!");
+        }
+
+        return path;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.client.runtime.AbstractPersistentFilableCmisObject
+     * #getPaths()
+     */
+    @Override
+    public List<String> getPaths() {
+        return Collections.singletonList(getPath());
+    }
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentPolicyImpl.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/PersistentPolicyImpl.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/PersistentPolicyImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentPolicyImpl.java Thu Apr 22 16:04:19 2010
@@ -26,16 +26,16 @@ import org.apache.chemistry.opencmis.com
 
 public class PersistentPolicyImpl extends AbstractPersistentFilableCmisObject implements Policy {
 
-	/**
-	 * Constructor.
-	 */
-	public PersistentPolicyImpl(PersistentSessionImpl session, ObjectType objectType, ObjectData objectData,
-			OperationContext context) {
-		initialize(session, objectType, objectData, context);
-	}
+    /**
+     * Constructor.
+     */
+    public PersistentPolicyImpl(PersistentSessionImpl session, ObjectType objectType, ObjectData objectData,
+            OperationContext context) {
+        initialize(session, objectType, objectData, context);
+    }
 
-	public String getPolicyText() {
-		return getPropertyValue(PropertyIds.POLICY_TEXT);
-	}
+    public String getPolicyText() {
+        return getPropertyValue(PropertyIds.POLICY_TEXT);
+    }
 
 }