mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merge IMAP in
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@14947 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -44,7 +44,7 @@ function processCommand()
|
||||
{
|
||||
var message = "Unknown command: " + command;
|
||||
logger.log(message);
|
||||
createEmail(message, message, message, false);
|
||||
createEmail(message, message, message);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ function processCommand()
|
||||
if (commandFolder == null)
|
||||
{
|
||||
var message = "Command Processor: wrong command=" + command;
|
||||
createEmail(message, message, message, false);
|
||||
createEmail(message, message, message);
|
||||
logger.log(message);
|
||||
return;
|
||||
}
|
||||
|
@@ -75,7 +75,17 @@ function createResponseTextHtml(nodes)
|
||||
*/
|
||||
function createContentTextHtml(nodes)
|
||||
{
|
||||
var content = "Command: " + title + "\n<br/><br/>\n";
|
||||
var content ="<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">" +
|
||||
"<html><head>" +
|
||||
"<meta http-equiv=Content-Type content=\"text/html; charset=UTF-8\">" +
|
||||
"<style type=\"text/css\">" +
|
||||
"* {font-family:Verdana,Arial,sans-serif;font-size:11px;}" +
|
||||
".links {border:1px dotted #555555;border-collapse:collapse;width:99%;}" +
|
||||
".links td {border:1px dotted #555555;padding:5px;}" +
|
||||
"</style>" +
|
||||
"</head>" +
|
||||
"<body>" +
|
||||
"<div>" + "Command: " + title + "\n<br/><br/>\n";
|
||||
content += "<table class=\"links\">\n";
|
||||
content += "<thead align=\"center\">";
|
||||
content += "<tr>";
|
||||
@@ -83,7 +93,7 @@ function createContentTextHtml(nodes)
|
||||
content += "<td>Url</td>";
|
||||
content += "<td>Download Url</td>";
|
||||
content += "</tr>";
|
||||
content += "</thead>\n"
|
||||
content += "</thead>\n" + "</div></body></html>";
|
||||
|
||||
|
||||
for (var i = 0; i < nodes.length; i++)
|
||||
@@ -133,7 +143,7 @@ function commandSearch(params)
|
||||
|
||||
if (query == null)
|
||||
{
|
||||
createEmail(errorParameter, errorParameter, errorParameter, false);
|
||||
createEmail(errorParameter, errorParameter, errorParameter);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -154,7 +164,7 @@ function commandSearch(params)
|
||||
}
|
||||
else
|
||||
{
|
||||
createEmail(errorXPathNotValid, errorXPathNotValid, errorXPathNotValid, false);
|
||||
createEmail(errorXPathNotValid, errorXPathNotValid, errorXPathNotValid);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -180,8 +190,8 @@ function commandSearch(params)
|
||||
createEmail(message, message, subject);
|
||||
return;
|
||||
}
|
||||
/*createEmail(createResponseTextHtml(nodes), createContentTextPlain(nodes), subject, true);*/
|
||||
createEmail(createContentTextHtml(nodes), createContentTextPlain(nodes), subject, false);
|
||||
/*createEmail(createContentTextPlain(nodes), createResponseTextHtml(nodes), subject);*/
|
||||
createEmail(createContentTextPlain(nodes), createContentTextHtml(nodes), subject);
|
||||
}
|
||||
/**
|
||||
* Decode subject
|
||||
@@ -224,13 +234,13 @@ function main()
|
||||
else
|
||||
{
|
||||
var message = unknownCommand + ": '" + title + "'";
|
||||
createEmail(message, message, message, false);
|
||||
createEmail(message, message, message);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var message = unknownCommand + ": '" + title + "'";
|
||||
createEmail(message, message, message, false);
|
||||
createEmail(message, message, message);
|
||||
}
|
||||
|
||||
document.remove();
|
||||
|
@@ -1,56 +1,57 @@
|
||||
/**
|
||||
* Create e-mail
|
||||
* contentTextHtml (string) html content
|
||||
* contentTextPlain (string) text content
|
||||
* contentEML (string) content message
|
||||
*/
|
||||
function createEmail(contentTextHtml, contentTextPlain, subject, templateUsed)
|
||||
function createEmail(messageTXT, messageHTML, subject)
|
||||
{
|
||||
var command = document.properties["cm:title"];
|
||||
var userName = person.properties["cm:userName"];
|
||||
|
||||
var inboxFolder = companyhome.childByNamePath("IMAP Home/" + userName + "/INBOX");
|
||||
var imapRoot = imap.getImapHomeRef("INBOX", userName);
|
||||
var inboxFolder = imapRoot.childByNamePath("INBOX");
|
||||
|
||||
if (inboxFolder == null)
|
||||
{
|
||||
logger.log("Command Processor: INBOX folder does't exists.");
|
||||
return;
|
||||
}
|
||||
|
||||
var nextMessageUID = inboxFolder.properties["imap:nextMessageUID"];
|
||||
inboxFolder.properties["imap:nextMessageUID"] = nextMessageUID + 1;
|
||||
inboxFolder.save();
|
||||
|
||||
var response = inboxFolder.createNode("response" + Date.now(), "imap:imapContent");
|
||||
var response = inboxFolder.createNode("response" + Date.now() + ".eml", "cm:content");
|
||||
response.properties["imap:messageFrom"] = "command@alfresco.com";
|
||||
response.properties["imap:messageSubject"] = subject;
|
||||
response.properties["imap:messageTo"] = document.properties["cm:originator"];
|
||||
response.properties["imap:messageCc"] = "";
|
||||
response.properties["imap:messageUID"] = nextMessageUID;
|
||||
response.addAspect("imap:imapContent", null);
|
||||
|
||||
response.content = createRFC822Message("command@alfresco.com", document.properties["cm:originator"], subject, messageTXT, messageHTML);
|
||||
response.save();
|
||||
|
||||
var textBody = response.createNode("Body.txt", "imap:imapBody");
|
||||
textBody.content = contentTextPlain;
|
||||
textBody.save();
|
||||
|
||||
var htmlBody = response.createNode("Body.html", "imap:imapBody");
|
||||
if (templateUsed == true)
|
||||
{
|
||||
htmlBody.content = contentTextHtml;
|
||||
}
|
||||
else
|
||||
{
|
||||
htmlBody.content = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">" +
|
||||
"<html><head>" +
|
||||
"<meta http-equiv=Content-Type content=\"text/html; charset=UTF-8\">" +
|
||||
"<style type=\"text/css\">" +
|
||||
"* {font-family:Verdana,Arial,sans-serif;font-size:11px;}" +
|
||||
".links {border:1px dotted #555555;border-collapse:collapse;width:99%;}" +
|
||||
".links td {border:1px dotted #555555;padding:5px;}" +
|
||||
"</style>" +
|
||||
"</head>" +
|
||||
"<body>" +
|
||||
"<div>" + contentTextHtml + "</div></body></html>";
|
||||
}
|
||||
htmlBody.save();
|
||||
|
||||
function createRFC822Message(from, to, subject, textPart, htmlPart)
|
||||
{
|
||||
var id = new Number(Date.now()).toString(16);
|
||||
var boundary = "----------" + id;
|
||||
var date = new Date().toGMTString();
|
||||
var messageHeaders = "MIME-Version: 1.0\r\n" +
|
||||
"Date: " + date + "\r\n" +
|
||||
"From: " + from + "\r\n" +
|
||||
"To: " + to + "\r\n" +
|
||||
"Subject: " + subject + "\r\n" +
|
||||
"Message-ID: " + id + "\r\n" +
|
||||
"X-Priority: 3 (Normal)\r\n" +
|
||||
"Content-Type: multipart/alternative; boundary=\"" + boundary + "\"\r\n\r\n";
|
||||
var messageBody = "";
|
||||
messageBody += messageHeaders;
|
||||
messageBody += "--" + boundary + "\r\n";
|
||||
messageBody += "Content-Type: text/plain; charset=utf-8\r\n";
|
||||
//TODO Content-Transfer-Encoding
|
||||
messageBody += "\r\n";
|
||||
messageBody += textPart + "\r\n\r\n";
|
||||
messageBody += "--" + boundary + "\r\n";
|
||||
messageBody += "Content-Type: text/html; charset=utf-8\r\n";
|
||||
//TODO Content-Transfer-Encoding
|
||||
messageBody += "\r\n";
|
||||
messageBody += htmlPart + "\r\n\r\n";
|
||||
messageBody += "--" + boundary + "--\r\n\r\n";
|
||||
return messageBody;
|
||||
}
|
Reference in New Issue
Block a user