org.opencms.workplace.list
Class A_CmsListResourceCollector

java.lang.Object
  extended by org.opencms.workplace.list.A_CmsListResourceCollector
All Implemented Interfaces:
java.lang.Comparable, I_CmsResourceCollector, I_CmsListResourceCollector
Direct Known Subclasses:
CmsDeleteBrokenRelationsCollector, CmsListResourceLinkRelationCollector, CmsLockedResourcesCollector, CmsNewResourceXmlContentModelCollector, CmsPublishBrokenRelationsCollector, CmsSearchResourcesCollector

public abstract class A_CmsListResourceCollector
extends java.lang.Object
implements I_CmsListResourceCollector

Collector to provide CmsResource objects for a explorer List.

Since:
6.1.0
Version:
$Revision: 1.11 $
Author:
Michael Moossen

Field Summary
protected  java.lang.String m_collectorParameter
          The collector parameter.
protected  java.util.Map m_liCache
          List item cache.
protected  java.util.Map m_resCache
          Resource cache.
protected  java.util.List m_resources
          Cache for resource list result.
static java.lang.String VFS_PATH_NONE
          VFS path to use for a dummy resource object.
 
Fields inherited from interface org.opencms.workplace.list.I_CmsListResourceCollector
PARAM_FILTER, PARAM_ORDER, PARAM_PAGE, PARAM_RESOURCES, PARAM_SORTBY, SEP_KEYVAL, SEP_PARAM
 
Constructor Summary
protected A_CmsListResourceCollector(A_CmsListExplorerDialog wp)
          Constructor, creates a new list collector.
 
Method Summary
 int compareTo(java.lang.Object arg0)
           
protected  CmsListItem createResourceListItem(CmsResource resource, CmsHtmlList list, boolean showPermissions, boolean showDateLastMod, boolean showUserLastMod, boolean showDateCreate, boolean showUserCreate, boolean showDateRel, boolean showDateExp, boolean showState, boolean showLockedBy, boolean showSite)
          Returns a list item created from the resource information, differs between valid resources and invalid resources.
 java.lang.String getCreateLink(CmsObject cms)
          Returns the link that must be executed when a user clicks on the direct edit "new" button on a list created by the default collector.
 java.lang.String getCreateLink(CmsObject cms, java.lang.String collectorName, java.lang.String param)
          Returns the link that must be executed when a user clicks on the direct edit "new" button on a list created by the named collector.
 java.lang.String getCreateParam(CmsObject cms)
          Returns the default parameter that must be passed to the I_CmsResourceCollector.getCreateLink(CmsObject, String, String) method.
 java.lang.String getCreateParam(CmsObject cms, java.lang.String collectorName, java.lang.String param)
          Returns the parameter that must be passed to the I_CmsResourceCollector.getCreateLink(CmsObject, String, String) method.
 java.lang.String getDefaultCollectorName()
          Returns the default collector name to use for collecting resources.
 java.lang.String getDefaultCollectorParam()
          Returns the default collector parameter to use for collecting resources.
protected  CmsListItem getDummyListItem(CmsHtmlList list)
          Returns a dummy list item.
protected  java.util.List getInternalResources(CmsObject cms, java.util.Map params)
          Wrapper method for caching the result of getResources(CmsObject, Map).
 java.util.List getListItems(java.lang.String parameter)
          Returns a list of list items from a list of resources.
 int getOrder()
          Returns the "order weight" of this collector.
 CmsResource getResource(CmsObject cms, CmsListItem item)
          Returns the resource for the given item.
protected  java.util.List getResourceNamesFromParam(java.util.Map params)
          Returns the list of resource names from the parameter map.
abstract  java.util.List getResources(CmsObject cms, java.util.Map params)
          Returns all, unsorted and unfiltered, resources.
 java.util.List getResults(CmsObject cms)
          Returns a list of CmsResource Objects that are gathered in the VFS using the default collector name and parameter.
 java.util.List getResults(CmsObject cms, java.lang.String collectorName, java.lang.String parameter)
          The parameter must follow the syntax "page:nr" where nr is the number of the page to be displayed.
protected  CmsListState getState(java.util.Map params)
          Returns the state of the parameter map.
 A_CmsListExplorerDialog getWp()
          Returns the workplace object.
protected abstract  void setAdditionalColumns(CmsListItem item, CmsResourceUtil resUtil)
          Set additional column entries for a resource.
 void setDefaultCollectorName(java.lang.String collectorName)
          Sets the default collector name to use for collecting resources.
 void setDefaultCollectorParam(java.lang.String param)
          The parameter must follow the syntax "mode|projectId" where mode is either "new", "changed", "deleted" or "modified" and projectId is the id of the project to be displayed.
 void setOrder(int order)
          Sets the "order weight" of this collector.
 void setPage(int page)
          Sets the current display page.
protected  void setResourcesParam(java.util.List resources)
          Sets the resources parameter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.opencms.file.collectors.I_CmsResourceCollector
getCollectorNames
 

Field Detail

VFS_PATH_NONE

public static final java.lang.String VFS_PATH_NONE
VFS path to use for a dummy resource object.

See Also:
Constant Field Values

m_collectorParameter

protected java.lang.String m_collectorParameter
The collector parameter.


m_liCache

protected java.util.Map m_liCache
List item cache.


m_resCache

protected java.util.Map m_resCache
Resource cache.


m_resources

protected java.util.List m_resources
Cache for resource list result.

Constructor Detail

A_CmsListResourceCollector

protected A_CmsListResourceCollector(A_CmsListExplorerDialog wp)
Constructor, creates a new list collector.

Parameters:
wp - the workplace object where the collector is used from
Method Detail

compareTo

public int compareTo(java.lang.Object arg0)
Specified by:
compareTo in interface java.lang.Comparable
See Also:
Comparable.compareTo(java.lang.Object)

getCreateLink

public java.lang.String getCreateLink(CmsObject cms)
Description copied from interface: I_CmsResourceCollector
Returns the link that must be executed when a user clicks on the direct edit "new" button on a list created by the default collector.

If this method returns null, it indicated that the selected collector implementation does not support a "create link", and so no "new" button will should shown on lists generated with this collector.

Specified by:
getCreateLink in interface I_CmsResourceCollector
Parameters:
cms - the current CmsObject
Returns:
the link to execute after a "new" button was clicked
See Also:
I_CmsResourceCollector.getCreateLink(org.opencms.file.CmsObject)

getCreateLink

public java.lang.String getCreateLink(CmsObject cms,
                                      java.lang.String collectorName,
                                      java.lang.String param)
Description copied from interface: I_CmsResourceCollector
Returns the link that must be executed when a user clicks on the direct edit "new" button on a list created by the named collector.

If this method returns null, it indicated that the selected collector implementation does not support a "create link", and so no "new" button will should shown on lists generated with this collector.

Specified by:
getCreateLink in interface I_CmsResourceCollector
Parameters:
cms - the current CmsObject
collectorName - the name of the collector to use
param - an optional collector parameter
Returns:
the link to execute after a "new" button was clicked
See Also:
I_CmsResourceCollector.getCreateLink(org.opencms.file.CmsObject, java.lang.String, java.lang.String)

getCreateParam

public java.lang.String getCreateParam(CmsObject cms)
Description copied from interface: I_CmsResourceCollector
Returns the default parameter that must be passed to the I_CmsResourceCollector.getCreateLink(CmsObject, String, String) method.

If this method returns null, it indicates that the selected collector implementation does not support a "create link", and so no "new" button will should shown on lists generated with this collector.

Specified by:
getCreateParam in interface I_CmsResourceCollector
Parameters:
cms - the current CmsObject
Returns:
the parameter that will be passed to the I_CmsResourceCollector.getCreateLink(CmsObject, String, String) method, or null
See Also:
I_CmsResourceCollector.getCreateParam(org.opencms.file.CmsObject)

getCreateParam

public java.lang.String getCreateParam(CmsObject cms,
                                       java.lang.String collectorName,
                                       java.lang.String param)
Description copied from interface: I_CmsResourceCollector
Returns the parameter that must be passed to the I_CmsResourceCollector.getCreateLink(CmsObject, String, String) method.

If this method returns null, it indicates that the selected collector implementation does not support a "create link", and so no "new" button will should shown on lists generated with this collector.

Specified by:
getCreateParam in interface I_CmsResourceCollector
Parameters:
cms - the current CmsObject
collectorName - the name of the collector to use
param - an optional collector parameter from the current page context
Returns:
the parameter that will be passed to the I_CmsResourceCollector.getCreateLink(CmsObject, String, String) method, or null
See Also:
I_CmsResourceCollector.getCreateParam(org.opencms.file.CmsObject, java.lang.String, java.lang.String)

getDefaultCollectorName

public java.lang.String getDefaultCollectorName()
Description copied from interface: I_CmsResourceCollector
Returns the default collector name to use for collecting resources.

Specified by:
getDefaultCollectorName in interface I_CmsResourceCollector
Returns:
the default collector name
See Also:
I_CmsResourceCollector.getDefaultCollectorName()

getDefaultCollectorParam

public java.lang.String getDefaultCollectorParam()
Description copied from interface: I_CmsResourceCollector
Returns the default collector parameter to use for collecting resources.

Specified by:
getDefaultCollectorParam in interface I_CmsResourceCollector
Returns:
the default collector parameter
See Also:
I_CmsResourceCollector.getDefaultCollectorParam()

getListItems

public java.util.List getListItems(java.lang.String parameter)
                            throws CmsException
Returns a list of list items from a list of resources.

Specified by:
getListItems in interface I_CmsListResourceCollector
Parameters:
parameter - the collector parameter or null for default.

Returns:
a list of CmsListItem objects
Throws:
CmsException - if something goes wrong

getOrder

public int getOrder()
Description copied from interface: I_CmsResourceCollector
Returns the "order weight" of this collector.

The "order weight" is important because two collector classes may provide a collector with the same name. If this is the case, the collector implementation with the higher order number "overrules" the lower order number class.

Specified by:
getOrder in interface I_CmsResourceCollector
Returns:
the "order weight" of this collector
See Also:
I_CmsResourceCollector.getOrder()

getResource

public CmsResource getResource(CmsObject cms,
                               CmsListItem item)
Returns the resource for the given item.

Specified by:
getResource in interface I_CmsListResourceCollector
Parameters:
cms - the cms object
item - the item
Returns:
the resource

getResources

public abstract java.util.List getResources(CmsObject cms,
                                            java.util.Map params)
                                     throws CmsException
Returns all, unsorted and unfiltered, resources.

Be sure to cache the resources.

Specified by:
getResources in interface I_CmsListResourceCollector
Parameters:
cms - the cms object
params - the parameter map
Returns:
a list of CmsResource objects
Throws:
CmsException - if something goes wrong

getResults

public java.util.List getResults(CmsObject cms)
                          throws CmsException
Description copied from interface: I_CmsResourceCollector
Returns a list of CmsResource Objects that are gathered in the VFS using the default collector name and parameter.

Specified by:
getResults in interface I_CmsResourceCollector
Parameters:
cms - the current CmsObject
Returns:
a list of CmsXmlContent objects
Throws:
CmsException - if something goes wrong
CmsDataAccessException - if the parameter attribute of the corresponding collector tag is invalid
See Also:
I_CmsResourceCollector.getResults(org.opencms.file.CmsObject)

getResults

public java.util.List getResults(CmsObject cms,
                                 java.lang.String collectorName,
                                 java.lang.String parameter)
                          throws CmsException
The parameter must follow the syntax "page:nr" where nr is the number of the page to be displayed.

Specified by:
getResults in interface I_CmsResourceCollector
Parameters:
cms - the current CmsObject
collectorName - the name of the collector to use
parameter - an optional collector parameter
Returns:
a list of CmsXmlContent objects
Throws:
CmsException - if something goes wrong
CmsDataAccessException - if the parameter attribute of the corresponding collector tag is invalid
See Also:
I_CmsResourceCollector.getResults(org.opencms.file.CmsObject, java.lang.String, java.lang.String)

getWp

public A_CmsListExplorerDialog getWp()
Returns the workplace object.

Specified by:
getWp in interface I_CmsListResourceCollector
Returns:
the workplace object

setDefaultCollectorName

public void setDefaultCollectorName(java.lang.String collectorName)
Description copied from interface: I_CmsResourceCollector
Sets the default collector name to use for collecting resources.

Specified by:
setDefaultCollectorName in interface I_CmsResourceCollector
Parameters:
collectorName - the default collector name
See Also:
I_CmsResourceCollector.setDefaultCollectorName(java.lang.String)

setDefaultCollectorParam

public void setDefaultCollectorParam(java.lang.String param)
The parameter must follow the syntax "mode|projectId" where mode is either "new", "changed", "deleted" or "modified" and projectId is the id of the project to be displayed.

Specified by:
setDefaultCollectorParam in interface I_CmsResourceCollector
Parameters:
param - the default collector parameter
See Also:
I_CmsResourceCollector.setDefaultCollectorParam(java.lang.String)

setOrder

public void setOrder(int order)
Description copied from interface: I_CmsResourceCollector
Sets the "order weight" of this collector.

Specified by:
setOrder in interface I_CmsResourceCollector
Parameters:
order - the order weight to set
See Also:
I_CmsResourceCollector.setOrder(int)

setPage

public void setPage(int page)
Sets the current display page.

Specified by:
setPage in interface I_CmsListResourceCollector
Parameters:
page - the new display page

createResourceListItem

protected CmsListItem createResourceListItem(CmsResource resource,
                                             CmsHtmlList list,
                                             boolean showPermissions,
                                             boolean showDateLastMod,
                                             boolean showUserLastMod,
                                             boolean showDateCreate,
                                             boolean showUserCreate,
                                             boolean showDateRel,
                                             boolean showDateExp,
                                             boolean showState,
                                             boolean showLockedBy,
                                             boolean showSite)
Returns a list item created from the resource information, differs between valid resources and invalid resources.

Parameters:
resource - the resource to create the list item from
list - the list
showPermissions - if to show permissions
showDateLastMod - if to show the last modification date
showUserLastMod - if to show the last modification user
showDateCreate - if to show the creation date
showUserCreate - if to show the creation date
showDateRel - if to show the date released
showDateExp - if to show the date expired
showState - if to show the state
showLockedBy - if to show the lock user
showSite - if to show the site
Returns:
a list item created from the resource information

getDummyListItem

protected CmsListItem getDummyListItem(CmsHtmlList list)
Returns a dummy list item.

Parameters:
list - the list object to create the entry for
Returns:
a dummy list item

getInternalResources

protected java.util.List getInternalResources(CmsObject cms,
                                              java.util.Map params)
                                       throws CmsException
Wrapper method for caching the result of getResources(CmsObject, Map).

Parameters:
cms - the cms object
params - the parameter map
Returns:
the result of getResources(CmsObject, Map)
Throws:
CmsException - if something goes wrong

getResourceNamesFromParam

protected java.util.List getResourceNamesFromParam(java.util.Map params)
Returns the list of resource names from the parameter map.

Parameters:
params - the parameter map
Returns:
the list of resource names
See Also:
I_CmsListResourceCollector.PARAM_RESOURCES

getState

protected CmsListState getState(java.util.Map params)
Returns the state of the parameter map.

Parameters:
params - the parameter map
Returns:
the state of the list from the parameter map

setAdditionalColumns

protected abstract void setAdditionalColumns(CmsListItem item,
                                             CmsResourceUtil resUtil)
Set additional column entries for a resource.

Overwrite this method to set additional column entries.

Parameters:
item - the current list item
resUtil - the resource util object for getting the info from

setResourcesParam

protected void setResourcesParam(java.util.List resources)
Sets the resources parameter.

Parameters:
resources - the list of resource names to use