Class AS2ClientRequest


  • public class AS2ClientRequest
    extends Object
    This class represents the content of an AS2 client request.
    Author:
    oleo Date: May 12, 2010 Time: 5:48:26 PM, Philip Helger
    • Field Detail

      • DEFAULT_CONTENT_TYPE

        public static final String DEFAULT_CONTENT_TYPE
    • Constructor Detail

      • AS2ClientRequest

        public AS2ClientRequest​(@Nonnull @Nonempty
                                String sSubject)
        Parameters:
        sSubject - The subject to use. May neither be null nor empty. Has no impact on the MIME part creation. Just declarative.
    • Method Detail

      • getSubject

        @Nonnull
        @Nonempty
        public String getSubject()
        Returns:
        The subject as provided in the constructor. May neither be null nor empty.
      • setContentType

        @Nonnull
        public AS2ClientRequest setContentType​(@Nonnull @Nonempty
                                               String sContentType)
        Set the content type to be used. Use this AFTER setData was called, as this may select a default MIME type.
        Parameters:
        sContentType - The content type. May neither be null nor empty.
        Returns:
        this
      • getContentType

        @Nonnull
        @Nonempty
        public String getContentType()
        Returns:
        The content type to be used. Defaults to DEFAULT_CONTENT_TYPE. Is overridden in the setData methods.
      • setData

        @Nonnull
        public AS2ClientRequest setData​(@Nonnull
                                        File aFile,
                                        @Nullable
                                        Charset aCharset)
        Set the content of the File as a payload. If no charset is applied ( null) no content type starting with "text/" may be used. The name of the file is used as the payload file name.
        Parameters:
        aFile - File to read the content from. Never null.
        aCharset - Charset to use. If it is null the content is set as a byte array, if not null the content is set as a String.
        Returns:
        this
      • setData

        @Nonnull
        public AS2ClientRequest setData​(@Nonnull @WillClose
                                        InputStream aIS,
                                        @Nullable
                                        Charset aCharset)
        Set the content of the InputStream as a payload. No charset is applied and therefore no content type starting with "text/" may be used.
        Parameters:
        aIS - InputStream to read the content from. Never null.
        aCharset - Charset to use. If it is null the content is set as a byte array, if not null the content is set as a String.
        Returns:
        this
      • setData

        @Nonnull
        public AS2ClientRequest setData​(@Nonnull
                                        byte[] aData)
        Set the provided byte array as data. The "Content-Type" is set to "application/octet-stream".
        Parameters:
        aData - The data to be used. May not be null.
        Returns:
        this for chaining.
      • setData

        @Nonnull
        public AS2ClientRequest setData​(@Nonnull
                                        String sText,
                                        @Nullable
                                        Charset aCharset)
        Set the provided String as data. The "Content-Type" is set to "text/plain".
        Parameters:
        sText - The data to be used. May not be null.
        aCharset - The charset to be used. May be null.
        Returns:
        this for chaining.
      • setData

        @Nonnull
        public AS2ClientRequest setData​(@Nonnull
                                        jakarta.activation.DataHandler aDataHandler)
        Set the provided DataHandler as data. The "Content-Type" is directly taken from the provided handler.
        Parameters:
        aDataHandler - The data handler to be used. May not be null.
        Returns:
        this for chaining.
      • setFilename

        @Nonnull
        public AS2ClientRequest setFilename​(@Nullable
                                            String sFilename)
        Set the filename to be used to name the content. This will add a Content-Disposition: attachment; filename=... header to the MIME part
        Parameters:
        sFilename - Filename to use. May be null to indicate none (also the default)
        Returns:
        this
      • setContentTransferEncoding

        @Nonnull
        public AS2ClientRequest setContentTransferEncoding​(@Nullable
                                                           com.helger.mail.cte.EContentTransferEncoding eCTE)
        Set the optional Content-Transfer-Encoding to be used. By default it is determined by the data type that defines the body.
        Parameters:
        eCTE - CTE to be used. May be null in which case the default CTE is used.
        Returns:
        this for chaining
        Since:
        3.0.4
      • getContentTransferEncoding

        @Nullable
        public com.helger.mail.cte.EContentTransferEncoding getContentTransferEncoding()
        Returns:
        The Content-Transfer-Encoding provided. May be null.
        Since:
        4.1.1
      • setContentDescription

        @Nonnull
        public AS2ClientRequest setContentDescription​(@Nullable
                                                      String sDescription)
        Set the optional Content-Description header to be used. By default non is present.
        Parameters:
        sDescription - Content description to be used. May be null.
        Returns:
        this for chaining
        Since:
        3.0.4
      • applyDataOntoMimeBodyPart

        public void applyDataOntoMimeBodyPart​(@Nonnull
                                              jakarta.mail.internet.MimeBodyPart aPart)
                                       throws jakarta.mail.MessagingException
        Throws:
        jakarta.mail.MessagingException