this is - /share/page/script/org/alfresco/modules/create-site.post
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()
{
model.success = false;
// 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");
}
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 = [];
tokens["siteid"] = repoJSON.shortName;
sitedata.newPreset(clientJSON.sitePreset, tokens);
model.success = true;
}
else if (repoJSON.status.code)
{
// Default error handler
status.setCode(repoJSON.status.code, repoJSON.message);
}
}
}
main();
Store: classpath:surf/webscripts
[No implementation files]
Store: classpath:webscripts
[No implementation files]