use of com.axway.ats.rbv.model.RbvStorageException in project ats-framework by Axway.
the class ImapFolder method getAllMetaData.
public List<MetaData> getAllMetaData() throws RbvException {
//first check if the folder is open
if (!isOpen) {
throw new MatchableNotOpenException(getDescription() + " is not open");
}
try {
allMetaDataList.clear();
newMetaDataList.clear();
boolean hasNew = folder.hasNewMessages();
log.debug("Has new messages in folder: " + hasNew);
Message[] imapMessages = folder.getMessages();
for (Message imapMessage : imapMessages) {
ImapMetaData currentMeta = createImapMetaData((MimeMessage) imapMessage);
if (currentMeta != null) {
if (!imapMessage.getFlags().contains(Flags.Flag.FLAGGED)) {
newMetaDataList.add(currentMeta);
}
imapMessage.setFlag(Flags.Flag.FLAGGED, true);
allMetaDataList.add(currentMeta);
}
}
//this was the first pass
isInitialPass = false;
return allMetaDataList;
} catch (MessagingException me) {
throw new RbvStorageException("Could not get meta data from " + getDescription(), me);
}
}
use of com.axway.ats.rbv.model.RbvStorageException in project ats-framework by Axway.
the class ImapFolder method createImapMetaData.
/**
* This method will convert a MIME message to meta data
*
* @param mimeMessage the input MimeMessage instance
* @return the MetaData produced
* @throws RbvStorageException
*/
protected ImapMetaData createImapMetaData(MimeMessage mimeMessage) throws RbvException {
try {
MimePackage mimePackage = new MimePackage(mimeMessage);
ImapMetaData metaData = new ImapMetaData(mimePackage);
return metaData;
} catch (PackageException pe) {
throw new RbvStorageException("Could not get meta data from " + getDescription(), pe);
}
}
use of com.axway.ats.rbv.model.RbvStorageException in project ats-framework by Axway.
the class ImapStorage method getFolder.
public ImapFolder getFolder(SearchTerm searchTerm) throws RbvStorageException {
try {
if (searchTerm.getClass().getName().equals(ImapFolderSearchTerm.class.getName())) {
ImapFolderSearchTerm imapSearchTerm = (ImapFolderSearchTerm) searchTerm;
Store store = session.getStore("imap");
return new ImapFolder(store, imapServerHost, imapSearchTerm.getFolderName(), imapSearchTerm.getUserName(), imapSearchTerm.getPassword());
} else {
throw new RbvStorageException("Search term " + searchTerm.getClass().getSimpleName() + " is not supported");
}
} catch (NoSuchProviderException e) {
throw new RuntimeException("Unable to get IMAP store for host " + imapServerHost, e);
}
}
Aggregations