Liferay 6.2.0-ce-m1

com.liferay.portal.kernel.trash
Interface TrashHandler

All Known Implementing Classes:
BaseTrashHandler, BlogsEntryTrashHandler, DLFileEntryTrashHandler, DLFileShortcutTrashHandler, DLFolderTrashHandler, MBThreadTrashHandler, WikiNodeTrashHandler, WikiPageTrashHandler

public interface TrashHandler

The interface for managing the basic trash operations of the Recycle Bin, which include:

These operations are supported for the following entities via their respective trash handlers:


Method Summary
 void checkDuplicateTrashEntry(TrashEntry trashEntry, long containerModelId, String newName)
          Checks if a duplicate trash entry already exists in the destination container.
 void deleteTrashAttachments(Group group, Date date)
          Deletes the group's attachments that were trashed before the given date.
 void deleteTrashEntries(long[] classPKs)
          Deletes all the model entities with the primary keys.
 void deleteTrashEntries(long[] classPKs, boolean checkPermission)
          Deletes all the model entities with the primary keys, optionally checking permission before deleting each model entity.
 void deleteTrashEntry(long classPK)
          Deletes the model entity with the primary key.
 void deleteTrashEntry(long classPK, boolean checkPermission)
          Deletes the model entity with the primary key.
 String getClassName()
          Returns the class name handled by this trash handler.
 ContainerModel getContainerModel(long containerModelId)
          Returns the container model with the primary key.
 String getContainerModelName()
          Returns the name of the container model (e.g. folder name).
 List<ContainerModel> 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.
 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.
 String getRestoreLink(PortletRequest portletRequest, long classPK)
          Returns the link to the location to which the model entity was restored.
 String getRestoreMessage(PortletRequest portletRequest, long classPK)
          Returns the message describing the location to which the model entity was restored.
 String getRootContainerModelName()
          Returns the name of the root container (e.g.
 String getSubcontainerModelName()
          Returns the name of the sub-container model (e.g. for a folder the sub-container model name may be "subfolder").
 TrashRenderer 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)
          Returns true if the user has the required permission to perform the trash action on the model entity with the primary key.
 boolean isInTrash(long classPK)
          Returns true if the model entity with the primary key is in the Recycle Bin.
 boolean isRestorable(long classPK)
          Returns true if the model entity can be restored to its original location.
 TrashEntry moveTrashEntry(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 restoreTrashEntries(long[] classPKs)
          Restores all the model entities with the primary keys.
 void restoreTrashEntry(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 Detail

checkDuplicateTrashEntry

void checkDuplicateTrashEntry(TrashEntry trashEntry,
                              long containerModelId,
                              String newName)
                              throws PortalException,
                                     SystemException
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 check
containerModelId - the primary key of the destination (e.g. folder)
newName - the new name to be assigned to the trash entry (optionally null to forego renaming the trash entry)
Throws:
PortalException - if a duplicate trash entry already existed in the destination container
SystemException - if a system exception occurred

deleteTrashAttachments

void deleteTrashAttachments(Group group,
                            Date date)
                            throws PortalException,
                                   SystemException
Deletes the group's attachments that were trashed before the given date.

Parameters:
group - ID the primary key of the group
date - the date from which attachments will be deleted
Throws:
PortalException - if any one of the attachment file paths were invalid
SystemException - if a system exception occurred

deleteTrashEntries

void deleteTrashEntries(long[] classPKs)
                        throws PortalException,
                               SystemException
Deletes all the model entities with the primary keys.

Parameters:
classPKs - the primary keys of the model entities to delete
Throws:
PortalException - if any one of the model entities could not be found
SystemException - if a system exception occurred

deleteTrashEntries

void deleteTrashEntries(long[] classPKs,
                        boolean checkPermission)
                        throws PortalException,
                               SystemException
Deletes all the model entities with the primary keys, optionally checking permission before deleting each model entity.

Parameters:
classPKs - the primary keys of the model entities to delete
checkPermission - whether to check permission before deleting each model entity
Throws:
PortalException - if any one of the model entities could not be found
SystemException - if a system exception occurred

deleteTrashEntry

void deleteTrashEntry(long classPK)
                      throws PortalException,
                             SystemException
Deletes the model entity with the primary key.

Parameters:
classPK - the primary key of the model entity to delete
Throws:
PortalException - if a model entity with the primary key could not be found
SystemException - if a system exception occurred

deleteTrashEntry

void deleteTrashEntry(long classPK,
                      boolean checkPermission)
                      throws PortalException,
                             SystemException
Deletes the model entity with the primary key.

Parameters:
classPK - the primary key of the model entity to delete
checkPermission - whether to check permission before deleting the model entity
Throws:
PortalException - if a model entity with the primary key could not be found
SystemException - if a system exception occurred

getClassName

String getClassName()
Returns the class name handled by this trash handler.

Returns:
the class name handled by this trash handler

getContainerModel

ContainerModel getContainerModel(long containerModelId)
                                 throws PortalException,
                                        SystemException
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 - if a container model with the primary key could not be found
SystemException - if a system exception occurred

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,
                                               SystemException
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. The start and end values are not primary keys but, rather, indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil.ALL_POS will return the full result set.

Parameters:
classPK - the primary key of a model entity the container models must be able to contain
containerModelId - the primary key of the parent container model
start - the lower bound of the range of results
end - the upper bound of the range of results (not inclusive)
Returns:
the range of matching container models
Throws:
PortalException - if a model entity with the primary key could not be found
SystemException - if a system exception occurred

getContainerModelsCount

int getContainerModelsCount(long classPK,
                            long containerModelId)
                            throws PortalException,
                                   SystemException
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 contain
containerModelId - the primary key of the parent container model
Returns:
the number of matching container models
Throws:
PortalException - if a model entity with the primary key could not be found
SystemException - if a system exception occurred

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

getRestoreLink

String getRestoreLink(PortletRequest portletRequest,
                      long classPK)
                      throws PortalException,
                             SystemException
Returns the link to the location to which the model entity was restored.

Parameters:
portletRequest - the portlet request
classPK - the primary key of the restored model entity
Returns:
the restore link
Throws:
PortalException - if a model entity with the primary key could not be found
SystemException - if a system exception occurred

getRestoreMessage

String getRestoreMessage(PortletRequest portletRequest,
                         long classPK)
                         throws PortalException,
                                SystemException
Returns the message describing the location to which the model entity was restored.

Parameters:
portletRequest - the portlet request
classPK - the primary key of the restored model entity
Returns:
the restore message
Throws:
PortalException - if a model entity with the primary key could not be found
SystemException - if a system exception occurred

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 sub-container model (e.g. for a folder the sub-container model name may be "subfolder").

Returns:
the name of the sub-container model

getTrashRenderer

TrashRenderer getTrashRenderer(long classPK)
                               throws PortalException,
                                      SystemException
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 - if a model entity with the primary key could not be found
SystemException - if a system exception occurred

hasTrashPermission

boolean hasTrashPermission(PermissionChecker permissionChecker,
                           long groupId,
                           long classPK,
                           String trashActionId)
                           throws PortalException,
                                  SystemException
Returns true 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 checker
groupId - the primary key of the group
classPK - the primary key of the model entity
trashActionId - the trash action permission to check
Returns:
true if the user has the required permission; false otherwise
Throws:
PortalException - if a model entity with the primary key could not be found
SystemException - if a system exception occurred

isInTrash

boolean isInTrash(long classPK)
                  throws PortalException,
                         SystemException
Returns true 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 - if a model entity with the primary key could not be found in the portal
SystemException - if a system exception occurred

isRestorable

boolean isRestorable(long classPK)
                     throws PortalException,
                            SystemException
Returns true 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 - if a model entity with the primary key could not be found
SystemException - if a system exception occurred

moveTrashEntry

TrashEntry moveTrashEntry(long classPK,
                          long containerModelId,
                          ServiceContext serviceContext)
                          throws PortalException,
                                 SystemException
Moves the model entity with the primary key out of the Recycle Bin to a new destination identified by the container model ID.

Parameters:
classPK - the primary key of the model entity
containerModelId - the primary key of the destination container model
serviceContext - the service context
Returns:
the moved model entity
Throws:
PortalException - if a model entity with the primary key or the destination container model with the primary key could not be found
SystemException - if a system exception occurred

restoreTrashEntries

void restoreTrashEntries(long[] classPKs)
                         throws PortalException,
                                SystemException
Restores all the model entities with the primary keys.

Parameters:
classPKs - the primary keys of the model entities to restore
Throws:
PortalException - if any one of the model entities could not be found
SystemException - if a system exception occurred

restoreTrashEntry

void restoreTrashEntry(long classPK)
                       throws PortalException,
                              SystemException
Restores the model entity with the primary key.

Parameters:
classPK - the primary key of the model entity to restore
Throws:
PortalException - if a model entity with the primary key could not be found
SystemException - if a system exception occurred

updateTitle

void updateTitle(long classPK,
                 String title)
                 throws PortalException,
                        SystemException
Updates the title of the model entity with the primary key. This method is called by EditEntryAction before restoring the model entity via its restore rename action.

Parameters:
classPK - the primary key of the model entity
title - the title to be assigned
Throws:
PortalException - if a model entity with the primary key could not be found
SystemException - if a system exception occurred

Liferay 6.2.0-ce-m1