View Javadoc
1   /*
2    * Copyright (C) 2003-2007 eXo Platform SAS.
3    *
4    * This program is free software; you can redistribute it and/or
5    * modify it under the terms of the GNU Affero General Public License
6    * as published by the Free Software Foundation; either version 3
7    * of the License, or (at your option) any later version.
8    *
9    * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU General Public License for more details.
13   *
14   * You should have received a copy of the GNU General Public License
15   * along with this program; if not, see<http://www.gnu.org/licenses/>.
16   */
17  package org.exoplatform.services.cms.watch;
18  
19  import javax.jcr.Node;
20  
21  import org.exoplatform.services.cms.watch.impl.MessageConfigPlugin;
22  
23  /**
24   * Created by The eXo Platform SARL
25   * Author : Pham Xuan Hoa
26   *          hoapham@exoplatform.com
27   * Nov 30, 2006
28   */
29  public interface WatchDocumentService {
30  
31    final public int NOTIFICATION_BY_EMAIL = 1;
32    final public int NOTIFICATION_BY_RSS = 2;
33    final public int FULL_NOTIFICATION = 0;
34  
35    /**
36     * Watching the document that is specified by the node by giving a userName, notifyType
37     * <p>If the document is watching, all thing that changes to it's property will be notified
38     * to user specified by the userName
39     * @param documentNode      Specify the document for watching
40     * @param userName          he username of current user is votting. It can't be <code>null</code>
41     * @param notifyType        Type of notification. Its can be 0, 1 or 2
42     *                          0 : Notification by email
43     *                          1 : Notification by rss
44     *                          2 : Full notification
45     * @see                     Node
46     * @throws Exception
47     */
48    public void watchDocument(Node documentNode, String userName, int notifyType) throws Exception;
49  
50    /**
51     * This method will gets the type of notification for the specify document
52     * <p>If that document is not a exo:watchable document, the value return is -1
53     * If notification is notified by email, the value return is 1
54     * If notification is notified by rss, the value return is 2
55     * If notification is notified by rss and email, the value return is 0
56     * @param documentNode      Specify the document for watching
57     * @param userName          The username of current user is votting. It can't be <code>null</code>
58     * @see                     Node
59     * @return                  0, 1, 2 or -1
60     * @throws Exception
61     */
62    public int getNotificationType(Node documentNode, String userName) throws Exception;
63  
64    /**
65     * UnWatching the document that is specified by the node by giving a userName, notifyType
66     * <p>If the document is unwatching, all thing that changes to it's property will not be notified
67     * to user specified by the userName
68     * @param documentNode      Specify the document for watching
69     * @param userName          The username of current user is votting. It can't be <code>null</code>
70     * @param notificationType  Type of notification. Its can be 0, 1 or 2
71     *                          0 : Notification by email
72     *                          1 : Notification by rss
73     *                          2 : Full notification
74     * @see                     Node
75     * @throws Exception
76     */
77    public void unwatchDocument(Node documentNode, String userName, int notificationType) throws Exception;
78    
79    /**
80     * Initialize the notification email contents of watching document when the
81     * notification type is by email.
82     * 
83     * @param msgConfigPlugin The message configuration plug-in
84     */
85    public void initializeMessageConfig(MessageConfigPlugin msgConfigPlugin);
86  }