public class CmsPublishManager extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
CmsPublishManager.PublishListRemoveMode
Enum for the different publish list remove modes.
|
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_HISTORY_SIZE
The default history size.
|
static boolean |
DEFAULT_QUEUE_PERSISTANCE
The default persistence setting for the publish queue.
|
static int |
DEFAULT_QUEUE_SHUTDOWNTIME
The default shutdown time for the running publish job.
|
Constructor and Description |
---|
CmsPublishManager()
Default constructor used in digester initialization.
|
CmsPublishManager(int historySize,
boolean queuePersistance,
int queueShutdowntime)
Constructor used to create a pre-initialized instance.
|
Modifier and Type | Method and Description |
---|---|
void |
abandonThread()
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.
|
void |
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.
|
void |
disablePublishing()
Disables the publishing of resources.
|
void |
enablePublishing()
Enables the enqeueing of resources for publishing.
|
CmsPublishJobRunning |
getCurrentPublishJob()
Returns the current running publish job.
|
protected CmsPublishEngine |
getEngine()
Returns the currently used publish engine.
|
CmsPublishJobBase |
getJobByPublishHistoryId(CmsUUID publishHistoryId)
Returns a publish job based on its publish history id.
|
java.util.List<CmsPublishJobFinished> |
getPublishHistory()
Returns the publish history list with already publish jobs.
|
java.util.List<CmsPublishJobFinished> |
getPublishHistory(CmsUser user)
Returns the publish history list with already publish jobs, filtered by the given user.
|
int |
getPublishHistorySize()
Returns the publish History Size.
|
CmsPublishList |
getPublishList(CmsObject cms)
Returns a publish list with all new/changed/deleted resources of the current (offline)
project that actually get published.
|
CmsPublishList |
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.
|
CmsPublishList |
getPublishList(CmsObject cms,
java.util.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.
|
CmsPublishList |
getPublishList(CmsObject cms,
java.util.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.
|
CmsPublishList |
getPublishListAll(CmsObject cms,
java.util.List<CmsResource> directPublishResources,
boolean directPublishSiblings,
boolean isUserPublishList)
Returns a publish list with all the given resources, filtered only by state.
|
CmsPublishManager.PublishListRemoveMode |
getPublishListRemoveMode()
Gets the publish list remove mode.
|
CmsPublishListVerifier |
getPublishListVerifier()
Gets the publish job verifier.
|
java.util.List<CmsPublishJobEnqueued> |
getPublishQueue()
Returns the queue with still waiting publish jobs.
|
int |
getPublishQueueShutdowntime()
Returns the amount of time in seconds the system will wait during shutdown for a running publish job.
|
CmsPublishList |
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.
|
java.util.List<CmsResource> |
getUsersPubList(CmsObject cms)
Returns the current user's publish list.
|
void |
initialize(CmsObject cms)
Initializes the publish manager and the publish engine finally.
|
boolean |
isPublishQueuePersistanceEnabled()
Returns if the publish queue is persisted an will be re-initialized on startup.
|
boolean |
isRunning()
Returns the working state, that is if no publish job
is waiting to be processed and there is no current running
publish job.
|
CmsPublishList |
mergePublishLists(CmsObject cms,
CmsPublishList pubList1,
CmsPublishList pubList2)
Returns a new publish list that contains all resources of both given publish lists.
|
CmsUUID |
publishProject(CmsObject cms)
Publishes the current project, printing messages to a shell report.
|
CmsUUID |
publishProject(CmsObject cms,
I_CmsReport report)
Publishes the current project.
|
CmsUUID |
publishProject(CmsObject cms,
I_CmsReport report,
CmsPublishList publishList)
Publishes the resources of a specified publish list.
|
CmsUUID |
publishProject(CmsObject cms,
I_CmsReport report,
CmsResource directPublishResource,
boolean directPublishSiblings)
Direct publishes a specified resource.
|
CmsUUID |
publishResource(CmsObject cms,
java.lang.String resourcename)
Publishes a single resource, printing messages to a shell report.
|
CmsUUID |
publishResource(CmsObject cms,
java.lang.String resourcename,
boolean publishSiblings,
I_CmsReport report)
Publishes a single resource.
|
void |
removePublishListener(I_CmsPublishEventListener listener)
Removes the given publish listener.
|
void |
removeResourceFromUsersPubList(CmsObject cms,
java.util.Collection<CmsUUID> structureIds)
Removes the given resource to the given user's publish list.
|
void |
setPublishEngine(CmsPublishEngine publishEngine)
Sets the publish engine during initialization.
|
void |
setPublishHistorySize(java.lang.String publishHistorySize)
Sets the publish History Size.
|
void |
setPublishListRemoveMode(CmsPublishManager.PublishListRemoveMode publishListRemoveMode)
Sets the publish list remove mode.
|
void |
setPublishQueuePersistance(java.lang.String publishQueuePersistance)
Sets if the publish queue is re-initialized on startup.
|
void |
setPublishQueueShutdowntime(java.lang.String publishQueueShutdowntime)
Sets the publish queue shutdown time.
|
void |
setSecurityManager(CmsSecurityManager securityManager)
Sets the security manager during initialization.
|
void |
startPublishing()
Starts publishing of enqueued publish jobs.
|
void |
stopPublishing()
Stops the publishing of enqueued publish jobs.
|
java.util.Map<java.lang.String,java.util.List<CmsRelation>> |
validateRelations(CmsObject cms,
CmsPublishList publishList,
I_CmsReport report)
Validates the relations for the given resources.
|
void |
waitWhileRunning()
Waits until no publish jobs remain.
|
void |
waitWhileRunning(long ms)
Waits until no publish jobs remain or the given max milliseconds.
|
public static final int DEFAULT_HISTORY_SIZE
public static final boolean DEFAULT_QUEUE_PERSISTANCE
public static final int DEFAULT_QUEUE_SHUTDOWNTIME
public CmsPublishManager()
public CmsPublishManager(int historySize, boolean queuePersistance, int queueShutdowntime)
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 shutdownpublic void abandonThread()
public void abortPublishJob(CmsObject cms, CmsPublishJobEnqueued publishJob, boolean removeJob) throws CmsException, CmsSecurityException, CmsPublishException
cms
- the cms contextpublishJob
- the publish job to abortremoveJob
- indicates if the job will be removed or added to historyCmsException
- if there is some problem during unlocking the resourcesCmsSecurityException
- if the current user has not enough permissionsCmsPublishException
- if the publish job can not been abortedpublic void addPublishListener(I_CmsPublishEventListener listener)
listener
- the publish listener to addpublic void checkCurrentPublishJobThread()
public void disablePublishing()
public void enablePublishing()
public CmsPublishJobRunning getCurrentPublishJob()
public CmsPublishJobBase getJobByPublishHistoryId(CmsUUID publishHistoryId)
The returned publish job may be an enqueued, running or finished publish job.
publishHistoryId
- the publish history id to search fornull
public java.util.List<CmsPublishJobFinished> getPublishHistory()
CmsPublishJobFinished
objectspublic java.util.List<CmsPublishJobFinished> getPublishHistory(CmsUser user)
user
- the user to filter the jobs withCmsPublishJobFinished
objectspublic int getPublishHistorySize()
public CmsPublishListVerifier getPublishListVerifier()
public CmsPublishList getPublishList(CmsObject cms) throws CmsException
cms
- the cms request contextCmsException
- if something goes wrongpublic CmsPublishList getPublishList(CmsObject cms, CmsResource directPublishResource, boolean directPublishSiblings) throws CmsException
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.CmsException
- if something goes wrongpublic CmsPublishList getPublishList(CmsObject cms, java.util.List<CmsResource> directPublishResources, boolean directPublishSiblings) throws CmsException
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.CmsException
- if something goes wrongpublic CmsPublishList getPublishList(CmsObject cms, java.util.List<CmsResource> directPublishResources, boolean directPublishSiblings, boolean publishSubResources) throws CmsException
cms
- the cms request contextdirectPublishResources
- the CmsResource
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)CmsException
- if something goes wrongpublic CmsPublishList getPublishListAll(CmsObject cms, java.util.List<CmsResource> directPublishResources, boolean directPublishSiblings, boolean isUserPublishList) throws CmsException
cms
- the cms request contextdirectPublishResources
- the CmsResource
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 publishCmsException
- if something goes wrongpublic CmsPublishManager.PublishListRemoveMode getPublishListRemoveMode()
public java.util.List<CmsPublishJobEnqueued> getPublishQueue()
CmsPublishJobEnqueued
objectspublic int getPublishQueueShutdowntime()
public CmsPublishList getRelatedResourcesToPublish(CmsObject cms, CmsPublishList publishList) throws CmsException
cms
- the cms request contextpublishList
- the publish list to exclude from resultCmsException
- if something goes wrongpublic byte[] getReportContents(CmsPublishJobFinished publishJob) throws CmsException
publishJob
- the published jobCmsException
- if something goes wrongpublic java.util.List<CmsResource> getUsersPubList(CmsObject cms) throws CmsException
cms
- the current cms contextCmsException
- if something goes wrongpublic void initialize(CmsObject cms) throws CmsException
cms
- an admin cms objectCmsException
- if something goes wrongpublic boolean isPublishQueuePersistanceEnabled()
true
if the publish queue is persistedpublic boolean isRunning()
public CmsPublishList mergePublishLists(CmsObject cms, CmsPublishList pubList1, CmsPublishList pubList2) throws CmsException
cms
- the cms request contextpubList1
- the first publish listpubList2
- the second publish listCmsException
- if something goes wrongpublic CmsUUID publishProject(CmsObject cms) throws java.lang.Exception
cms
- the cms request contextjava.lang.Exception
- if something goes wrongCmsShellReport
public CmsUUID publishProject(CmsObject cms, I_CmsReport report) throws CmsException
cms
- the cms request contextreport
- an instance of I_CmsReport
to print messagesCmsException
- if something goes wrongpublic CmsUUID publishProject(CmsObject cms, I_CmsReport report, CmsPublishList publishList) throws CmsException
cms
- the cms request contextreport
- an instance of I_CmsReport
to print messagespublishList
- a publish listCmsException
- if something goes wronggetPublishList(CmsObject)
,
getPublishList(CmsObject, CmsResource, boolean)
,
getPublishList(CmsObject, List, boolean)
public CmsUUID publishProject(CmsObject cms, I_CmsReport report, CmsResource directPublishResource, boolean directPublishSiblings) throws CmsException
cms
- the cms request contextreport
- an instance of I_CmsReport
to print messagesdirectPublishResource
- a CmsResource
that gets directly published;
or null
if an entire project gets published.directPublishSiblings
- if a CmsResource
that should get published directly is
provided as an argument, all eventual siblings of this resource
get publish too, if this flag is true
.CmsException
- if something goes wrongpublic CmsUUID publishResource(CmsObject cms, java.lang.String resourcename) throws java.lang.Exception
The siblings of the resource will not be published.
cms
- the cms request contextresourcename
- the name of the resource to be publishedjava.lang.Exception
- if something goes wrongCmsShellReport
public CmsUUID publishResource(CmsObject cms, java.lang.String resourcename, boolean publishSiblings, I_CmsReport report) throws java.lang.Exception
cms
- the cms request contextresourcename
- the name of the resource to be publishedpublishSiblings
- if true
, all siblings of the resource are also publishedreport
- the report to write the progress information tojava.lang.Exception
- if something goes wrongpublic void removePublishListener(I_CmsPublishEventListener listener)
listener
- the publish listener to removepublic void removeResourceFromUsersPubList(CmsObject cms, java.util.Collection<CmsUUID> structureIds) throws CmsException
cms
- the current cms contextstructureIds
- the collection of structure IDs to removeCmsException
- if something goes wrongpublic void setPublishEngine(CmsPublishEngine publishEngine)
publishEngine
- the publish engine instancepublic void setPublishHistorySize(java.lang.String publishHistorySize)
publishHistorySize
- the publish History Size to setpublic void setPublishListRemoveMode(CmsPublishManager.PublishListRemoveMode publishListRemoveMode)
publishListRemoveMode
- the publish list remove modepublic void setPublishQueuePersistance(java.lang.String publishQueuePersistance)
publishQueuePersistance
- the persistence flag, parsed as boolean
public void setPublishQueueShutdowntime(java.lang.String publishQueueShutdowntime)
publishQueueShutdowntime
- the shutdown time to set, parsed as int
public void setSecurityManager(CmsSecurityManager securityManager)
securityManager
- the security managerpublic void startPublishing()
public void stopPublishing()
public java.util.Map<java.lang.String,java.util.List<CmsRelation>> validateRelations(CmsObject cms, CmsPublishList publishList, I_CmsReport report) throws java.lang.Exception
cms
- the cms request contextpublishList
- the publish list to validate against the online projectreport
- a report to write the messages toCmsRelation
}
objects)
keyed by root paths
TODO: change return value to List of CmsRelationjava.lang.Exception
- if something goes wrongpublic void waitWhileRunning()
public void waitWhileRunning(long ms)
ms
- the max milliseconds to waitprotected CmsPublishEngine getEngine()