[opencms-dev] MyCmsEventListener and CmsObject

Andras Balogh andras at reea.net
Fri Dec 10 17:00:25 CET 2004


Hello All,

    I have written my CmsEventListener that listens to events of type 
EVENT_PROPERTY_MODIFIED.
Things works as expected and i have 2 available Objects in the data Map a
CmsFile and a CmsProperty.
Now i would like add another property and for this i need a CmsObject i 
supose.
I can grab one as described by Thomas in thread "Accessing files with a 
new CmsObject instance":

<from Thomas Maerz>

,----
| 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( "/" );
`----

</from Thomas Maerz>

but like this  i need to hardcode in the my java class the admin password.
Is there no other way?

Thank you for any suggestion.

Best regards,
Andras.




More information about the opencms-dev mailing list