Class 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 testFileId and named testFile in folder with id testFolderId and named testFolder then this implementation upon a non-permanent delete will move the file such that the new absolute path and properties of the "deleted" node will be as follows.

    Trash Structure 2

    Uses JCR XPath queries for iteration and filtering. File ID nodes exist to prevent same-name sibling conflicts. Original parent folder path stored in property. All delete-related properties stored in file ID node to avoid the need to checkout versioned files when they are deleted. Note that use of JCR XPath queries may require enabling features in the JCR implementation.
     /pentaho/acme/home/suzy/.trash/pho:testFileId/testFile
     /pentaho/acme/home/suzy/.trash/pho:testFileId/pho:deletedDate (deleted date property)
     /pentaho/acme/home/suzy/.trash/pho:testFileId/pho:origName (original filename property)
     /pentaho/acme/home/suzy/.trash/pho:testFileId/pho:origParentFolderPath (original parent folder path property)
     

    Trash Structure 1 (aka legacy)

    Uses node iterators and Node.getNodes(String) when filtering. File ID nodes exist to prevent same-name sibling conflicts. Original parent folder path derived from folder ID node name. All delete-related properties stored in file ID node to avoid the need to checkout versioned files when they are deleted.
     /pentaho/acme/home/suzy/.trash/pho:testFolderId/pho:testFileId/testFile
     /pentaho/acme/home/suzy/.trash/pho:testFolderId/pho:testFileId/pho:deletedDate (deleted date property)
     

    Assumptions:

    • User home folder and all ancestors are not versioned.
    • Internal folders are never versioned.

    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
    • 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.
        Specified by:
        deleteFile in interface IDeleteHelper
        Throws:
        javax.jcr.RepositoryException
      • getDeletedFiles

        public List<org.pentaho.platform.api.repository2.unified.RepositoryFile> getDeletedFiles​(javax.jcr.Session session,
                                                                                                 PentahoJcrConstants pentahoJcrConstants,
                                                                                                 String origParentFolderPath,
                                                                                                 String filter)
                                                                                          throws javax.jcr.RepositoryException
        Lists deleted files for this folder and user.
        Specified by:
        getDeletedFiles in interface IDeleteHelper
        origParentFolderPath - path to original parent folder
        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<org.pentaho.platform.api.repository2.unified.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
      • isAdmin

        protected boolean isAdmin()
      • getAllDeletedFiles

        public List<org.pentaho.platform.api.repository2.unified.RepositoryFile> getAllDeletedFiles​(javax.jcr.Session session,
                                                                                                    PentahoJcrConstants pentahoJcrConstants)
                                                                                             throws javax.jcr.RepositoryException
        Description copied from interface: IDeleteHelper
        Lists deleted files for all users. In this case, the path field of each file is the original path where it was located prior to deletion. This is the administrator "recycle bin" view.
        Specified by:
        getAllDeletedFiles in interface IDeleteHelper
        Returns:
        list of deleted files for all users
        Throws:
        javax.jcr.RepositoryException
      • getHomePath

        protected String getHomePath​(org.pentaho.platform.api.mt.ITenant tenant,
                                     String user)
      • getCurrentUser

        protected String getCurrentUser()
      • getUserList

        protected List<String> getUserList()
      • 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
      • getReferrerFile

        protected org.pentaho.platform.api.repository2.unified.RepositoryFile getReferrerFile​(javax.jcr.Session session,
                                                                                              PentahoJcrConstants pentahoJcrConstants,
                                                                                              javax.jcr.Property referrerProperty)
                                                                                       throws javax.jcr.RepositoryException
        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