Web Script: org/alfresco/modules/delete-site.post
Generated from /share/service/script/org/alfresco/modules/delete-site.post on Jun 15, 2026 6:32:41 PM

Script Properties
Id:org/alfresco/modules/delete-site.post
Short Name:Delete Site Module Repository Call
Description:Will redirect post to the repo to delete the site in the repo and then remove the AVM sitestore model object artifacts.
Authentication:none
Transaction:none
Method:POST
URL Template:/modules/delete-site
Format Style:any
Default Format:json
Negotiated Formats:[undefined]
Implementation:class org.alfresco.web.scripts.DeclarativeWebScript
Extensions:[undefined]

Store: classpath:alfresco/site-webscripts

File: org/alfresco/modules/delete-site.post.desc.xml
<webscript>
   <shortname>Delete Site Module Repository Call</shortname>
   <description>
      Will redirect post to the repo to delete the site in the repo
      and then remove the AVM sitestore model object artifacts.
   </description>
   <format default="json"/>
   <url>/modules/delete-site</url>
</webscript>
File: org/alfresco/modules/delete-site.post.json.ftl
{
   "success": ${success?string}
<#if code?exists>, "code": ${code}</#if>
<#if error?exists>, "error": "${error}"</#if>
}
File: org/alfresco/modules/delete-site.post.json.js
function main()
{
   var req = json.toString();
   var reqJSON = eval('(' + req + ')');
   
   // Call the repo to delete the site
   var conn = remote.connect("alfresco");
   var res = conn.del("/api/sites/" + reqJSON.shortName);
   var resJSON = eval('(' + res + ')');
   
   // Check if we got a positive result
   if (resJSON.success)
   {
      // Yes we did - now remove sitestore model artifacts...
      
      // remove dashboard page instance
      var dashboardURL = "site/" + reqJSON.shortName + "/dashboard";
      var dashboardPage = sitedata.getPage(dashboardURL);
      if (dashboardPage != null)
      {
         dashboardPage.remove();
      }
      
      // remove component instances
      var components = sitedata.findComponents("page", null, dashboardURL, null);
      for (var i=0; i < components.length; i++)
      {
         components[i].remove();
      }
      
      // the client will refresh on success
      model.success = true;
   }
   else
   {
      // Error occured - report back to client with the status and message
      status.setCode(resJSON.status.code, resJSON.message);
      model.success = false;
   }
}

main();

Store: classpath:alfresco/webscripts

[No implementation files]