Liferay 6.2-ce-ga5

com.liferay.portal.kernel.trash
Class BaseTrashHandler

java.lang.Object
  extended by com.liferay.portal.kernel.trash.BaseTrashHandler
All Implemented Interfaces:
TrashHandler

public abstract class BaseTrashHandler
extends Object
implements TrashHandler

Provides the base implementation of TrashHandler.

See Also:
TrashHandler

Constructor Summary
BaseTrashHandler()
           
 
Method Summary
 SystemEvent addDeletionSystemEvent(long userId, long groupId, long classPK, String classUuid, String referrerClassName)
           
 void checkDuplicateEntry(long classPK, long containerModelId, String newName)
           
 void checkDuplicateTrashEntry(TrashEntry trashEntry, long containerModelId, String newName)
          Checks if a duplicate trash entry already exists in the destination container.
protected  AssetRendererFactory getAssetRendererFactory()
           
 ContainerModel getContainerModel(long containerModelId)
          Returns the container model with the primary key.
 String getContainerModelClassName()
          Returns the parent container model's class name.
 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.
 ContainerModel getParentContainerModel(long classPK)
          Returns the parent container model of the model entity with the primary key.
 ContainerModel getParentContainerModel(TrashedModel trashedModel)
           
 List<ContainerModel> getParentContainerModels(long classPK)
          Returns all the parent container models of the model entity with the primary key ordered by hierarchy.
 String getRestoreContainedModelLink(PortletRequest portletRequest, long classPK)
           
 String getRestoreContainerModelLink(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 subcontainer model (e.g. for a folder the subcontainer model name may be "subfolder").
 String getSystemEventClassName()
           
 String getTrashContainedModelName()
          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.
 List<TrashRenderer> getTrashContainedModelTrashRenderers(long classPK, int start, int end)
          Returns a range of all the trash renderers of model entities (excluding container models) that are children of the parent container model identified by the primary key.
 String getTrashContainerModelName()
          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.
 List<TrashRenderer> getTrashContainerModelTrashRenderers(long classPK, int start, int end)
          Returns a range of all the trash renderers of model entities that are children of the parent container model identified by the primary key.
 TrashEntry getTrashEntry(long classPK)
           
 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 isContainerModel()
          Returns true if the entity is a container model.
 boolean isDeletable()
          Returns true if the entity can be deleted from the Recycle Bin.
 boolean isInTrashContainer(long classPK)
          Returns true if the model entity with the primary key is in a container that is in the Recycle Bin.
 boolean isMovable()
          Returns true if the entity can be moved from one container model (such as a folder) to another.
 boolean isRestorable(long classPK)
          Returns true if the model entity can be restored to its original location.
 boolean isTrashEntry(TrashEntry trashEntry, ClassedModel classedModel)
           
 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 key
 void 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 updateTitle(long classPK, String title)
          Updates the title of the model entity 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
deleteTrashEntry, getClassName, isInTrash, restoreTrashEntry
 

Constructor Detail

BaseTrashHandler

public BaseTrashHandler()
Method Detail

addDeletionSystemEvent

public SystemEvent addDeletionSystemEvent(long userId,
                                          long groupId,
                                          long classPK,
                                          String classUuid,
                                          String referrerClassName)
                                   throws PortalException,
                                          SystemException
Specified by:
addDeletionSystemEvent in interface TrashHandler
Throws:
PortalException
SystemException

checkDuplicateEntry

public void checkDuplicateEntry(long classPK,
                                long containerModelId,
                                String newName)
                         throws PortalException,
                                SystemException
Specified by:
checkDuplicateEntry in interface TrashHandler
Throws:
PortalException
SystemException

checkDuplicateTrashEntry

public void checkDuplicateTrashEntry(TrashEntry trashEntry,
                                     long containerModelId,
                                     String newName)
                              throws PortalException,
                                     SystemException
Description copied from interface: TrashHandler
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

getContainerModel

public ContainerModel getContainerModel(long containerModelId)
                                 throws PortalException,
                                        SystemException
Description copied from interface: TrashHandler
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

getContainerModelClassName

public String getContainerModelClassName()
Description copied from interface: TrashHandler
Returns the parent container model's class name.

Specified by:
getContainerModelClassName in interface TrashHandler

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
Description copied from interface: TrashHandler
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.

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

public int getContainerModelsCount(long classPK,
                                   long containerModelId)
                            throws PortalException,
                                   SystemException
Description copied from interface: TrashHandler
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.

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

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

getParentContainerModel

public ContainerModel getParentContainerModel(long classPK)
                                       throws PortalException,
                                              SystemException
Description copied from interface: TrashHandler
Returns the parent container model of the model entity with the primary key.

Specified by:
getParentContainerModel in interface TrashHandler
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 - if a portal exception occurred
SystemException - if a system exception occurred

getParentContainerModel

public ContainerModel getParentContainerModel(TrashedModel trashedModel)
                                       throws PortalException,
                                              SystemException
Specified by:
getParentContainerModel in interface TrashHandler
Throws:
PortalException
SystemException

getParentContainerModels

public List<ContainerModel> getParentContainerModels(long classPK)
                                              throws PortalException,
                                                     SystemException
Description copied from interface: TrashHandler
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.

Specified by:
getParentContainerModels in interface TrashHandler
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 - if a portal exception occurred
SystemException - if a system exception occurred

getRestoreContainedModelLink

public String getRestoreContainedModelLink(PortletRequest portletRequest,
                                           long classPK)
                                    throws PortalException,
                                           SystemException
Specified by:
getRestoreContainedModelLink in interface TrashHandler
Throws:
PortalException
SystemException

getRestoreContainerModelLink

public String getRestoreContainerModelLink(PortletRequest portletRequest,
                                           long classPK)
                                    throws PortalException,
                                           SystemException
Description copied from interface: TrashHandler
Returns the link to the location to which the model entity was restored.

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

public String getRestoreMessage(PortletRequest portletRequest,
                                long classPK)
                         throws PortalException,
                                SystemException
Description copied from interface: TrashHandler
Returns the message describing the location to which the model entity was restored.

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

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

Specified by:
getSubcontainerModelName in interface TrashHandler
Returns:
the name of the subcontainer model

getSystemEventClassName

public String getSystemEventClassName()
Specified by:
getSystemEventClassName in interface TrashHandler

getTrashContainedModelName

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

Specified by:
getTrashContainedModelName in interface TrashHandler
Returns:
the name of the contained model

getTrashContainedModelsCount

public int getTrashContainedModelsCount(long classPK)
                                 throws PortalException,
                                        SystemException
Description copied from interface: TrashHandler
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.

Specified by:
getTrashContainedModelsCount in interface TrashHandler
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 - if a portal exception occurred
SystemException - if a system exception occurred

getTrashContainedModelTrashRenderers

public List<TrashRenderer> getTrashContainedModelTrashRenderers(long classPK,
                                                                int start,
                                                                int end)
                                                         throws PortalException,
                                                                SystemException
Description copied from interface: TrashHandler
Returns a range of all the trash renderers of model entities (excluding container models) that are children of the parent container model identified by the primary key.

For example, for a folder with subfolders and documents, a range of all the trash renderers of documents (excluding those explicitly moved to the recycle bin) is returned.

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:
getTrashContainedModelTrashRenderers in interface TrashHandler
Parameters:
classPK - the primary key of a 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 trash renderers of model entities (excluding container models) that are children of the parent container model identified by the primary key
Throws:
PortalException - if a portal exception occurred
SystemException - if a system exception occurred

getTrashContainerModelName

public String getTrashContainerModelName()
Description copied from interface: TrashHandler
Returns the name of the container model.

For example, "folder" may be the container model name for a file entry.

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

getTrashContainerModelsCount

public int getTrashContainerModelsCount(long classPK)
                                 throws PortalException,
                                        SystemException
Description copied from interface: TrashHandler
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.

Specified by:
getTrashContainerModelsCount in interface TrashHandler
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 - if a portal exception occurred
SystemException - if a system exception occurred

getTrashContainerModelTrashRenderers

public List<TrashRenderer> getTrashContainerModelTrashRenderers(long classPK,
                                                                int start,
                                                                int end)
                                                         throws PortalException,
                                                                SystemException
Description copied from interface: TrashHandler
Returns a range of all the trash renderers of 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 range of renderers representing folders (excluding those explicitly moved to the recycle bin) is returned.

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:
getTrashContainerModelTrashRenderers in interface TrashHandler
Parameters:
classPK - the primary key of a 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 trash renderers of model entities
Throws:
PortalException - if a portal exception occurred
SystemException - if a system exception occurred

getTrashEntry

public TrashEntry getTrashEntry(long classPK)
                         throws PortalException,
                                SystemException
Specified by:
getTrashEntry in interface TrashHandler
Throws:
PortalException
SystemException

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

isContainerModel

public boolean isContainerModel()
Description copied from interface: TrashHandler
Returns true if the entity is a container model.

Specified by:
isContainerModel in interface TrashHandler
Returns:
true if the entity is a container model; false otherwise

isDeletable

public boolean isDeletable()
Description copied from interface: TrashHandler
Returns true if the entity can be deleted from the Recycle Bin.

Specified by:
isDeletable in interface TrashHandler
Returns:
true if the entity can be deleted from the Recycle Bin.

isInTrashContainer

public boolean isInTrashContainer(long classPK)
                           throws PortalException,
                                  SystemException
Description copied from interface: TrashHandler
Returns true if the model entity with the primary key is in a container that is in the Recycle Bin.

Specified by:
isInTrashContainer in interface TrashHandler
Parameters:
classPK - the primary key of the model entity
Returns:
true if the model entity with the primary key is in a container that 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

isMovable

public boolean isMovable()
Description copied from interface: TrashHandler
Returns true if the entity can be moved from one container model (such as a folder) to another.

Specified by:
isMovable in interface TrashHandler
Returns:
true if the entity can be moved from one container model to another; false otherwise

isRestorable

public boolean isRestorable(long classPK)
                     throws PortalException,
                            SystemException
Description copied from interface: TrashHandler
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).

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

isTrashEntry

public boolean isTrashEntry(TrashEntry trashEntry,
                            ClassedModel classedModel)
Specified by:
isTrashEntry in interface TrashHandler

moveEntry

public void moveEntry(long userId,
                      long classPK,
                      long containerModelId,
                      ServiceContext serviceContext)
               throws PortalException,
                      SystemException
Description copied from interface: TrashHandler
Moves the entity with the class primary key to the container model with the class primary key

Specified by:
moveEntry in interface TrashHandler
Parameters:
userId - the user ID
classPK - the primary key of the model entity
containerModelId - the primary key of the destination container model
serviceContext - the service context to be applied
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

moveTrashEntry

public void moveTrashEntry(long userId,
                           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:
userId - the user ID
classPK - the primary key of the model entity
containerModelId - the primary key of the destination container model
serviceContext - the service context to be applied
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

restoreRelatedTrashEntry

public void restoreRelatedTrashEntry(String className,
                                     long classPK)
                              throws PortalException,
                                     SystemException
Description copied from interface: TrashHandler
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.

Specified by:
restoreRelatedTrashEntry in interface TrashHandler
Parameters:
className - the class name of the model entity with a related model entity to restore
classPK - the primary key of the model entity with a related 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
Description copied from interface: TrashHandler
Updates the title of the model entity with the primary key. This method is called by com.liferay.portlet.trash.action.EditEntryAction before restoring the model entity via its restore rename action.

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

getAssetRendererFactory

protected AssetRendererFactory getAssetRendererFactory()

hasPermission

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

Liferay 6.2-ce-ga5