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

Marc Johnen opencms at johnen.biz
Wed Jul 22 11:30:26 CEST 2009


Hi Achim,

actually I was quite happy about you as an Alkacon-employee answering
a lot of questions, this is a big improvement. 
Also the community is slowly doing more and there are more modules
coming up (many don't seem to make an entry on the website, which
is a pitty).
I try to make it a habbit answering one or two questions before I
ask one myself.

Greetings
Marc


Achim Westermann-2 wrote:
> 
> 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
>> 	}
>> 
>> }
>> 
> 
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev
> 
> 

-- 
View this message in context: http://www.nabble.com/publish-resourceb.html-when-resourcea.html-is-published-tp24495047p24602890.html
Sent from the OpenCMS - Dev mailing list archive at Nabble.com.




More information about the opencms-dev mailing list