PUT http://<host>:<port>/rest/private/managed-components/template/portal Content-Type: application/zip
Templates allow portal admins to update all existing portal, group and user sites.
Templates can be also used to create new sites.
The following scenarios describe in detail what is the objective of this new feature added into REST API.
Portal with 1000 users and each one with their own dashboard.
A portal admin would like to modify (all or some) dashboards adding changes to dashboard layout or adding new pages and navigation nodes.
This task can be done in past releases using REST management API but in an individual way: exporting all users sites (dashboards), modifying dashboards individually and re-importing them with a MERGE strategy.
Templates can make same operation but using a single template for all or some selected users.
Portal with 100 portal sites created from "templateA" and 50 portal sites created from "templateB".
A portal admin would like to add 2 new pages to all "templateA" based sites and 3 new pages to all "templateB" based sites.
Templates can make this operation using 1 template for "templateA" based sites with new 2 pages and 1 template for "templateB" based sites with 3 new pages.
Portal with 20 different navigation groups.
A portal admin would like to add 3 new pages to 10 navigation groups.
Templates can make this operation using a single template applied to 10 navigation groups.
PUT http://<host>:<port>/rest/private/managed-components/template/portal Content-Type: application/zip
Template file has to be a .zip with following structure:
/portal /portal/template /portal/template/<name_of_template1> /portal/template/<name_of_template1>/navigation.xml /portal/template/<name_of_template1>/pages.xml /portal/template/<name_of_template1>/portal.xml /portal/template/<name_of_template2> /portal/template/<name_of_template2>/navigation.xml /portal/template/<name_of_template2>/pages.xml /portal/template/<name_of_template2>/portal.xml ...
Parameter |
Type |
Default |
Description |
importMode |
String |
merge |
Data import strategy. Possible values: conserve, insert, merge, overwrite |
targetSite |
String |
all sites |
If this targetSite attribute is not present template is applied in all portals created from templates defined in .zip, this attribute allows to filter and define in which sites this operation is performed. This attribute can be multiple. |
$ curl -i -H "Content-Type: application/zip" -u root:gtn -X PUT -T "template-templateA.zip" http://localhost:8080/rest/private/managed-components/template/portal?importMode=merge&targetSite=site1&targetSite=site2 Where template-templateA.zip: portal/template/templateA/navigation.xml portal/template/templateA/pages.xml portal/tempalte/templateA/portal.xml Result: Update only "site1" and "site2" of sites created from template "templateA".
PUT http://<host>:<port>/rest/private/managed-components/template/group Content-Type: application/zip
Template file has to be a .zip with following structure:
/group /group/template /group/template/navigation.xml /group/template/pages.xml /group/template/group.xml
Parameter |
Type |
Default |
Description |
importMode |
String |
merge |
Data import strategy. Possible values: conserve, insert, merge, overwrite |
targetGroup |
String |
all sites |
If this targetGroup attribute is not present template is applied in all group sites, this attribute allows to filter and define in which sites this operation is performed. This attribute can be multiple. |
$ curl -i -H "Content-Type: application/zip" -u root:gtn -X PUT -T "template-group.zip" http://localhost:8080/rest/private/managed-components/template/group?importMode=merge&targetGroup=myorg/mygroup1&targetGroup=myorg/mygroup2 Where template-group.zip: group/template/navigation.xml group/template/pages.xml group/tempalte/group.xml Result: "myorg/mygroup1" and "myorg/mygroup2" groups sites created are updated with MERGE strategy using template defined in template-group.zip.
PUT http://<host>:<port>/rest/private/managed-components/template/user Content-Type: application/zip
Template file has to be a .zip with following structure:
/user /user/template /user/template/navigation.xml /user/template/pages.xml /user/template/user.xml
Parameter |
Type |
Default |
Description |
importMode |
String |
merge |
Data import strategy. Possible values: conserve, insert, merge, overwrite |
targetExpr |
String |
all users |
This attribute defines a search expresion for users sites who will be target of the template operation. This attribute has priority over targetUser attribute. |
targetUser |
String |
all users |
If targetExpr is not defined, targetUser can define user target for template operation. This attribute can be multiple. |
dashboardMode |
String |
none |
Create Dashboard if user has not a previous one. If this attribute is not present template only be applied on users who has a Dashboard created. Possible values: create. |
$ curl -i -H "Content-Type: application/zip" -u root:gtn -X PUT -T "template-user.zip" http://localhost:8080/rest/private/managed-components/template/user?importMode=merge&targetExpr=user* Where template-user.zip: user/template/navigation.xml user/template/pages.xml user/template/user.xml Result: All dashboards from users starting with "user" updated with MERGE strategy using template defined in template-user.zip
The following attachment has a comprehensive set of templates examples and operations:
Creator |
Comment |
|||
ZIP Archive gatein-examples-REST-templates.zip |
47 kB |
Mar 25, 2014 16:00 |
REST templates examples |