creating pages using the API [Our Ref:CPTEE8C7 Your Ref:CPTB3A81]

[email protected]
Newsgroups gmane.comp.cms.jahia.template
Message-ID <OFE02E948B.250E0AB1-ON42256F04.003EE8C7-42256F04.0041398C@crb.apmoller.net>
hi there,

I've created a servlet in the Jahia context, from which I can get the 
sites base service (JahiaSitesBaseService.getInstance()), page base 
service (JahiaPageBaseService.getInstance()), etc -- the getInstance() 
methods work.  I now wish to call this servlet from my portlet.

I'm trying to create a page using the API.  It looks like I should use 
JahiaPageBaseService.createPage.  I'm having trouble constructing the last 
argument - ParamBean.

When running the servlet by typing in the URL in a browser, setting the 
parameter to NULL I get a NullPointerException.

I use the following code to run the servlet from my portlet:
        URL url = new 
URL("http://localhost:8080/jahia/CreatePersonalHomePage");
        HttpURLConnection con = (HttpURLConnection)url.openConnection();
        con.setRequestMethod("POST");
        con.setDoInput(true);
        con.setDoOutput(true);
        con.setUseCaches(false); 
        con.getInputStream();

In my servlet, I construct my parambean as follows -- I construct the 
parambean and call createPage from the "service" method of my servlet:
        ParamBean paramBean =
                new ParamBean(
                        request,
                        response,
                        this.getServletContext(),
                        settingsBean,
                        System.currentTimeMillis(),
                        1);

I construct settingsBean as follows:
        String licenseFilename =
 
"C:\\jahia404_build5822\\tomcat\\webapps\\jahia\\WEB-INF\\etc\\config\\license.xml";
        String propertiesFilename =
 "C:\\jahia404_build5822\\tomcat\\webapps\\jahia\\WEB-INF\\etc\\config";
        SettingsBean settingsBean =
                new SettingsBean(this.config, propertiesFilename, 
licenseFilename, 6131);

create page looks as follows:
        svc.createPage(
                1,
                0,
                JahiaPage.TYPE_DIRECT,
                "my personal page",
                25,
                "http://",
                0,
                "thepage",
                -8,
                paramBean);

Problem: the process appears to hang - the last output on my tomcat 
console is as follows:
 64297 DEBUG 
org.jahia.services.database.ConnectionDispenser.getConnection:195 - 
Retrieving new onnection from pool..
 64328 DEBUG org.jahia.bin.JahiaWebAppListener.sessionCreated:32 - Session 
093E81F94E6D374963AC8558475636FE was just created...
 64328 DEBUG org.jahia.params.ParamBean.getSiteInfos:1598 - Can't find 
site in serverName, trying to reverse from page ID...
 64328 DEBUG org.jahia.params.ParamBean.getSiteInfos:1647 - No site found 
in URL, serverName or via page ID, going to default site...

My browser displays an empty page, and looks like it is still waiting for 
a response (the icon in the top-right corner continues spinning).

Am I on the right track for creating pages? How should I construct 
paramBean?

thanks,
Manoj









[email protected] 
2004/09/02 10:14 AM
Please respond to
[email protected]


To
[email protected]
cc

Subject
Re: how to use ServicesRegistry? 






        OREF:CPTB3A81





Hi,

This is probably the same problem of trying to call the Jahia API from a 
servlet in another context. Please read the Web application developer 
guide.

Regards,
  Serge Huber.

[email protected] wrote:

>
> hi there,
>
> I wish to create pages using the Jahia API.  It looks like I've got to 
> use ServicesRegistry (ServicesRegistry.getInstance 
> ().getJahiaPageTemplateService(), etc).  From my servlet, I've got the 
> code ServicesRegistry.getInstance() but that returns an exception and 
> my servlet doesn't render -- I've attached the console output (as well 
> as the exception) below.
>
> What setup do I have to do before calling ServicesRegistry.getInstance 
> ()?
>
> thanks,
> Manoj
>
>
> 
> To
>                [email protected]
> cc
> 
> Subject
>                JahiaSitesBaseService API
>
>
>
> 
>
>
>
> 
>         OREF:CPT60548 
>
>
>
>
> hi there,
>
> I'm trying to use the Jahia API to create pages and then to set ACLs 
> on the pages.
>
> As a starting point, I'm trying to use the JahiaService classes - like 
> JahiaSitesBaseService to get a handle to the site and then perhaps 
> JahiaPageBaseService to get a handle to a page.
>
> When calling the static getInstance() methods  from my servlet, I get 
> an exception (extract attached below).  What is the correct way of 
> using the API? Should I be able to use the JahiaServices from my 
> servlets?
>
> 756594 DEBUG org.jahia.exceptions.JahiaException.dispatchRequest:335 - 
> called.
> org.jahia.exceptions.JahiaException: Can't access application 
> NCOP_Portlet_Test, Servlet Exception occured in getAppOutput 
> dispatching process ! Message = [javax.servlet.ServletException: Error 
> instantiating servlet class org.ncop.minimal.HelloServlet], root 
> cause:Error instantiating servlet class org.ncop.minimal.HelloServlet 
> root cause=javax.servlet.ServletException: Error instantiating servlet 
> class org.ncop.minimal.HelloServlet
>         at 
> 
org.jahia.services.applications.JahiaApplicationsDispatchingServletService.dispatchRequest(JahiaApplicationsDispatchingServletService.java:335) 

>
>         at 
> 
org.jahia.services.applications.JahiaApplicationsDispatchingServletService.getAppOutputNoAction(JahiaApplicationsDispatchingServletService.java:653) 

>
>         at 
> 
org.jahia.services.applications.JahiaApplicationsDispatchingServletService.getAppOutput(JahiaApplicationsDispatchingServletService.java:910) 

>
>         at 
> 
org.jahia.services.fields.ContentApplicationField.getValue(ContentApplicationField.java:102) 

>
>         at 
> org.jahia.services.fields.ContentField.getValue(ContentField.java:265)
>         at 
> 
org.jahia.data.fields.JahiaApplicationField.load(JahiaApplicationField.java:65) 

>
>         at 
> 
org.jahia.services.fields.JahiaFieldBaseService.loadField(JahiaFieldBaseService.java:811) 

>
>         at 
> 
org.jahia.services.fields.JahiaFieldBaseService.loadField(JahiaFieldBaseService.java:774) 

>
>         at 
> 
org.jahia.services.containers.ContainerFactory.fullyLoadContainer(ContainerFactory.java:147) 

>
>         at 
> 
org.jahia.services.containers.ContainerFactoryProxy.load(ContainerFactoryProxy.java:136) 

>
>         at 
> 
org.jahia.data.containers.JahiaContainer.checkProxy(JahiaContainer.java:870) 

>
>         at 
> 
org.jahia.data.containers.JahiaContainer.getField(JahiaContainer.java:462) 

>
>         at 
> 
org.jahia.taglibs.field.AbstractFieldTag.doStartTag(AbstractFieldTag.java:142) 

>
>
> thanks,
> Manoj
>
>
> This e-mail is intended exclusively for the addressee.
> If you are not the addressee you must not read, copy, use or disclose
> the e-mail nor the content; please notify us immediately (by clicking 
> "Reply") and delete this e-mail.
>




This e-mail is intended exclusively for the addressee.
If you are not the addressee you must not read, copy, use or disclose
the e-mail nor the content; please notify us immediately (by clicking "Reply") and delete this e-mail.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.