Search in sources :

Example 6 with RbvStorageException

use of com.axway.ats.rbv.model.RbvStorageException in project ats-framework by Axway.

the class FileSystemFolder method open.

public void open() throws RbvStorageException {
    //first check if the folder is already open
    if (isOpen) {
        throw new MatchableAlreadyOpenException("File system folder is already open");
    }
    try {
        //get the name of the OS
        this.osType = this.systemOperations.getOperatingSystemType();
        // provide path valid for the target host
        this.path = IoUtils.normalizeDirPath(path, this.osType);
    } catch (Exception e) {
        throw new RbvStorageException("Could not open " + getDescription(), e);
    }
    isOpen = true;
}
Also used : MatchableAlreadyOpenException(com.axway.ats.rbv.model.MatchableAlreadyOpenException) RbvStorageException(com.axway.ats.rbv.model.RbvStorageException) MatchableAlreadyOpenException(com.axway.ats.rbv.model.MatchableAlreadyOpenException) MatchableNotOpenException(com.axway.ats.rbv.model.MatchableNotOpenException) RbvException(com.axway.ats.rbv.model.RbvException) PackageException(com.axway.ats.action.objects.model.PackageException) RbvStorageException(com.axway.ats.rbv.model.RbvStorageException)

Example 7 with RbvStorageException

use of com.axway.ats.rbv.model.RbvStorageException in project ats-framework by Axway.

the class FileModtimeRule method performMatch.

@Override
public boolean performMatch(MetaData metaData) throws RbvException {
    boolean actualResult = false;
    if (metaData instanceof FileSystemMetaData) {
        //get the file from the meta data
        FilePackage file = ((FileSystemMetaData) metaData).getFilePackage();
        try {
            //get destination file's size
            long destModtime = file.getModTime();
            actualResult = destModtime == this.srcModtime;
        } catch (PackageException pe) {
            throw new RbvStorageException(pe);
        }
    }
    return actualResult;
}
Also used : FilePackage(com.axway.ats.action.objects.FilePackage) PackageException(com.axway.ats.action.objects.model.PackageException) RbvStorageException(com.axway.ats.rbv.model.RbvStorageException) FileSystemMetaData(com.axway.ats.rbv.filesystem.FileSystemMetaData)

Example 8 with RbvStorageException

use of com.axway.ats.rbv.model.RbvStorageException in project ats-framework by Axway.

the class ImapFolder method getNewMetaData.

public List<MetaData> getNewMetaData() throws RbvException {
    //first check if the folder is open
    if (!isOpen) {
        throw new MatchableNotOpenException(getDescription() + " is not open");
    }
    if (isInitialPass) {
        isInitialPass = false;
        return getAllMetaData();
    }
    try {
        newMetaDataList.clear();
        Message[] imapMessages = folder.getMessages();
        for (Message imapMessage : imapMessages) {
            if (!imapMessage.getFlags().contains(Flags.Flag.FLAGGED)) {
                imapMessage.setFlag(Flags.Flag.FLAGGED, true);
                ImapMetaData currentMeta = createImapMetaData((MimeMessage) imapMessage);
                if (currentMeta != null) {
                    allMetaDataList.add(currentMeta);
                    newMetaDataList.add(currentMeta);
                }
            }
        }
    } catch (MessagingException me) {
        throw new RbvStorageException("Could not get meta data from " + getDescription(), me);
    }
    return newMetaDataList;
}
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 9 with RbvStorageException

use of com.axway.ats.rbv.model.RbvStorageException in project ats-framework by Axway.

the class ImapFolder method expunge.

/**
     * Cleans up the associated IMAP folder
     * @throws RbvStorageException
     */
@PublicAtsApi
public void expunge() throws RbvStorageException {
    //first check if the folder is open
    if (!isOpen) {
        throw new MatchableNotOpenException(getDescription() + " is not open");
    }
    try {
        folder.setFlags(folder.getMessages(), new Flags(Flags.Flag.DELETED), true);
        folder.expunge();
    } catch (MessagingException me) {
        throw new RbvStorageException(me);
    }
    log.info("Expunged " + getDescription());
}
Also used : MatchableNotOpenException(com.axway.ats.rbv.model.MatchableNotOpenException) MessagingException(javax.mail.MessagingException) Flags(javax.mail.Flags) RbvStorageException(com.axway.ats.rbv.model.RbvStorageException) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 10 with RbvStorageException

use of com.axway.ats.rbv.model.RbvStorageException in project ats-framework by Axway.

the class ImapFolder method close.

/**
     * Closes the IMAP folder
     * @see com.axway.ats.rbv.storage.Matchable#close()
     */
@PublicAtsApi
public void close() throws RbvStorageException {
    //first check if the folder is open
    if (!isOpen) {
        throw new MatchableNotOpenException(getDescription() + " is not open");
    }
    try {
        if (store.isConnected()) {
            folder.close(true);
            store.close();
            log.info("Closed " + getDescription());
        }
        isOpen = false;
    } catch (MessagingException me) {
        throw new RbvStorageException("Could not close " + getDescription(), me);
    }
}
Also used : MatchableNotOpenException(com.axway.ats.rbv.model.MatchableNotOpenException) MessagingException(javax.mail.MessagingException) RbvStorageException(com.axway.ats.rbv.model.RbvStorageException) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

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