Search code examples
alfrescoalfresco-sharealfresco-webscripts

How do I make a programatically changed site dashboard refresh without restarting the Alfresco/Tomcat service?


I've created a web-script module extension and have verified that it works correctly. What it does is takes the dashboard.xml and related page.component-X-Y.type~id~dashboard.xml files from one site, deletes all dashboard related files on another site then copies the source files to the new site that had them deleted.

pseudo-code

var siteDashboard = getDashboard("site1-shortname");
var siteDashboard = renameShortNames("site1-shortname", "short2-shortname");

deleteDashboard("site2-shortname");
createDashboard("site2-shortname", siteDashboard);

renameShortNames just renames the site id inside the dashboard files to the new site's id.

This all works, I've tested and verified it. My problem is that when I go to http://alfrescosite.com/alfresco/s/remoteadm/get/s/sitestore/alfresco/site-data/pages/site/site2-shortname/dashboard.xml it shows me the new dashboard layout from site1-shortname which is the correct behavior but when I go to the actual site's dashboard within Alfresco share it shows the old site2-shortname dashboard. The only way I can get the new dashboard to show is by restarting the Alfresco/Tomcat service. I've even tried looking at the dashboard with a different browser just in case it was a local caching issue but it's not.

Any ideas on how to make the dashboards refresh to the new layout without having to restart the Alfresco/Tomcat service every time?


Solution

  • I figured out what the problem was. The problem was that I was deleting and recreating the dashboard via Remote API calls to the Alfresco Repository and doing it that way was making the appropriate changes but not telling Alfresco Share of those changes.

    The solution was to use a combination the Share root object sitedata to remove the component bindings, delete the components and recreate them through Share so that the changes are automatically updated on the front end without the need for a service restart.

    Basically this ended up being a modified version of the code in customise-dashboard.post.json.js inside Alfresco Share