Web Script: org/alfresco/modules/create-site.post
Generated from /share/service/script/org/alfresco/modules/create-site.post on Jun 14, 2026 2:45:07 PM

Script Properties
Id:org/alfresco/modules/create-site.post
Short Name:Create Site Module Repository Call
Description:Will redirect post to the repo to create the site in the repo and then create the preset in the web tier.
Authentication:none
Transaction:none
Method:POST
URL Template:/modules/create-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/create-site.post.desc.xml
<webscript>
   <shortname>Create Site Module Repository Call</shortname>
   <description>
      Will redirect post to the repo to create the site in the repo
      and then create the preset in the web tier.
   </description>
   <format default="json"/>
   <url>/modules/create-site</url>
</webscript>
File: org/alfresco/modules/create-site.post.json.ftl
{
   "success": ${success?string}
<#if code?exists>, "code": ${code}</#if>
<#if error?exists>, "error": "${error}"</#if>
}
File: org/alfresco/modules/create-site.post.json.js
function main()
{
   // Get clients json request as a "normal" js object literal
   var clientRequest = json.toString();
   var clientJSON = eval('(' + clientRequest + ')');

   // Call the repo to create the site
   var scriptRemoteConnector = remote.connect("alfresco");
   var repoResponse = scriptRemoteConnector.post("/api/sites", clientRequest, "application/json");
   if (repoResponse.status == 401)
   {
      status.setCode(repoResponse.status, "error.loggedOut");
      return;
   }
   else
   {
      var repoJSON = eval('(' + repoResponse + ')');

      // Check if we got a positive result
      if (repoJSON.shortName)
      {
         // Yes we did, now create the site in the webtier
         var tokens = new Array();
         tokens["siteid"] = repoJSON.shortName;
         sitedata.newPreset(clientJSON.sitePreset, tokens);

         model.success = true;
      }
      else if (repoJSON.status.code)
      {
         status.setCode(repoJSON.status.code, repoJSON.message);
         return;
      }
   }
}

main();

Store: classpath:alfresco/webscripts

[No implementation files]