[opencms-dev] Getting a CmsResource by means of the resource id

M Butcher mbutcher at grcomputing.net
Fri Jun 25 17:48:01 CEST 2004


Claus,

I think your best bet would be to use CmsObject.readFileHeader() to 
determine whether its a file or a folder, and then use the 
CmsObject.readFile() or readFolder() methods.


CmsResource res = cmso.readFileHeader( resourceName );
if( res.isFolder() ) {
    CmsFolder folder = cmso.readFolder(res);
    ...
} else if( res.isFile() ) {
    CmsFile file = cmso.readFile(res)
    ...
}

And since both CmsFile and CmsFolder are subclasses of CmsResource, you 
can cast them back to CmsResources if you need.

Matt

Claus Priisholm wrote:
> I'm probably overlooking something, but I haven't found a method in the 
> 5.0.1 API that returns a CmsResource object given a resource id. Can 
> anyone point me in the right direction?
> 
> Thanks
> Claus
> 
> 
> 
> OpenCms links & API's: http://www.codedroids.com/community/opencms
> -- 
> Claus Priisholm
> +45 48 22 46 46
> cpr <you know what> codedroids.com
> http://www.codedroids.com
> 
> _______________________________________________
> This mail is send to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://mail.opencms.org/mailman/listinfo/opencms-dev




More information about the opencms-dev mailing list