Interface TrashHandler
- Deleting trash entries
- Moving trash entries out of the Recycle Bin to new destinations
- Restoring trash entries to their original locations
These operations are supported for the following entities via their respective trash handlers:
-
BlogsEntry via
com.liferay.portlet.blogs.trash.BlogsEntryTrashHandler
-
BookmarksEntry via
com.liferay.bookmarks.trash.BookmarksEntryTrashHandler
located in Liferay Portal's externalmodules
directory. -
DLFileEntry via
com.liferay.portlet.documentlibrary.trash.DLFileEntryTrashHandler
-
DLFileShortcut via
com.liferay.portlet.documentlibrary.trash.DLFileShortcutTrashHandler
-
DLFolder via
com.liferay.portlet.documentlibrary.trash.DLFolderTrashHandler
-
MBThread via
com.liferay.message.boards.trash.MBThreadTrashHandler
located in Liferay Portal's externalmodules
directory. -
WikiNode via
com.liferay.wiki.trash.WikiNodeTrashHandler
located in Liferay Portal's externalmodules
directory. -
WikiPage via
com.liferay.wiki.trash.WikiPageTrashHandler
located in Liferay Portal's externalmodules
directory.
- Author:
- Alexander Chow, Zsolt Berentey
-
Method Summary
Modifier and TypeMethodDescriptionaddDeletionSystemEvent
(long userId, long groupId, long classPK, String classUuid, String referrerClassName) void
checkRestorableEntry
(long classPK, long containerModelId, String newName) void
checkRestorableEntry
(TrashEntry trashEntry, long containerModelId, String newName) Checks if a duplicate trash entry already exists in the destination container.void
deleteTrashEntry
(long classPK) Deletes the model entity with the primary key.Returns the class name handled by this trash handler.getContainerModel
(long containerModelId) Returns the container model with the primary key.getContainerModelClassName
(long classPK) Returns the name of the container model (e.g. folder name).getContainerModels
(long classPK, long containerModelId, int start, int end) Returns a range of all the container models that are children of the parent container model identified by the container model ID.int
getContainerModelsCount
(long classPK, long containerModelId) Returns the number of container models that are children of the parent container model identified by the container model ID.Returns the language key to the localized message to display next to a trash entry listed in a search result, indicating that the trash entry was found in a trashed container (e.g. folder or message board thread) this trash handler is associated with.long
getDestinationContainerModelId
(long classPK, long destinationContainerModelId) getExcludeFilter
(SearchContext searchContext) getParentContainerModel
(long classPK) Returns the parent container model of the model entity with the primary key.getParentContainerModel
(TrashedModel trashedModel) getParentContainerModels
(long classPK) Returns all the parent container models of the model entity with the primary key ordered by hierarchy.getRestoreContainedModelLink
(PortletRequest portletRequest, long classPK) getRestoreContainerModelLink
(PortletRequest portletRequest, long classPK) Returns the link to the location to which the model entity was restored.getRestoreMessage
(PortletRequest portletRequest, long classPK) Returns the message describing the location to which the model entity was restored.Returns the name of the root container (e.g.Returns the name of the subcontainer model (e.g. for a folder the subcontainer model name may be "subfolder").Returns the name of the contained model.int
getTrashContainedModelsCount
(long classPK) Returns the number of model entities (excluding container model entities) that are children of the parent container model identified by the primary key.Returns the name of the container model.int
getTrashContainerModelsCount
(long classPK) Returns the number of container models that are children of the parent container model identified by the primary key.getTrashedModel
(long classPK) int
getTrashModelsCount
(long classPK) default List<TrashedModel>
getTrashModelTrashedModels
(long classPK, int start, int end, OrderByComparator<?> orderByComparator) getTrashRenderer
(long classPK) Returns the trash renderer associated to the model entity with the primary key.boolean
hasTrashPermission
(PermissionChecker permissionChecker, long groupId, long classPK, String trashActionId) Returnstrue
if the user has the required permission to perform the trash action on the model entity with the primary key.boolean
Returnstrue
if the entity is a container model.boolean
isDeletable
(long classPK) Returnstrue
if the entity can be deleted from the Recycle Bin.default boolean
isInTrash
(long classPK) Returnstrue
if the model entity with the primary key is in the Recycle Bin.boolean
isMovable
(long classPK) Returnstrue
if the entity can be moved from one container model (such as a folder) to another.boolean
isRestorable
(long classPK) Returnstrue
if the model entity can be restored to its original location.void
moveEntry
(long userId, long classPK, long containerModelId, ServiceContext serviceContext) Moves the entity with the class primary key to the container model with the class primary keyvoid
moveTrashEntry
(long userId, long classPK, long containerModelId, ServiceContext serviceContext) Moves the model entity with the primary key out of the Recycle Bin to a new destination identified by the container model ID.void
restoreRelatedTrashEntry
(String className, long classPK) Restores the model entity that is related to the model entity with the class name and class PK.void
restoreTrashEntry
(long userId, long classPK) Restores the model entity with the primary key.void
updateTitle
(long classPK, String title) Updates the title of the model entity with the primary key.
-
Method Details
-
addDeletionSystemEvent
SystemEvent addDeletionSystemEvent(long userId, long groupId, long classPK, String classUuid, String referrerClassName) throws PortalException - Throws:
PortalException
-
checkRestorableEntry
void checkRestorableEntry(long classPK, long containerModelId, String newName) throws PortalException - Throws:
PortalException
-
checkRestorableEntry
void checkRestorableEntry(TrashEntry trashEntry, long containerModelId, String newName) throws PortalException Checks if a duplicate trash entry already exists in the destination container.This method is used to check for duplicates when a trash entry is being restored or moved out of the Recycle Bin.
- Parameters:
trashEntry
- the trash entry to checkcontainerModelId
- the primary key of the destination (e.g. folder)newName
- the new name to be assigned to the trash entry (optionallynull
to forego renaming the trash entry)- Throws:
PortalException
-
deleteTrashEntry
Deletes the model entity with the primary key.- Parameters:
classPK
- the primary key of the model entity to delete- Throws:
PortalException
-
getClassName
String getClassName()Returns the class name handled by this trash handler.- Returns:
- the class name handled by this trash handler
-
getContainerModel
Returns the container model with the primary key.- Parameters:
containerModelId
- the primary key of the container model- Returns:
- the container model with the primary key
- Throws:
PortalException
-
getContainerModelClassName
-
getContainerModelName
String getContainerModelName()Returns the name of the container model (e.g. folder name).- Returns:
- the name of the container model
-
getContainerModels
List<ContainerModel> getContainerModels(long classPK, long containerModelId, int start, int end) throws PortalException Returns a range of all the container models that are children of the parent container model identified by the container model ID. These container models must be able to contain the model entity identified by the primary key.This method checks for the view permission when retrieving the container models.
Useful when paginating results. Returns a maximum of
end - start
instances. Thestart
andend
values are not primary keys but, rather, indexes in the result set. Thus,0
refers to the first result in the set. Setting bothstart
andend
toQueryUtil.ALL_POS
will return the full result set.- Parameters:
classPK
- the primary key of a model entity the container models must be able to containcontainerModelId
- the primary key of the parent container modelstart
- the lower bound of the range of resultsend
- the upper bound of the range of results (not inclusive)- Returns:
- the range of matching container models
- Throws:
PortalException
-
getContainerModelsCount
Returns the number of container models that are children of the parent container model identified by the container model ID. These container models must be able to contain the model entity identified by the primary key.This method checks for the view permission when counting the container models.
- Parameters:
classPK
- the primary key of a model entity the container models must be able to containcontainerModelId
- the primary key of the parent container model- Returns:
- the number of matching container models
- Throws:
PortalException
-
getDeleteMessage
String getDeleteMessage()Returns the language key to the localized message to display next to a trash entry listed in a search result, indicating that the trash entry was found in a trashed container (e.g. folder or message board thread) this trash handler is associated with.If the language key (e.g.
found-in-deleted-folder-x
) used accepts a single parameter, the trash framework replaces that parameter with the trashed container's name.- Returns:
- the language key to the localized message to display next to a trash entry listed in a search result
-
getDestinationContainerModelId
long getDestinationContainerModelId(long classPK, long destinationContainerModelId) -
getExcludeFilter
-
getParentContainerModel
Returns the parent container model of the model entity with the primary key.- Parameters:
classPK
- the primary key of a model entity the container models must be able to contain- Returns:
- the parent container model of the model entity with the primary key
- Throws:
PortalException
-
getParentContainerModel
- Throws:
PortalException
-
getParentContainerModels
Returns all the parent container models of the model entity with the primary key ordered by hierarchy.For example, if the primary key is for a file entry inside folder C, which is inside folder B, which is inside folder A; this method returns container models for folders A, B, and C.
- Parameters:
classPK
- the primary key of a model entity the container models must be able to contain- Returns:
- all the matching parent container models of the model entity
- Throws:
PortalException
-
getRestoreContainedModelLink
String getRestoreContainedModelLink(PortletRequest portletRequest, long classPK) throws PortalException - Throws:
PortalException
-
getRestoreContainerModelLink
String getRestoreContainerModelLink(PortletRequest portletRequest, long classPK) throws PortalException Returns the link to the location to which the model entity was restored.- Parameters:
portletRequest
- the portlet requestclassPK
- the primary key of the restored model entity- Returns:
- the restore link
- Throws:
PortalException
-
getRestoreMessage
Returns the message describing the location to which the model entity was restored.- Parameters:
portletRequest
- the portlet requestclassPK
- the primary key of the restored model entity- Returns:
- the restore message
- Throws:
PortalException
-
getRootContainerModelName
String getRootContainerModelName()Returns the name of the root container (e.g. "home").- Returns:
- the name of the root container
-
getSubcontainerModelName
String getSubcontainerModelName()Returns the name of the subcontainer model (e.g. for a folder the subcontainer model name may be "subfolder").- Returns:
- the name of the subcontainer model
-
getSystemEventClassName
String getSystemEventClassName() -
getTrashContainedModelName
String getTrashContainedModelName()Returns the name of the contained model.For example, "files" may be the model name for a folder and "pages" may be the model name for a wiki node.
- Returns:
- the name of the contained model
-
getTrashContainedModelsCount
Returns the number of model entities (excluding container model entities) that are children of the parent container model identified by the primary key.For example, for a folder with subfolders and documents, the number of documents (excluding those explicitely moved to the recycle bin) is returned.
- Parameters:
classPK
- the primary key of a container model- Returns:
- the number of model entities that are children of the parent container model identified by the primary key
- Throws:
PortalException
-
getTrashContainerModelName
String getTrashContainerModelName()Returns the name of the container model.For example, "folder" may be the container model name for a file entry.
- Returns:
- the name of the container model
-
getTrashContainerModelsCount
Returns the number of container models that are children of the parent container model identified by the primary key.For example, for a folder with subfolders and documents, the number of folders (excluding those explicitly moved to the recycle bin) is returned.
- Parameters:
classPK
- the primary key of a container model- Returns:
- the number of container models that are children of the parent container model identified by the primary key
- Throws:
PortalException
-
getTrashedModel
-
getTrashModelsCount
- Throws:
PortalException
-
getTrashModelTrashedModels
default List<TrashedModel> getTrashModelTrashedModels(long classPK, int start, int end, OrderByComparator<?> orderByComparator) throws PortalException - Throws:
PortalException
-
getTrashRenderer
Returns the trash renderer associated to the model entity with the primary key.- Parameters:
classPK
- the primary key of the model entity- Returns:
- the trash renderer associated to the model entity
- Throws:
PortalException
-
hasTrashPermission
boolean hasTrashPermission(PermissionChecker permissionChecker, long groupId, long classPK, String trashActionId) throws PortalException Returnstrue
if the user has the required permission to perform the trash action on the model entity with the primary key.This method is a mapper for special Recycle Bin operations that are not real permissions. The implementations of this method should translate these virtual permissions to real permission checks.
- Parameters:
permissionChecker
- the permission checkergroupId
- the primary key of the groupclassPK
- the primary key of the model entitytrashActionId
- the trash action permission to check- Returns:
true
if the user has the required permission;false
otherwise- Throws:
PortalException
-
isContainerModel
boolean isContainerModel()Returnstrue
if the entity is a container model.- Returns:
true
if the entity is a container model;false
otherwise
-
isDeletable
Returnstrue
if the entity can be deleted from the Recycle Bin.- Returns:
true
if the entity can be deleted from the Recycle Bin.- Throws:
PortalException
-
isInTrash
Returnstrue
if the model entity with the primary key is in the Recycle Bin.- Parameters:
classPK
- the primary key of the model entity- Returns:
true
if the model entity is in the Recycle Bin;false
otherwise- Throws:
PortalException
-
isMovable
Returnstrue
if the entity can be moved from one container model (such as a folder) to another.- Parameters:
classPK
- the primary key of the model entity- Returns:
true
if the entity can be moved from one container model to another;false
otherwise- Throws:
PortalException
-
isRestorable
Returnstrue
if the model entity can be restored to its original location.This method usually returns
false
if the container (e.g. folder) of the model entity is no longer available (e.g. moved to the Recycle Bin or deleted).- Parameters:
classPK
- the primary key of the model entity- Returns:
true
if the model entity can be restored to its original location;false
otherwise- Throws:
PortalException
-
moveEntry
void moveEntry(long userId, long classPK, long containerModelId, ServiceContext serviceContext) throws PortalException Moves the entity with the class primary key to the container model with the class primary key- Parameters:
userId
- the user IDclassPK
- the primary key of the model entitycontainerModelId
- the primary key of the destination container modelserviceContext
- the service context to be applied- Throws:
PortalException
-
moveTrashEntry
void moveTrashEntry(long userId, long classPK, long containerModelId, ServiceContext serviceContext) throws PortalException Moves the model entity with the primary key out of the Recycle Bin to a new destination identified by the container model ID.- Parameters:
userId
- the user IDclassPK
- the primary key of the model entitycontainerModelId
- the primary key of the destination container modelserviceContext
- the service context to be applied- Throws:
PortalException
-
restoreRelatedTrashEntry
Restores the model entity that is related to the model entity with the class name and class PK. For example,com.liferay.portlet.wiki.trash.WikiPageTrashHandler#restoreRelatedTrashEntry(String, long)
restores the attachment related to the wiki page with the class name and class PK.- Parameters:
className
- the class name of the model entity with a related model entity to restoreclassPK
- the primary key of the model entity with a related model entity to restore- Throws:
PortalException
-
restoreTrashEntry
Restores the model entity with the primary key.- Parameters:
userId
- the user IDclassPK
- the primary key of the model entity to restore- Throws:
PortalException
-
updateTitle
Updates the title of the model entity with the primary key. This method is called bycom.liferay.portlet.trash.action.EditEntryAction
before restoring the model entity via its restore rename action.- Parameters:
classPK
- the primary key of the model entitytitle
- the title to be assigned- Throws:
PortalException
-