4 Replies Latest reply on Apr 30, 2008 11:30 AM by soshah

    Access CMS trought a Portlet

    dragonsk1ll

      Hello,

      All is in the title, I want to access the JBoss Portal CMS through a portlet but I don't know how. Can you please tell me how can I proced to do what I want. I run on JBossPortal 2.6.4 GA on Windows Vista.

      Thanks.

        • 1. Re: Access CMS trought a Portlet
          peterj

          To access a file named mydir/myfile.xxx stored in CMS, you can use this URL:

          /portal/content/mydir/myfile.xxx

          Be aware that accessing an HTML file causes the Portal to redirect to the home page (page where the CMS Portlet is located). For all other file types, the file is passed back as-is, making it ideal for things such as displaying images or providing links to download documents.

          • 2. Re: Access CMS trought a Portlet
            dragonsk1ll

            Thanks for your answer but, I don't want to access the CMS by a URL I want to explore the content of the CMS by programmation with a portlet that I develop myself.

            • 3. Re: Access CMS trought a Portlet
              dragonsk1ll

              I found how to proceed to access the CMS by a programatic way but i had to look in source of JBoss Portal... I don't found any documentation about that.
              Here is my solution if that can help somebody:

              CMS CMSService = (CMS)this.getPortletContext().getAttribute("CMS");
              Command listCMD = CMSService.getCommandFactory().createFolderGetListCommand("/");
              Folder mainFolder = (Folder)CMSService.execute(listCMD);
              List l=mainFolder.getFolders();
              Iterator it=l.iterator();
              while(it.hasNext())
              {
               System.out.println(((Folder)(it.next())).getName());
              }
              


              jboss-portlet.xml

              <portlet-app>
               <portlet>
               <portlet-name>NewsWithCms</portlet-name>
               <transaction>
               <trans-attribute>Required</trans-attribute>
               </transaction>
               </portlet>
               <service>
               <service-name>CMS</service-name>
               <service-class>org.jboss.portal.cms.CMS</service-class>
               <service-ref>portal:service=CMS</service-ref>
               </service>
              </portlet-app>
              


              It's work but there always a litle problem, I must include the jboss-portal.sar\portal-cms.sar\portal-cms-lib to compile my portlet but when I deploy it I must remove that jar to avoid a Class Cast Exeption during the execution (java.lang.ClassCastException org.jboss.portal.cms.impl.jcr.JCRCommandFactory).

              • 4. Re: Access CMS trought a Portlet
                soshah

                Your observation is correct and the behavior is expected.

                As far is deployment goes, you do not need to include the cms library with your application. Its already included with the core jboss-portal.sar file.

                For compile time you obviously need it

                Thanks