Class DefaultDeleteHelper
- java.lang.Object
-
- org.pentaho.platform.repository2.unified.jcr.DefaultDeleteHelper
-
- All Implemented Interfaces:
IDeleteHelper
public class DefaultDeleteHelper extends Object implements IDeleteHelper
Default implementation ofIDeleteHelper
.If user
suzy
in tenantacme
deletes a file with idtestFileId
and namedtestFile
in folder with idtestFolderId
and namedtestFolder
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 andNode.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
-
-
Field Summary
Fields Modifier and Type Field Description static String
JCR_ROOT_VERSION
-
Constructor Summary
Constructors Constructor Description DefaultDeleteHelper(ILockHelper lockHelper, IPathConversionHelper pathConversionHelper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deleteFile(javax.jcr.Session session, PentahoJcrConstants pentahoJcrConstants, Serializable fileId)
Deletes a file in a way that it can be recovered.List<org.pentaho.platform.api.repository2.unified.RepositoryFile>
getAllDeletedFiles(javax.jcr.Session session, PentahoJcrConstants pentahoJcrConstants)
Lists deleted files for all users.protected String
getCurrentUser()
List<org.pentaho.platform.api.repository2.unified.RepositoryFile>
getDeletedFiles(javax.jcr.Session session, PentahoJcrConstants pentahoJcrConstants)
Lists deleted files for this user.List<org.pentaho.platform.api.repository2.unified.RepositoryFile>
getDeletedFiles(javax.jcr.Session session, PentahoJcrConstants pentahoJcrConstants, String origParentFolderPath, String filter)
Lists deleted files for this folder and user.protected String
getHomePath(org.pentaho.platform.api.mt.ITenant tenant, String user)
String
getOriginalParentFolderPath(javax.jcr.Session session, PentahoJcrConstants pentahoJcrConstants, Serializable fileId)
Returns the absolute path of the original parent folder.protected org.pentaho.platform.api.repository2.unified.RepositoryFile
getReferrerFile(javax.jcr.Session session, PentahoJcrConstants pentahoJcrConstants, javax.jcr.Property referrerProperty)
protected List<String>
getUserList()
protected boolean
isAdmin()
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.
-
-
-
Field Detail
-
JCR_ROOT_VERSION
public static final String JCR_ROOT_VERSION
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DefaultDeleteHelper
public DefaultDeleteHelper(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.- Specified by:
deleteFile
in interfaceIDeleteHelper
- 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 interfaceIDeleteHelper
origParentFolderPath
- path to original parent folderfilter
- 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 interfaceIDeleteHelper
- 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 interfaceIDeleteHelper
- Returns:
- list of deleted files for all users
- Throws:
javax.jcr.RepositoryException
-
getCurrentUser
protected String getCurrentUser()
-
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 interfaceIDeleteHelper
- 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 interfaceIDeleteHelper
- Throws:
javax.jcr.RepositoryException
-
getOriginalParentFolderPath
public String getOriginalParentFolderPath(javax.jcr.Session session, PentahoJcrConstants pentahoJcrConstants, Serializable fileId) throws javax.jcr.RepositoryException
Returns the absolute path of the original parent folder. Can be used by caller to checkout parent folder before callingIDeleteHelper.undeleteFile(Session, PentahoJcrConstants, Serializable)
.- Specified by:
getOriginalParentFolderPath
in interfaceIDeleteHelper
fileId
- file id of deleted file- Throws:
javax.jcr.RepositoryException
-
-