Package org.opencms.publish
Class CmsPublishManager
java.lang.Object
org.opencms.publish.CmsPublishManager
This manager provide access to the publish engine runtime information.
- Since:
- 6.5.5
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Enum for the different publish list remove modes. -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The default history size.static final boolean
The default persistence setting for the publish queue.static final int
The default shutdown time for the running publish job. -
Constructor Summary
ConstructorDescriptionDefault constructor used in digester initialization.CmsPublishManager
(int historySize, boolean queuePersistance, int queueShutdowntime) Constructor used to create a pre-initialized instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Abandons the current publish thread.void
abortPublishJob
(CmsObject cms, CmsPublishJobEnqueued publishJob, boolean removeJob) Aborts the given publish job.void
addPublishListener
(I_CmsPublishEventListener listener) Adds a publish listener to listen on publish events.static void
addSpecialHistoryIdProvider
(Supplier<List<CmsUUID>> provider) Adds provider for history ids that shouldn't be removed by bulk history cleanup operations.void
Check if the thread for the current publish job is still active or was interrupted and so the next job in the queue can be started.int
Cleans up all unreferenced publish history entries except for the ones with a history id provided by the special history id providers.int
cleanupPublishHistory
(CmsObject cms, List<CmsUUID> exceptions) Cleans up all unreferenced publish history entries except for the ones with a history id from the given list of exceptions.int
cleanupPublishHistory
(CmsObject cms, CmsUUID historyId) Removes publish history entries for the given history id.void
Disables the publishing of resources.void
Enables the enqeueing of resources for publishing.Returns the current running publish job.protected CmsPublishEngine
Returns the currently used publish engine.getJobByPublishHistoryId
(CmsUUID publishHistoryId) Returns a publish job based on its publish history id.Returns the publish history list with already publish jobs.getPublishHistory
(CmsUser user) Returns the publish history list with already publish jobs, filtered by the given user.int
Returns the publish History Size.getPublishList
(CmsObject cms) Returns a publish list with all new/changed/deleted resources of the current (offline) project that actually get published.getPublishList
(CmsObject cms, List<CmsResource> directPublishResources, boolean directPublishSiblings) Returns a publish list with all new/changed/deleted resources of the current (offline) project that actually get published for a direct publish of a List of resources.getPublishList
(CmsObject cms, List<CmsResource> directPublishResources, boolean directPublishSiblings, boolean publishSubResources) Returns a publish list with all new/changed/deleted resources of the current (offline) project that actually get published for a direct publish of a List of resources.getPublishList
(CmsObject cms, CmsResource directPublishResource, boolean directPublishSiblings) Returns a publish list with all new/changed/deleted resources of the current (offline) project that actually get published for a direct publish of a single resource.getPublishListAll
(CmsObject cms, List<CmsResource> directPublishResources, boolean directPublishSiblings, boolean isUserPublishList) Returns a publish list with all the given resources, filtered only by state.Gets the publish list remove mode.Gets the publish job verifier.Returns the queue with still waiting publish jobs.int
Returns the amount of time in seconds the system will wait during shutdown for a running publish job.getRelatedResourcesToPublish
(CmsObject cms, CmsPublishList publishList) Returns a new publish list that contains the unpublished resources related to all resources in the given publish list, the related resources exclude all resources in the given publish list and also locked (by other users) resources.byte[]
getReportContents
(CmsPublishJobFinished publishJob) Returns the content of the publish report assigned to the given publish job.getUsersPubList
(CmsObject cms) Returns the current user's publish list.void
initialize
(CmsObject cms) Initializes the publish manager and the publish engine finally.boolean
Returns true if publish history entries should be automatically removed when the corresponding publish job is removed.boolean
Returns if the publish queue is persisted an will be re-initialized on startup.boolean
Returns the working state, that is if no publish job is waiting to be processed and there is no current running publish job.mergePublishLists
(CmsObject cms, CmsPublishList pubList1, CmsPublishList pubList2) Returns a new publish list that contains all resources of both given publish lists.publishProject
(CmsObject cms) Publishes the current project, printing messages to a shell report.publishProject
(CmsObject cms, I_CmsReport report) Publishes the current project.publishProject
(CmsObject cms, I_CmsReport report, CmsPublishList publishList) Publishes the resources of a specified publish list.publishProject
(CmsObject cms, I_CmsReport report, CmsResource directPublishResource, boolean directPublishSiblings) Direct publishes a specified resource.publishResource
(CmsObject cms, String resourcename) Publishes a single resource, printing messages to a shell report.publishResource
(CmsObject cms, String resourcename, boolean publishSiblings, I_CmsReport report) Publishes a single resource.void
Removes the given publish listener.void
removeResourceFromUsersPubList
(CmsObject cms, Collection<CmsUUID> structureIds) Removes the given resource to the given user's publish list.void
Configures automatic removal of publish history entries.void
setPublishEngine
(CmsPublishEngine publishEngine) Sets the publish engine during initialization.void
setPublishHistorySize
(String publishHistorySize) Sets the publish History Size.void
setPublishListRemoveMode
(CmsPublishManager.PublishListRemoveMode publishListRemoveMode) Sets the publish list remove mode.void
setPublishQueuePersistance
(String publishQueuePersistance) Sets if the publish queue is re-initialized on startup.void
setPublishQueueShutdowntime
(String publishQueueShutdowntime) Sets the publish queue shutdown time.void
setSecurityManager
(CmsSecurityManager securityManager) Sets the security manager during initialization.void
Starts publishing of enqueued publish jobs.void
Stops the publishing of enqueued publish jobs.validateRelations
(CmsObject cms, CmsPublishList publishList, I_CmsReport report) Validates the relations for the given resources.void
Waits until no publish jobs remain.void
waitWhileRunning
(long ms) Waits until no publish jobs remain or the given max milliseconds.
-
Field Details
-
DEFAULT_HISTORY_SIZE
The default history size.- See Also:
-
DEFAULT_QUEUE_PERSISTANCE
The default persistence setting for the publish queue.- See Also:
-
DEFAULT_QUEUE_SHUTDOWNTIME
The default shutdown time for the running publish job.- See Also:
-
-
Constructor Details
-
CmsPublishManager
public CmsPublishManager()Default constructor used in digester initialization. -
CmsPublishManager
Constructor used to create a pre-initialized instance.- Parameters:
historySize
- the size of the publish historyqueuePersistance
- indicates if the queue is re-initialized on startupqueueShutdowntime
- the amount of time to wait for a publish job during shutdown
-
-
Method Details
-
addSpecialHistoryIdProvider
Adds provider for history ids that shouldn't be removed by bulk history cleanup operations.- Parameters:
provider
- the provider for special history ids
-
abandonThread
Abandons the current publish thread. -
abortPublishJob
public void abortPublishJob(CmsObject cms, CmsPublishJobEnqueued publishJob, boolean removeJob) throws CmsException, CmsSecurityException, CmsPublishException Aborts the given publish job.- Parameters:
cms
- the cms contextpublishJob
- the publish job to abortremoveJob
- indicates if the job will be removed or added to history- Throws:
CmsException
- if there is some problem during unlocking the resourcesCmsSecurityException
- if the current user has not enough permissionsCmsPublishException
- if the publish job can not been aborted
-
addPublishListener
Adds a publish listener to listen on publish events.- Parameters:
listener
- the publish listener to add
-
checkCurrentPublishJobThread
Check if the thread for the current publish job is still active or was interrupted and so the next job in the queue can be started. -
cleanupPublishHistory
Cleans up all unreferenced publish history entries except for the ones with a history id provided by the special history id providers.- Parameters:
cms
- the CMS context- Returns:
- the number of cleaned up rows
- Throws:
CmsException
- if something goes wrong
-
cleanupPublishHistory
Removes publish history entries for the given history id.- Parameters:
cms
- the CMS contexthistoryId
- a publish history id- Returns:
- the number of cleaned up rows
- Throws:
CmsException
- if something goes wrong
-
cleanupPublishHistory
Cleans up all unreferenced publish history entries except for the ones with a history id from the given list of exceptions.- Parameters:
cms
- the CMS contextexceptions
- the list of exceptional history ids which shouldn't be removed- Returns:
- the number of cleaned up rows
- Throws:
CmsException
- if something goes wrong
-
disablePublishing
Disables the publishing of resources. -
enablePublishing
Enables the enqeueing of resources for publishing. -
getCurrentPublishJob
Returns the current running publish job.- Returns:
- the current running publish job
-
getJobByPublishHistoryId
Returns a publish job based on its publish history id.The returned publish job may be an enqueued, running or finished publish job.
- Parameters:
publishHistoryId
- the publish history id to search for- Returns:
- the publish job with the given publish history id, or
null
-
getPublishHistory
Returns the publish history list with already publish jobs.- Returns:
- a list of
CmsPublishJobFinished
objects
-
getPublishHistory
Returns the publish history list with already publish jobs, filtered by the given user.- Parameters:
user
- the user to filter the jobs with- Returns:
- a list of
CmsPublishJobFinished
objects
-
getPublishHistorySize
Returns the publish History Size.- Returns:
- the publish History Size
-
getPublishList
Returns a publish list with all new/changed/deleted resources of the current (offline) project that actually get published.- Parameters:
cms
- the cms request context- Returns:
- a publish list
- Throws:
CmsException
- if something goes wrong
-
getPublishList
public CmsPublishList getPublishList(CmsObject cms, CmsResource directPublishResource, boolean directPublishSiblings) throws CmsException Returns a publish list with all new/changed/deleted resources of the current (offline) project that actually get published for a direct publish of a single resource.- Parameters:
cms
- the cms request contextdirectPublishResource
- the resource which will be directly publisheddirectPublishSiblings
-true
, if all eventual siblings of the direct published resource should also get published.- Returns:
- a publish list
- Throws:
CmsException
- if something goes wrong
-
getPublishList
public CmsPublishList getPublishList(CmsObject cms, List<CmsResource> directPublishResources, boolean directPublishSiblings) throws CmsException Returns a publish list with all new/changed/deleted resources of the current (offline) project that actually get published for a direct publish of a List of resources.- Parameters:
cms
- the cms request contextdirectPublishResources
- the resources which will be directly publisheddirectPublishSiblings
-true
, if all eventual siblings of the direct published resources should also get published.- Returns:
- a publish list
- Throws:
CmsException
- if something goes wrong
-
getPublishList
public CmsPublishList getPublishList(CmsObject cms, List<CmsResource> directPublishResources, boolean directPublishSiblings, boolean publishSubResources) throws CmsException Returns a publish list with all new/changed/deleted resources of the current (offline) project that actually get published for a direct publish of a List of resources.- Parameters:
cms
- the cms request contextdirectPublishResources
- theCmsResource
objects which will be directly publisheddirectPublishSiblings
-true
, if all eventual siblings of the direct published resources should also get published.publishSubResources
- indicates if sub-resources in folders should be published (for direct publish only)- Returns:
- a publish list
- Throws:
CmsException
- if something goes wrong
-
getPublishListAll
public CmsPublishList getPublishListAll(CmsObject cms, List<CmsResource> directPublishResources, boolean directPublishSiblings, boolean isUserPublishList) throws CmsException Returns a publish list with all the given resources, filtered only by state.- Parameters:
cms
- the cms request contextdirectPublishResources
- theCmsResource
objects which will be directly publisheddirectPublishSiblings
-true
, if all eventual siblings of the direct published resources should also get publishedisUserPublishList
- if true, the publish list consists of resources directly selected by the user to publish- Returns:
- a publish list
- Throws:
CmsException
- if something goes wrong
-
getPublishListRemoveMode
Gets the publish list remove mode.- Returns:
- the publish list remove mode
-
getPublishListVerifier
Gets the publish job verifier.- Returns:
- the publish job verifier
-
getPublishQueue
Returns the queue with still waiting publish jobs.- Returns:
- a list of
CmsPublishJobEnqueued
objects
-
getPublishQueueShutdowntime
Returns the amount of time in seconds the system will wait during shutdown for a running publish job.- Returns:
- the shutdown time for a running publish job
-
getRelatedResourcesToPublish
public CmsPublishList getRelatedResourcesToPublish(CmsObject cms, CmsPublishList publishList) throws CmsException Returns a new publish list that contains the unpublished resources related to all resources in the given publish list, the related resources exclude all resources in the given publish list and also locked (by other users) resources.- Parameters:
cms
- the cms request contextpublishList
- the publish list to exclude from result- Returns:
- a new publish list that contains the related resources
- Throws:
CmsException
- if something goes wrong
-
getReportContents
Returns the content of the publish report assigned to the given publish job.- Parameters:
publishJob
- the published job- Returns:
- the content of the assigned publish report
- Throws:
CmsException
- if something goes wrong
-
getUsersPubList
Returns the current user's publish list.- Parameters:
cms
- the current cms context- Returns:
- the current user's publish list
- Throws:
CmsException
- if something goes wrong
-
initialize
Initializes the publish manager and the publish engine finally.- Parameters:
cms
- an admin cms object- Throws:
CmsException
- if something goes wrong
-
isAutoCleanupHistoryEntries
Returns true if publish history entries should be automatically removed when the corresponding publish job is removed.- Returns:
- true if publish history entries should autoamtically be removed
-
isPublishQueuePersistanceEnabled
Returns if the publish queue is persisted an will be re-initialized on startup.- Returns:
true
if the publish queue is persisted
-
isRunning
Returns the working state, that is if no publish job is waiting to be processed and there is no current running publish job.- Returns:
- the working state
-
mergePublishLists
public CmsPublishList mergePublishLists(CmsObject cms, CmsPublishList pubList1, CmsPublishList pubList2) throws CmsException Returns a new publish list that contains all resources of both given publish lists.- Parameters:
cms
- the cms request contextpubList1
- the first publish listpubList2
- the second publish list- Returns:
- a new publish list that contains all resources of both given publish lists
- Throws:
CmsException
- if something goes wrong
-
publishProject
Publishes the current project, printing messages to a shell report.- Parameters:
cms
- the cms request context- Returns:
- the publish history id of the published project
- Throws:
Exception
- if something goes wrong- See Also:
-
publishProject
Publishes the current project.- Parameters:
cms
- the cms request contextreport
- an instance of
to print messagesI_CmsReport
- Returns:
- the publish history id of the published project
- Throws:
CmsException
- if something goes wrong
-
publishProject
public CmsUUID publishProject(CmsObject cms, I_CmsReport report, CmsPublishList publishList) throws CmsException Publishes the resources of a specified publish list.- Parameters:
cms
- the cms request contextreport
- an instance of
to print messagesI_CmsReport
publishList
- a publish list- Returns:
- the publish history id of the published project
- Throws:
CmsException
- if something goes wrong- See Also:
-
publishProject
public CmsUUID publishProject(CmsObject cms, I_CmsReport report, CmsResource directPublishResource, boolean directPublishSiblings) throws CmsException Direct publishes a specified resource.- Parameters:
cms
- the cms request contextreport
- an instance of
to print messagesI_CmsReport
directPublishResource
- a
that gets directly published; orCmsResource
null
if an entire project gets published.directPublishSiblings
- if a
that should get published directly is provided as an argument, all eventual siblings of this resource get publish too, if this flag isCmsResource
true
.- Returns:
- the publish history id of the published project
- Throws:
CmsException
- if something goes wrong
-
publishResource
Publishes a single resource, printing messages to a shell report.The siblings of the resource will not be published.
- Parameters:
cms
- the cms request contextresourcename
- the name of the resource to be published- Returns:
- the publish history id of the published project
- Throws:
Exception
- if something goes wrong- See Also:
-
publishResource
public CmsUUID publishResource(CmsObject cms, String resourcename, boolean publishSiblings, I_CmsReport report) throws Exception Publishes a single resource.- Parameters:
cms
- the cms request contextresourcename
- the name of the resource to be publishedpublishSiblings
- iftrue
, all siblings of the resource are also publishedreport
- the report to write the progress information to- Returns:
- the publish history id of the published project
- Throws:
Exception
- if something goes wrong
-
removePublishListener
Removes the given publish listener.- Parameters:
listener
- the publish listener to remove
-
removeResourceFromUsersPubList
public void removeResourceFromUsersPubList(CmsObject cms, Collection<CmsUUID> structureIds) throws CmsException Removes the given resource to the given user's publish list.- Parameters:
cms
- the current cms contextstructureIds
- the collection of structure IDs to remove- Throws:
CmsException
- if something goes wrong
-
setAutoCleanupHistoryEntries
Configures automatic removal of publish history entries.- Parameters:
val
- the string value from the configuration
-
setPublishEngine
Sets the publish engine during initialization.- Parameters:
publishEngine
- the publish engine instance
-
setPublishHistorySize
Sets the publish History Size.- Parameters:
publishHistorySize
- the publish History Size to set
-
setPublishListRemoveMode
Sets the publish list remove mode.- Parameters:
publishListRemoveMode
- the publish list remove mode
-
setPublishQueuePersistance
Sets if the publish queue is re-initialized on startup.- Parameters:
publishQueuePersistance
- the persistence flag, parsed asboolean
-
setPublishQueueShutdowntime
Sets the publish queue shutdown time.- Parameters:
publishQueueShutdowntime
- the shutdown time to set, parsed asint
-
setSecurityManager
Sets the security manager during initialization.- Parameters:
securityManager
- the security manager
-
startPublishing
Starts publishing of enqueued publish jobs. -
stopPublishing
Stops the publishing of enqueued publish jobs. -
validateRelations
public Map<String,List<CmsRelation>> validateRelations(CmsObject cms, CmsPublishList publishList, I_CmsReport report) throws Exception Validates the relations for the given resources.- Parameters:
cms
- the cms request contextpublishList
- the publish list to validate against the online projectreport
- a report to write the messages to- Returns:
- a map with lists of invalid links
(
objects) keyed by root paths TODO: change return value to List of CmsRelationCmsRelation
} - Throws:
Exception
- if something goes wrong
-
waitWhileRunning
Waits until no publish jobs remain. -
waitWhileRunning
Waits until no publish jobs remain or the given max milliseconds.- Parameters:
ms
- the max milliseconds to wait
-
getEngine
Returns the currently used publish engine.- Returns:
- the publish engine
-