Chapter 4. Model Object for Portal (MOP) Management Extension
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
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
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
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.
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
Path template variables
- site-type
- These are the site types of the portal to include or exclude. Available values are:
portal,group, anduser. - site-name
- The sites to include or exclude. Examples could be
classicand/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
mop managed component resource (root managed resource) is the only resource that accepts the import-resource operation.
4.3.2. Site Layout Resource
portal.xml, group.xml , and user.xml files (depending on site type) used in portal extensions to configure data.
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.8. HTTP Request
GET /mop/portalsites/classic/portal.zip or GET /mop/portalsites/classic/portal?op=export-resource
4.3.3. Page Resource
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.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 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>Example 4.15. HTTP Request
GET /mop/portalsites/classic/pages.zip or GET /mop/portalsites/classic/pages?op=export-resource
4.3.4. Navigation Resource
navigation.xml used in portal extensions to configure data.
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>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>Example 4.22. HTTP Request
GET /mop/portalsites/classic/navigation.zip or GET /mop/portalsites/classic/navigation?op=export-resource
4.3.5. Exporting and Filtering
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
Example 4.24. Export only registry and pageManagement navigation nodes
GET /mop/groupsites/platform/administrators/navigation.zip?filter=nav-uri:/administration/registry,/administration/pageManagement
4.4. Command Line Interface
4.4.1. Resource Paths
Example 4.26. Path of homepage for the classic site
[ /]% cd /mop/portalsites/classic/pages/homepage [homepage]% pwd /mop/portalsites/classic/pages/homepage
Note
Tab key.
4.4.2. Exporting and Filtering
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
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
; 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
4.5. Using Secure Copy Command
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
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'