Package org.opencms.db
Class CmsPublishList
java.lang.Object
org.opencms.db.CmsPublishList
- All Implemented Interfaces:
Externalizable
,Serializable
A container for all new/changed/deteled Cms resources that are published together.
Only classes inside the org.opencms.db package can add or remove elements to or from this list. This allows the OpenCms API to pass the list around between classes, but with restricted access to create this list.
To create a publish list, one of the public constructors must be used in order to set the basic operation mode
(project publish or direct publish).
After this, use
to fill the actual values of the publish list.CmsDriverManager.fillPublishList(CmsDbContext, CmsPublishList)
- Since:
- 6.0.0
- See Also:
-
Constructor Summary
ConstructorDescriptionEmpty constructor.CmsPublishList
(boolean all, List<CmsResource> directPublishResources, boolean directPublishSiblings) Constructs a publish list for a list of direct publish resources.CmsPublishList
(List<CmsResource> directPublishResources, boolean publishSiblings) Constructs a publish list for a list of direct publish resources.CmsPublishList
(List<CmsResource> directPublishResources, boolean publishSiblings, boolean publishSubResources) Constructs a publish list for a list of direct publish resources.CmsPublishList
(CmsProject project) Constructs a publish list for a given project.CmsPublishList
(CmsResource directPublishResource, boolean publishSiblings) Constructs a publish list for a single direct publish resource. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
add
(CmsResource resource, boolean check) Adds a new/changed Cms folder resource to the publish list.protected void
addAll
(Collection<CmsResource> resources, boolean check) Appends all the given resources to this publish list.protected CmsResource
checkContainsSubResources
(CmsObject cms, List<CmsResource> folders) Checks whether the publish list contains all sub-resources of a list of folders.protected boolean
Checks if the publish list contains a resource.protected boolean
containsSubResources
(CmsObject cms, CmsResource folder) Checks if the publish list contains all sub-resources of a given folder.Returns a list of all resources in the publish list, including folders and files.Returns a list of folder resources with the deleted state.Returns the list of resources that should be published for a "direct" publish operation.Returns an unmodifiable list of the files in this publish list.Returns an unmodifiable list of the new/changed folders in this publish list.protected List<CmsResource>
getMissingSubResources
(CmsObject cms, List<CmsResource> folders) Gets the sub-resources of a list of folders which are missing from the publish list.protected List<CmsResource>
getMovedFolders
(CmsObject cms) Internal method to get the moved folders from the publish list.Returns the id of the project that should be published, or-1
if this publish list is initialized for a "direct publish" operation.Returns the publish history Id for this publish list.protected List<CmsResource>
getTopFolders
(List<CmsResource> folders) Gives the "roots" of a list of folders, i.e.Gets the list of moved folders which are not subfolders of other moved folders in the publish list.protected void
Initializes the publish list, ensuring all internal lists are in the right order.boolean
Checks if this is a publish list is used for a "direct publish" operation.boolean
Returnstrue
if all siblings of the project resources are to be published.boolean
Returnstrue
if sub-resources in folders should be published (for direct publish only).boolean
Returns true if this is a user publish list.void
protected boolean
remove
(CmsResource resource) Removes a Cms resource from the publish list.void
Revives the publish list by populating the internal resource lists with
instances.CmsResource
void
setUserPublishList
(boolean isUserPublishList) Sets the 'user publish list' flag on this publish list.int
size()
Returns the number of all resources to be published.toString()
void
-
Constructor Details
-
CmsPublishList
public CmsPublishList()Empty constructor. -
CmsPublishList
public CmsPublishList(boolean all, List<CmsResource> directPublishResources, boolean directPublishSiblings) Constructs a publish list for a list of direct publish resources.- Parameters:
all
- no redundant resource are filtered outdirectPublishResources
- a list of
instances to be published directlyCmsResource
directPublishSiblings
- indicates if all siblings of the selected resources should be published
-
CmsPublishList
Constructs a publish list for a given project.- Parameters:
project
- the project to publish, this should always be the id of the current project
-
CmsPublishList
Constructs a publish list for a single direct publish resource.- Parameters:
directPublishResource
- a VFS resource to be published directlypublishSiblings
- indicates if all siblings of the selected resources should be published
-
CmsPublishList
Constructs a publish list for a list of direct publish resources.- Parameters:
directPublishResources
- a list of
instances to be published directlyCmsResource
publishSiblings
- indicates if all siblings of the selected resources should be published
-
CmsPublishList
public CmsPublishList(List<CmsResource> directPublishResources, boolean publishSiblings, boolean publishSubResources) Constructs a publish list for a list of direct publish resources.- Parameters:
directPublishResources
- a list of
instances to be published directlyCmsResource
publishSiblings
- indicates if all siblings of the selected resources should be publishedpublishSubResources
- indicates if sub-resources in folders should be published (for direct publish only)
-
-
Method Details
-
getAllResources
Returns a list of all resources in the publish list, including folders and files.- Returns:
- a list of
CmsResource
objects
-
getDeletedFolderList
Returns a list of folder resources with the deleted state.- Returns:
- a list of folder resources with the deleted state
-
getDirectPublishResources
Returns the list of resources that should be published for a "direct" publish operation.Will return
null
if this publish list was not initialized for a "direct publish" but for a project publish.- Returns:
- the list of resources that should be published for a "direct" publish operation, or
null
-
getFileList
Returns an unmodifiable list of the files in this publish list.- Returns:
- the list with the files in this publish list
-
getFolderList
Returns an unmodifiable list of the new/changed folders in this publish list.- Returns:
- the list with the new/changed folders in this publish list
-
getProjectId
Returns the id of the project that should be published, or-1
if this publish list is initialized for a "direct publish" operation.- Returns:
- the id of the project that should be published, or
-1
-
getPublishHistoryId
Returns the publish history Id for this publish list.- Returns:
- the publish history Id
-
getTopMovedFolders
Gets the list of moved folders which are not subfolders of other moved folders in the publish list.- Parameters:
cms
- the current cms context- Returns:
- the moved folders which are not subfolders of other moved folders in the publish list
- Throws:
CmsException
- if something goes wrong
-
isDirectPublish
Checks if this is a publish list is used for a "direct publish" operation.- Returns:
- true if this is a publish list is used for a "direct publish" operation
-
isPublishSiblings
Returnstrue
if all siblings of the project resources are to be published.- Returns:
true
if all siblings of the project resources are to be publisheds
-
isPublishSubResources
Returnstrue
if sub-resources in folders should be published (for direct publish only).- Returns:
true
if sub-resources in folders should be published (for direct publish only)
-
isUserPublishList
Returns true if this is a user publish list.- Returns:
- true if this is a user publish list
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
- See Also:
-
revive
Revives the publish list by populating the internal resource lists with
instances.CmsResource
- Parameters:
cms
- a cms object used to read the resource instances
-
setUserPublishList
Sets the 'user publish list' flag on this publish list.- Parameters:
isUserPublishList
- if true, the list is marked as a user publish list
-
size
Returns the number of all resources to be published.- Returns:
- the number of all resources to be published
-
toString
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
- See Also:
-
add
Adds a new/changed Cms folder resource to the publish list.- Parameters:
resource
- a new/changed Cms folder resourcecheck
- if set an exception is thrown if the specified resource is unchanged, if not set the resource is ignored- Throws:
IllegalArgumentException
- if the specified resource is unchanged
-
addAll
protected void addAll(Collection<CmsResource> resources, boolean check) throws IllegalArgumentException Appends all the given resources to this publish list.- Parameters:
resources
- resources to be added to this publish listcheck
- if set an exception is thrown if the a resource is unchanged, if not set the resource is ignored- Throws:
IllegalArgumentException
- if one of the resources is unchanged
-
checkContainsSubResources
protected CmsResource checkContainsSubResources(CmsObject cms, List<CmsResource> folders) throws CmsException Checks whether the publish list contains all sub-resources of a list of folders.- Parameters:
cms
- the current CMS contextfolders
- the folders which should be checked- Returns:
- a folder from the list if one of its sub-resources is not contained in the publish list, otherwise null
- Throws:
CmsException
- if something goes wrong
-
containsResource
Checks if the publish list contains a resource.- Parameters:
res
- the resource- Returns:
- true if the publish list contains a resource
-
containsSubResources
Checks if the publish list contains all sub-resources of a given folder.- Parameters:
cms
- the current CMS contextfolder
- the folder for which the check should be performed- Returns:
- true if the publish list contains all sub-resources of a given folder
- Throws:
CmsException
- if something goes wrong
-
getMissingSubResources
protected List<CmsResource> getMissingSubResources(CmsObject cms, List<CmsResource> folders) throws CmsException Gets the sub-resources of a list of folders which are missing from the publish list.- Parameters:
cms
- the current CMS contextfolders
- the folders which should be checked- Returns:
- a list of missing sub resources
- Throws:
CmsException
- if something goes wrong
-
getMovedFolders
Internal method to get the moved folders from the publish list.- Parameters:
cms
- the current CMS context- Returns:
- the list of moved folders from the publish list
- Throws:
CmsException
- if something goes wrong
-
getTopFolders
Gives the "roots" of a list of folders, i.e. the list of folders which are not descendants of any other folders in the original list- Parameters:
folders
- the original list of folders- Returns:
- the root folders of the list
-
initialize
Initializes the publish list, ensuring all internal lists are in the right order. -
remove
Removes a Cms resource from the publish list.- Parameters:
resource
- a Cms resource- Returns:
- true if this publish list contains the specified resource
- See Also:
-