View Javadoc
1   /*
2    * Copyright (c) 2002-2021, 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.plugins.extend.modules.comment.service;
35  
36  import java.util.List;
37  import java.util.Set;
38  
39  import javax.servlet.http.HttpServletRequest;
40  import javax.validation.ConstraintViolation;
41  
42  import fr.paris.lutece.plugins.extend.modules.comment.business.Comment;
43  import fr.paris.lutece.portal.service.security.LuteceUser;
44  
45  /**
46   * Interface of listeners of comments
47   * 
48   * @param <A>
49   */
50  public interface ICommentListener
51  {
52      /**
53       * Notify the creation of a comment
54       * 
55       * @param strIdExtendableResource
56       *            The id of the extendable resource associated with the created comment
57       * @param bPublished
58       *            True if the created comment is published, false otherwise
59       */
60      void createComment( String strIdExtendableResource, boolean bPublished );
61  
62      /**
63       * Notify the creation of a comment
64       * 
65       * @param strIdExtendableResource
66       *            The id of the extendable resource associated with the created comment
67       * @param bPublished
68       *            True if the created comment is published, false otherwise request HttpServletRequest the Http request
69       */
70      void createComment( String strIdExtendableResource, boolean bPublished, HttpServletRequest request );
71  
72      /**
73       * Notify the publication or unpublication of a comment
74       * 
75       * @param strIdExtendableResource
76       *            The id of the extendable resource associated with the modified comment
77       * @param bPublished
78       *            True if the comment was published, false if it was unpublished
79       */
80      void publishComment( String strIdExtendableResource, boolean bPublished );
81  
82      /**
83       * Notify the removal of a comment
84       * 
85       * @param strIdExtendableResource
86       *            The id of the extendable resource associated with the removed comment
87       * @param listIdRemovedComment
88       *            The list of ids of removed comments
89       */
90      void deleteComment( String strIdExtendableResource, List<Integer> listIdRemovedComment );
91  
92      /**
93       * Notify the check comment
94       * 
95       * @param listErrors
96       * @return
97       */
98      public String checkComment( String comment, String uidUser );
99  
100     /**
101      * Notify the check comment
102      * 
103      * @param comment
104      * @param uidUser
105      * @param strResourceType
106      * @param strResourceId
107      * @return
108      */
109     public String checkComment( String comment, String uidUser, String strResourceType, String strResourceId );
110 
111     /**
112      * Check if user can comment
113      * 
114      * @param user
115      *            The lutece user
116      * @param strIdExtendableResource
117      *            The id of the extendable resource
118      * @param strExtendableResourceType
119      *            The type of the resource
120      * @return true when the user has the rights, otherwise false
121      */
122     public boolean canComment( LuteceUser user, String strIdExtendableResource, String strExtendableResourceType );
123 }