MailItem.java

  1. /*
  2.  * Copyright (c) 2002-2022, City of Paris
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  *
  9.  *  1. Redistributions of source code must retain the above copyright notice
  10.  *     and the following disclaimer.
  11.  *
  12.  *  2. Redistributions in binary form must reproduce the above copyright notice
  13.  *     and the following disclaimer in the documentation and/or other materials
  14.  *     provided with the distribution.
  15.  *
  16.  *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
  17.  *     contributors may be used to endorse or promote products derived from
  18.  *     this software without specific prior written permission.
  19.  *
  20.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21.  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  23.  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
  24.  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  25.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  26.  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  27.  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  28.  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  29.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  30.  * POSSIBILITY OF SUCH DAMAGE.
  31.  *
  32.  * License 1.0
  33.  */
  34. package fr.paris.lutece.portal.service.mail;

  35. import fr.paris.lutece.util.mail.FileAttachment;
  36. import fr.paris.lutece.util.mail.UrlAttachment;

  37. import java.io.Serializable;

  38. import java.util.List;

  39. /**
  40.  * MailIem
  41.  */
  42. public class MailItem implements Serializable
  43. {
  44.     public static final int FORMAT_HTML = 0; // Default
  45.     public static final int FORMAT_TEXT = 1;
  46.     public static final int FORMAT_MULTIPART_HTML = 2;
  47.     public static final int FORMAT_MULTIPART_TEXT = 3;
  48.     public static final int FORMAT_CALENDAR = 4;
  49.     private static final long serialVersionUID = 1L;

  50.     // Variables declarations
  51.     private String _strRecipientsTo;
  52.     private String _strRecipientsCc;
  53.     private String _strRecipientsBcc;
  54.     private String _strSenderName;
  55.     private String _strSenderEmail;
  56.     private String _strSubject;
  57.     private String _strMessage;
  58.     private String _strCalendarMessage;
  59.     private boolean _bCreateEvent;
  60.     private int _nFormat;
  61.     private List<UrlAttachment> _listUrlsAttachement;
  62.     private List<FileAttachment> _listFilesAttachement;
  63.     private boolean _bUniqueRecipientTo;

  64.     /**
  65.      * Returns the Recipient
  66.      *
  67.      * @return The Recipient
  68.      */
  69.     public String getRecipientsTo( )
  70.     {
  71.         return _strRecipientsTo;
  72.     }

  73.     /**
  74.      * Sets the Recipient
  75.      *
  76.      * @param strRecipient
  77.      *            The Recipient
  78.      */
  79.     public void setRecipientsTo( String strRecipient )
  80.     {
  81.         _strRecipientsTo = strRecipient;
  82.     }

  83.     /**
  84.      * Returns the Recipient
  85.      *
  86.      * @return The Recipient
  87.      */
  88.     public String getRecipientsCc( )
  89.     {
  90.         return _strRecipientsCc;
  91.     }

  92.     /**
  93.      * Sets the Recipient
  94.      *
  95.      * @param strRecipient
  96.      *            The Recipient
  97.      */
  98.     public void setRecipientsCc( String strRecipient )
  99.     {
  100.         _strRecipientsCc = strRecipient;
  101.     }

  102.     /**
  103.      * Returns the Recipient
  104.      *
  105.      * @return The Recipient
  106.      */
  107.     public String getRecipientsBcc( )
  108.     {
  109.         return _strRecipientsBcc;
  110.     }

  111.     /**
  112.      * Sets the Recipient
  113.      *
  114.      * @param strRecipient
  115.      *            The Recipient
  116.      */
  117.     public void setRecipientsBcc( String strRecipient )
  118.     {
  119.         _strRecipientsBcc = strRecipient;
  120.     }

  121.     /**
  122.      * Returns the SenderName
  123.      *
  124.      * @return The SenderName
  125.      */
  126.     public String getSenderName( )
  127.     {
  128.         return _strSenderName;
  129.     }

  130.     /**
  131.      * Sets the SenderName
  132.      *
  133.      * @param strSenderName
  134.      *            The SenderName
  135.      */
  136.     public void setSenderName( String strSenderName )
  137.     {
  138.         _strSenderName = strSenderName;
  139.     }

  140.     /**
  141.      * Returns the SenderEmail
  142.      *
  143.      * @return The SenderEmail
  144.      */
  145.     public String getSenderEmail( )
  146.     {
  147.         return _strSenderEmail;
  148.     }

  149.     /**
  150.      * Sets the SenderEmail
  151.      *
  152.      * @param strSenderEmail
  153.      *            The SenderEmail
  154.      */
  155.     public void setSenderEmail( String strSenderEmail )
  156.     {
  157.         _strSenderEmail = strSenderEmail;
  158.     }

  159.     /**
  160.      * Returns the Subject
  161.      *
  162.      * @return The Subject
  163.      */
  164.     public String getSubject( )
  165.     {
  166.         return _strSubject;
  167.     }

  168.     /**
  169.      * Sets the Subject
  170.      *
  171.      * @param strSubject
  172.      *            The Subject
  173.      */
  174.     public void setSubject( String strSubject )
  175.     {
  176.         _strSubject = strSubject;
  177.     }

  178.     /**
  179.      * Returns the Message
  180.      *
  181.      * @return The Message
  182.      */
  183.     public String getMessage( )
  184.     {
  185.         return _strMessage;
  186.     }

  187.     /**
  188.      * Sets the Message
  189.      *
  190.      * @param strMessage
  191.      *            The Message
  192.      */
  193.     public void setMessage( String strMessage )
  194.     {
  195.         _strMessage = strMessage;
  196.     }

  197.     /**
  198.      * Returns the calendar message
  199.      *
  200.      * @return The calendar message
  201.      */
  202.     public String getCalendarMessage( )
  203.     {
  204.         return _strCalendarMessage;
  205.     }

  206.     /**
  207.      * Sets the calendar message
  208.      *
  209.      * @param strCalendarMessage
  210.      *            The calendar message
  211.      */
  212.     public void setCalendarMessage( String strCalendarMessage )
  213.     {
  214.         _strCalendarMessage = strCalendarMessage;
  215.     }

  216.     /**
  217.      * Check if the calendar event of this mail item should be created or removed
  218.      *
  219.      * @return True if the event should be created, false if it should be removed
  220.      */
  221.     public boolean getCreateEvent( )
  222.     {
  223.         return _bCreateEvent;
  224.     }

  225.     /**
  226.      * Create or remove the event of this mail item
  227.      *
  228.      * @param bCreateEvent
  229.      *            True to create the event, false otherwise
  230.      */
  231.     public void setCreateEvent( boolean bCreateEvent )
  232.     {
  233.         this._bCreateEvent = bCreateEvent;
  234.     }

  235.     /**
  236.      * Returns the Format
  237.      *
  238.      * @return The Format
  239.      */
  240.     public int getFormat( )
  241.     {
  242.         return _nFormat;
  243.     }

  244.     /**
  245.      * Sets the Format
  246.      *
  247.      * @param nFormat
  248.      *            The Format
  249.      */
  250.     public void setFormat( int nFormat )
  251.     {
  252.         _nFormat = nFormat;
  253.     }

  254.     /**
  255.      * Returns a collection of files attachement
  256.      *
  257.      * @return The Attachements Map
  258.      */
  259.     public List<FileAttachment> getFilesAttachement( )
  260.     {
  261.         return _listFilesAttachement;
  262.     }

  263.     /**
  264.      * Set a collection of files attachement
  265.      *
  266.      * @param fileAttachements
  267.      *            The collection of files attachement
  268.      */
  269.     public void setFilesAttachement( List<FileAttachment> fileAttachements )
  270.     {
  271.         _listFilesAttachement = fileAttachements;
  272.     }

  273.     /**
  274.      * return the list of urls attachement
  275.      *
  276.      * @return the list of urls attachement
  277.      */
  278.     public List<UrlAttachment> getUrlsAttachement( )
  279.     {
  280.         return _listUrlsAttachement;
  281.     }

  282.     /**
  283.      * set the list of urls attachement
  284.      *
  285.      * @param urlsAttachement
  286.      *            the list of urls attachement
  287.      */
  288.     public void setUrlsAttachement( List<UrlAttachment> urlsAttachement )
  289.     {
  290.         _listUrlsAttachement = urlsAttachement;
  291.     }

  292.     /**
  293.      * set true if the mail must be send unitarily for each recipient
  294.      *
  295.      * @param bUniqueRecipient
  296.      *            true if the mail must be send unitarily for each recipient
  297.      */
  298.     public void setUniqueRecipientTo( boolean bUniqueRecipient )
  299.     {
  300.         _bUniqueRecipientTo = bUniqueRecipient;
  301.     }

  302.     /**
  303.      *
  304.      * @return if the mail must be send unitarily for each recipient
  305.      */
  306.     public boolean isUniqueRecipientTo( )
  307.     {
  308.         return _bUniqueRecipientTo;
  309.     }
  310. }