Search in sources :

Example 96 with PublicAtsApi

use of com.axway.ats.common.PublicAtsApi in project ats-framework by Axway.

the class MimePackage method getRecipients.

/**
     * Get the recipients of the specified type
     *
     * @param recipientType
     *            the type of recipient - to, cc or bcc
     * @return array with recipients, emtpy array of no recipients of this type
     *         are present
     * @throws PackageException
     */
@PublicAtsApi
public String[] getRecipients(RecipientType recipientType) throws PackageException {
    try {
        Address[] recipientAddresses = message.getRecipients(recipientType.toJavamailType());
        // return an empty string if no recipients are present
        if (recipientAddresses == null) {
            return new String[] {};
        }
        String[] recipients = new String[recipientAddresses.length];
        for (int i = 0; i < recipientAddresses.length; i++) {
            recipients[i] = recipientAddresses[i].toString();
        }
        return recipients;
    } catch (MessagingException me) {
        throw new PackageException(me);
    }
}
Also used : Address(javax.mail.Address) 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) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 97 with PublicAtsApi

use of com.axway.ats.common.PublicAtsApi in project ats-framework by Axway.

the class MimePackage method addAlternativePart.

/**
     * Add a multipart/alternative part to message body
     *
     * @param plainContent
     *            the content of the text/plain sub-part
     * @param htmlContent
     *            the content of the text/html sub-part
     * @param charset
     *            the character set for the part
     * @throws PackageException
     */
@PublicAtsApi
public void addAlternativePart(String plainContent, String htmlContent, String charset) throws PackageException {
    MimeMultipart alternativePart = new MimeMultipart("alternative");
    try {
        // create a new text/plain part
        MimeBodyPart plainPart = new MimeBodyPart();
        plainPart.setText(plainContent, charset, PART_TYPE_TEXT_PLAIN);
        plainPart.setDisposition(MimeBodyPart.INLINE);
        MimeBodyPart htmlPart = new MimeBodyPart();
        htmlPart.setText(htmlContent, charset, PART_TYPE_TEXT_HTML);
        htmlPart.setDisposition(MimeBodyPart.INLINE);
        alternativePart.addBodyPart(plainPart, 0);
        alternativePart.addBodyPart(htmlPart, 1);
        MimeBodyPart mimePart = new MimeBodyPart();
        mimePart.setContent(alternativePart);
        addPart(mimePart, PART_POSITION_LAST);
    } catch (MessagingException me) {
        throw new PackageException(me);
    }
}
Also used : MimeMultipart(javax.mail.internet.MimeMultipart) MessagingException(javax.mail.MessagingException) NoSuchMimePackageException(com.axway.ats.action.objects.model.NoSuchMimePackageException) PackageException(com.axway.ats.action.objects.model.PackageException) MimeBodyPart(javax.mail.internet.MimeBodyPart) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 98 with PublicAtsApi

use of com.axway.ats.common.PublicAtsApi in project ats-framework by Axway.

the class MimePackage method addRecipient.

/**
     * Add recipients of a specified type
     *
     * @param type the recipients' type
     * @param addresses the email addresses of the recipients
     * @throws PackageException
     */
@PublicAtsApi
public void addRecipient(RecipientType type, String[] addresses) throws PackageException {
    try {
        // add the recipient
        InternetAddress[] address = new InternetAddress[addresses.length];
        for (int i = 0; i < addresses.length; i++) address[i] = new InternetAddress(addresses[i]);
        message.addRecipients(type.toJavamailType(), address);
    } catch (MessagingException me) {
        throw new PackageException(me);
    }
}
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) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 99 with PublicAtsApi

use of com.axway.ats.common.PublicAtsApi in project ats-framework by Axway.

the class MimePackage method getPartHeader.

/**
     * Get the specified header value from a specified MIME part
     *
     * @param headerName
     * @param partNum
     * @param headerIndex
     * @return
     * @throws PackageException
     */
@PublicAtsApi
public String getPartHeader(String headerName, int partNum, int headerIndex) throws PackageException {
    try {
        String[] headers;
        if (partNum >= parts.size()) {
            throw new NoSuchMimePartException("No MIME part at position '" + partNum + "'");
        }
        MimePart part = parts.get(partNum);
        headers = part.getHeader(headerName);
        if ((headers != null) && (headers.length > headerIndex)) {
            return headers[headerIndex];
        } else {
            throw new NoSuchHeaderException(headerName, partNum, headerIndex);
        }
    } catch (MessagingException me) {
        throw new PackageException(me);
    }
}
Also used : MessagingException(javax.mail.MessagingException) NoSuchMimePartException(com.axway.ats.action.objects.model.NoSuchMimePartException) MimePart(javax.mail.internet.MimePart) NoSuchMimePackageException(com.axway.ats.action.objects.model.NoSuchMimePackageException) PackageException(com.axway.ats.action.objects.model.PackageException) NoSuchHeaderException(com.axway.ats.action.objects.model.NoSuchHeaderException) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 100 with PublicAtsApi

use of com.axway.ats.common.PublicAtsApi in project ats-framework by Axway.

the class MimePackage method getRegularPartContentType.

/**
     * Get the content type of a regular part
     *
     * @param partIndex
     *            the index of the regular part
     * @return the content type as string
     * @throws PackageException
     */
@PublicAtsApi
public String getRegularPartContentType(int partIndex) throws PackageException {
    // first check if there is part at this position at all
    if (partIndex >= regularPartIndices.size()) {
        throw new NoSuchMimePartException("No regular part at position '" + partIndex + "'");
    }
    try {
        MimePart part = getPart(regularPartIndices.get(partIndex));
        // get the content type header
        ContentType contentType = new ContentType(part.getContentType());
        return contentType.getBaseType();
    } catch (MessagingException me) {
        throw new PackageException(me);
    }
}
Also used : ContentType(javax.mail.internet.ContentType) MessagingException(javax.mail.MessagingException) NoSuchMimePartException(com.axway.ats.action.objects.model.NoSuchMimePartException) MimePart(javax.mail.internet.MimePart) NoSuchMimePackageException(com.axway.ats.action.objects.model.NoSuchMimePackageException) PackageException(com.axway.ats.action.objects.model.PackageException) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Aggregations

PublicAtsApi (com.axway.ats.common.PublicAtsApi)409 Validator (com.axway.ats.core.validation.Validator)66 SwingElementState (com.axway.ats.uiengine.utilities.swing.SwingElementState)60 WebElement (org.openqa.selenium.WebElement)57 IFileSystemOperations (com.axway.ats.core.filesystem.model.IFileSystemOperations)44 HiddenHtmlElementState (com.axway.ats.uiengine.utilities.hiddenbrowser.HiddenHtmlElementState)32 NoSuchMimePackageException (com.axway.ats.action.objects.model.NoSuchMimePackageException)31 PackageException (com.axway.ats.action.objects.model.PackageException)31 RealHtmlElementState (com.axway.ats.uiengine.utilities.realbrowser.html.RealHtmlElementState)31 MessagingException (javax.mail.MessagingException)31 VerificationException (com.axway.ats.uiengine.exceptions.VerificationException)24 ArrayList (java.util.ArrayList)18 SeleniumOperationException (com.axway.ats.uiengine.exceptions.SeleniumOperationException)16 UiElementException (com.axway.ats.uiengine.exceptions.UiElementException)16 IOException (java.io.IOException)16 JTableFixture (org.fest.swing.fixture.JTableFixture)16 Actions (org.openqa.selenium.interactions.Actions)16 NotSupportedOperationException (com.axway.ats.uiengine.exceptions.NotSupportedOperationException)15 VerifyNotEqualityException (com.axway.ats.uiengine.exceptions.VerifyNotEqualityException)15 XMLException (com.axway.ats.common.xml.XMLException)14