[opencms-dev] Re: CmsObject#readAllProjectResources(id) throwsClassCastException

Alexander Kandzior alex at opencms.org
Tue May 10 09:17:09 CEST 2005


Sure this can't work as the method just returns Strings that define the
project view, not CmsResource objects. Have a look at the JavaDoc.

Best Regards,
Alex.

Alexander Kandzior
Alkacon Software - The OpenCms Experts
http://www.alkacon.com

 

> -----Original Message-----
> From: opencms-dev-bounces at opencms.org 
> [mailto:opencms-dev-bounces at opencms.org] On Behalf Of John Emmer
> Sent: Monday, May 09, 2005 10:29 PM
> To: opencms-dev at opencms.org
> Subject: [opencms-dev] Re: 
> CmsObject#readAllProjectResources(id) throwsClassCastException
> 
> 
> 
> 
> 
> Alexander Kandzior wrote:
> > You are right, the method 
> CmsObject#readAllProjectResources(int) does 
> > not
> work.  ...
> > The replacement method that does work is
> CmsObject#readProjectResources(CmsProject).
> 
> Thanks.  Here's what I'm doing now.  When I build the .war 
> from source, the installation doesn't work, (it says it can't 
> read an XML configuration file), so I've installed the latest 
> beta (3).  Then I'm putting my .class file in the 
> WEB-INF/classes and adding my servlet definition to the 
> web.xml.  The new code is below, and it still gets a 
> ClassCastException when I call resIter.next()
> 
>         PrintWriter out = response.getWriter();
> 
>         try {
> 
>             CmsObject cms = OpenCms.initCmsObject("Guest");
> 
>             cms.loginUser("Admin","admin");
>             out.println("Accessible Projects<BR>");
>             out.println("<UL>");
>             for ( Iterator projIter =
> cms.getAllAccessibleProjects().iterator(); projIter.hasNext();) {
>                 CmsProject project = (CmsProject)projIter.next();
>                 out.println( "<LI>"+project.toString()+"</LI>" );
>                 out.println("Project Resources<BR>");
>                 out.println("<OL>");
>                 List resources = cms.readProjectResources(project);
>                 for ( Iterator resIter = 
> resources.iterator(); resIter.hasNext(); ) {
>                     Object next = resIter.next();
>                     out.println( "<LI>"+next.getClass().toString()+" :
> "+next.toString()+"</LI>");
> //                    CmsResource resource = 
> (CmsResource)resIter.next();
> //                    I_CmsResourceType type =
> OpenCms.getResourceManager().getResourceType(resource.getTypeId());
> //                    out.println(
> "<LI>"+resource.getResourceId().toString()+" : "+type+" : "
> //                            +resource.getName()+" :
> "+resource.getRootPath()+"</LI>" );
>                 }
>                 out.println("</OL>");
>             }
>             out.println("</UL>");
>         } catch (CmsException e) {
>             e.printStackTrace(out);
>         }
> --------------------------------------------------------------
> ---------------
> 
> John Emmer
> Senior Software Engineer
> Avega
> 200 N. Sepulveda, Suite 600   El Segundo, CA 90245
> 310-563-3322    jemmer at avega.com
> 
> 
> 
> 
> _______________________________________________
> This mail is send to you from the opencms-dev mailing list To 
> change your list options, or to unsubscribe from the list, 
> please visit http://mail.opencms.org/mailman/listinfo/opencms-dev
> 
> 




More information about the opencms-dev mailing list