Bootstrapping Sites - Alfresco Content Services - 23.4 - 23.4 - Ready - Alfresco - external

Alfresco Content Services

Platform
Alfresco
Product
Alfresco Content Services
Release
23.4
License

We will now look at how to bootstrap a site. We can use some of the previously set up users and groups as members for demonstration purposes. First thing we need to do is create the site via Alfresco Share and then export it. We can export the site via the GET /alfresco/s/api/sites/{shortname}/export would use the http://localhost:8080/alfresco/s/api/sites/alfresco-kb/export URL. This will trigger an export of the site as a ZIP file with the following content:

  • Contents.acp (Contains all the content created for the site - set this up as bootstrapView “contents”)
  • Groups.txt (User/Group -> Site Group mapping - set this up as bootstrapView “groups”)
  • People.acp (Contains the User Profile XML - same bootstrap we did above with import-user-profiles.xml or set this up as bootstrapView “people”)
  • Users.acp (Contains the User User XML - same bootstrap we did above with import-user.xml or set this up as bootstrapView “users”)

We have already set up the users above so we need only the Contents.acp and Groups.txt files. We can then bootstrap the site with a special site load patch class as follows:

<beanid="org.alfresco.tutorial.bootstrap.patch.alfrescoKBsiteLoader"class="org.alfresco.repo.admin.patch.impl.SiteLoadPatch"parent="basePatch">
    <property name="id"><value>org.alfresco.tutorial.bootstrap.patch.alfrescoKBsiteLoader</value></property>
    <property name="description"><value>org.alfresco.tutorial.bootstrap.patch.alfrescoKBsiteLoader.description</value></property>
    <property name="fixesFromSchema"><value>0</value></property>
    <property name="fixesToSchema"><value>${version.schema}</value></property>
    <property name="targetSchema"><value>99999</value></property>
    <property name="dependsOn" >
        <list>
            <ref bean="org.alfresco.tutorial.bootstrap.patch.groupMembershipsLoader" />
        </list>
    </property>
    <property name="spacesBootstrap" ref="siteLoadBootstrap-Spaces"/>
    <property name="usersBootstrap" ref="siteLoadBootstrap-Users"/>
    <property name="siteService" ref="siteService"/>
    <property name="authorityService" ref="authorityService"/>
    <property name="behaviorFilter" ref="policyBehaviourFilter"/>
    <property name="siteName">
        <value>alfresco-kb</value>
    </property>
    <property name="bootstrapViews">
        <map>
            <entry key="contents">
                <props>
                    <prop key="location">alfresco/module/bootstrap-content-repo/bootstrap/alfresco-kb-site-contents.acp</prop>
                </props>
            </entry>
            <entry key="groups">
                <props>
                    <prop key="location">alfresco/module/bootstrap-content-repo/bootstrap/alfresco-kb-site-groups.txt</prop>
                </props>
            </entry>
        </map>
    </property>
</bean>

Note that the contents and groups files were renamed. The site load patch also depends on the groupMembershipsLoader so we can be sure that the users have been set up before this patch runs. If we don’t want to set up the users separately we can have the site load patch bootstrap everything like this:

<beanid="org.alfresco.tutorial.bootstrap.patch.alfrescoKBsiteLoader"class="org.alfresco.repo.admin.patch.impl.SiteLoadPatch"parent="basePatch">
        ...
        <property name="bootstrapViews">
        <map>
            <entry key="contents">
                <props>
                    <prop key="location">alfresco/module/bootstrap-content-repo/bootstrap/alfresco-kb-site-contents.acp</prop>
                </props>
            </entry>
            <entry key="groups">
                <props>
                    <prop key="location">alfresco/module/bootstrap-content-repo/bootstrap/alfresco-kb-site-groups.txt</prop>
                </props>
            </entry>
            <entry key="users">
                <props>
                    <prop key="location">alfresco/module/bootstrap-content-repo/bootstrap/Users.acp</prop>
                </props>
            </entry>
            <entry key="people">
                <props>
                    <prop key="location">alfresco/module/bootstrap-content-repo/bootstrap/Users.acp</prop>
                </props>
            </entry>
        </map>
    </property>
</bean>

The id and description properties for the site load patch should be specified in a message resource file as follows:

org.alfresco.tutorial.bootstrap.patch.groupMembershipsLoader.description=Loads the groups KB Consumer and KB Coordinator with 2 users
org.alfresco.tutorial.bootstrap.patch.alfrescoKBsiteLoader=Load Alfresco KB Site