Search in sources :

Example 11 with RbvStorageException

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);
    }
}
Also used : Message(javax.mail.Message) MimeMessage(javax.mail.internet.MimeMessage) MatchableNotOpenException(com.axway.ats.rbv.model.MatchableNotOpenException) MessagingException(javax.mail.MessagingException) RbvStorageException(com.axway.ats.rbv.model.RbvStorageException)

Example 12 with RbvStorageException

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);
    }
}
Also used : MimePackage(com.axway.ats.action.objects.MimePackage) PackageException(com.axway.ats.action.objects.model.PackageException) RbvStorageException(com.axway.ats.rbv.model.RbvStorageException)

Example 13 with RbvStorageException

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);
    }
}
Also used : Store(javax.mail.Store) RbvStorageException(com.axway.ats.rbv.model.RbvStorageException) NoSuchProviderException(javax.mail.NoSuchProviderException)

Aggregations

RbvStorageException (com.axway.ats.rbv.model.RbvStorageException)13 PackageException (com.axway.ats.action.objects.model.PackageException)5 MatchableNotOpenException (com.axway.ats.rbv.model.MatchableNotOpenException)5 MessagingException (javax.mail.MessagingException)5 FilePackage (com.axway.ats.action.objects.FilePackage)3 FileSystemMetaData (com.axway.ats.rbv.filesystem.FileSystemMetaData)3 PublicAtsApi (com.axway.ats.common.PublicAtsApi)2 BaseTest (com.axway.ats.rbv.BaseTest)2 MatchableAlreadyOpenException (com.axway.ats.rbv.model.MatchableAlreadyOpenException)2 Message (javax.mail.Message)2 MimeMessage (javax.mail.internet.MimeMessage)2 Test (org.junit.Test)2 FileSystemOperations (com.axway.ats.action.filesystem.FileSystemOperations)1 MimePackage (com.axway.ats.action.objects.MimePackage)1 SystemOperations (com.axway.ats.action.system.SystemOperations)1 FileSystemFolder (com.axway.ats.rbv.filesystem.FileSystemFolder)1 FileSystemFolderSearchTerm (com.axway.ats.rbv.filesystem.FileSystemFolderSearchTerm)1 FileSystemStorage (com.axway.ats.rbv.filesystem.FileSystemStorage)1 RbvException (com.axway.ats.rbv.model.RbvException)1 Flags (javax.mail.Flags)1