Managing portals using XML

In this recipe, we will see how to set a specific site as the default portal available for the entire portal instance. We will set the Financials site as the default portal of the GateIn instance.

Getting ready

Locate the portal configuration file at the following path in your application server, assuming that we are using JBoss AS:

/gatein.ear/02portal.war/WEB-INF/conf/portal/portal-configuration.xml

Otherwise, if you are using the Tomcat distribution, you should have the same file starting from the portal web application:

/GateIn-3.2.0.Final-tomcat6/webapps/portal/WEB-INF/conf/portal/portal-configuration.xml

How to do it...

  1. Locate the snippet related to the UserPortalConfigService:
    <component>
        <key>org.exoplatform.portal.config.UserPortalConfigService</key>
        <type>org.exoplatform.portal.config.UserPortalConfigService</type>
    …
    </component>

    Tip

    Downloading the example code

    You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

  2. You can change the default.portal value and page.templates.location that are highlighted here:
    <component>
        <key>org.exoplatform.portal.config.UserPortalConfigService</key>
        <type>org.exoplatform.portal.config.UserPortalConfigService</type>
        <component-plugins>
           <component-plugin>
             <name>new.portal.config.user.listener</name>
             <set-method>initListener</set-method>
             <type>org.exoplatform.portal.config.NewPortalConfigListener</type>
             <description>this listener init the portal configuration</description>
             <init-params>
               <value-param>
                 <name>default.portal</name>
                 <description>The default portal for checking db is empty or not</description>
                 <value>financials</value>
               </value-param> 
               <value-param>
                 <name>page.templates.location</name>
                 <description>the path to the location that contains Page templates</description>
             <value>war:/conf/portal/template/pages</value>
               </value-param>
  3. You can also override the default templates for any page type (portal, user, and group):
       <object-param>
                 <name>site.templates.location</name>
                 <description>description</description>
              <object type="org.exoplatform.portal.config.SiteConfigTemplates">
                         <field name="location">
                     <string>war:/conf/portal</string>
                   </field>
                   <field name="portalTemplates">
                     <collection type="java.util.HashSet">
                       <value>
                         <string>basic</string>
                       </value>
                       <value>
                         <string>classic</string>
                       </value>
                  </collection>
                   </field>
                   <field name="groupTemplates">
                     <collection type="java.util.HashSet">
                               <value>
                         <string>group</string>
                       </value>
                            </collection>
                   </field>
                   <field name="userTemplates">
                     <collection type="java.util.HashSet">
                       <value>
                         <string>user</string>
                       </value>
                            </collection>
                   </field>
                 </object>
               </object-param>
  4. Be sure to have completed all the configuration files explained in this chapter. Some sections that are needed are described later.
  5. Save the file and restart the application server and try to access to http://localhost:8080/portal. You should be redirected to the Financials portal at the following URL: http://localhost:8080/portal/financials

How it works…

The extension mechanism provided by GateIn allows overriding the default portal configuration with your own settings. Each portal can be configured in many ways and it is possible to configure each aspect of a portal instance. For example, in the preceding snippet, we have seen the following settings:

  • The default portal is available from the homepage
  • The location of all the default page templates

All the other options that we can override will be described later in the chapter.

Notice that we have assumed that you have created the Financials portal before starting this recipe.

There's more...

If you need to create a new site in the same portal instance, you have to declare the default portal layout in a specific XML navigation file. By taking a look at the examples in the GateIn source code, you will see how to set all parameters.

We are going to create the Financials portal instance by defining the following portal page layout:

  1. Create a new folder financials in the following path: 02portal.war/WEB-INF/conf/portal/portal
  2. Create a new portal.xml file for defining the new portal layout and enter the following:
    <portal-config
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_2 http://www.gatein.org/xml/ns/gatein_objects_1_2"
        xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_2">
      <portal-name>financials</portal-name>
      <label>Financials</label>
      <description>Financials portal</description>
      <locale>en</locale>
      <access-permissions>Everyone</access-permissions>
      <edit-permission>*:/platform/administrators</edit-permission>
      <properties>
        <entry key="sessionAlive">onDemand</entry>
        <entry key="showPortletInfo">0</entry>
      </properties>
        
        <portal-layout>
         <portlet-application>
          <portlet>
            <application-ref>web</application-ref>
            <portlet-ref>BannerPortlet</portlet-ref>
            <preferences>
              <preference>
                <name>template</name>
                <value>par:/groovy/groovy/webui/component/UIBannerPortlet.gtmpl</value>
                <read-only>false</read-only>
              </preference>
            </preferences>
          </portlet>
          <access-permissions>Everyone</access-permissions>
           <show-info-bar>false</show-info-bar>
         </portlet-application>
    
         <portlet-application>
          <portlet>
            <application-ref>web</application-ref>
            <portlet-ref>NavigationPortlet</portlet-ref>
            <preferences>
              <preference>
                <name>useAJAX</name>
                <value>false</value>
                <read-only>false</read-only>
              </preference>
            </preferences>
          </portlet>
          <access-permissions>Everyone</access-permissions>
           <show-info-bar>false</show-info-bar>
         </portlet-application>
          
         <portlet-application>
          <portlet>
            <application-ref>web</application-ref>
            <portlet-ref>BreadcumbsPortlet</portlet-ref>
             <preferences>
                <preference>
                   <name>useAJAX</name>
                   <value>false</value>
                   <read-only>false</read-only>
                </preference>
             </preferences>
          </portlet>
          <access-permissions>Everyone</access-permissions>
           <show-info-bar>false</show-info-bar>
         </portlet-application>
         
         <page-body> </page-body>
         
         <portlet-application>
           <portlet>
             <application-ref>web</application-ref>
             <portlet-ref>FooterPortlet</portlet-ref>
             <preferences>
               <preference>
                 <name>template</name>
                 <value>par:/groovy/groovy/webui/component/UIFooterPortlet.gtmpl</value>
                 <read-only>false</read-only>
               </preference>
             </preferences>
           </portlet>
           <access-permissions>Everyone</access-permissions>
           <show-info-bar>false</show-info-bar>
         </portlet-application>
    
      </portal-layout>
      
    </portal-config>

Notice that the first part of the snippet contains all the parameters that you learned in Chapter 2, Managing Portal Contents using the GUI, the following are related to the creation of a new portal:

  • label: This is the portal label
  • description: A description for the portal instance
  • access-permission: The group that can access the portal
  • edit-permission: The group that can edit the portal
  • sessionAlive: This shows how to manage the user session
  • showPortletInfo: Manages the default behavior information bar
  • page-body: This is the center section of the body for the portal page

Each XML element declared as portlet-application is used to define a specific block for the default layout of the portal page. In this configuration snippet, as you can see, you need to set the following XML sub-elements:

  • application-ref: This is the portlet category
  • portlet-ref: This is the name of the portlet declaration
  • preferences: Sets the portlet preferences
  • access-permissions: Sets permissions to access the portlet
  • show-info-bar: Manages the information bar

See also

  • The Managing portals recipe in Chapter 2, Managing Portal Contents Using the GUI
  • The Managing portal pages using XML recipe
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.76.237