use of javax.mail.Flags.Flag in project nhin-d by DirectProject.
the class MessageServiceImplService method requestStatus.
@Override
public StatusResponseType requestStatus(StatusRefType body) {
List<String> msgs = body.getMessageID();
StatusResponseType response = new StatusResponseType();
try {
checkAuth(response);
Authenticator auth = new SMTPAuthenticator();
Session session = Session.getInstance(imapProps, auth);
session.setDebug(true);
if (msgs.size() > 0) {
Store store = session.getStore(new javax.mail.URLName("imaps://" + username));
store.connect(getImapHost(), Integer.valueOf(getImapPort()).intValue(), username, password);
for (int x = 0; x < msgs.size(); x++) {
String msgid = msgs.get(x);
MessageIDTerm messageIdTerm = new MessageIDTerm(msgid);
IMAPFolder folder = (IMAPFolder) store.getFolder("INBOX");
folder.open(Folder.READ_ONLY);
SearchTerm st = messageIdTerm;
IMAPMessage[] msgsearch = (IMAPMessage[]) folder.search(st);
if (msgsearch.length > 0) {
Flags flags = msgsearch[0].getFlags();
Flag[] inboxflags = flags.getSystemFlags();
String[] listofflags = new String[inboxflags.length];
listofflags = setSystemFlags(inboxflags);
setMessageIdStatus(msgid, listofflags, response.getMessageIDAndStatus());
}
}
}
} catch (AddressException e) {
log.error(e);
} catch (MessagingException e) {
log.error(e);
} catch (Exception e) {
log.error(e);
}
return response;
}
Aggregations