[opencms-dev] OpenCMS and portlets.
Alexander Kandzior
alex at opencms.org
Wed Jul 28 16:33:01 CEST 2004
Ivo,
you can't initialize the CmsObject with the "Admin" user. This is a security
contraint. Only the "Guest" user can be initilized that way. However, once
you have the CmsObject with the "Guest" user, you can use the "loginUser()"
method to change the User to Admin. For that you will need to supply the
password of the Admin user.
Try the following code on a JSP in the OpenCms web application:
------------------------------
<%@ page import="org.opencms.main.*, org.opencms.file.*" %>
<% CmsObject cms = OpenCms.initCmsObject("Guest"); %>
<p>Now I am user: <b><%= cms.getRequestContext().currentUser().getName()
%></b></p>
<% cms.loginUser("Admin", "admin"); %>
<p>Now I am user: <b><%= cms.getRequestContext().currentUser().getName()
%></b></p>
------------------------------
Best Regards,
Alex.
Alexander Kandzior
Alkacon Software - The OpenCms Experts
http://www.alkacon.com <http://www.alkacon.com/>
-----Original Message-----
From: opencms-dev-admin at opencms.org [mailto:opencms-dev-admin at opencms.org]
On Behalf Of Ivo Esteves
Sent: Wednesday, July 28, 2004 3:21 PM
To: opencms-dev at opencms.org
Subject: RE: [opencms-dev] OpenCMS and portlets.
Alex
Once again, thanks allot for your help and time.
You gave me good news, because I make deploy of my application (in this case
portlet) in "webapps" directory, so the problems isn't the application
context. So I assume that the problem is in my code.
My problem, is that I get a java.lang.NullPointerException, when I call
OpenCms.initCmsObject("Admin").
The exception occurs in
"org.opencms.main.OpenCmsCore.initCmsObject(OpenCmsCore.java:935)", like
I don't have the source of version 5.3.5, I can't go to source to see what's
happening wrong...
Do you have any idea about what's happening???
Best Regards.
Ivo
-----Original Message-----
From: opencms-dev-admin at opencms.org [mailto:opencms-dev-admin at opencms.org]
On Behalf Of Alexander Kandzior
Sent: quarta-feira, 28 de Julho de 2004 9:13
To: opencms-dev at opencms.org
Subject: RE: [opencms-dev] OpenCMS and portlets.
Ivo,
an application context is a web application deployed in the "webapps" folder
in the ${CATALINA_HOME} directory. OpenCms usually is installed in the
"opencms" directory / application context. In case you want to share an
instance of the OpenCms object, your application must be deployed in the
same directory in "webapps" as OpenCms. Of course, you can rename the
directory name.
I think there is also a way to access one application context from another
in a Servlet, like this:
ServletContext otherContext = getServletContext().getContext("name");
but I did not try using this myself so far.
Best Regards,
Alex.
Alexander Kandzior
Alkacon Software - The OpenCms Experts
http://www.alkacon.com <http://www.alkacon.com/>
-----Original Message-----
From: opencms-dev-admin at opencms.org [mailto:opencms-dev-admin at opencms.org]
On Behalf Of Ivo Esteves
Sent: Tuesday, July 27, 2004 7:40 PM
To: opencms-dev at opencms.org
Subject: RE: [opencms-dev] OpenCMS and portlets.
Hi, again...
In advance, thanks for your quick response. :-)
The version that I'm using is the 5.3.5, so I can use the solution you give
me. But I have a problem and I think that is the application context...
I've OpenCms and portles(eXo platform) running under TomCat 5.0.25. Can you
tell me if the solution should work in this environment?? I already tried
but don't work, maybe TomCat isn't an application context, or maybe I've
done something wrong???
Someone have an idea???
Thanks
Ivo Esteves
-----Original Message-----
From: opencms-dev-admin at opencms.org [mailto:opencms-dev-admin at opencms.org]
On Behalf Of Alexander Kandzior
Sent: sexta-feira, 23 de Julho de 2004 15:52
To: opencms-dev at opencms.org
Subject: RE: [opencms-dev] OpenCMS and portlets.
What version do you use?
If you use the current "stable" release, there is no easy way (without core
code modifications) to get a CmsObject.
This has changed in the current development version (CVS HEAD). In this
version you can get access to a CmsObject using the OpenCms singleton Object
(e.g. using method OpenCms.initCmsObject(String unsername). This just
requires that OpenCms shares an application context with your application.
Best Regards,
Alex.
Alexander Kandzior
Alkacon Software - The OpenCms Experts
http://www.alkacon.com <http://www.alkacon.com/>
-----Original Message-----
From: opencms-dev-admin at opencms.org [mailto:opencms-dev-admin at opencms.org]
On Behalf Of Ivo Esteves
Sent: Friday, July 23, 2004 4:25 PM
To: opencms-dev at opencms.org
Subject: [opencms-dev] OpenCMS and portlets.
Hi,
I'm newbie in OpenCMS.
I'm developing a portal using portlets and we decide to use OpenCMS only to
be the Content Management Service.
To access resources I've got to use the OpenCMS API, so far so good, but I
don't know how to get the CMSObject.
So far I only see examples in JSP, that use CmsJspActionElement class to get
it, but I'm using portlets (Java) and I don't how to get the CMSObject to
access resources,
If anyone has an idea...
Thanks in advance.
Ivo Esteves
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20040728/3bb2c035/attachment.htm>
More information about the opencms-dev
mailing list