Liferay 6.2.0-ce-m1

com.liferay.portal.kernel.trash
Class BaseTrashHandler

java.lang.Object
  extended by com.liferay.portal.kernel.trash.BaseTrashHandler
All Implemented Interfaces:
TrashHandler
Direct Known Subclasses:
BlogsEntryTrashHandler, DLFileEntryTrashHandler, DLFileShortcutTrashHandler, DLFolderTrashHandler, MBThreadTrashHandler, WikiNodeTrashHandler, WikiPageTrashHandler

public abstract class BaseTrashHandler
extends Object
implements TrashHandler

Provides the base implementation of TrashHandler.

See Also:
TrashHandler}

Constructor Summary
BaseTrashHandler()
           
 
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 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.
protected  AssetRendererFactory getAssetRendererFactory()
           
 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 trash entry was restored.
 String getRestoreMessage(PortletRequest portletRequest, long classPK)
          Returns the message describing the location to which the trash entry 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.
protected abstract  boolean hasPermission(PermissionChecker permissionChecker, long classPK, String actionId)
           
 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 isRestorable(long classPK)
          Returns true if the trash entry 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 restoreTrashEntry(long classPK)
          Restores the model entity with the primary key.
 void updateTitle(long classPK, String title)
          Updates the title of the trash entry with the primary key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.liferay.portal.kernel.trash.TrashHandler
deleteTrashEntries, getClassName, isInTrash, restoreTrashEntries
 

Constructor Detail

BaseTrashHandler

public BaseTrashHandler()
Method Detail

checkDuplicateTrashEntry

public 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.

Specified by:
checkDuplicateTrashEntry in interface TrashHandler
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

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

Specified by:
deleteTrashAttachments in interface TrashHandler
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

public void deleteTrashEntries(long[] classPKs)
                        throws PortalException,
                               SystemException
Description copied from interface: TrashHandler
Deletes all the model entities with the primary keys.

Specified by:
deleteTrashEntries in interface TrashHandler
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

deleteTrashEntry

public void deleteTrashEntry(long classPK)
                      throws PortalException,
                             SystemException
Description copied from interface: TrashHandler
Deletes the model entity with the primary key.

Specified by:
deleteTrashEntry in interface TrashHandler
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

public void deleteTrashEntry(long classPK,
                             boolean checkPermission)
                      throws PortalException,
                             SystemException
Description copied from interface: TrashHandler
Deletes the model entity with the primary key.

Specified by:
deleteTrashEntry in interface TrashHandler
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

getContainerModel

public ContainerModel getContainerModel(long containerModelId)
                                 throws PortalException,
                                        SystemException
Returns the container model with the primary key.

Specified by:
getContainerModel in interface TrashHandler
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

public String getContainerModelName()
Description copied from interface: TrashHandler
Returns the name of the container model (e.g. folder name).

Specified by:
getContainerModelName in interface TrashHandler
Returns:
the name of the container model

getContainerModels

public 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 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.

Specified by:
getContainerModels in interface TrashHandler
Parameters:
classPK - the primary key of an 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 trash entry with the primary key could not be found
SystemException - if a system exception occurred

getContainerModelsCount

public 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 entity identified by the primary key.

This method checks for the view permission when counting the container models.

Specified by:
getContainerModelsCount in interface TrashHandler
Parameters:
classPK - the primary key of an 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 trash entry with the primary key could not be found
SystemException - if a system exception occurred

getDeleteMessage

public String getDeleteMessage()
Description copied from interface: TrashHandler
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.

Specified by:
getDeleteMessage in interface TrashHandler
Returns:
the language key to the localized message to display next to a trash entry listed in a search result

getRestoreLink

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

Specified by:
getRestoreLink in interface TrashHandler
Parameters:
portletRequest - the portlet request
classPK - the primary key of the restored trash entry
Returns:
the restore link
Throws:
PortalException - if a trash entry with the primary key could not be found
SystemException - if a system exception occurred

getRestoreMessage

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

Specified by:
getRestoreMessage in interface TrashHandler
Parameters:
portletRequest - the portlet request
classPK - the primary key of the restored trash entry
Returns:
the restore message
Throws:
PortalException - if a trash entry with the primary key could not be found
SystemException - if a system exception occurred

getRootContainerModelName

public String getRootContainerModelName()
Description copied from interface: TrashHandler
Returns the name of the root container (e.g. "home").

Specified by:
getRootContainerModelName in interface TrashHandler
Returns:
the name of the root container

getSubcontainerModelName

public String getSubcontainerModelName()
Description copied from interface: TrashHandler
Returns the name of the sub-container model (e.g. for a folder the sub-container model name may be "subfolder").

Specified by:
getSubcontainerModelName in interface TrashHandler
Returns:
the name of the sub-container model

getTrashRenderer

public TrashRenderer getTrashRenderer(long classPK)
                               throws PortalException,
                                      SystemException
Description copied from interface: TrashHandler
Returns the trash renderer associated to the model entity with the primary key.

Specified by:
getTrashRenderer in interface TrashHandler
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

public boolean hasTrashPermission(PermissionChecker permissionChecker,
                                  long groupId,
                                  long classPK,
                                  String trashActionId)
                           throws PortalException,
                                  SystemException
Description copied from interface: TrashHandler
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.

Specified by:
hasTrashPermission in interface TrashHandler
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

isRestorable

public boolean isRestorable(long classPK)
                     throws PortalException,
                            SystemException
Returns true if the trash entry can be restored to its original location.

This method usually returns false if the container (e.g. folder) of the trash entry is no longer available (e.g. moved to the Recycle Bin or deleted).

Specified by:
isRestorable in interface TrashHandler
Parameters:
classPK - the primary key of the trash entry
Returns:
true if the trash entry can be restored to its original location; false otherwise
Throws:
PortalException - if a trash entry with the primary key could not be found
SystemException - if a system exception occurred

moveTrashEntry

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

Specified by:
moveTrashEntry in interface TrashHandler
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

restoreTrashEntry

public void restoreTrashEntry(long classPK)
                       throws PortalException,
                              SystemException
Description copied from interface: TrashHandler
Restores the model entity with the primary key.

Specified by:
restoreTrashEntry in interface TrashHandler
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

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

Specified by:
updateTitle in interface TrashHandler
Parameters:
classPK - the primary key of the trash entry
title - the title to be assigned
Throws:
PortalException - if a trash entry with the primary key could not be found
SystemException - if a system exception occurred

getAssetRendererFactory

protected AssetRendererFactory getAssetRendererFactory()

hasPermission

protected abstract boolean hasPermission(PermissionChecker permissionChecker,
                                         long classPK,
                                         String actionId)
                                  throws PortalException,
                                         SystemException
Throws:
PortalException
SystemException

Liferay 6.2.0-ce-m1