mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-21 18:09:20 +00:00
Remove unmaintained Document Library action webscripts that have been superceded by new functionality (Forms & Advanced Workflow support).
Reminder: /slingshot REST APIs are not public and therefore prone to change between versions without maintaining compatibility. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@22622 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
<webscript>
|
||||
<shortname>assign-workflow</shortname>
|
||||
<description>Document List Action - Assign Workflow</description>
|
||||
<url>/slingshot/doclib/action/assign-workflow</url>
|
||||
<format default="json">argument</format>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
</webscript>
|
@@ -1,2 +0,0 @@
|
||||
<#import "action.lib.ftl" as actionLib />
|
||||
<@actionLib.resultsJSON results=results />
|
@@ -1,147 +0,0 @@
|
||||
<import resource="classpath:/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/action.lib.js">
|
||||
|
||||
/**
|
||||
* Assign Workflow to single/multiple files and single/multiple people action
|
||||
* @method POST
|
||||
*/
|
||||
|
||||
/**
|
||||
* Entrypoint required by action.lib.js
|
||||
*
|
||||
* @method runAction
|
||||
* @param p_params {object} Object literal containing files array
|
||||
* @return {object|null} object representation of action results
|
||||
*/
|
||||
function runAction(p_params)
|
||||
{
|
||||
var result, results = [], file, files = [], i, j, workflowName, assignees, dueDate, description;
|
||||
|
||||
// Must have workflow type
|
||||
if (json.isNull("type"))
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "No workflow type.");
|
||||
return;
|
||||
}
|
||||
workflowName = "jbpm$" + json.get("type");
|
||||
|
||||
// Only add files that aren't containers
|
||||
for (i in p_params.files)
|
||||
{
|
||||
file = search.findNode(p_params.files[i]);
|
||||
if (file !== null && !file.isContainer)
|
||||
{
|
||||
files.push(file);
|
||||
}
|
||||
}
|
||||
|
||||
if (!files || files.length == 0)
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "No files.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Must also have array of people
|
||||
assignees = getMultipleInputValues("people");
|
||||
if (typeof assignees == "string")
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "No people assigned.");
|
||||
return;
|
||||
}
|
||||
if (!assignees || assignees.length == 0)
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "No people assigned.");
|
||||
return;
|
||||
}
|
||||
for (i = 0, j = assignees.length; i < j; i++)
|
||||
{
|
||||
assignees[i] = people.getPerson(assignees[i]);
|
||||
}
|
||||
|
||||
// Date supplied?
|
||||
dueDate = null;
|
||||
if (!json.isNull("date"))
|
||||
{
|
||||
if (json.get("date") != "")
|
||||
{
|
||||
dueDate = new Date(json.get("date"));
|
||||
}
|
||||
}
|
||||
|
||||
// Description supplied?
|
||||
if (!json.isNull("description"))
|
||||
{
|
||||
description = json.get("description");
|
||||
description = description.substr(0, 255);
|
||||
}
|
||||
else
|
||||
{
|
||||
description = "";
|
||||
}
|
||||
|
||||
// Get the workflow definition
|
||||
var workflowDefinition = workflow.getDefinitionByName(workflowName);
|
||||
|
||||
// Create the workflow package to contain the file nodes
|
||||
var workflowPackage = workflow.createPackage();
|
||||
|
||||
// Add each file to the workflowPackage as a child association
|
||||
for (i in files)
|
||||
{
|
||||
file = files[i];
|
||||
result =
|
||||
{
|
||||
nodeRef: file.nodeRef,
|
||||
action: "assignWorkflow",
|
||||
success: false
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
result.id = file.name;
|
||||
result.type = "document";
|
||||
// Add the file as a child assoc of the workflow node
|
||||
workflowPackage.addNode(file);
|
||||
result.success = true;
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
result.id = file.name;
|
||||
result.nodeRef = file.nodeRef;
|
||||
result.success = false;
|
||||
}
|
||||
|
||||
results.push(result);
|
||||
}
|
||||
|
||||
var workflowParameters =
|
||||
{
|
||||
"bpm:workflowDescription": description
|
||||
};
|
||||
|
||||
if (assignees.length == 1)
|
||||
{
|
||||
workflowParameters["bpm:assignee"] = assignees[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
workflowParameters["bpm:assignees"] = assignees;
|
||||
}
|
||||
if (dueDate)
|
||||
{
|
||||
workflowParameters["bpm:workflowDueDate"] = dueDate;
|
||||
}
|
||||
|
||||
var workflowPath = workflowDefinition.startWorkflow(workflowPackage, workflowParameters);
|
||||
|
||||
// Auto-end the start task
|
||||
var tasks = workflowPath.tasks;
|
||||
for (task in tasks)
|
||||
{
|
||||
tasks[task].endTask(null);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/* Bootstrap action script */
|
||||
main();
|
@@ -1,12 +0,0 @@
|
||||
<webscript>
|
||||
<shortname>folder</shortname>
|
||||
<description>Document List Action - Create folder</description>
|
||||
<url>/slingshot/doclib/action/folder/site/{site}/{container}/{path}</url>
|
||||
<url>/slingshot/doclib/action/folder/site/{site}/{container}</url>
|
||||
<url>/slingshot/doclib/action/folder/node/{store_type}/{store_id}/{id}/{path}</url>
|
||||
<url>/slingshot/doclib/action/folder/node/{store_type}/{store_id}/{id}</url>
|
||||
<format default="json">argument</format>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
</webscript>
|
||||
|
@@ -1,2 +0,0 @@
|
||||
<#import "action.lib.ftl" as actionLib />
|
||||
<@actionLib.resultsJSON results=results />
|
@@ -1,85 +0,0 @@
|
||||
<import resource="classpath:/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/action.lib.js">
|
||||
|
||||
/**
|
||||
* Create folder action
|
||||
* @method POST
|
||||
* @param uri {string} /{siteId}/{containerId}/{filepath}
|
||||
* @param json.name {string} New folder name
|
||||
* @param json.title {string} Title metadata
|
||||
* @param json.description {string} Description metadata
|
||||
*/
|
||||
|
||||
/**
|
||||
* Entrypoint required by action.lib.js
|
||||
*
|
||||
* @method runAction
|
||||
* @param p_params {object} common parameters
|
||||
* @return {object|null} object representation of action result
|
||||
*/
|
||||
function runAction(p_params)
|
||||
{
|
||||
var results;
|
||||
|
||||
try
|
||||
{
|
||||
// Mandatory: json.name
|
||||
if (json.isNull("name"))
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "Folder name is a mandatory parameter.");
|
||||
return;
|
||||
}
|
||||
|
||||
var folderName = json.get("name"),
|
||||
destNode = p_params.destNode;
|
||||
|
||||
// Check folder doesn't already exist
|
||||
var existsNode = getAssetNode(destNode, folderName);
|
||||
if (typeof existsNode == "object")
|
||||
{
|
||||
status.setCode(status.STATUS_BAD_REQUEST, "Folder '" + folderName + "' already exists.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Title and description
|
||||
var folderTitle = "",
|
||||
folderDescription = "";
|
||||
if (!json.isNull("title"))
|
||||
{
|
||||
folderTitle = json.get("title");
|
||||
}
|
||||
if (!json.isNull("description"))
|
||||
{
|
||||
folderDescription = json.get("description");
|
||||
}
|
||||
|
||||
// Create the folder and apply metadata
|
||||
var folderNode = destNode.createFolder(folderName);
|
||||
// Always add title & description, default icon
|
||||
folderNode.properties["cm:title"] = folderTitle;
|
||||
folderNode.properties["cm:description"] = folderDescription;
|
||||
folderNode.properties["app:icon"] = "space-icon-default";
|
||||
folderNode.save();
|
||||
// Add uifacets aspect for the web client
|
||||
folderNode.addAspect("app:uifacets");
|
||||
|
||||
// Construct the result object
|
||||
results = [
|
||||
{
|
||||
id: folderName,
|
||||
name: folderName,
|
||||
nodeRef: folderNode.nodeRef.toString(),
|
||||
action: "createFolder",
|
||||
success: true
|
||||
}];
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
status.setCode(status.STATUS_INTERNAL_SERVER_ERROR, e.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/* Bootstrap action script */
|
||||
main();
|
Reference in New Issue
Block a user