[opencms-dev] SOLVED Re: always publish resourceb.html when resourcea.html is published

Achim Westermann achim.westermann at gmx.de
Tue Jul 21 22:35:22 CEST 2009


Hi Marc,

good to see you were able to understand my cryptic keywords. Sometimes I 
feel sorry that I do not have the time to go into detail with more 
elaborated tips. Google, opencms-wiki, this list ... the community and 
last but not least the source code of OpenCms sometimes may provide 
details on how to customize OpenCms to a remarkable level.


Kind Regards,
Achim.

-------------------
Achim Westermann

Alkacon Software GmbH  - The OpenCms Experts
http://www.alkacon.com - http://www.opencms.org


Marc Johnen wrote:
> 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
> 	}
> 
> }
> 



More information about the opencms-dev mailing list