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

John Emmer jemmer at avega.com
Mon May 9 22:28:37 CEST 2005





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





More information about the opencms-dev mailing list