[opencms-dev] Accessing files with a new CmsObject instance

Thomas Maerz thomasmaerz at gmx.de
Thu Dec 9 20:48:03 CET 2004


bart vandendriessche <bart at nascom.be> writes:

> This code however fails. Any help or tips on this matter are greatly
> appreciated.

Only for OpenCms > 5.0.1

,----
| import org.opencms.file.CmsObject;
| import org.opencms.file.CmsProject;
| import org.opencms.main.CmsException;
| import org.opencms.main.OpenCms;
| 
| // ...
| 
| cmsObject = OpenCms.initCmsObject( "Guest" );
| cmsObject.loginUser( "Admin", "admin" );
|             
| CmsProject cmsProject = cmsObject.readProject( "Offline" );
| cmsObject.getRequestContext().setCurrentProject( cmsProject );
|             
| cmsObject.getRequestContext().setSiteRoot( "/" );
`----

HTH.

Regards,
Thomas




More information about the opencms-dev mailing list