[opencms-dev] simple API question

Joe Desbonnet jdesbonnet at gmail.com
Mon Aug 8 02:03:50 CEST 2005


Sorry,  maybe because it's late but I'm just stuck on a very very
simple problem...

I've got two files in a directory: say a.jpg and b.jpg.

I have the CmsObject ('imgObj') and CmsFile ('imgFile') objects
representing 'a.jpg'.

I need to able to access the content (ie by getting a CmsFile
instance) of b.jpg.

So far I have:

String requestUri = imgObject.getRequestContext().getUri();

CmsResource imgResource = imgObject.readResource(requestUri);


// path of image relative to root of VFS			

String imgRootPath = imgFile.getRootPath();

// path of image relative to root of site

String imgSitePath = imgObject.getSitePath(imgResource);

// path of parent folder relative to root of  VFS

String parentRootPath = CmsFile.getFolderPath(imgRootPath);

// path of parent folder relative to root of site
CmsResource parentResource = ????????????????????;
String parentSitePath = imgObject.setSitePath(parentResource)

I know I can do it by hacking the paths manually with String.spli()
etc, but I'm sure there is a cleaner solution...

Any suggestions? 

Thanks,
Joe.



More information about the opencms-dev mailing list