Search in sources :

Example 46 with PackageException

use of com.axway.ats.action.objects.model.PackageException in project ats-framework by Axway.

the class Test_FileGIDRule method performMatchNegativeWxception.

@Test(expected = RbvException.class)
public void performMatchNegativeWxception() throws RbvException, PackageException {
    expect(meta.getFilePackage()).andReturn(pack);
    expect(pack.getGid()).andThrow(new PackageException(""));
    replayAll();
    rule = new FileGidRule(1, "ruleName", true);
    rule.performMatch(meta);
    verifyAll();
}
Also used : PackageException(com.axway.ats.action.objects.model.PackageException) FileGidRule(com.axway.ats.rbv.filesystem.rules.FileGidRule) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 47 with PackageException

use of com.axway.ats.action.objects.model.PackageException in project ats-framework by Axway.

the class Test_FileFolderRule method performMatchException.

@Test(expected = RbvException.class)
public void performMatchException() throws RbvException, PackageException {
    expect(meta.getFilePackage()).andReturn(pack);
    expect(pack.isFile()).andThrow(new PackageException(""));
    replayAll();
    rule = new FileFolderRule(true, "ruleName", true);
    assertTrue(rule.performMatch(meta));
    verifyAll();
}
Also used : FileFolderRule(com.axway.ats.rbv.filesystem.rules.FileFolderRule) PackageException(com.axway.ats.action.objects.model.PackageException) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Example 48 with PackageException

use of com.axway.ats.action.objects.model.PackageException 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 49 with PackageException

use of com.axway.ats.action.objects.model.PackageException 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 50 with PackageException

use of com.axway.ats.action.objects.model.PackageException in project ats-framework by Axway.

the class MimePackage method setSenderName.

/**
     * Set the sender display name on the From header
     *
     * @param name
     *            the display name to set
     * @throws PackageException
     */
@PublicAtsApi
public void setSenderName(String name) throws PackageException {
    try {
        InternetAddress address = new InternetAddress();
        String[] fromHeaders = getHeaderValues(FROM_HEADER);
        if (fromHeaders != null && fromHeaders.length > 0) {
            // parse the from header if such exists
            String fromHeader = fromHeaders[0];
            if (fromHeader != null) {
                address = InternetAddress.parse(fromHeader)[0];
            }
        }
        address.setPersonal(name);
        message.setFrom(address);
    } catch (ArrayIndexOutOfBoundsException aioobe) {
        throw new PackageException("Sender not present");
    } catch (MessagingException me) {
        throw new PackageException(me);
    } catch (UnsupportedEncodingException uee) {
        throw new PackageException(uee);
    }
}
Also used : InternetAddress(javax.mail.internet.InternetAddress) MessagingException(javax.mail.MessagingException) NoSuchMimePackageException(com.axway.ats.action.objects.model.NoSuchMimePackageException) PackageException(com.axway.ats.action.objects.model.PackageException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Aggregations

PackageException (com.axway.ats.action.objects.model.PackageException)52 NoSuchMimePackageException (com.axway.ats.action.objects.model.NoSuchMimePackageException)34 MessagingException (javax.mail.MessagingException)32 PublicAtsApi (com.axway.ats.common.PublicAtsApi)31 MimePart (javax.mail.internet.MimePart)11 IOException (java.io.IOException)10 NoSuchMimePartException (com.axway.ats.action.objects.model.NoSuchMimePartException)9 FilePackage (com.axway.ats.action.objects.FilePackage)7 BaseTest (com.axway.ats.rbv.BaseTest)7 InternetAddress (javax.mail.internet.InternetAddress)7 Test (org.junit.Test)7 MimePackage (com.axway.ats.action.objects.MimePackage)6 RbvException (com.axway.ats.rbv.model.RbvException)6 InputStream (java.io.InputStream)6 RbvStorageException (com.axway.ats.rbv.model.RbvStorageException)5 ContentType (javax.mail.internet.ContentType)5 MimeBodyPart (javax.mail.internet.MimeBodyPart)5 MimeMultipart (javax.mail.internet.MimeMultipart)5 FileSystemMetaData (com.axway.ats.rbv.filesystem.FileSystemMetaData)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4