org.pentaho.platform.repository2.unified.jcr
Class DefaultDeleteHelper

java.lang.Object
  extended by org.pentaho.platform.repository2.unified.jcr.DefaultDeleteHelper
All Implemented Interfaces:
IDeleteHelper

public class DefaultDeleteHelper
extends Object
implements IDeleteHelper

Default implementation of IDeleteHelper. If user suzy in tenant acme deletes a file with id xyz and named test in folder with id abc then this implementation will move the file to delete in such a way that the new absolute path to the deleted file will be /pentaho/acme/home/suzy/.trash/pho:abc/pho:xyz/test. This provides fast access to the deleted items of a particular folder plus fast access to all deleted items (aka the recycle bin view).

Assumptions:

By storing deleted files inside the user's home folder, the user's recycle bin is effectively private. This is desirable because a deleted file with confidential information should not be seen by anyone else except the deleting user.

Author:
mlowery

Constructor Summary
DefaultDeleteHelper(IOwnerLookupHelper ownerLookupHelper, ILockHelper lockHelper, IPathConversionHelper pathConversionHelper)
           
 
Method Summary
 void deleteFile(javax.jcr.Session session, PentahoJcrConstants pentahoJcrConstants, Serializable fileId)
          Deletes a file in a way that it can be recovered.
 List<RepositoryFile> getDeletedFiles(javax.jcr.Session session, PentahoJcrConstants pentahoJcrConstants)
          Lists deleted files for this user.
 List<RepositoryFile> getDeletedFiles(javax.jcr.Session session, PentahoJcrConstants pentahoJcrConstants, Serializable folderId, String filter)
          Lists deleted files for this folder and user.
 Serializable getOriginalParentFolderId(javax.jcr.Session session, PentahoJcrConstants pentahoJcrConstants, Serializable fileId)
          Returns the ID of the original parent folder.
 void permanentlyDeleteFile(javax.jcr.Session session, PentahoJcrConstants pentahoJcrConstants, Serializable fileId)
          Deletes a file in a way that it cannot be recovered.
 void undeleteFile(javax.jcr.Session session, PentahoJcrConstants pentahoJcrConstants, Serializable fileId)
          Recovers a deleted file to its original location.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultDeleteHelper

public DefaultDeleteHelper(IOwnerLookupHelper ownerLookupHelper,
                           ILockHelper lockHelper,
                           IPathConversionHelper pathConversionHelper)
Method Detail

deleteFile

public void deleteFile(javax.jcr.Session session,
                       PentahoJcrConstants pentahoJcrConstants,
                       Serializable fileId)
                throws javax.jcr.RepositoryException
Deletes a file in a way that it can be recovered.

Moves file to subfolder of .trash folder in same folder as file.

Specified by:
deleteFile in interface IDeleteHelper
Throws:
javax.jcr.RepositoryException

getDeletedFiles

public List<RepositoryFile> getDeletedFiles(javax.jcr.Session session,
                                            PentahoJcrConstants pentahoJcrConstants,
                                            Serializable folderId,
                                            String filter)
                                     throws javax.jcr.RepositoryException
Lists deleted files for this folder and user. TODO mlowery true JCR queries might be better for performance

Specified by:
getDeletedFiles in interface IDeleteHelper
filter - filter may be a full name or a partial name with one or more wildcard characters ("*")
Returns:
list of deleted files IDs for this folder and user
Throws:
javax.jcr.RepositoryException

getDeletedFiles

public List<RepositoryFile> getDeletedFiles(javax.jcr.Session session,
                                            PentahoJcrConstants pentahoJcrConstants)
                                     throws javax.jcr.RepositoryException
Lists deleted files for this user. In this case, the path field of each file is the original path where it was located prior to deletion. This is the "recycle bin" view.

Specified by:
getDeletedFiles in interface IDeleteHelper
Returns:
list of deleted files for this user
Throws:
javax.jcr.RepositoryException

permanentlyDeleteFile

public void permanentlyDeleteFile(javax.jcr.Session session,
                                  PentahoJcrConstants pentahoJcrConstants,
                                  Serializable fileId)
                           throws javax.jcr.RepositoryException
Deletes a file in a way that it cannot be recovered. (Note that "cannot be recovered" doesn't mean "shred"--it means that the file cannot be recovered using this API.)

Specified by:
permanentlyDeleteFile in interface IDeleteHelper
Throws:
javax.jcr.RepositoryException

undeleteFile

public void undeleteFile(javax.jcr.Session session,
                         PentahoJcrConstants pentahoJcrConstants,
                         Serializable fileId)
                  throws javax.jcr.RepositoryException
Recovers a deleted file to its original location.

Specified by:
undeleteFile in interface IDeleteHelper
Throws:
javax.jcr.RepositoryException

getOriginalParentFolderId

public Serializable getOriginalParentFolderId(javax.jcr.Session session,
                                              PentahoJcrConstants pentahoJcrConstants,
                                              Serializable fileId)
                                       throws javax.jcr.RepositoryException
Returns the ID of the original parent folder. Can be used by caller to checkout parent folder before calling IDeleteHelper.undeleteFile(Session, PentahoJcrConstants, Serializable).

Specified by:
getOriginalParentFolderId in interface IDeleteHelper
fileId - file id of deleted file
Throws:
javax.jcr.RepositoryException