cmspublishmanager.java
来自「找了很久才找到到源代码」· Java 代码 · 共 697 行 · 第 1/2 页
JAVA
697 行
* 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.<p>
*
* @param cms the cms request context
* @param publishList the publish list to exclude from result
*
* @return a new publish list that contains the related resources
*
* @throws CmsException if something goes wrong
*/
public CmsPublishList getRelatedResourcesToPublish(CmsObject cms, CmsPublishList publishList) throws CmsException {
return m_securityManager.getRelatedResourcesToPublish(
cms.getRequestContext(),
publishList,
CmsRelationFilter.TARGETS.filterStrong());
}
/**
* Returns the content of the publish report assigned to the given publish job.<p>
*
* @param publishJob the published job
* @return the content of the assigned publish report
*
* @throws CmsException if somethign goes wrong
*/
public byte[] getReportContents(CmsPublishJobFinished publishJob) throws CmsException {
return m_publishEngine.getReportContents(publishJob);
}
/**
* Initializes the publish manager and the publish engine finally.<p>
*
* @param cms an admin cms object
*
* @throws CmsException if something goes wrong
*/
public void initialize(CmsObject cms) throws CmsException {
m_publishEngine.initialize(cms, m_publishQueuePersistance, m_publishQueueShutdowntime);
m_frozen = true;
}
/**
* Returns if the publish queue is persisted an will be re-initialized on startup.<p>
*
* @return <code>true</code> if the publish queue is persisted
*/
public boolean isPublishQueuePersistanceEnabled() {
return m_publishQueuePersistance;
}
/**
* Returns the working state, that is if no publish job
* is waiting to be processed and there is no current running
* publish job.<p>
*
* @return the working state
*/
public boolean isRunning() {
return m_publishEngine.isRunning();
}
/**
* Returns a new publish list that contains all resources of both given publish lists.<p>
*
* @param cms the cms request context
* @param pubList1 the first publish list
* @param pubList2 the second publish list
*
* @return a new publish list that contains all resources of both given publish lists
*
* @throws CmsException if something goes wrong
*/
public CmsPublishList mergePublishLists(CmsObject cms, CmsPublishList pubList1, CmsPublishList pubList2)
throws CmsException {
return m_securityManager.mergePublishLists(cms.getRequestContext(), pubList1, pubList2);
}
/**
* Publishes the current project, printing messages to a shell report.<p>
*
* @param cms the cms request context
* @return the publish history id of the published project
*
* @throws Exception if something goes wrong
*
* @see CmsShellReport
*/
public CmsUUID publishProject(CmsObject cms) throws Exception {
return publishProject(cms, new CmsShellReport(cms.getRequestContext().getLocale()));
}
/**
* Publishes the current project.<p>
*
* @param cms the cms request context
* @param report an instance of <code>{@link I_CmsReport}</code> to print messages
*
* @return the publish history id of the published project
*
* @throws CmsException if something goes wrong
*/
public CmsUUID publishProject(CmsObject cms, I_CmsReport report) throws CmsException {
return publishProject(cms, report, getPublishList(cms));
}
/**
* Validates the relations for the given resources.<p>
*
* @param cms the cms request context
* @param publishList the publish list to validate against the online project
* @param report a report to write the messages to
*
* @return a map with lists of invalid links
* (<code>{@link org.opencms.relations.CmsRelation}}</code> objects)
* keyed by root paths
*
* TODO: change return value to List of CmsRelation
*
* @throws Exception if something goes wrong
*/
public Map validateRelations(CmsObject cms, CmsPublishList publishList, I_CmsReport report) throws Exception {
return m_securityManager.validateRelations(cms.getRequestContext(), publishList, report);
}
/**
* Publishes the resources of a specified publish list.<p>
*
* @param cms the cms request context
* @param report an instance of <code>{@link I_CmsReport}</code> to print messages
* @param publishList a publish list
*
* @return the publish history id of the published project
*
* @throws CmsException if something goes wrong
*
* @see #getPublishList(CmsObject)
* @see #getPublishList(CmsObject, CmsResource, boolean)
* @see #getPublishList(CmsObject, List, boolean)
*/
public CmsUUID publishProject(CmsObject cms, I_CmsReport report, CmsPublishList publishList) throws CmsException {
return m_securityManager.publishProject(cms, publishList, report);
}
/**
* Direct publishes a specified resource.<p>
*
* @param cms the cms request context
* @param report an instance of <code>{@link I_CmsReport}</code> to print messages
* @param directPublishResource a <code>{@link CmsResource}</code> that gets directly published;
* or <code>null</code> if an entire project gets published.
* @param directPublishSiblings if a <code>{@link CmsResource}</code> that should get published directly is
* provided as an argument, all eventual siblings of this resource
* get publish too, if this flag is <code>true</code>.
*
* @return the publish history id of the published project
*
* @throws CmsException if something goes wrong
*/
public CmsUUID publishProject(
CmsObject cms,
I_CmsReport report,
CmsResource directPublishResource,
boolean directPublishSiblings) throws CmsException {
return publishProject(cms, report, getPublishList(cms, directPublishResource, directPublishSiblings));
}
/**
* Publishes a single resource, printing messages to a shell report.<p>
*
* The siblings of the resource will not be published.<p>
*
* @param cms the cms request context
* @param resourcename the name of the resource to be published
*
* @return the publish history id of the published project
*
* @throws Exception if something goes wrong
*
* @see CmsShellReport
*/
public CmsUUID publishResource(CmsObject cms, String resourcename) throws Exception {
return publishResource(cms, resourcename, false, new CmsShellReport(cms.getRequestContext().getLocale()));
}
/**
* Publishes a single resource.<p>
*
* @param cms the cms request context
* @param resourcename the name of the resource to be published
* @param publishSiblings if <code>true</code>, all siblings of the resource are also published
* @param report the report to write the progress information to
*
* @return the publish history id of the published project
*
* @throws Exception if something goes wrong
*/
public CmsUUID publishResource(CmsObject cms, String resourcename, boolean publishSiblings, I_CmsReport report)
throws Exception {
CmsResource resource = cms.readResource(resourcename, CmsResourceFilter.ALL);
return publishProject(cms, report, resource, publishSiblings);
}
/**
* Removes the given publish listener.<p>
*
* @param listener the publish listener to remove
*/
public void removePublishListener(I_CmsPublishEventListener listener) {
m_publishEngine.removePublishListener(listener);
}
/**
* Sets the publish engine during initialization.<p>
*
* @param publishEngine the publish engine instance
*/
public void setPublishEngine(CmsPublishEngine publishEngine) {
if (m_frozen) {
throw new CmsRuntimeException(Messages.get().container(Messages.ERR_CONFIG_FROZEN_0));
}
m_publishEngine = publishEngine;
}
/**
* Sets the publish History Size.<p>
*
* @param publishHistorySize the publish History Size to set
*/
public void setPublishHistorySize(String publishHistorySize) {
if (m_frozen) {
throw new CmsRuntimeException(Messages.get().container(Messages.ERR_CONFIG_FROZEN_0));
}
m_publishHistorySize = Integer.parseInt(publishHistorySize);
}
/**
* Sets if the publish queue is re-initialized on startup.<p>
*
* @param publishQueuePersistance the persistance flag, parsed as <code>boolean</code>
*/
public void setPublishQueuePersistance(String publishQueuePersistance) {
if (m_frozen) {
throw new CmsRuntimeException(Messages.get().container(Messages.ERR_CONFIG_FROZEN_0));
}
m_publishQueuePersistance = Boolean.valueOf(publishQueuePersistance).booleanValue();
}
/**
* Sets the publish queue shutdown time.
*
* @param publishQueueShutdowntime the shutdowntime to set, parsed as <code>int</code>
*/
public void setPublishQueueShutdowntime(String publishQueueShutdowntime) {
if (m_frozen) {
throw new CmsRuntimeException(Messages.get().container(Messages.ERR_CONFIG_FROZEN_0));
}
m_publishQueueShutdowntime = Integer.parseInt(publishQueueShutdowntime);
}
/**
* Sets the security manager during initialization.<p>
*
* @param securityManager the security manager
*/
public void setSecurityManager(CmsSecurityManager securityManager) {
if (m_frozen) {
throw new CmsRuntimeException(Messages.get().container(Messages.ERR_CONFIG_FROZEN_0));
}
m_securityManager = securityManager;
}
/**
* Starts publishing of enqueued publish jobs.<p>
*/
public void startPublishing() {
m_publishEngine.startEngine();
}
/**
* Stops the publishing of enqueued publish jobs.<p>
*/
public void stopPublishing() {
m_publishEngine.stopEngine();
}
/**
* Waits until no publish jobs remain.<p>
*/
public void waitWhileRunning() {
waitWhileRunning(Long.MAX_VALUE);
}
/**
* Waits until no publish jobs remain or the given max milliseconds.<p>
*
* @param ms the max milliseconds to wait
*/
public void waitWhileRunning(long ms) {
int i = 0;
// wait until it is done or time is over
synchronized (this) {
while (isRunning() && ((MS_ONE_SECOND * i) <= ms)) {
try {
this.wait(MS_ONE_SECOND); // wait a second
} catch (InterruptedException e) {
// ignore
e.printStackTrace();
}
i++;
}
}
}
/**
* Returns the currently used publish engine.<p>
*
* @return the publish engine
*/
protected CmsPublishEngine getEngine() {
return m_publishEngine;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?