mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Initial cut of IMAP support (disabled by default, to enable move imap sample files into extension folder)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@14279 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
77
config/alfresco/imap/scripts/command-processor.js
Executable file
77
config/alfresco/imap/scripts/command-processor.js
Executable file
@@ -0,0 +1,77 @@
|
||||
<import resource="/Company Home/Data Dictionary/Scripts/command-utils.js">
|
||||
|
||||
function processCommand()
|
||||
{
|
||||
var isEmailed = document.hasAspect("emailserver:emailed");
|
||||
|
||||
logger.log("Command Processor: isEmailed=" + isEmailed);
|
||||
|
||||
if (isEmailed)
|
||||
{
|
||||
// Delete email attachments
|
||||
var attachments = document.assocs["attachments"];
|
||||
if (attachments != null)
|
||||
{
|
||||
for (var i = 0; i < attachments.length; i++)
|
||||
{
|
||||
attachments[i].remove();
|
||||
}
|
||||
}
|
||||
|
||||
var command = document.properties["cm:title"];
|
||||
logger.log("Command Processor: command=" + command);
|
||||
|
||||
var parts = new Array();
|
||||
var str = command;
|
||||
var i = 0;
|
||||
while (true)
|
||||
{
|
||||
var index = str.indexOf("-");
|
||||
if (index == -1)
|
||||
{
|
||||
parts[i] = str;
|
||||
break;
|
||||
}
|
||||
parts[i] = str.substring(0, index);
|
||||
str = str.substr(index + 1);
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// do-<commandName>-<arg1>-...-<argN>
|
||||
if (parts.length < 3 || parts[0].toLowerCase() != "do")
|
||||
{
|
||||
var message = "Unknown command: " + command;
|
||||
logger.log(message);
|
||||
createEmail(message, message, message, false);
|
||||
return;
|
||||
}
|
||||
|
||||
var commandName = parts[1].toLowerCase();
|
||||
var commandFolder = space.childByNamePath(commandName);
|
||||
logger.log("Found '" + commandName + "' command folder: '" + commandFolder + "'");
|
||||
if (commandFolder == null)
|
||||
{
|
||||
var message = "Command Processor: wrong command=" + command;
|
||||
createEmail(message, message, message, false);
|
||||
logger.log(message);
|
||||
return;
|
||||
}
|
||||
|
||||
document.move(commandFolder);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
processCommand();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user