Chapter 4. Model Object for Portal (MOP) Management Extension

The MOP management extension registers the 'mop' managed component. The managed component is responsible for managing pages, navigation, and site layout. It primarily supports exporting and importing the data through the export-resource and import-resource operations. It also supports the read-config-as-xml operation to expose the portal's metadata as XML.

4.1. Types of Operations

4.1.1. Understanding read-config-as-xml Operation

The read-config-as-xml operation can only be executed on the site layout, pages, and navigation managed resources. The XML format returned is defined by the gatein-objects XSD, which can be found at http://www.gatein.org/xml/ns/. These resources are exposed in the same format a portal extension would accept for importing data into the portal.

4.1.2. Understanding export-resource Operation

The export-resource operation can be executed on any resource of the MOP extension (including the mop component). Since the management system recursively searches for all sub-resources that have export-resource defined (which is defined at the site layout, page, and navigation level), exports can be very granular.

4.1.3. Understanding import-resource Operation

The import-resource operation can only be executed at the mop component (root managed resource of the mop extension). This is because the exported Zip file contains path information (like site type and site name). So executing an import-resource operation on a group site, when the Zip contains data from a portal site, does not make sense.
The MOP import-resource operation defines the importMode attribute as follows during import.

Table 4.1. importMode Attribute

importMode Attribute Description
Conserve Import data only if no artifacts exist for that site. For example, if one page exists for site classic, nothing will be imported.
Insert Import data when data does not exist, otherwise do nothing.
Merge (default) Import data when data does not exist, update data when it does exist.
Overwrite Delete all data for that artifact of the site, then import new data. For example, if the Zip file only contains pages for site classic, then all pages for that site are deleted and the contents of the Zip file imported.

4.2. Using Path Template Variables

The path template variables are defined in the MOP management extension. The path template variables are used for filtering during export operation

Path template variables

site-type
These are the site types of the portal to include or exclude. Available values are: portal , group , and user.
site-name
The sites to include or exclude. Examples could be classic and /platform/administrators.
site-layout
The name of the site layout depending on the site type. Available values are: portal, group, user.
page-name
The name of the page(s) to include or exclude.
nav-uri
The URI of the navigation node to include or exclude.

4.3. REST API Management

4.3.1. MOP Component Resource

The mop managed component resource (root managed resource) is the only resource that accepts the import-resource operation.

Example 4.1. HTTP Request

PUT /mop

Headers:
   Content-Type: application/zip

Example 4.2. HTTP Response

HTTP/1.1 200 OK

4.3.2. Site Layout Resource

The site layout resource represents the site layout of the portal. It is the data defined in the portal.xml, group.xml , and user.xml files (depending on site type) used in portal extensions to configure data.

Example 4.3. URL

URL: /mop/{site-type}sites/{site-name}/{site-layout}

Example 4.4. config-as-xml

Example of reading the site layout as XML for site classic.

Example 4.5. HTTP Request

GET /mop/portalsites/classic/portal.xml

or

GET /mop/portalsites/classic/portal?op=read-config-as-xml

Example 4.6. HTTP Response

HTTP/1.1 200 OK
Content-Type: application/xml

<portal-config>
   <portal-name>classic</portal-name>
   <label>Classic</label>
   <description>GateIn default portal</description>
   <locale>en</locale>
...
</portal-config>

Example 4.7. export-resource

Example of exporting the site layout for site classic.

Example 4.8. HTTP Request

GET /mop/portalsites/classic/portal.zip

or

GET /mop/portalsites/classic/portal?op=export-resource

Example 4.9. HTTP Response

HTTP/1.1 200 OK
Content-Type: application/zip

[binary data]

4.3.3. Page Resource

Pages Resource
The pages resource represents the pages of the portal. It is the data defined in the pages.xml used in portal extensions to configure data.

Example 4.10. URL

URL: /mop/{site-type}sites/{site-name}/pages/{page-name}
config-as-xml
Example of reading all pages as XML for site classic.

Example 4.11. HTTP Request

GET /mop/portalsites/classic/pages.xml

or

GET /mop/portalsites/classic/pages?op=read-config-as-xml

Example 4.12. HTTP Response

HTTP/1.1 200 OK
Content-Type: application/xml

<page-set>
   <page>
      <name>homepage</name>
      <title>Home Page</title>
      <access-permissions>Everyone</access-permissions>
      <edit-permission>*:/platform/administrators</edit-permission>
      <show-max-window>false</show-max-window>
      <portlet-application>
...
</page-set>
Example of reading the homepage as XML for site classic.

Example 4.13. HTTP Request

GET /mop/portalsites/classic/pages/homepage.xml

or

GET /mop/portalsites/classic/pages/homepage?op=read-config-as-xml

Example 4.14. HTTP Response

HTTP/1.1 200 OK
Content-Type: application/xml

<page-set>
   <page>
      <name>homepage</name>
      <title>Home Page</title>
      <access-permissions>Everyone</access-permissions>
      <edit-permission>*:/platform/administrators</edit-permission>
      <show-max-window>false</show-max-window>
      <portlet-application>
...
</page-set>
export-resource
Example of exporting all pages of site classic.

Example 4.15. HTTP Request

GET /mop/portalsites/classic/pages.zip

or

GET /mop/portalsites/classic/pages?op=export-resource

Example 4.16. HTTP Response

HTTP/1.1 200 OK
Content-Type: application/zip

[binary data]

4.3.4. Navigation Resource

Navigation Resource
The navigation resource represents the navigation of the portal. It is the data defined in the navigation.xml used in portal extensions to configure data.

Example 4.17. URL

URL: /mop/{site-type}sites/{site-name}/navigation/{nav-uri}
Examples of Navigation resources
config-as-xml
Example of reading all navigation as XML for site classic.

Example 4.18. HTTP Request

GET /mop/portalsites/classic/navigation.xml

or

GET /mop/portalsites/classic/navigation?op=read-config-as-xml

Example 4.19. HTTP Response

HTTP/1.1 200 OK
Content-Type: application/xml

<node-navigation>
   <priority>1</priority>
   <page-nodes>
      <node>
         <name>home</name>
         <label xml:lang="en">Home</label>
         ...
         <visibility>DISPLAYED</visibility>
         <page-reference>portal::classic::homepage</page-reference>
      </node>
      <node>
         <name>sitemap</name>
...
</node-navigation>
Example of reading the home node as XML for site classic.

Example 4.20. HTTP Request

GET /mop/portalsites/classic/navigation/home.xml

or

GET /mop/portalsites/classic/navigation/home?op=read-config-as-xml

Example 4.21. HTTP Response

HTTP/1.1 200 OK
Content-Type: application/xml

<node-navigation>
   <priority>1</priority>
   <page-nodes>
      <parent-uri></parent-uri>
      <node>
         <name>home</name>
         <label xml:lang="en">Home</label>
         ...
         <visibility>DISPLAYED</visibility>
         <page-reference>portal::classic::homepage</page-reference>
      </node>
   </page-nodes>
</node-navigation>
export-resource
Example of exporting all navigation of site classic.

Example 4.22. HTTP Request

GET /mop/portalsites/classic/navigation.zip

or

GET /mop/portalsites/classic/navigation?op=export-resource

Example 4.23. HTTP Response

HTTP/1.1 200 OK
Content-Type: application/zip

[binary data]

4.3.5. Exporting and Filtering

Filtering is activated when the filter attribute is passed to an export-resource operation. The filter attribute is a multi-value attribute that is passed as request parameters of the HTTP request.

Note

You can either include multiple filter parameters (?filter=foo:bar&filter=baz:foo-bar) or separate via ';' character (?filter=foo:bar;baz:foo-bar)

Example 4.24. Export only registry and pageManagement navigation nodes

GET /mop/groupsites/platform/administrators/navigation.zip?filter=nav-uri:/administration/registry,/administration/pageManagement

Example 4.25. Export all site types but user and group

GET /mop.zip?filter=site-type:!user,group

4.4. Command Line Interface

The commands included in the management component provide us the tools to perform management operations on these MOP artifacts: site layout, pages, and navigation.

4.4.1. Resource Paths

The paths of the MOP resources are exactly the same as the REST URLs (without the URL syntax). For example the path of the homepage for the classic site would be:

Example 4.26. Path of homepage for the classic site

[ /]% cd /mop/portalsites/classic/pages/homepage

[homepage]% pwd
/mop/portalsites/classic/pages/homepage

Note

All resources/paths can be autocompleted by pressing the Tab key.

4.4.2. Exporting and Filtering

Filtering is activated when the filter attribute is passed to an export-resource operation. The filter attribute is a multi-value attribute that is passed to the CLI using the --filter attribute for the export command.

Example 4.27. Export all portal site types

export --file /tmp/mop.zip --filter site-type:portal /mop

Example 4.28. Export all sites types but user

export --file /tmp/mop.zip --filter site-type:!user /mop
The option can be specified multiple times for multiple values.

Example 4.29. Export only the /platform/administrators group site

export --file /tmp/mop.zip --filter site-type:group --filter site-name:/platform/administrators /mop
Also as discussed in the Path Templates section, the filter attribute can separate different path templates by the ; character.

Example 4.30. Export only pages named homepage, navigation named home for site classic

export --file /tmp/classic.zip --filter page-name:homepage;nav-uri:home /mop/portalsites/classic

Important

All three artifacts (site layout, navigation, and pages) are included in export by default. In other words if you do not specify their path template in the filter, the data will be included.

4.5. Using Secure Copy Command

The SCP command can be used to export and import MOP artifacts: site layout, pages, and navigation over different hosts. The following examples assume the portal and CLI is running at host 'example.org' with default ssh port configured to 2000.
The export-resource command is supported on all resources of the MOP extension. Use the following examples as syntax guides to export artifacts based on the configuration of the production network.

Example 4.31. Export MOP artifacts

$ scp -P 2000 'root@example.org:portal:/mop/portalsites/classic' classic.zip $ scp -P 2000 'root@example.org:portal:/mop/portalsites/classic/pages/homepage' homepage.zip $ scp -P 2000 'root@example.org:portal:/mop' mop.zip
The import-resource operation is only supported at the mop resource, so for every import the path must be '/mop'.

Example 4.32. Import MOP artifacts

$ scp -P 2000 classic.zip 'root@example.org:portal:/mop' $ scp -P 2000 homepage.zip 'root@example.org:portal:/mop?importMode=overwrite' $ scp -P 2000 mop.zip 'root@example.org:portal:/mop'