[opencms-dev] SOLVED Re: always publish resourceb.html when resourcea.html is published
Marc Johnen
opencms at johnen.biz
Tue Jul 21 20:54:17 CEST 2009
Thanks again Achim,
in case anyone tries to do the same here is my (not quite finished) code.
Greetings
Marc
public class EventListener implements I_CmsModuleAction {
private CmsObject cmsObject;
public EventListener() {
// intentionally left blank
}
public void initialize(CmsObject adminCms, CmsConfigurationManager
configurationManager, CmsModule module) {
int[] eventTypes = {I_CmsEventListener.EVENT_PUBLISH_PROJECT,
I_CmsEventListener.EVENT_BEFORE_PUBLISH_PROJECT,
I_CmsEventListener.EVENT_RESOURCE_MODIFIED};
OpenCms.addCmsEventListener(this, eventTypes);
this.cmsObject = adminCms;
}
/**
* Implements the CmsEvent interface.
* <p>
*
* @param event CmsEvent that has occurred
*/
public void cmsEvent(CmsEvent event) {
// den Report holen, um etwas ausgeben zu koennen
I_CmsReport report = (I_CmsReport) event.getData().get("report");
Map m_eventData = event.getData();
switch (event.getType()) {
// ****************************************************
// a resource was changed
// ****************************************************
case I_CmsEventListener.EVENT_RESOURCE_MODIFIED:
if (o_eventRes.getRootPath().equals("/sites/mysite/index.html")) {
if (LOG.isInfoEnabled()) {LOG.info("Starting touching RSS-Feed");}
try {
CmsRequestContext context = cmsObject.getRequestContext();
// Projekt setzen (muss Offline sein)
CmsProject o_offlineProject = cmsObject.readProject("Offline");
context.setCurrentProject(o_offlineProject);
String folder = "/system/modules/mytemplate/resources/feed.rss";
cmsObject.lockResource(folder);
cmsObject.setDateLastModified(folder,System.currentTimeMillis(),true);
cmsObject.unlockResource(folder);
} catch (Exception e4) {
LOG.warn("Error touching RSS-Feed" , e4);
}
}
break;
// ****************************************************
// something was published
// ****************************************************
case I_CmsEventListener.EVENT_PUBLISH_PROJECT:
...
cmsObject.publishResource("/system/modules/mytemplate/resources/feed.rss");
...
break;
default:
// no operation
} // end switch
}
public void moduleUninstall(CmsModule module) {
// intentionally left blank
}
public void moduleUpdate(CmsModule module) {
// intentionally left blank
}
public void publishProject(CmsObject cms, CmsPublishList publishList, int
backupTagId, I_CmsReport report) {
// intentionally left blank
}
public void shutDown(CmsModule module) {
// intentionally left blank
}
}
--
View this message in context: http://www.nabble.com/publish-resourceb.html-when-resourcea.html-is-published-tp24495047p24593387.html
Sent from the OpenCMS - Dev mailing list archive at Nabble.com.
More information about the opencms-dev
mailing list