[opencms-dev] How to make CmsObject use offline project instead of online (createSibling problem)?

Jani Kankaanpää Jani.Kankaanpaa at eget.fi
Tue May 23 14:36:32 CEST 2006


Hi,

I'm trying to create a sibling (with a different locale) automatically when a user creates a new html resource for a site in offline mode. The problem is that by default OpenCms object uses the project in online mode and I don't know how to make it use offline project instead. Currently, when I try to create a sibling, I get CmsVfsResourceNotFoundException. When I try cmsObject.existsResource(myResource.getRootPath()), it returns false (for unpublished resources).

Here's the relevant part of the code:

---
public class MyActionClass implements I_CmsModuleAction {

  private CmsObject cms = null;
	
  public void initialize(CmsObject _cms, CmsConfigurationManager arg1, CmsModule arg2) {
		OpenCms.addCmsEventListener(this);
		cms = _cms;
  }

  public void cmsEvent(CmsEvent event) {
		// Do stuff to figure out that a new resource was created
		// and we want to create a sibling of it
		String src = "/sites/default/mysite/index.html";
		String dest = "/sites/default/mysite/fi/index.html";
		List props = new ArrayList();
		try {
			cms.createSibling(src, dest, props);
		} catch (Exception e) {
			// we get org.opencms.file.CmsVfsResourceNotFoundException
                  // The VFS folder '/sites/default/mysite/fi' DOES exist
		}
  }

}
---

Any ideas? How can I force CmsObject to do createSibling, existsResource, and other actions on offline project instead of online project?

Br, Jani



More information about the opencms-dev mailing list