Class A_CmsResourceCollector
- java.lang.Object
-
- org.opencms.file.collectors.A_CmsResourceCollector
-
- All Implemented Interfaces:
java.lang.Comparable<I_CmsResourceCollector>
,I_CmsCollectorPublishListProvider
,I_CmsResourceCollector
- Direct Known Subclasses:
CmsCategoryResourceCollector
,CmsChangedResourceCollector
,CmsDateResourceCollector
,CmsDefaultResourceCollector
,CmsPriorityResourceCollector
,CmsSolrCollector
,CmsSubscriptionCollector
,CmsTimeFrameCategoryCollector
public abstract class A_CmsResourceCollector extends java.lang.Object implements I_CmsResourceCollector
Provides some helpful base implementations for resource collector classes.- Since:
- 6.0.0
-
-
Field Summary
Fields Modifier and Type Field Description protected int
m_order
The collector order of this collector.static java.lang.String
SEPARATOR_TEMPLATEFILE
The template file separator string for creating a new resource in direct edit mode, can be used to append an explicit template file name inI_CmsResourceCollector.getCreateParam(CmsObject, String, String)
.-
Fields inherited from interface org.opencms.file.collectors.I_CmsResourceCollector
DEFAULT_LIMIT
-
-
Constructor Summary
Constructors Constructor Description A_CmsResourceCollector()
Constructor to initialize some default values.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkParams()
Checks if the required parameters have been set.int
compareTo(I_CmsResourceCollector obj)
static java.lang.String
createResourceForCollector(CmsObject cms, java.lang.String newLink, java.util.Locale locale, java.lang.String referenceResource, java.lang.String modelFile, java.lang.String mode, java.lang.String postCreateHandler)
Creates a new content collector resource.boolean
equals(java.lang.Object obj)
Two collectors are considered to be equal if they are sharing the same implementation class.protected java.lang.String
getCreateInFolder(CmsObject cms, java.lang.String param)
Returns the link to create a new XML content item in the folder pointed to by the parameter.protected java.lang.String
getCreateInFolder(CmsObject cms, CmsCollectorData data)
Returns the link to create a new XML content item in the folder pointed to by the parameter.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
getCreateParam(CmsObject cms)
Returns the default parameter that must be passed to theI_CmsResourceCollector.getCreateLink(CmsObject, String, String)
method.int
getCreateTypeId(CmsObject cms, java.lang.String collectorName, java.lang.String param)
Returns the id of the resource type for new collector items.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.int
getOrder()
Returns the "order weight" of this collector.static I_CmsCollectorPostCreateHandler
getPostCreateHandler(java.lang.String className)
Instantiates a post-create handler given a class name (which may actually be null).java.util.Set<CmsResource>
getPublishResources(CmsObject cms, I_CmsContentLoadCollectorInfo info)
Gets the publish list for the collector.java.util.List<CmsResource>
getResults(CmsObject cms)
Returns a list ofCmsResource
Objects that are gathered in the VFS using the default collector name and parameter.int
hashCode()
void
setDefaultCollectorName(java.lang.String collectorName)
Sets the default collector name to use for collecting resources.void
setDefaultCollectorParam(java.lang.String param)
Sets the default collector parameter to use for collecting resources.void
setOrder(int order)
Sets the "order weight" of this collector.protected java.util.List<CmsResource>
shrinkToFit(java.util.List<CmsResource> result, int maxSize)
Shrinks a List to fit a maximum size.protected java.util.List<CmsResource>
shrinkToFit(java.util.List<CmsResource> result, int maxSize, int explicitNumResults)
Shrinks a List to fit a maximum size.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.opencms.file.collectors.I_CmsResourceCollector
getCollectorNames, getCreateLink, getCreateParam, getResults, getResults
-
-
-
-
Field Detail
-
SEPARATOR_TEMPLATEFILE
public static final java.lang.String SEPARATOR_TEMPLATEFILE
The template file separator string for creating a new resource in direct edit mode, can be used to append an explicit template file name inI_CmsResourceCollector.getCreateParam(CmsObject, String, String)
.- See Also:
- Constant Field Values
-
m_order
protected int m_order
The collector order of this collector.
-
-
Constructor Detail
-
A_CmsResourceCollector
public A_CmsResourceCollector()
Constructor to initialize some default values.
-
-
Method Detail
-
createResourceForCollector
public static java.lang.String createResourceForCollector(CmsObject cms, java.lang.String newLink, java.util.Locale locale, java.lang.String referenceResource, java.lang.String modelFile, java.lang.String mode, java.lang.String postCreateHandler) throws CmsException
Creates a new content collector resource.- Parameters:
cms
- the cms contextnewLink
- the new resource linklocale
- the content localereferenceResource
- the reference resourcemodelFile
- the model filemode
- the optional creation mode (can be null)postCreateHandler
- optional class name of anI_CmsCollectorPostCreateHandler
which is invoked after the content has been created. The fully qualified class name can be followed by a "|" symbol and a handler specific configuration string.- Returns:
- the new file name
- Throws:
CmsException
- if something goes wrong
-
getPostCreateHandler
public static I_CmsCollectorPostCreateHandler getPostCreateHandler(java.lang.String className)
Instantiates a post-create handler given a class name (which may actually be null).If the given name is null or does not refer to a valid post-create handler class, a default implementation will be returned.
- Parameters:
className
- the class name of the post-create handler class- Returns:
- a post-create handler instance
-
compareTo
public int compareTo(I_CmsResourceCollector obj)
- Specified by:
compareTo
in interfacejava.lang.Comparable<I_CmsResourceCollector>
- See Also:
Comparable.compareTo(java.lang.Object)
-
equals
public boolean equals(java.lang.Object obj)
Two collectors are considered to be equal if they are sharing the same implementation class.- Overrides:
equals
in classjava.lang.Object
- See Also:
Object.equals(java.lang.Object)
-
getCreateLink
public java.lang.String getCreateLink(CmsObject cms) throws CmsException, CmsDataAccessException
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 interfaceI_CmsResourceCollector
- Parameters:
cms
- the current CmsObject- Returns:
- the link to execute after a "new" button was clicked
- Throws:
CmsException
- if something goes wrongCmsDataAccessException
- if the parameter attribute of the corresponding collector tag is invalid- See Also:
I_CmsResourceCollector.getCreateLink(org.opencms.file.CmsObject)
-
getCreateParam
public java.lang.String getCreateParam(CmsObject cms) throws CmsDataAccessException
Description copied from interface:I_CmsResourceCollector
Returns the default parameter that must be passed to theI_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 interfaceI_CmsResourceCollector
- Parameters:
cms
- the current CmsObject- Returns:
- the parameter that will be passed to the
I_CmsResourceCollector.getCreateLink(CmsObject, String, String)
method, or null - Throws:
CmsDataAccessException
- if the param attrib of the corresponding collector tag is invalid- See Also:
I_CmsResourceCollector.getCreateParam(org.opencms.file.CmsObject)
-
getCreateTypeId
public int getCreateTypeId(CmsObject cms, java.lang.String collectorName, java.lang.String param) throws CmsException
Description copied from interface:I_CmsResourceCollector
Returns the id of the resource type for new collector items.Returns -1 if creation of new items is not supported.
- Specified by:
getCreateTypeId
in interfaceI_CmsResourceCollector
- Parameters:
cms
- the current CmsObjectcollectorName
- the name of the collector to useparam
- an optional collector parameter- Returns:
- the resource type id
- Throws:
CmsException
- if something goes wrong- See Also:
I_CmsResourceCollector.getCreateTypeId(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 interfaceI_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 interfaceI_CmsResourceCollector
- Returns:
- the default collector parameter
- See Also:
I_CmsResourceCollector.getDefaultCollectorParam()
-
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 interfaceI_CmsResourceCollector
- Returns:
- the "order weight" of this collector
- See Also:
I_CmsResourceCollector.getOrder()
-
getPublishResources
public java.util.Set<CmsResource> getPublishResources(CmsObject cms, I_CmsContentLoadCollectorInfo info) throws CmsException
Description copied from interface:I_CmsCollectorPublishListProvider
Gets the publish list for the collector.- Specified by:
getPublishResources
in interfaceI_CmsCollectorPublishListProvider
- Parameters:
cms
- the CMS context to useinfo
- the collector information- Returns:
- the resources to include in the publish list
- Throws:
CmsException
- if soemthing goes wrong- See Also:
I_CmsCollectorPublishListProvider.getPublishResources(org.opencms.file.CmsObject, org.opencms.gwt.shared.I_CmsContentLoadCollectorInfo)
-
getResults
public java.util.List<CmsResource> getResults(CmsObject cms) throws CmsDataAccessException, CmsException
Description copied from interface:I_CmsResourceCollector
Returns a list ofCmsResource
Objects that are gathered in the VFS using the default collector name and parameter.- Specified by:
getResults
in interfaceI_CmsResourceCollector
- Parameters:
cms
- the current CmsObject- Returns:
- a list of CmsXmlContent objects
- Throws:
CmsDataAccessException
- if the parameter attribute of the corresponding collector tag is invalidCmsException
- if something goes wrong- See Also:
I_CmsResourceCollector.getResults(org.opencms.file.CmsObject)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
- See Also:
Object.hashCode()
-
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 interfaceI_CmsResourceCollector
- Parameters:
collectorName
- the default collector name- See Also:
I_CmsResourceCollector.setDefaultCollectorName(java.lang.String)
-
setDefaultCollectorParam
public void setDefaultCollectorParam(java.lang.String param)
Description copied from interface:I_CmsResourceCollector
Sets the default collector parameter to use for collecting resources.- Specified by:
setDefaultCollectorParam
in interfaceI_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 interfaceI_CmsResourceCollector
- Parameters:
order
- the order weight to set- See Also:
I_CmsResourceCollector.setOrder(int)
-
checkParams
protected void checkParams()
Checks if the required parameters have been set.
-
getCreateInFolder
protected java.lang.String getCreateInFolder(CmsObject cms, CmsCollectorData data) throws CmsException
Returns the link to create a new XML content item in the folder pointed to by the parameter.- Parameters:
cms
- the current CmsObjectdata
- the collector data to use- Returns:
- the link to create a new XML content item in the folder
- Throws:
CmsException
- if something goes wrong- Since:
- 7.0.2
-
getCreateInFolder
protected java.lang.String getCreateInFolder(CmsObject cms, java.lang.String param) throws CmsException
Returns the link to create a new XML content item in the folder pointed to by the parameter.- Parameters:
cms
- the current CmsObjectparam
- the folder name to use- Returns:
- the link to create a new XML content item in the folder
- Throws:
CmsException
- if something goes wrong
-
shrinkToFit
protected java.util.List<CmsResource> shrinkToFit(java.util.List<CmsResource> result, int maxSize)
Shrinks a List to fit a maximum size.- Parameters:
result
- a ListmaxSize
- the maximum size of the List- Returns:
- the reduced list
-
shrinkToFit
protected java.util.List<CmsResource> shrinkToFit(java.util.List<CmsResource> result, int maxSize, int explicitNumResults)
Shrinks a List to fit a maximum size.- Parameters:
result
- a ListmaxSize
- the maximum size of the ListexplicitNumResults
- the value of the numResults parameter given to the getResults method (this overrides maxSize if it is positive)- Returns:
- the reduced list
-
-