fixed bug not reading text of emails
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/social-mail-servlet@117280 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
93b0031f10
commit
845134a9b7
|
@ -72,7 +72,6 @@ public class PeriodicTask implements Runnable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
//check("pop.isti.cnr.it", "social.post", "kof9044+");
|
|
||||||
check(portalName, host, mailserver_username, password);
|
check(portalName, host, mailserver_username, password);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -113,6 +112,7 @@ public class PeriodicTask implements Runnable {
|
||||||
return SessionManager.getInstance().getASLSession(sessionID, username);
|
return SessionManager.getInstance().getASLSession(sessionID, username);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void check(String portalName, String host, String user, String password) {
|
public void check(String portalName, String host, String user, String password) {
|
||||||
try {
|
try {
|
||||||
MailSSLSocketFactory sf = null;
|
MailSSLSocketFactory sf = null;
|
||||||
|
@ -158,12 +158,11 @@ public class PeriodicTask implements Runnable {
|
||||||
|
|
||||||
String escapedCommentText = Utils.escapeHtmlAndTransformUrl(commentText);
|
String escapedCommentText = Utils.escapeHtmlAndTransformUrl(commentText);
|
||||||
|
|
||||||
|
|
||||||
Address[] froms = message.getFrom();
|
Address[] froms = message.getFrom();
|
||||||
String emailAddress = froms == null ? null : ((InternetAddress) froms[0]).getAddress();
|
String emailAddress = froms == null ? null : ((InternetAddress) froms[0]).getAddress();
|
||||||
|
|
||||||
ASLSession fakeSession = getFakeASLSession(emailAddress);
|
ASLSession fakeSession = getFakeASLSession(emailAddress);
|
||||||
if (commentText.trim().compareTo("") == 0) {//it is a favorite/subscription
|
if (escapedCommentText.trim().compareTo("") == 0) {//it is a favorite/subscription
|
||||||
_log.debug("Found favorite/subscription for feed with subject: " + subject);
|
_log.debug("Found favorite/subscription for feed with subject: " + subject);
|
||||||
favoriteFeed(feedId, fakeSession);
|
favoriteFeed(feedId, fakeSession);
|
||||||
}
|
}
|
||||||
|
@ -282,7 +281,7 @@ public class PeriodicTask implements Runnable {
|
||||||
* @return
|
* @return
|
||||||
* @throws MessagingException
|
* @throws MessagingException
|
||||||
*/
|
*/
|
||||||
private String extractFeedId(Message message) throws MessagingException {
|
private static String extractFeedId(Message message) throws MessagingException {
|
||||||
Address[] emails = message.getRecipients(RecipientType.TO);
|
Address[] emails = message.getRecipients(RecipientType.TO);
|
||||||
String toParse = emails[0].toString();
|
String toParse = emails[0].toString();
|
||||||
int plus = toParse.indexOf('+');
|
int plus = toParse.indexOf('+');
|
||||||
|
@ -299,12 +298,13 @@ public class PeriodicTask implements Runnable {
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private String extractText(String portalName, String subjectId, Message message) throws Exception {
|
private static String extractText(String portalName, String subjectId, Message message) throws Exception {
|
||||||
Object messageContent = message.getContent();
|
Object messageContent = message.getContent();
|
||||||
String toParse = null;
|
String toParse = null;
|
||||||
|
final String SEPARATOR = EmailPlugin.WRITE_ABOVE_TO_REPLY.substring(0, 23);
|
||||||
// Check if content is pure text/html or in parts
|
// Check if content is pure text/html or in parts
|
||||||
if (messageContent instanceof Multipart) {
|
if (messageContent instanceof Multipart) {
|
||||||
_log.debug("Found Multipart Message, getting text part");
|
_log.debug("Found Multipart Message, getting text part ... looking for separator " + SEPARATOR);
|
||||||
Multipart multipart = (Multipart) messageContent;
|
Multipart multipart = (Multipart) messageContent;
|
||||||
BodyPart part = multipart.getBodyPart(0);
|
BodyPart part = multipart.getBodyPart(0);
|
||||||
part.toString();
|
part.toString();
|
||||||
|
@ -318,11 +318,12 @@ public class PeriodicTask implements Runnable {
|
||||||
String[] lines = toParse.split(System.getProperty("line.separator"));
|
String[] lines = toParse.split(System.getProperty("line.separator"));
|
||||||
int until = -1;
|
int until = -1;
|
||||||
for (int i = 0; i < lines.length; i++) {
|
for (int i = 0; i < lines.length; i++) {
|
||||||
if (lines[i].contains(EmailPlugin.WRITE_ABOVE_TO_REPLY)) {
|
if (lines[i].contains(SEPARATOR)) {
|
||||||
until = i;
|
until = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
/*
|
/*
|
||||||
* this is needed to remove the text added by the email client like when you reply, e.g. On <day> <sender> wrote ...
|
* this is needed to remove the text added by the email client like when you reply, e.g. On <day> <sender> wrote ...
|
||||||
|
|
Loading…
Reference in New Issue