[opencms-dev] Access resources in another site

Christian Steinert christian_steinert at web.de
Sat Mar 4 15:26:38 CET 2006


Christian Steinert wrote:
> Dear List,
>
> I have a multi-site project. I try to access files that are in another 
> site, because I want to provide cross-links between the two.
> My problem is, that it doesn't seem to be possible to access files of 
> another site.
hi,

Maybe someone's interested...

opencms itself seems to do have no privileged way to do cross-site 
access the CmsStaticExportManager does site-switching before accessing 
other resources
(which came to my mind, but is rather ugly):

        try {
            cms.getRequestContext().saveSiteRoot();
            cms.getRequestContext().setSiteRoot(siteRoot);

            // ... >> access resources of another site << ...

        } finally {
            cms.getRequestContext().restoreSiteRoot();
        }


But if you do something like that, you have to be VERY careful. You must 
make sure that for one session NO TWO THREADS try this at the SAME time.
For that you need to use thread synchronization before executing then 
code above. All threads that belong to the same user must synchronize!


Regards
Christian



More information about the opencms-dev mailing list