View Javadoc
1   /*
2    * Copyright (C) 2003-2008 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.lock;
18  
19  import java.util.HashMap;
20  import java.util.List;
21  import java.util.Map;
22  
23  import javax.jcr.Node;
24  
25  /**
26   * Created by The eXo Platform SAS
27   * Author : Chien Nguyen
28   * chien.nguyen@exoplatform.com
29   * Nov 17, 2009
30   */
31  
32  /**
33   * This service used to manage all the stuff which related to the locking nodes.
34   * @author minh_dang
35   *
36   */
37  public interface LockService {
38  
39    /**
40     * Get all pre-setting lock list
41     * @return lock list
42     * @throws Exception
43     */
44    public List<String> getPreSettingLockList() throws Exception;
45  
46  /**
47   * Get all the identities which allowed to unlock nodes
48   * @return lock list
49   * @throws Exception
50   */
51    public List<String> getAllGroupsOrUsersForLock() throws Exception;
52  
53    /**
54     * Allow to add user or group to the locking manager list which allowed to unlock all nodes
55     * @param groupsOrUsers User id or group id
56     * @throws Exception
57     */
58    public void addGroupsOrUsersForLock(String groupsOrUsers) throws Exception;
59  
60    /**
61     * Remove user or group out of the locking manager list
62     * @param groupsOrUsers
63     * @throws Exception
64     */
65    public void removeGroupsOrUsersForLock(String groupsOrUsers) throws Exception;
66  
67    /**
68     * Return a HashMap which keeping all locked nodes informations
69     * @return locks holding map
70     */
71    public HashMap<String, Map<String, String>> getLockHolding();
72  
73    /**
74     * Put all informations of locked node such as locktoken to the Map
75     * @param userId It is a key which will be used to get the locked information
76     * @param lockedNodesInfo A Map which kept the locked node information
77     */
78    public void putToLockHoding(String userId, Map<String, String> lockedNodesInfo);
79  
80    /**
81     * Return a Map which kept lock token of node which locked by user
82     * @param userId
83     * @return
84     */
85    public Map<String, String> getLockInformation(String userId);
86  
87    /**
88     * Remove all locked nodes user
89     * @param userId User Identity which will be used to remove all locked node which belong to he/she
90     */
91    public void removeLocksOfUser(String userId);
92  
93    /**
94     * Remove all locked nodes in the system. This function just used in the case server stop working
95     */
96    public void removeLocks();
97  
98    /**
99     * Get lock token of user from a specific node.
100    * @param node a specific node
101    * @return lock token
102    * @throws Exception
103    */
104   public String getLockTokenOfUser(Node node) throws Exception;
105 
106   /**
107    * Create Lock key from specific node.
108    *
109    * @param node a specific node
110    * @return lock key
111    * @throws Exception
112    */
113   public String createLockKey(Node node) throws Exception;
114 
115   /**
116    * Create Lock key from a specific node and user id.
117    *
118    * @param node a specific node
119    * @param userId user ID
120    * @return lock key
121    * @throws Exception
122    */
123   public String createLockKey(Node node, String userId) throws Exception;
124 
125   /**
126    * Get Lock token from specifiec node.
127    *
128    * @param node a specific node
129    * @return lock token
130    * @throws Exception
131    */
132   public String getLockToken(Node node) throws Exception;
133 
134   /**
135    * Change lock token from source path to new node.
136    *
137    * @param srcPath source node path
138    * @param newNode new node
139    * @throws Exception
140    */
141   public void changeLockToken(String srcPath, Node newNode) throws Exception;
142 
143   /**
144    * Change lock token from old node to new node.
145    *
146    * @param oldNode old node
147    * @param newNode new node
148    * @throws Exception
149    */
150   public void changeLockToken(Node oldNode, Node newNode) throws Exception;
151 
152   /**
153    * Get old lock key from source path and a specific node.
154    *
155    * @param srcPath source path
156    * @param node a specific node
157    * @return
158    * @throws Exception
159    */
160   public String getOldLockKey(String srcPath, Node node) throws Exception;
161 
162 }