chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r934878 [6/13] - in /incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src: main/java/org/apache/chemistry/opencmis/inmemory/ main/java/org/apache/chemistry/opencmis/inmemory/clientprovider/ mai...
Date Fri, 16 Apr 2010 14:00:25 GMT
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/Version.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/Version.java?rev=934878&r1=934877&r2=934878&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/Version.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/Version.java Fri Apr 16 14:00:23 2010
@@ -19,27 +19,28 @@
 package org.apache.chemistry.opencmis.inmemory.storedobj.api;
 
 /**
- * The interface version adds the version specific functionality to an object. It 
- * has minor and major versions, stores a comment and has a label
+ * The interface version adds the version specific functionality to an object.
+ * It has minor and major versions, stores a comment and has a label
+ * 
  * @author Jens
- *
+ * 
  */
 public interface Version {
 
-  boolean isMajor();
-  
-  boolean isPwc();
-  
-  /**
-   * make the private working copy an official version.
-   */
-  void commit(boolean isMajor);
-
-  void setCheckinComment(String comment);
-  
-  String getCheckinComment();
-  
-  String getVersionLabel();
-  
-  VersionedDocument getParentDocument();
+	boolean isMajor();
+
+	boolean isPwc();
+
+	/**
+	 * make the private working copy an official version.
+	 */
+	void commit(boolean isMajor);
+
+	void setCheckinComment(String comment);
+
+	String getCheckinComment();
+
+	String getVersionLabel();
+
+	VersionedDocument getParentDocument();
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/VersionedDocument.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/VersionedDocument.java?rev=934878&r1=934877&r2=934878&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/VersionedDocument.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/VersionedDocument.java Fri Apr 16 14:00:23 2010
@@ -24,43 +24,43 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.enums.VersioningState;
 
 /**
- * A version series is a concrete object (meaning it can be stored) and has 
+ * A version series is a concrete object (meaning it can be stored) and has
  * methods for check-out and checkin. It has a path (is contained in a folder)
  * In contrast to a non-versioned document it has no content, but versions
  * instead.
  * 
  * @author Jens
- *
+ * 
  */
 public interface VersionedDocument extends MultiFiling, StoredObject {
-  
-  DocumentVersion addVersion(ContentStream content, VersioningState verState, String user);
-  
-  /**
-   * delete a version from this object, throw exception if document is checked out
-   * or document does not contain this version
-   * @param version
-   *    version to be removed
-   * @return
-   *    true if version could be removed, and other versions exist,
-   *    false if the deleted version was the last version in this document
-   */
-  boolean deleteVersion(DocumentVersion version);
-  
-  boolean isCheckedOut();
-  
-  void cancelCheckOut(String user);
-  
-  DocumentVersion checkOut(ContentStream content, String user);
-  
-  void checkIn(boolean isMajor, String checkinComment, String user);
-  
-  List<DocumentVersion> getAllVersions();
-  
-  DocumentVersion getLatestVersion(boolean major);
-  
-  String getCheckedOutBy();
-   
-  DocumentVersion getPwc();
+
+	DocumentVersion addVersion(ContentStream content, VersioningState verState, String user);
+
+	/**
+	 * delete a version from this object, throw exception if document is checked
+	 * out or document does not contain this version
+	 * 
+	 * @param version
+	 *            version to be removed
+	 * @return true if version could be removed, and other versions exist, false
+	 *         if the deleted version was the last version in this document
+	 */
+	boolean deleteVersion(DocumentVersion version);
+
+	boolean isCheckedOut();
+
+	void cancelCheckOut(String user);
+
+	DocumentVersion checkOut(ContentStream content, String user);
+
+	void checkIn(boolean isMajor, String checkinComment, String user);
+
+	List<DocumentVersion> getAllVersions();
+
+	DocumentVersion getLatestVersion(boolean major);
+
+	String getCheckedOutBy();
+
+	DocumentVersion getPwc();
 
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/AbstractMultiFilingImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/AbstractMultiFilingImpl.java?rev=934878&r1=934877&r2=934878&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/AbstractMultiFilingImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/AbstractMultiFilingImpl.java Fri Apr 16 14:00:23 2010
@@ -29,65 +29,81 @@ import org.apache.chemistry.opencmis.inm
 /**
  * @author Jens
  * 
- * AbstractMultiPathImpl is the common superclass of all objects hold in the repository that 
- * have multiple parent folders, these are: Folders
+ *         AbstractMultiPathImpl is the common superclass of all objects hold in
+ *         the repository that have multiple parent folders, these are: Folders
  */
 public abstract class AbstractMultiFilingImpl extends StoredObjectImpl implements MultiFiling {
 
-  protected List<Folder> fParents = new ArrayList<Folder>(1);
+	protected List<Folder> fParents = new ArrayList<Folder>(1);
 
-  AbstractMultiFilingImpl(ObjectStoreImpl objStore) {
-    super(objStore);
-  }
-
-  /* (non-Javadoc)
-   * @see org.apache.opencmis.inmemory.storedobj.api.MultiParentPath#addParent(org.apache.opencmis.inmemory.storedobj.api.Folder)
-   */
-  public void addParent(Folder parent) {
-    
-    if (parent.hasChild(getName()))
-      throw new IllegalArgumentException(
-          "Cannot assign new parent folder, this name already exists in target folder.");
-
-    if (null == fParents)
-      fParents = new ArrayList<Folder>();
-    
-    fParents.add(parent);
-  }
-
-  
-  /* (non-Javadoc)
-   * @see org.apache.opencmis.inmemory.storedobj.api.MultiParentPath#removeParent(org.apache.opencmis.inmemory.storedobj.api.Folder)
-   */
-  public void removeParent(Folder parent){
-    fParents.remove(parent);
-    if (fParents.isEmpty())
-      fParents = null;
-  }
-  
-  
-  /* (non-Javadoc)
-   * @see org.apache.opencmis.inmemory.storedobj.api.MultiParentPath#getParents()
-   */
-  public List<Folder> getParents() {
-    return fParents;
-  }
-
-  
-  /* (non-Javadoc)
-   * @see org.apache.opencmis.inmemory.storedobj.api.MultiParentPath#getPathSegment()
-   */
-  public String getPathSegment() {
-    return getName();
-  }
-
-  
-  /* (non-Javadoc)
-   * @see org.apache.opencmis.inmemory.storedobj.api.Path#move(org.apache.opencmis.inmemory.storedobj.api.Folder, org.apache.opencmis.inmemory.storedobj.api.Folder)
-   */
-  public void move(Folder oldParent, Folder newParent) {
-    addParent(newParent);
-    removeParent(oldParent);
-  }
+	AbstractMultiFilingImpl(ObjectStoreImpl objStore) {
+		super(objStore);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.inmemory.storedobj.api.MultiParentPath#addParent(
+	 * org.apache.opencmis.inmemory.storedobj.api.Folder)
+	 */
+	public void addParent(Folder parent) {
+
+		if (parent.hasChild(getName()))
+			throw new IllegalArgumentException(
+					"Cannot assign new parent folder, this name already exists in target folder.");
+
+		if (null == fParents)
+			fParents = new ArrayList<Folder>();
+
+		fParents.add(parent);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.inmemory.storedobj.api.MultiParentPath#removeParent
+	 * (org.apache.opencmis.inmemory.storedobj.api.Folder)
+	 */
+	public void removeParent(Folder parent) {
+		fParents.remove(parent);
+		if (fParents.isEmpty())
+			fParents = null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.inmemory.storedobj.api.MultiParentPath#getParents()
+	 */
+	public List<Folder> getParents() {
+		return fParents;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.inmemory.storedobj.api.MultiParentPath#getPathSegment
+	 * ()
+	 */
+	public String getPathSegment() {
+		return getName();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.inmemory.storedobj.api.Path#move(org.apache.opencmis
+	 * .inmemory.storedobj.api.Folder,
+	 * org.apache.opencmis.inmemory.storedobj.api.Folder)
+	 */
+	public void move(Folder oldParent, Folder newParent) {
+		addParent(newParent);
+		removeParent(oldParent);
+	}
 
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/AbstractSingleFilingImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/AbstractSingleFilingImpl.java?rev=934878&r1=934877&r2=934878&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/AbstractSingleFilingImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/AbstractSingleFilingImpl.java Fri Apr 16 14:00:23 2010
@@ -33,94 +33,100 @@ import org.apache.chemistry.opencmis.inm
  * 
  * @author Jens
  * 
- * AbstractPathImpl is the common superclass of all objects hold in the repository that
- * have a single parent, these are: Folders
+ *         AbstractPathImpl is the common superclass of all objects hold in the
+ *         repository that have a single parent, these are: Folders
  * 
  */
 
-public abstract class AbstractSingleFilingImpl extends StoredObjectImpl implements
-    SingleFiling {
+public abstract class AbstractSingleFilingImpl extends StoredObjectImpl implements SingleFiling {
 
-  protected FolderImpl fParent;
-
-  protected AbstractSingleFilingImpl(ObjectStoreImpl objStore) {
-    super(objStore);
-  }
-    
-  /*
-   * (non-Javadoc)
-   * 
-   * @see org.opencmis.client.provider.spi.inmemory.StoredObjectWithPath#getPath()
-   */
-  public String getPath() {
-    StringBuffer path= new StringBuffer(getName());
-    if (null == getParent())
-      path.replace(0, path.length(), PATH_SEPARATOR); // root folder--> set /
-    else {
-      Folder f = getParent();
-      while (f.getParent() != null) {
-        path.insert(0,  PATH_SEPARATOR);
-        path.insert(0,  f.getName());
-        f = f.getParent();
-      }
-      path.insert(0,  PATH_SEPARATOR);
-    }
-//    if (LOG.isDebugEnabled())
-//      LOG.debug("getPath() returns: " + path.toString());
-    return path.toString();    
-  }
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see org.opencmis.client.provider.spi.inmemory.StoredObjectWithPath#getParent()
-   */
-  public Folder getParent() {
-    return fParent;
-  }
-  
-  public List<Folder> getParents() {
-    if (null==fParent)
-      return Collections.emptyList();
-    else
-      return Collections.singletonList((Folder)fParent);
-  }
-
-  /* (non-Javadoc)
-   * @see org.opencmis.client.provider.spi.inmemory.storedobj.api.StoredObjectWithPath#setParent(org.opencmis.client.provider.spi.inmemory.storedobj.api.Folder)
-   */
-  public void setParent(Folder parent) {
-    fParent = (FolderImpl) parent;
-  }
-  
-  public void rename(String newName) {
-    if (!NameValidator.isValidId(newName))
-      throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
-    if (getParent() == null)
-      throw new CmisInvalidArgumentException("Root folder cannot be renamed.");
-    if (getParent().hasChild(newName))
-      throw new CmisNameConstraintViolationException("Cannot rename object to " + newName
-          + ". This path already exists.");
-
-    setName(newName);
-  }
-  
-  public void move(Folder oldParent, Folder newParent) {
-    
-    if (this instanceof Document || this instanceof VersionedDocument)
-      fParent.moveChildDocument(this, oldParent, newParent);    
-    else {// it must be a folder
-      if (getParent() == null)
-        throw new IllegalArgumentException("Root folder cannot be moved.");
-      if (newParent == null)
-        throw new IllegalArgumentException("null is not a valid move target.");
-      if (newParent.hasChild(getName()))
-        throw new IllegalArgumentException(
-            "Cannot move folder, this name already exists in target.");
-
-      setParent(newParent);
-    }
-  }
+	protected FolderImpl fParent;
 
+	protected AbstractSingleFilingImpl(ObjectStoreImpl objStore) {
+		super(objStore);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.opencmis.client.provider.spi.inmemory.StoredObjectWithPath#getPath()
+	 */
+	public String getPath() {
+		StringBuffer path = new StringBuffer(getName());
+		if (null == getParent())
+			path.replace(0, path.length(), PATH_SEPARATOR); // root folder-->
+															// set /
+		else {
+			Folder f = getParent();
+			while (f.getParent() != null) {
+				path.insert(0, PATH_SEPARATOR);
+				path.insert(0, f.getName());
+				f = f.getParent();
+			}
+			path.insert(0, PATH_SEPARATOR);
+		}
+		// if (LOG.isDebugEnabled())
+		// LOG.debug("getPath() returns: " + path.toString());
+		return path.toString();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.opencmis.client.provider.spi.inmemory.StoredObjectWithPath#getParent
+	 * ()
+	 */
+	public Folder getParent() {
+		return fParent;
+	}
+
+	public List<Folder> getParents() {
+		if (null == fParent)
+			return Collections.emptyList();
+		else
+			return Collections.singletonList((Folder) fParent);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.opencmis.client.provider.spi.inmemory.storedobj.api.StoredObjectWithPath
+	 * #
+	 * setParent(org.opencmis.client.provider.spi.inmemory.storedobj.api.Folder)
+	 */
+	public void setParent(Folder parent) {
+		fParent = (FolderImpl) parent;
+	}
+
+	public void rename(String newName) {
+		if (!NameValidator.isValidId(newName))
+			throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
+		if (getParent() == null)
+			throw new CmisInvalidArgumentException("Root folder cannot be renamed.");
+		if (getParent().hasChild(newName))
+			throw new CmisNameConstraintViolationException("Cannot rename object to " + newName
+					+ ". This path already exists.");
+
+		setName(newName);
+	}
+
+	public void move(Folder oldParent, Folder newParent) {
+
+		if (this instanceof Document || this instanceof VersionedDocument)
+			fParent.moveChildDocument(this, oldParent, newParent);
+		else {// it must be a folder
+			if (getParent() == null)
+				throw new IllegalArgumentException("Root folder cannot be moved.");
+			if (newParent == null)
+				throw new IllegalArgumentException("null is not a valid move target.");
+			if (newParent.hasChild(getName()))
+				throw new IllegalArgumentException("Cannot move folder, this name already exists in target.");
+
+			setParent(newParent);
+		}
+	}
 
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ContentStreamDataImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ContentStreamDataImpl.java?rev=934878&r1=934877&r2=934878&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ContentStreamDataImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ContentStreamDataImpl.java Fri Apr 16 14:00:23 2010
@@ -11,92 +11,91 @@ import org.apache.chemistry.opencmis.com
 
 public class ContentStreamDataImpl implements ContentStream {
 
-  private int fLength;
+	private int fLength;
 
-  private String fMimeType;
+	private String fMimeType;
 
-  private String fFileName;
+	private String fFileName;
 
-  private byte[] fContent;
+	private byte[] fContent;
 
-  private long fStreamLimitOffset;
-
-  private long fStreamLimitLength;
-
-  public void setContent (InputStream in) throws IOException {
-    fStreamLimitOffset = fStreamLimitLength = -1;
-    if (null == in) {
-      fContent = null; // delete content
-      fLength = 0;
-    } else {
-      byte[] buffer = new byte[ 0xFFFF ];
-      ByteArrayOutputStream contentStream = new ByteArrayOutputStream();
-      for ( int len=0; (len = in.read(buffer)) != -1; )  {
-        contentStream.write( buffer, 0, len );
-        fLength += len;
-      }
-      fContent = contentStream.toByteArray();
-      fLength = contentStream.size();
-      contentStream.close();
-      in.close();
-    }
-  }
-
-  public long getLength() {
-    return fLength;
-  }
-
-  public BigInteger getBigLength() {
-    return BigInteger.valueOf(fLength);
-  }
-
-  public String getMimeType() {
-    return fMimeType;
-  }
-
-  public void setMimeType(String fMimeType) {
-    this.fMimeType = fMimeType;
-  }
-
-  public String getFileName() {
-    return fFileName;
-  }
-
-  public void setFileName(String fileName) {
-    this.fFileName = fileName;
-  }
-
-  public String getFilename() {
-    return fFileName;
-  }
-
-  public InputStream getStream() {
-    if (null == fContent)
-      return null;
-    else if (fStreamLimitOffset <= 0 && fStreamLimitLength < 0)
-      return new ByteArrayInputStream(fContent);
-    else
-      return new ByteArrayInputStream(fContent, (int)(fStreamLimitOffset<0 ? 0 : fStreamLimitOffset),
-          (int)(fStreamLimitLength<0 ? fLength : fStreamLimitLength));
-  }
-
-  public ContentStream getCloneWithLimits(long offset, long length) {
-    ContentStreamDataImpl clone = new ContentStreamDataImpl();
-    clone.fFileName = fFileName;
-    clone.fLength = fLength;
-    clone.fContent = fContent;
-    clone.fMimeType = fMimeType;
-    clone.fStreamLimitOffset = offset;
-    clone.fStreamLimitLength = length;
-    return clone;
-  }
-
-
-  public List<Object> getExtensions() {
-    return null;
-  }
-
-  public void setExtensions(List<Object> extensions) {
-    // not implemented
-  }
+	private long fStreamLimitOffset;
+
+	private long fStreamLimitLength;
+
+	public void setContent(InputStream in) throws IOException {
+		fStreamLimitOffset = fStreamLimitLength = -1;
+		if (null == in) {
+			fContent = null; // delete content
+			fLength = 0;
+		} else {
+			byte[] buffer = new byte[0xFFFF];
+			ByteArrayOutputStream contentStream = new ByteArrayOutputStream();
+			for (int len = 0; (len = in.read(buffer)) != -1;) {
+				contentStream.write(buffer, 0, len);
+				fLength += len;
+			}
+			fContent = contentStream.toByteArray();
+			fLength = contentStream.size();
+			contentStream.close();
+			in.close();
+		}
+	}
+
+	public long getLength() {
+		return fLength;
+	}
+
+	public BigInteger getBigLength() {
+		return BigInteger.valueOf(fLength);
+	}
+
+	public String getMimeType() {
+		return fMimeType;
+	}
+
+	public void setMimeType(String fMimeType) {
+		this.fMimeType = fMimeType;
+	}
+
+	public String getFileName() {
+		return fFileName;
+	}
+
+	public void setFileName(String fileName) {
+		this.fFileName = fileName;
+	}
+
+	public String getFilename() {
+		return fFileName;
+	}
+
+	public InputStream getStream() {
+		if (null == fContent)
+			return null;
+		else if (fStreamLimitOffset <= 0 && fStreamLimitLength < 0)
+			return new ByteArrayInputStream(fContent);
+		else
+			return new ByteArrayInputStream(fContent, (int) (fStreamLimitOffset < 0 ? 0 : fStreamLimitOffset),
+					(int) (fStreamLimitLength < 0 ? fLength : fStreamLimitLength));
+	}
+
+	public ContentStream getCloneWithLimits(long offset, long length) {
+		ContentStreamDataImpl clone = new ContentStreamDataImpl();
+		clone.fFileName = fFileName;
+		clone.fLength = fLength;
+		clone.fContent = fContent;
+		clone.fMimeType = fMimeType;
+		clone.fStreamLimitOffset = offset;
+		clone.fStreamLimitLength = length;
+		return clone;
+	}
+
+	public List<Object> getExtensions() {
+		return null;
+	}
+
+	public void setExtensions(List<Object> extensions) {
+		// not implemented
+	}
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentImpl.java?rev=934878&r1=934877&r2=934878&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentImpl.java Fri Apr 16 14:00:23 2010
@@ -32,94 +32,94 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 /**
- * InMemory Stored Document A document is a stored object that has a path and (optional) content
- *
+ * InMemory Stored Document A document is a stored object that has a path and
+ * (optional) content
+ * 
  * @author Jens
- *
+ * 
  */
 
 public class DocumentImpl extends AbstractMultiFilingImpl implements Document {
-  private ContentStreamDataImpl fContent;
+	private ContentStreamDataImpl fContent;
 
-  private static final Log LOG = LogFactory.getLog(AbstractSingleFilingImpl.class.getName());
-
-  DocumentImpl(ObjectStoreImpl objStore) { // visibility should be package
-    super(objStore);
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.opencmis.client.provider.spi.inmemory.IDocument#getContent()
-   */
-  public ContentStream getContent(long offset, long length) {
-    if (null == fContent)
-      return null;
-    else if (offset<=0 && length<0)
-      return fContent;
-    else
-      return fContent.getCloneWithLimits(offset, length);
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see
-   * org.opencmis.client.provider.spi.inmemory.IDocument#setContent(org.opencmis.client.provider
-   * .ContentStreamData)
-   */
-  public void setContent(ContentStream content, boolean mustPersist) {
-
-    if (null == content) {
-      fContent = null;
-    } else {
-      fContent = new ContentStreamDataImpl();
-      fContent.setFileName(content.getFileName());
-      fContent.setMimeType(content.getMimeType());
-      try {
-        fContent.setContent(content.getStream());
-      }
-      catch (IOException e) {
-        e.printStackTrace();
-        throw new RuntimeException("Failed to get content from InputStream" , e);
-      }
-    }
-  }
-
-  public void fillProperties(Map<String, PropertyData<?>> properties, BindingsObjectFactory objFactory,
-      List<String> requestedIds) {
-
-    super.fillProperties(properties, objFactory, requestedIds);
-
-    // fill the version related properties (versions should override this but the spec requires some
-    // properties always to be set
-
-    if (FilterParser.isContainedInFilter(PropertyIds.IS_IMMUTABLE, requestedIds)) {
-      properties.put(PropertyIds.IS_IMMUTABLE, objFactory.createPropertyBooleanData(PropertyIds.IS_IMMUTABLE, false));
-    }
-
-    // Set the content related properties
-    if (null != fContent) {
-      if (FilterParser.isContainedInFilter(PropertyIds.CONTENT_STREAM_FILE_NAME, requestedIds)) {
-        properties.put(PropertyIds.CONTENT_STREAM_FILE_NAME, objFactory
-            .createPropertyStringData(PropertyIds.CONTENT_STREAM_FILE_NAME, fContent
-                .getFileName()));
-      }
-      // omit: PropertyIds.CMIS_CONTENT_STREAM_ID
-      if (FilterParser.isContainedInFilter(PropertyIds.CONTENT_STREAM_LENGTH, requestedIds)) {
-        properties.put(PropertyIds.CONTENT_STREAM_LENGTH, objFactory
-            .createPropertyIntegerData(PropertyIds.CONTENT_STREAM_LENGTH, fContent.getBigLength()));
-      }
-      if (FilterParser.isContainedInFilter(PropertyIds.CONTENT_STREAM_MIME_TYPE, requestedIds)) {
-        properties.put(PropertyIds.CONTENT_STREAM_MIME_TYPE, objFactory
-            .createPropertyStringData(PropertyIds.CONTENT_STREAM_MIME_TYPE, fContent.getMimeType()));
-      }
-    }
-  }
-
-  public boolean hasContent() {
-    return null != fContent;
-  }
+	private static final Log LOG = LogFactory.getLog(AbstractSingleFilingImpl.class.getName());
 
+	DocumentImpl(ObjectStoreImpl objStore) { // visibility should be package
+		super(objStore);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.opencmis.client.provider.spi.inmemory.IDocument#getContent()
+	 */
+	public ContentStream getContent(long offset, long length) {
+		if (null == fContent)
+			return null;
+		else if (offset <= 0 && length < 0)
+			return fContent;
+		else
+			return fContent.getCloneWithLimits(offset, length);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.opencmis.client.provider.spi.inmemory.IDocument#setContent(org.opencmis
+	 * .client.provider .ContentStreamData)
+	 */
+	public void setContent(ContentStream content, boolean mustPersist) {
+
+		if (null == content) {
+			fContent = null;
+		} else {
+			fContent = new ContentStreamDataImpl();
+			fContent.setFileName(content.getFileName());
+			fContent.setMimeType(content.getMimeType());
+			try {
+				fContent.setContent(content.getStream());
+			} catch (IOException e) {
+				e.printStackTrace();
+				throw new RuntimeException("Failed to get content from InputStream", e);
+			}
+		}
+	}
+
+	public void fillProperties(Map<String, PropertyData<?>> properties, BindingsObjectFactory objFactory,
+			List<String> requestedIds) {
+
+		super.fillProperties(properties, objFactory, requestedIds);
+
+		// fill the version related properties (versions should override this
+		// but the spec requires some
+		// properties always to be set
+
+		if (FilterParser.isContainedInFilter(PropertyIds.IS_IMMUTABLE, requestedIds)) {
+			properties.put(PropertyIds.IS_IMMUTABLE, objFactory.createPropertyBooleanData(PropertyIds.IS_IMMUTABLE,
+					false));
+		}
+
+		// Set the content related properties
+		if (null != fContent) {
+			if (FilterParser.isContainedInFilter(PropertyIds.CONTENT_STREAM_FILE_NAME, requestedIds)) {
+				properties.put(PropertyIds.CONTENT_STREAM_FILE_NAME, objFactory.createPropertyStringData(
+						PropertyIds.CONTENT_STREAM_FILE_NAME, fContent.getFileName()));
+			}
+			// omit: PropertyIds.CMIS_CONTENT_STREAM_ID
+			if (FilterParser.isContainedInFilter(PropertyIds.CONTENT_STREAM_LENGTH, requestedIds)) {
+				properties.put(PropertyIds.CONTENT_STREAM_LENGTH, objFactory.createPropertyIntegerData(
+						PropertyIds.CONTENT_STREAM_LENGTH, fContent.getBigLength()));
+			}
+			if (FilterParser.isContainedInFilter(PropertyIds.CONTENT_STREAM_MIME_TYPE, requestedIds)) {
+				properties.put(PropertyIds.CONTENT_STREAM_MIME_TYPE, objFactory.createPropertyStringData(
+						PropertyIds.CONTENT_STREAM_MIME_TYPE, fContent.getMimeType()));
+			}
+		}
+	}
+
+	public boolean hasContent() {
+		return null != fContent;
+	}
 
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentVersionImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentVersionImpl.java?rev=934878&r1=934877&r2=934878&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentVersionImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/DocumentVersionImpl.java Fri Apr 16 14:00:23 2010
@@ -35,207 +35,218 @@ import org.apache.chemistry.opencmis.inm
 
 /**
  * A class representing a single version of a document
- *
+ * 
  * @author Jens
- *
+ * 
  */
 public class DocumentVersionImpl extends StoredObjectImpl implements DocumentVersion {
 
-  private ContentStreamDataImpl fContent;
-  private VersionedDocument fContainer; // the document this version belongs to
-  private String fComment; // checkin comment
-  boolean fIsMajor;
-  boolean fIsPwc; // true if this is the PWC
-
-  public DocumentVersionImpl(String repositoryId, VersionedDocument container, ContentStream content,
-      VersioningState verState, ObjectStoreImpl objStore) {
-    super(objStore);
-    setRepositoryId(repositoryId);
-    fContainer = container;
-    setContent(content, false);
-    fIsMajor = verState == VersioningState.MAJOR;
-    fIsPwc = verState == VersioningState.CHECKEDOUT;
-    fProperties = new HashMap<String, PropertyData<?>>(); // ensure that we have a map
-  }
-
-  public void setContent(ContentStream content, boolean mustPersist) {
-    if (null == content) {
-      fContent = null;
-    } else {
-      fContent = new ContentStreamDataImpl();
-      fContent.setFileName(content.getFileName());
-      fContent.setMimeType(content.getMimeType());
-      try {
-        fContent.setContent(content.getStream());
-      }
-      catch (IOException e) {
-        e.printStackTrace();
-        throw new RuntimeException("Failed to get content from InputStream" , e);
-      }
-    }
-  }
-
-  public void setCheckinComment(String comment) {
-    fComment = comment;
-  }
-
-  public String getCheckinComment() {
-    return fComment;
-  }
-
-  public String getVersionLabel() {
-    int majorNo = 0;
-    int minorNo = 0;
-    List<DocumentVersion> allVersions = fContainer.getAllVersions();
-    for (DocumentVersion ver : allVersions) {
-      if (ver.isMajor()) {
-        ++majorNo;
-        minorNo = 0;
-      } else
-        ++minorNo;
-    }
-    String label = "V " + majorNo + "." + minorNo;
-    return label;
-  }
-
-  public boolean isMajor() {
-    return fIsMajor && !isPwc();
-  }
-
-  public boolean isPwc() {
-    return fIsPwc;
-  }
-
-  public void commit(boolean isMajor) {
-    fIsPwc = false; // unset working copy flag
-    fIsMajor = isMajor;
-  }
-
-  public ContentStream getContent(long offset, long length) {
-    if (offset<=0 && length<0)
-      return fContent;
-    else
-      return fContent.getCloneWithLimits(offset, length);
-  }
-
-  public VersionedDocument getParentDocument() {
-    return fContainer;
-  }
-
-  private boolean isLatestVersion() {
-    List<DocumentVersion> allVers = fContainer.getAllVersions();
-    boolean isLatestVersion;
-    if (isPwc())
-      isLatestVersion = allVers.size()>1 && allVers.get(allVers.size()-2).equals(this);
-    else
-      isLatestVersion = allVers.get(allVers.size()-1).equals(this);
-    return isLatestVersion;
-  }
-
-  private boolean isLatestMajorVersion() {
-    if (!fIsMajor)
-      return false;
-
-    List<DocumentVersion> allVersions = fContainer.getAllVersions();
-    DocumentVersion latestMajor=null;
-
-    for (DocumentVersion ver : allVersions)
-      if (ver.isMajor() && !ver.isPwc())
-        latestMajor = ver;
-
-    boolean isLatestMajorVersion = latestMajor == this;
-    return isLatestMajorVersion;
-  }
-
-//  public void persist() {
-//    if (null==fId)
-//      fId = UUID.randomUUID().toString();
-//  }
-
-  public void fillProperties(Map<String, PropertyData<?>> properties, BindingsObjectFactory objFactory,
-      List<String> requestedIds) {
-
-    DocumentVersion pwc = fContainer.getPwc();
-
-    // First get the properties of the container (like custom type properties, etc)
-    fContainer.fillProperties(properties, objFactory, requestedIds);
-
-    // overwrite the version specific properties (like modification date, user, etc.)
-    // and set some properties specific to the version
-    super.fillProperties(properties, objFactory, requestedIds);
-
-    // fill the version related properties
-    if (FilterParser.isContainedInFilter(PropertyIds.IS_LATEST_VERSION, requestedIds)) {
-      properties.put(PropertyIds.IS_LATEST_VERSION, objFactory.createPropertyBooleanData(PropertyIds.IS_LATEST_VERSION, isLatestVersion()));
-    }
-    if (FilterParser.isContainedInFilter(PropertyIds.IS_MAJOR_VERSION, requestedIds)) {
-      properties.put(PropertyIds.IS_MAJOR_VERSION, objFactory.createPropertyBooleanData(PropertyIds.IS_MAJOR_VERSION, fIsMajor));
-    }
-    if (FilterParser.isContainedInFilter(PropertyIds.IS_LATEST_MAJOR_VERSION, requestedIds)) {
-      properties.put(PropertyIds.IS_LATEST_MAJOR_VERSION, objFactory.createPropertyBooleanData(PropertyIds.IS_LATEST_MAJOR_VERSION, isLatestMajorVersion()));
-    }
-    if (FilterParser.isContainedInFilter(PropertyIds.VERSION_SERIES_ID, requestedIds)) {
-      properties.put(PropertyIds.VERSION_SERIES_ID, objFactory.createPropertyIdData(PropertyIds.VERSION_SERIES_ID, fContainer.getId()));
-    }
-    if (FilterParser.isContainedInFilter(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT, requestedIds)) {
-      properties.put(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT, objFactory.createPropertyBooleanData(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT, fContainer.isCheckedOut()));
-    }
-    if (FilterParser.isContainedInFilter(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY, requestedIds)) {
-      properties.put(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY, objFactory.createPropertyStringData(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY, fContainer.getCheckedOutBy()));
-    }
-    if (FilterParser.isContainedInFilter(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID, requestedIds)) {
-      properties.put(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID, objFactory.createPropertyIdData(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID, pwc == null ? null : pwc.getId()));
-    }
-    if (FilterParser.isContainedInFilter(PropertyIds.CHECKIN_COMMENT, requestedIds)) {
-      properties.put(PropertyIds.CHECKIN_COMMENT, objFactory.createPropertyStringData(PropertyIds.CHECKIN_COMMENT, fComment));
-    }
-    if (FilterParser.isContainedInFilter(PropertyIds.VERSION_LABEL, requestedIds)) {
-      properties.put(PropertyIds.VERSION_LABEL, objFactory.createPropertyStringData(PropertyIds.VERSION_LABEL, getVersionLabel()));
-    }
-
-    // Set the content related properties
-    if (null != fContent) {
-      if (FilterParser.isContainedInFilter(PropertyIds.CONTENT_STREAM_FILE_NAME, requestedIds)) {
-        properties.put(PropertyIds.CONTENT_STREAM_FILE_NAME, objFactory
-            .createPropertyStringData(PropertyIds.CONTENT_STREAM_FILE_NAME, fContent
-                .getFileName()));
-      }
-
-      // omit: PropertyIds.CMIS_CONTENT_STREAM_ID
-
-      if (FilterParser.isContainedInFilter(PropertyIds.CONTENT_STREAM_LENGTH, requestedIds)) {
-        properties.put(PropertyIds.CONTENT_STREAM_LENGTH, objFactory
-            .createPropertyIntegerData(PropertyIds.CONTENT_STREAM_LENGTH, fContent.getBigLength()));
-      }
-      if (FilterParser.isContainedInFilter(PropertyIds.CONTENT_STREAM_MIME_TYPE, requestedIds)) {
-        properties.put(PropertyIds.CONTENT_STREAM_MIME_TYPE, objFactory
-            .createPropertyStringData(PropertyIds.CONTENT_STREAM_MIME_TYPE, fContent.getMimeType()));
-      }
-    }
-  }
-
-  public List<Folder> getParents() {
-    return fContainer.getParents();
-  }
-
-  public String getPathSegment() {
-    return fContainer.getPathSegment();
-  }
-
-  public void move(Folder oldParent, Folder newParent) {
-    fContainer.move(oldParent, newParent);
-  }
-
-  public void addParent(Folder parent) {
-    fContainer.addParent(parent);
-  }
-
-  public void removeParent(Folder parent) {
-    fContainer.removeParent(parent);
-  }
-
-  public boolean hasContent() {
-    return null != fContent;
-  }
+	private ContentStreamDataImpl fContent;
+	private VersionedDocument fContainer; // the document this version belongs
+											// to
+	private String fComment; // checkin comment
+	boolean fIsMajor;
+	boolean fIsPwc; // true if this is the PWC
+
+	public DocumentVersionImpl(String repositoryId, VersionedDocument container, ContentStream content,
+			VersioningState verState, ObjectStoreImpl objStore) {
+		super(objStore);
+		setRepositoryId(repositoryId);
+		fContainer = container;
+		setContent(content, false);
+		fIsMajor = verState == VersioningState.MAJOR;
+		fIsPwc = verState == VersioningState.CHECKEDOUT;
+		fProperties = new HashMap<String, PropertyData<?>>(); // ensure that we
+																// have a map
+	}
+
+	public void setContent(ContentStream content, boolean mustPersist) {
+		if (null == content) {
+			fContent = null;
+		} else {
+			fContent = new ContentStreamDataImpl();
+			fContent.setFileName(content.getFileName());
+			fContent.setMimeType(content.getMimeType());
+			try {
+				fContent.setContent(content.getStream());
+			} catch (IOException e) {
+				e.printStackTrace();
+				throw new RuntimeException("Failed to get content from InputStream", e);
+			}
+		}
+	}
+
+	public void setCheckinComment(String comment) {
+		fComment = comment;
+	}
+
+	public String getCheckinComment() {
+		return fComment;
+	}
+
+	public String getVersionLabel() {
+		int majorNo = 0;
+		int minorNo = 0;
+		List<DocumentVersion> allVersions = fContainer.getAllVersions();
+		for (DocumentVersion ver : allVersions) {
+			if (ver.isMajor()) {
+				++majorNo;
+				minorNo = 0;
+			} else
+				++minorNo;
+		}
+		String label = "V " + majorNo + "." + minorNo;
+		return label;
+	}
+
+	public boolean isMajor() {
+		return fIsMajor && !isPwc();
+	}
+
+	public boolean isPwc() {
+		return fIsPwc;
+	}
+
+	public void commit(boolean isMajor) {
+		fIsPwc = false; // unset working copy flag
+		fIsMajor = isMajor;
+	}
+
+	public ContentStream getContent(long offset, long length) {
+		if (offset <= 0 && length < 0)
+			return fContent;
+		else
+			return fContent.getCloneWithLimits(offset, length);
+	}
+
+	public VersionedDocument getParentDocument() {
+		return fContainer;
+	}
+
+	private boolean isLatestVersion() {
+		List<DocumentVersion> allVers = fContainer.getAllVersions();
+		boolean isLatestVersion;
+		if (isPwc())
+			isLatestVersion = allVers.size() > 1 && allVers.get(allVers.size() - 2).equals(this);
+		else
+			isLatestVersion = allVers.get(allVers.size() - 1).equals(this);
+		return isLatestVersion;
+	}
+
+	private boolean isLatestMajorVersion() {
+		if (!fIsMajor)
+			return false;
+
+		List<DocumentVersion> allVersions = fContainer.getAllVersions();
+		DocumentVersion latestMajor = null;
+
+		for (DocumentVersion ver : allVersions)
+			if (ver.isMajor() && !ver.isPwc())
+				latestMajor = ver;
+
+		boolean isLatestMajorVersion = latestMajor == this;
+		return isLatestMajorVersion;
+	}
+
+	// public void persist() {
+	// if (null==fId)
+	// fId = UUID.randomUUID().toString();
+	// }
+
+	public void fillProperties(Map<String, PropertyData<?>> properties, BindingsObjectFactory objFactory,
+			List<String> requestedIds) {
+
+		DocumentVersion pwc = fContainer.getPwc();
+
+		// First get the properties of the container (like custom type
+		// properties, etc)
+		fContainer.fillProperties(properties, objFactory, requestedIds);
+
+		// overwrite the version specific properties (like modification date,
+		// user, etc.)
+		// and set some properties specific to the version
+		super.fillProperties(properties, objFactory, requestedIds);
+
+		// fill the version related properties
+		if (FilterParser.isContainedInFilter(PropertyIds.IS_LATEST_VERSION, requestedIds)) {
+			properties.put(PropertyIds.IS_LATEST_VERSION, objFactory.createPropertyBooleanData(
+					PropertyIds.IS_LATEST_VERSION, isLatestVersion()));
+		}
+		if (FilterParser.isContainedInFilter(PropertyIds.IS_MAJOR_VERSION, requestedIds)) {
+			properties.put(PropertyIds.IS_MAJOR_VERSION, objFactory.createPropertyBooleanData(
+					PropertyIds.IS_MAJOR_VERSION, fIsMajor));
+		}
+		if (FilterParser.isContainedInFilter(PropertyIds.IS_LATEST_MAJOR_VERSION, requestedIds)) {
+			properties.put(PropertyIds.IS_LATEST_MAJOR_VERSION, objFactory.createPropertyBooleanData(
+					PropertyIds.IS_LATEST_MAJOR_VERSION, isLatestMajorVersion()));
+		}
+		if (FilterParser.isContainedInFilter(PropertyIds.VERSION_SERIES_ID, requestedIds)) {
+			properties.put(PropertyIds.VERSION_SERIES_ID, objFactory.createPropertyIdData(
+					PropertyIds.VERSION_SERIES_ID, fContainer.getId()));
+		}
+		if (FilterParser.isContainedInFilter(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT, requestedIds)) {
+			properties.put(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT, objFactory.createPropertyBooleanData(
+					PropertyIds.IS_VERSION_SERIES_CHECKED_OUT, fContainer.isCheckedOut()));
+		}
+		if (FilterParser.isContainedInFilter(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY, requestedIds)) {
+			properties.put(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY, objFactory.createPropertyStringData(
+					PropertyIds.VERSION_SERIES_CHECKED_OUT_BY, fContainer.getCheckedOutBy()));
+		}
+		if (FilterParser.isContainedInFilter(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID, requestedIds)) {
+			properties.put(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID, objFactory.createPropertyIdData(
+					PropertyIds.VERSION_SERIES_CHECKED_OUT_ID, pwc == null ? null : pwc.getId()));
+		}
+		if (FilterParser.isContainedInFilter(PropertyIds.CHECKIN_COMMENT, requestedIds)) {
+			properties.put(PropertyIds.CHECKIN_COMMENT, objFactory.createPropertyStringData(
+					PropertyIds.CHECKIN_COMMENT, fComment));
+		}
+		if (FilterParser.isContainedInFilter(PropertyIds.VERSION_LABEL, requestedIds)) {
+			properties.put(PropertyIds.VERSION_LABEL, objFactory.createPropertyStringData(PropertyIds.VERSION_LABEL,
+					getVersionLabel()));
+		}
+
+		// Set the content related properties
+		if (null != fContent) {
+			if (FilterParser.isContainedInFilter(PropertyIds.CONTENT_STREAM_FILE_NAME, requestedIds)) {
+				properties.put(PropertyIds.CONTENT_STREAM_FILE_NAME, objFactory.createPropertyStringData(
+						PropertyIds.CONTENT_STREAM_FILE_NAME, fContent.getFileName()));
+			}
+
+			// omit: PropertyIds.CMIS_CONTENT_STREAM_ID
+
+			if (FilterParser.isContainedInFilter(PropertyIds.CONTENT_STREAM_LENGTH, requestedIds)) {
+				properties.put(PropertyIds.CONTENT_STREAM_LENGTH, objFactory.createPropertyIntegerData(
+						PropertyIds.CONTENT_STREAM_LENGTH, fContent.getBigLength()));
+			}
+			if (FilterParser.isContainedInFilter(PropertyIds.CONTENT_STREAM_MIME_TYPE, requestedIds)) {
+				properties.put(PropertyIds.CONTENT_STREAM_MIME_TYPE, objFactory.createPropertyStringData(
+						PropertyIds.CONTENT_STREAM_MIME_TYPE, fContent.getMimeType()));
+			}
+		}
+	}
+
+	public List<Folder> getParents() {
+		return fContainer.getParents();
+	}
+
+	public String getPathSegment() {
+		return fContainer.getPathSegment();
+	}
+
+	public void move(Folder oldParent, Folder newParent) {
+		fContainer.move(oldParent, newParent);
+	}
+
+	public void addParent(Folder parent) {
+		fContainer.addParent(parent);
+	}
+
+	public void removeParent(Folder parent) {
+		fContainer.removeParent(parent);
+	}
+
+	public boolean hasContent() {
+		return null != fContent;
+	}
 
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FolderImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FolderImpl.java?rev=934878&r1=934877&r2=934878&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FolderImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/FolderImpl.java Fri Apr 16 14:00:23 2010
@@ -24,207 +24,206 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 public class FolderImpl extends AbstractSingleFilingImpl implements Folder {
-  private static final Log LOG = LogFactory.getLog(AbstractSingleFilingImpl.class.getName());
+	private static final Log LOG = LogFactory.getLog(AbstractSingleFilingImpl.class.getName());
 
-  FolderImpl(ObjectStoreImpl objStore) {
-    super(objStore);
-  }
-
-  public FolderImpl(ObjectStoreImpl objStore, String name, Folder parent) {
-    super(objStore);
-    init(name, parent);
-  }
-
-  public void addChildFolder(Folder folder) {
-    boolean hasChild;
-    String name = folder.getName();
-    hasChild = hasChild(name);
-    if (hasChild)
-      throw new RuntimeException("Cannot create folder " + name
-          + ". Name already exists in parent folder");
-    folder.setParent(this);
-    folder.persist();
-  }
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see
-   * org.opencmis.client.provider.spi.inmemory.IFolder#addChildDocument(org.opencmis.client.provider
-   * .spi.inmemory.storedobj.impl.DocumentImpl)
-   */
-  public void addChildDocument(Document doc) {
-    addChildObject(doc);
-  }
-
-  public void addChildDocument(VersionedDocument doc) {
-    addChildObject(doc);
-  }
-  
-  private void addChildObject(StoredObject so) {
-    String name = so.getName();
-    if (!NameValidator.isValidId(name))
-      throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
-
-    boolean hasChild;
-    hasChild = hasChild(name);
-    if (hasChild)
-      throw new RuntimeException("Cannot create document " + name
-          + ". Name already exists in parent folder");
-
-    if (so instanceof SingleFiling)
-      ((SingleFiling)so).setParent(this);
-    else if (so instanceof MultiFiling)
-      ((MultiFiling)so).addParent(this);
-    else 
-      throw new RuntimeException("Cannot create document, object is not fileable.");
-      
-    so.persist();
-  }
-  
-  /*
-   * (non-Javadoc)
-   * 
-   * @see org.opencmis.client.provider.spi.inmemory.IFolder#getChildren()
-   */
-  public List<StoredObject> getChildren(int maxItems, int skipCount) {
-    List<StoredObject> result = new ArrayList<StoredObject>();
-    for (String id : fObjStore.getIds()) {
-      StoredObject obj = fObjStore.getObject(id);
-      Filing pathObj = (Filing) obj;
-      if (pathObj.getParents().contains(this)) {
-        if (pathObj instanceof VersionedDocument) {
-          DocumentVersion ver = ((VersionedDocument) pathObj).getLatestVersion(false);
-          result.add(ver);
-          } else if (pathObj instanceof DocumentVersion) {
-          // ignore
-        } else {
-          result.add(obj);
-        }
-      }
-    }
-    sortFolderList(result);
-
-    if (maxItems < 0)
-      maxItems = result.size();
-    if (skipCount < 0)
-      skipCount = 0;
-    int from = Math.min(skipCount, result.size());
-    int to = Math.min(maxItems + from, result.size());
-    result = result.subList(from, to);
-    return result;
-  }
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see org.opencmis.client.provider.spi.inmemory.IFolder#getFolderChildren()
-   */
-  public List<Folder> getFolderChildren(int maxItems, int skipCount) {
-    List<Folder> result = new ArrayList<Folder>();
-    for (String id : fObjStore.getIds()) {
-      StoredObject obj = fObjStore.getObject(id);
-      if (obj instanceof SingleFiling) {
-        SingleFiling pathObj = (SingleFiling) obj;
-        if (pathObj.getParent() == this && pathObj instanceof Folder)
-          result.add((Folder)obj);
-      }
-    }
-    sortFolderList(result);
-    int from = Math.min(skipCount, result.size());
-    int to = Math.min(maxItems + from, result.size());
-    result = result.subList(from, to);
-    return result;
-  }
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see org.opencmis.client.provider.spi.inmemory.IFolder#hasChild(java.lang.String)
-   */
-  public boolean hasChild(String name) {
-    for (String id : fObjStore.getIds()) {
-      StoredObject obj = fObjStore.getObject(id);
-      if (obj instanceof Filing) {
-        Filing pathObj = (Filing) obj;
-        if (pathObj.getParents().contains(this) && obj.getName().equals(name))
-          return true;
-      }
-    }
-    return false;
-  }
-
-  public void fillProperties(Map<String, PropertyData<?>> properties, BindingsObjectFactory objFactory,
-      List<String> requestedIds) {
-
-    super.fillProperties(properties, objFactory, requestedIds);
-
-    // add folder specific properties
-
-    if (FilterParser.isContainedInFilter(PropertyIds.PARENT_ID, requestedIds)) {
-      String parentId = getParent() == null ? null : getParent().getId();
-      if ( parentId != null )
-        properties.put(PropertyIds.PARENT_ID, objFactory.createPropertyStringData(PropertyIds.PARENT_ID, parentId));
-    }
-
-    if (FilterParser.isContainedInFilter(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS,
-        requestedIds)) {
-      String allowedChildObjects = "*"; // TODO: not yet supported
-      properties.put(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS, objFactory.createPropertyStringData(
-          PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS, allowedChildObjects));
-    }
-
-    if (FilterParser.isContainedInFilter(PropertyIds.PATH, requestedIds)) {
-      String path = getPath();
-      properties.put(PropertyIds.PATH, objFactory.createPropertyStringData(PropertyIds.PATH, path));
-    }
-  }
-
-  // Helper functions
-  private void init(String name, Folder parent) {
-    if (!NameValidator.isValidId(name))
-      throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
-    setName(name);
-    setParent(parent);
-  }
-
-  private void sortFolderList(List<? extends StoredObject> list) {
-
-    // TODO evaluate orderBy, for now sort by path segment
-    class FolderComparator implements Comparator<StoredObject> {
-
-      public int compare(StoredObject f1, StoredObject f2) {
-        String segment1 = f1.getName();
-        String segment2 = f2.getName();
-
-        return segment1.compareTo(segment2);
-      }
-    }
-
-    Collections.sort(list, new FolderComparator());
-  }
-
-  public void moveChildDocument(StoredObject so, Folder oldParent, Folder newParent) {
-    if (newParent.hasChild(so.getName()))
-      throw new IllegalArgumentException(
-          "Cannot move object, this name already exists in target.");
-    if (!(so instanceof Filing))
-      throw new IllegalArgumentException(
-      "Cannot move object, object does not have a path.");
-    
-    if (so instanceof SingleFiling) {
-      SingleFiling pathObj = (SingleFiling) so;
-      pathObj.setParent(newParent);
-    } else if (so instanceof MultiFiling) {
-      MultiFiling pathObj = (MultiFiling) so;
-      pathObj.addParent(newParent);
-      pathObj.removeParent(oldParent);      
-    }
-  }
-
-  public List<String> getAllowedChildObjectTypeIds() {
-    // TODO implement this.
-    return null;
-  }
+	FolderImpl(ObjectStoreImpl objStore) {
+		super(objStore);
+	}
+
+	public FolderImpl(ObjectStoreImpl objStore, String name, Folder parent) {
+		super(objStore);
+		init(name, parent);
+	}
+
+	public void addChildFolder(Folder folder) {
+		boolean hasChild;
+		String name = folder.getName();
+		hasChild = hasChild(name);
+		if (hasChild)
+			throw new RuntimeException("Cannot create folder " + name + ". Name already exists in parent folder");
+		folder.setParent(this);
+		folder.persist();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.opencmis.client.provider.spi.inmemory.IFolder#addChildDocument(org
+	 * .opencmis.client.provider .spi.inmemory.storedobj.impl.DocumentImpl)
+	 */
+	public void addChildDocument(Document doc) {
+		addChildObject(doc);
+	}
+
+	public void addChildDocument(VersionedDocument doc) {
+		addChildObject(doc);
+	}
+
+	private void addChildObject(StoredObject so) {
+		String name = so.getName();
+		if (!NameValidator.isValidId(name))
+			throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
+
+		boolean hasChild;
+		hasChild = hasChild(name);
+		if (hasChild)
+			throw new RuntimeException("Cannot create document " + name + ". Name already exists in parent folder");
+
+		if (so instanceof SingleFiling)
+			((SingleFiling) so).setParent(this);
+		else if (so instanceof MultiFiling)
+			((MultiFiling) so).addParent(this);
+		else
+			throw new RuntimeException("Cannot create document, object is not fileable.");
+
+		so.persist();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.opencmis.client.provider.spi.inmemory.IFolder#getChildren()
+	 */
+	public List<StoredObject> getChildren(int maxItems, int skipCount) {
+		List<StoredObject> result = new ArrayList<StoredObject>();
+		for (String id : fObjStore.getIds()) {
+			StoredObject obj = fObjStore.getObject(id);
+			Filing pathObj = (Filing) obj;
+			if (pathObj.getParents().contains(this)) {
+				if (pathObj instanceof VersionedDocument) {
+					DocumentVersion ver = ((VersionedDocument) pathObj).getLatestVersion(false);
+					result.add(ver);
+				} else if (pathObj instanceof DocumentVersion) {
+					// ignore
+				} else {
+					result.add(obj);
+				}
+			}
+		}
+		sortFolderList(result);
+
+		if (maxItems < 0)
+			maxItems = result.size();
+		if (skipCount < 0)
+			skipCount = 0;
+		int from = Math.min(skipCount, result.size());
+		int to = Math.min(maxItems + from, result.size());
+		result = result.subList(from, to);
+		return result;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.opencmis.client.provider.spi.inmemory.IFolder#getFolderChildren()
+	 */
+	public List<Folder> getFolderChildren(int maxItems, int skipCount) {
+		List<Folder> result = new ArrayList<Folder>();
+		for (String id : fObjStore.getIds()) {
+			StoredObject obj = fObjStore.getObject(id);
+			if (obj instanceof SingleFiling) {
+				SingleFiling pathObj = (SingleFiling) obj;
+				if (pathObj.getParent() == this && pathObj instanceof Folder)
+					result.add((Folder) obj);
+			}
+		}
+		sortFolderList(result);
+		int from = Math.min(skipCount, result.size());
+		int to = Math.min(maxItems + from, result.size());
+		result = result.subList(from, to);
+		return result;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.opencmis.client.provider.spi.inmemory.IFolder#hasChild(java.lang.
+	 * String)
+	 */
+	public boolean hasChild(String name) {
+		for (String id : fObjStore.getIds()) {
+			StoredObject obj = fObjStore.getObject(id);
+			if (obj instanceof Filing) {
+				Filing pathObj = (Filing) obj;
+				if (pathObj.getParents().contains(this) && obj.getName().equals(name))
+					return true;
+			}
+		}
+		return false;
+	}
+
+	public void fillProperties(Map<String, PropertyData<?>> properties, BindingsObjectFactory objFactory,
+			List<String> requestedIds) {
+
+		super.fillProperties(properties, objFactory, requestedIds);
+
+		// add folder specific properties
+
+		if (FilterParser.isContainedInFilter(PropertyIds.PARENT_ID, requestedIds)) {
+			String parentId = getParent() == null ? null : getParent().getId();
+			if (parentId != null)
+				properties.put(PropertyIds.PARENT_ID, objFactory.createPropertyStringData(PropertyIds.PARENT_ID,
+						parentId));
+		}
+
+		if (FilterParser.isContainedInFilter(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS, requestedIds)) {
+			String allowedChildObjects = "*"; // TODO: not yet supported
+			properties.put(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS, objFactory.createPropertyStringData(
+					PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS, allowedChildObjects));
+		}
+
+		if (FilterParser.isContainedInFilter(PropertyIds.PATH, requestedIds)) {
+			String path = getPath();
+			properties.put(PropertyIds.PATH, objFactory.createPropertyStringData(PropertyIds.PATH, path));
+		}
+	}
+
+	// Helper functions
+	private void init(String name, Folder parent) {
+		if (!NameValidator.isValidId(name))
+			throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
+		setName(name);
+		setParent(parent);
+	}
+
+	private void sortFolderList(List<? extends StoredObject> list) {
+
+		// TODO evaluate orderBy, for now sort by path segment
+		class FolderComparator implements Comparator<StoredObject> {
+
+			public int compare(StoredObject f1, StoredObject f2) {
+				String segment1 = f1.getName();
+				String segment2 = f2.getName();
+
+				return segment1.compareTo(segment2);
+			}
+		}
+
+		Collections.sort(list, new FolderComparator());
+	}
+
+	public void moveChildDocument(StoredObject so, Folder oldParent, Folder newParent) {
+		if (newParent.hasChild(so.getName()))
+			throw new IllegalArgumentException("Cannot move object, this name already exists in target.");
+		if (!(so instanceof Filing))
+			throw new IllegalArgumentException("Cannot move object, object does not have a path.");
+
+		if (so instanceof SingleFiling) {
+			SingleFiling pathObj = (SingleFiling) so;
+			pathObj.setParent(newParent);
+		} else if (so instanceof MultiFiling) {
+			MultiFiling pathObj = (MultiFiling) so;
+			pathObj.addParent(newParent);
+			pathObj.removeParent(oldParent);
+		}
+	}
+
+	public List<String> getAllowedChildObjectTypeIds() {
+		// TODO implement this.
+		return null;
+	}
 
 }
\ No newline at end of file

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java?rev=934878&r1=934877&r2=934878&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/ObjectStoreImpl.java Fri Apr 16 14:00:23 2010
@@ -47,241 +47,242 @@ import org.apache.chemistry.opencmis.inm
 
 public class ObjectStoreImpl implements ObjectStore {
 
-  /**
-   * Simple id generator that uses just an integer 
-   */
-  private static int NEXT_UNUSED_ID = 100;
-  
-  /**
-   * Maps the absolute folder path to the corresponding folder object
-   */
-  private Map<String, StoredObject> fStoredObjectMap = new HashMap<String, StoredObject>();
-  final String fRepositoryId; 
-  FolderImpl fRootFolder = null;
-
-  public ObjectStoreImpl(String repositoryId) {
-    fRepositoryId = repositoryId;
-    createRootFolder();
-  }
-
-  private static synchronized Integer getNextId() {
-    return NEXT_UNUSED_ID++;
-  }
-  
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see org.opencmis.client.provider.spi.inmemory.storedobj.impl.ObjectStore#getRootFolder()
-   */
-  public Folder getRootFolder() {
-    return fRootFolder;
-  }
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see
-   * org.opencmis.client.provider.spi.inmemory.storedobj.impl.ObjectStore#getFolderByPath(java.lang
-   * .String)
-   */
-  public StoredObject getObjectByPath(String path) {
-    
-    for (StoredObject so : fStoredObjectMap.values()) {
-      if (so instanceof SingleFiling) {
-        String soPath = ((SingleFiling) so).getPath();
-        if (soPath.equals(path))
-          return so;
-      }
-      else if (so instanceof MultiFiling) {
-        MultiFiling mfo = (MultiFiling)so;
-        List<Folder> parents = mfo.getParents();
-        for (Folder parent : parents) {
-          String parentPath = parent.getPath();
-          String mfPath = parentPath.equals(Folder.PATH_SEPARATOR) ? parentPath
-              + mfo.getPathSegment() : parentPath + Folder.PATH_SEPARATOR + mfo.getPathSegment();
-          if (mfPath.equals(path))
-            return so;
-        }
-      }
-      else
-        return null;
-    }
-    return null;
-  }
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see
-   * org.opencmis.client.provider.spi.inmemory.storedobj.impl.ObjectStore#getObjectById(java.lang
-   * .String)
-   */
-  public StoredObject getObjectById(String objectId) {
-    // we use path as id so we just can look it up in the map
-    StoredObject so = fStoredObjectMap.get(objectId);
-    return so;
-  }
-
- /*
-   * (non-Javadoc)
-   * 
-   * @see
-   * org.opencmis.client.provider.spi.inmemory.storedobj.impl.ObjectStore#deleteObject(java.lang
-   * .String)
-   */
-  public void deleteObject(String objectId) {
-    String path = objectId; // currently the same
-    StoredObject obj = fStoredObjectMap.get(path);
-
-    if (null == obj)
-      throw new RuntimeException("Cannot delete object with id  " + objectId
-          + ". Object does not exist.");
-
-    if (obj instanceof FolderImpl) {
-      deleteFolder(objectId);
-    }
-    else if (obj instanceof DocumentVersion ){
-      DocumentVersion vers = (DocumentVersion) obj;
-      VersionedDocument parentDoc = vers.getParentDocument();
-      fStoredObjectMap.remove(path);
-      boolean otherVersionsExist =  vers.getParentDocument().deleteVersion(vers);
-      if (!otherVersionsExist)
-        fStoredObjectMap.remove(parentDoc.getId());
-    }
-    else {
-      fStoredObjectMap.remove(path);
-    }
-  }
-  public void removeVersion(DocumentVersion vers) {
-    StoredObject found = fStoredObjectMap.remove(vers.getId());
-
-    if (null == found)
-      throw new RuntimeException("Cannot delete object with id  " + vers.getId()
-          + ". Object does not exist.");    
-  }
-  
-//  public void changePath(StoredObject obj, String oldPath, String newPath) {
-//    fStoredObjectMap.remove(oldPath);
-//    fStoredObjectMap.put(newPath, obj);
-//  }
-
-  // /////////////////////////////////////////
-  // methods used by folders and documents, but not for public use
-  
-//  void storeObject(String id, StoredObject sop) {
-//    fStoredObjectMap.put(id, sop);
-//  }
-
-  public String storeObject(StoredObject so) {    
-    String id = so.getId();
-    // check if update or create
-    if (null == id)
-      id = getNextId().toString();
-    fStoredObjectMap.put(id, so);
-    return id;
-  }
-  
-  StoredObject getObject(String id) {
-    return fStoredObjectMap.get(id);
-  }
-
-  void removeObject(String id) {
-    fStoredObjectMap.remove(id);
-  }
-  
-  Set<String> getIds() {
-   Set<String> entries = fStoredObjectMap.keySet();
-   return entries;
-  }
-  
-//  void renameAllIdsWithPrefix(String oldPath, String newPath) {
-//    Iterator<Entry<String, StoredObject>> it = fStoredObjectMap.entrySet().iterator();
-//    Map<String, StoredObject> newMap = new HashMap<String, StoredObject>();
-//    while (it.hasNext()) {
-//      Map.Entry<String, StoredObject> entry = (Map.Entry<String, StoredObject>) it
-//          .next();
-//
-//      if (entry.getKey().startsWith(oldPath)) {
-//        if (entry.getValue() instanceof Path) {
-//          newPath = ((Path)entry.getValue()).getPath();
-//          it.remove(); // the only safe way to modify while iteration
-//          newMap.put(newPath, entry.getValue()); // we can't add to the current collection while
-//                                                 // iterating          
-//        }
-//      }
-//    }
-//    fStoredObjectMap.putAll(newMap); // add all at once when iteration is complete  
-//  }
-  
-  // /////////////////////////////////////////
-  // private helper methods
-
-  private void createRootFolder() {
-    FolderImpl rootFolder = new FolderImpl(this);
-    rootFolder.setName("RootFolder");
-    rootFolder.setParent(null);
-    rootFolder.setTypeId(BaseTypeId.CMIS_FOLDER.value());
-    rootFolder.setCreatedBy("Admin");
-    rootFolder.setModifiedBy("Admin");
-    rootFolder.setModifiedAtNow();
-    rootFolder.setRepositoryId(fRepositoryId);
-    rootFolder.persist();
-    fRootFolder =  rootFolder;
-  }
-
-  public Document createDocument(String name) {
-    Document doc = new DocumentImpl(this);
-    doc.setRepositoryId(fRepositoryId);
-    doc.setName(name);
-    return doc;
-  }
-
-  public VersionedDocument createVersionedDocument(String name) {
-    VersionedDocument doc = new VersionedDocumentImpl(this);
-    doc.setRepositoryId(fRepositoryId);
-    doc.setName(name);
-    return doc;
-  }
-
-  public Folder createFolder(String name) {
-    Folder folder = new FolderImpl(this, name, null);;
-    folder.setRepositoryId(fRepositoryId);
-    return folder;
-  }
-
-  public List<VersionedDocument> getCheckedOutDocuments(String orderBy) {
-    List<VersionedDocument> res = new ArrayList<VersionedDocument>();
-    
-    for (StoredObject so : fStoredObjectMap.values() ) {
-      if (so instanceof VersionedDocument) {
-        VersionedDocument verDoc = (VersionedDocument) so;
-        if (verDoc.isCheckedOut()) {
-          res.add(verDoc);
-        }
-      }
-    }
-    
-    return res;
-  }
-  
-  private void deleteFolder(String folderId) {
-    StoredObject folder = fStoredObjectMap.get(folderId);
-    if (folder == null)
-      throw new RuntimeException("Unknown object with id:  " + folderId);
-
-    if (!(folder instanceof FolderImpl)) {
-        throw new RuntimeException("Cannot delete folder with id:  " + folderId
-            + ". Object exists but is not a folder.");
-    }
-
-    // check if children exist
-    List<StoredObject> children = ((Folder)folder).getChildren(-1, -1);
-    if (children!=null && !children.isEmpty())
-      throw new CmisConstraintException("Cannot delete folder with id:  " + folderId
-          + ". Folder is not empty.");
-      
-    fStoredObjectMap.remove(folderId);    
-  }
+	/**
+	 * Simple id generator that uses just an integer
+	 */
+	private static int NEXT_UNUSED_ID = 100;
+
+	/**
+	 * Maps the absolute folder path to the corresponding folder object
+	 */
+	private Map<String, StoredObject> fStoredObjectMap = new HashMap<String, StoredObject>();
+	final String fRepositoryId;
+	FolderImpl fRootFolder = null;
+
+	public ObjectStoreImpl(String repositoryId) {
+		fRepositoryId = repositoryId;
+		createRootFolder();
+	}
+
+	private static synchronized Integer getNextId() {
+		return NEXT_UNUSED_ID++;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.opencmis.client.provider.spi.inmemory.storedobj.impl.ObjectStore#
+	 * getRootFolder()
+	 */
+	public Folder getRootFolder() {
+		return fRootFolder;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.opencmis.client.provider.spi.inmemory.storedobj.impl.ObjectStore#
+	 * getFolderByPath(java.lang .String)
+	 */
+	public StoredObject getObjectByPath(String path) {
+
+		for (StoredObject so : fStoredObjectMap.values()) {
+			if (so instanceof SingleFiling) {
+				String soPath = ((SingleFiling) so).getPath();
+				if (soPath.equals(path))
+					return so;
+			} else if (so instanceof MultiFiling) {
+				MultiFiling mfo = (MultiFiling) so;
+				List<Folder> parents = mfo.getParents();
+				for (Folder parent : parents) {
+					String parentPath = parent.getPath();
+					String mfPath = parentPath.equals(Folder.PATH_SEPARATOR) ? parentPath + mfo.getPathSegment()
+							: parentPath + Folder.PATH_SEPARATOR + mfo.getPathSegment();
+					if (mfPath.equals(path))
+						return so;
+				}
+			} else
+				return null;
+		}
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.opencmis.client.provider.spi.inmemory.storedobj.impl.ObjectStore#
+	 * getObjectById(java.lang .String)
+	 */
+	public StoredObject getObjectById(String objectId) {
+		// we use path as id so we just can look it up in the map
+		StoredObject so = fStoredObjectMap.get(objectId);
+		return so;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.opencmis.client.provider.spi.inmemory.storedobj.impl.ObjectStore#
+	 * deleteObject(java.lang .String)
+	 */
+	public void deleteObject(String objectId) {
+		String path = objectId; // currently the same
+		StoredObject obj = fStoredObjectMap.get(path);
+
+		if (null == obj)
+			throw new RuntimeException("Cannot delete object with id  " + objectId + ". Object does not exist.");
+
+		if (obj instanceof FolderImpl) {
+			deleteFolder(objectId);
+		} else if (obj instanceof DocumentVersion) {
+			DocumentVersion vers = (DocumentVersion) obj;
+			VersionedDocument parentDoc = vers.getParentDocument();
+			fStoredObjectMap.remove(path);
+			boolean otherVersionsExist = vers.getParentDocument().deleteVersion(vers);
+			if (!otherVersionsExist)
+				fStoredObjectMap.remove(parentDoc.getId());
+		} else {
+			fStoredObjectMap.remove(path);
+		}
+	}
+
+	public void removeVersion(DocumentVersion vers) {
+		StoredObject found = fStoredObjectMap.remove(vers.getId());
+
+		if (null == found)
+			throw new RuntimeException("Cannot delete object with id  " + vers.getId() + ". Object does not exist.");
+	}
+
+	// public void changePath(StoredObject obj, String oldPath, String newPath)
+	// {
+	// fStoredObjectMap.remove(oldPath);
+	// fStoredObjectMap.put(newPath, obj);
+	// }
+
+	// /////////////////////////////////////////
+	// methods used by folders and documents, but not for public use
+
+	// void storeObject(String id, StoredObject sop) {
+	// fStoredObjectMap.put(id, sop);
+	// }
+
+	public String storeObject(StoredObject so) {
+		String id = so.getId();
+		// check if update or create
+		if (null == id)
+			id = getNextId().toString();
+		fStoredObjectMap.put(id, so);
+		return id;
+	}
+
+	StoredObject getObject(String id) {
+		return fStoredObjectMap.get(id);
+	}
+
+	void removeObject(String id) {
+		fStoredObjectMap.remove(id);
+	}
+
+	Set<String> getIds() {
+		Set<String> entries = fStoredObjectMap.keySet();
+		return entries;
+	}
+
+	// void renameAllIdsWithPrefix(String oldPath, String newPath) {
+	// Iterator<Entry<String, StoredObject>> it =
+	// fStoredObjectMap.entrySet().iterator();
+	// Map<String, StoredObject> newMap = new HashMap<String, StoredObject>();
+	// while (it.hasNext()) {
+	// Map.Entry<String, StoredObject> entry = (Map.Entry<String, StoredObject>)
+	// it
+	// .next();
+	//
+	// if (entry.getKey().startsWith(oldPath)) {
+	// if (entry.getValue() instanceof Path) {
+	// newPath = ((Path)entry.getValue()).getPath();
+	// it.remove(); // the only safe way to modify while iteration
+	// newMap.put(newPath, entry.getValue()); // we can't add to the current
+	// collection while
+	// // iterating
+	// }
+	// }
+	// }
+	// fStoredObjectMap.putAll(newMap); // add all at once when iteration is
+	// complete
+	// }
+
+	// /////////////////////////////////////////
+	// private helper methods
+
+	private void createRootFolder() {
+		FolderImpl rootFolder = new FolderImpl(this);
+		rootFolder.setName("RootFolder");
+		rootFolder.setParent(null);
+		rootFolder.setTypeId(BaseTypeId.CMIS_FOLDER.value());
+		rootFolder.setCreatedBy("Admin");
+		rootFolder.setModifiedBy("Admin");
+		rootFolder.setModifiedAtNow();
+		rootFolder.setRepositoryId(fRepositoryId);
+		rootFolder.persist();
+		fRootFolder = rootFolder;
+	}
+
+	public Document createDocument(String name) {
+		Document doc = new DocumentImpl(this);
+		doc.setRepositoryId(fRepositoryId);
+		doc.setName(name);
+		return doc;
+	}
+
+	public VersionedDocument createVersionedDocument(String name) {
+		VersionedDocument doc = new VersionedDocumentImpl(this);
+		doc.setRepositoryId(fRepositoryId);
+		doc.setName(name);
+		return doc;
+	}
+
+	public Folder createFolder(String name) {
+		Folder folder = new FolderImpl(this, name, null);
+		;
+		folder.setRepositoryId(fRepositoryId);
+		return folder;
+	}
+
+	public List<VersionedDocument> getCheckedOutDocuments(String orderBy) {
+		List<VersionedDocument> res = new ArrayList<VersionedDocument>();
+
+		for (StoredObject so : fStoredObjectMap.values()) {
+			if (so instanceof VersionedDocument) {
+				VersionedDocument verDoc = (VersionedDocument) so;
+				if (verDoc.isCheckedOut()) {
+					res.add(verDoc);
+				}
+			}
+		}
+
+		return res;
+	}
+
+	private void deleteFolder(String folderId) {
+		StoredObject folder = fStoredObjectMap.get(folderId);
+		if (folder == null)
+			throw new RuntimeException("Unknown object with id:  " + folderId);
+
+		if (!(folder instanceof FolderImpl)) {
+			throw new RuntimeException("Cannot delete folder with id:  " + folderId
+					+ ". Object exists but is not a folder.");
+		}
+
+		// check if children exist
+		List<StoredObject> children = ((Folder) folder).getChildren(-1, -1);
+		if (children != null && !children.isEmpty())
+			throw new CmisConstraintException("Cannot delete folder with id:  " + folderId + ". Folder is not empty.");
+
+		fStoredObjectMap.remove(folderId);
+	}
 
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerFactory.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerFactory.java?rev=934878&r1=934877&r2=934878&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerFactory.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerFactory.java Fri Apr 16 14:00:23 2010
@@ -29,41 +29,38 @@ import org.apache.commons.logging.LogFac
  */
 
 public class StoreManagerFactory {
-  private static Log log = LogFactory.getLog(StoreManagerFactory.class);
+	private static Log log = LogFactory.getLog(StoreManagerFactory.class);
 
-  public static StoreManager createInstance(String className) {
+	public static StoreManager createInstance(String className) {
 
-    Class<?> clazz = null;
-    try {
-      clazz = Class.forName(className);
-    }
-    catch (ClassNotFoundException e) {
-      String msg = "Failed to create StoredObjectCreator, class " + className + " does not exist.";
-      log.error(msg, e);
-      e.printStackTrace();
-      throw new RuntimeException(msg, e);
-    }
-
-    Object obj = null;
-    try {
-      obj = clazz.newInstance();
-    }
-    catch (InstantiationException e) {
-      log.error("Failed to create StoredObjectCreator from class " + className, e);
-      e.printStackTrace();
-    }
-    catch (IllegalAccessException e) {
-      log.error("Failed to create StoredObjectCreator from class " + className, e);
-      e.printStackTrace();
-    }
-
-    if (obj instanceof StoreManager)
-      return (StoreManager) obj;
-    else {
-      log.error("Failed to create StoredObjectCreator, class " + className
-          + " does not implement interface StoredObjectCreator");
-      return null;
-    }
-  }
+		Class<?> clazz = null;
+		try {
+			clazz = Class.forName(className);
+		} catch (ClassNotFoundException e) {
+			String msg = "Failed to create StoredObjectCreator, class " + className + " does not exist.";
+			log.error(msg, e);
+			e.printStackTrace();
+			throw new RuntimeException(msg, e);
+		}
+
+		Object obj = null;
+		try {
+			obj = clazz.newInstance();
+		} catch (InstantiationException e) {
+			log.error("Failed to create StoredObjectCreator from class " + className, e);
+			e.printStackTrace();
+		} catch (IllegalAccessException e) {
+			log.error("Failed to create StoredObjectCreator from class " + className, e);
+			e.printStackTrace();
+		}
+
+		if (obj instanceof StoreManager)
+			return (StoreManager) obj;
+		else {
+			log.error("Failed to create StoredObjectCreator, class " + className
+					+ " does not implement interface StoredObjectCreator");
+			return null;
+		}
+	}
 
 }



Mime
View raw message