KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > slide > lock > Lock


1 /*
2  * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/lock/Lock.java,v 1.20 2004/07/28 09:35:44 ib Exp $
3  * $Revision: 1.20 $
4  * $Date: 2004/07/28 09:35:44 $
5  *
6  * ====================================================================
7  *
8  * Copyright 1999-2002 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

23
24 package org.apache.slide.lock;
25
26 import java.util.Date JavaDoc;
27 import java.util.Enumeration JavaDoc;
28
29 import org.apache.slide.common.ServiceAccessException;
30 import org.apache.slide.common.SlideException;
31 import org.apache.slide.common.SlideToken;
32 import org.apache.slide.security.AccessDeniedException;
33 import org.apache.slide.structure.ActionNode;
34 import org.apache.slide.structure.ObjectNode;
35 import org.apache.slide.structure.ObjectNotFoundException;
36 import org.apache.slide.structure.SubjectNode;
37 import org.apache.slide.event.VetoException;
38
39 /**
40  * Lock helper class.
41  *
42  * @version $Revision: 1.20 $
43  */

44 public interface Lock {
45     
46     
47     // ------------------------------------------------------ Interface Methods
48

49     
50     /**
51      * Put a lock on a subject.
52      *
53      * @param slideToken The token to access slide.
54      * @param lockToken Object containing all the lock information
55      * @exception ServiceAccessException Low level service access exception
56      * @exception ObjectNotFoundException One of the objects referenced
57      * in the lock token were not found
58      * @exception ObjectIsAlreadyLockedException Object is already locked
59      * with an incompatible lock token
60      * @exception AccessDeniedException Insufficient credentials to allow
61      * object locking
62      */

63     void lock(SlideToken slideToken, NodeLock lockToken)
64         throws ServiceAccessException, ObjectIsAlreadyLockedException,
65         AccessDeniedException, ObjectNotFoundException, VetoException;
66     
67     
68     /**
69      * Removes a lock.
70      *
71      * @param slideToken The token to access slide.
72      * @param lockToken Object containing all the lock information
73      *
74      * @return <code>true</code> if the lock was successfully removed
75      *
76      * @exception ServiceAccessException Low level service access exception
77      * @exception LockTokenNotFoundException Cannot find the Lock in the
78      * Lock Store service
79      */

80     boolean unlock(SlideToken slideToken, NodeLock lockToken)
81         throws ServiceAccessException, LockTokenNotFoundException, VetoException;
82     
83     /**
84      * Removes a set of linked locks.
85      *
86      * @param slideToken Slide token
87      * @param objectUri Uri of the locked object.
88      * @param lockId The id of the locks, which will be removed.
89      * @exception ServiceAccessException Low level service access exception
90      * @exception LockTokenNotFoundException Cannot find the Lock in the
91      * Lock Store service
92      * @exception ObjectNotFoundException One of the objects referenced
93      * in the lock token were not found
94      */

95     void unlock(SlideToken slideToken, String JavaDoc objectUri,
96                 String JavaDoc lockId)
97         throws ServiceAccessException, LockTokenNotFoundException,
98         ObjectNotFoundException, VetoException;
99     
100     
101     /**
102      * Renew a lock.
103      *
104      * @param slideToken Slide token
105      * @param lockToken Token containing the lock info.
106      * @param newExpirationDate the desired expiration date
107      * @exception ServiceAccessException Low level service access exception
108      * @exception LockTokenNotFoundException Cannot find the Lock in
109      * the Lock Store service
110      */

111     void renew(SlideToken slideToken, NodeLock lockToken,
112                Date JavaDoc newExpirationDate)
113         throws ServiceAccessException, LockTokenNotFoundException, VetoException;
114     
115     
116    /**
117      * Renew a set of linked locks.
118      *
119      * @param slideToken Slide token
120      * @param objectUri Uri of the locked object
121      * @param lockId Id of the locks, which will be renewed.
122      * @param newExpirationDate The new expiration date of the locks
123      * @exception ServiceAccessException Low level service access exception
124      * @exception LockTokenNotFoundException Cannot find the Lock in the
125      * Lock Store service
126      * @exception ObjectNotFoundException One of the objects referenced
127      * in the lock token were not found
128      */

129     void renew(SlideToken slideToken, String JavaDoc objectUri,
130                String JavaDoc lockId, Date JavaDoc newExpirationDate)
131         throws ServiceAccessException, LockTokenNotFoundException,
132         ObjectNotFoundException, VetoException;
133     
134     
135     /**
136      * Kills locks.
137      *
138      * @param slideToken Slide token
139      * @param subject Subject on which locks are to be removed
140      * @exception ServiceAccessException Low level service access exception
141      * @exception ObjectNotFoundException One of the objects referenced
142      * in the lock token were not found
143      * @exception LockTokenNotFoundException Cannot find the Lock in the
144      * Lock Store service
145      * @exception AccessDeniedException Insufficient credentials to allow
146      * forced removal of locks
147      */

148     void kill(SlideToken slideToken, SubjectNode subject)
149         throws ServiceAccessException, AccessDeniedException,
150         LockTokenNotFoundException, ObjectNotFoundException, VetoException;
151     
152     
153     /**
154      * Enumerate locks on a subject, including any locks inherited from parent
155      * subjects.
156      *
157      * @param slideToken the slide token
158      * @param objectUri the URI of the object of which we want to enumerate
159      * active locks
160      *
161      * @return an Enumeration of NodeLock objects
162      *
163      * @exception ServiceAccessException low level service access exception
164      * @exception ObjectNotFoundException one of the objects referenced in
165      * the lock token were not found
166      */

167     Enumeration JavaDoc enumerateLocks(SlideToken slideToken,
168                                String JavaDoc objectUri)
169         throws ServiceAccessException, ObjectNotFoundException,
170         LockTokenNotFoundException;
171     
172     
173     /**
174      * Enumerate locks on a subject, optionally excluding locks inherited
175      * from parent subjects.
176      *
177      * @param slideToken the slide token
178      * @param objectUri the URI of the object of which we want to enumerate
179      * active locks
180      * @param inherited if true, locks inherited from parent objects will be
181      * included in the result, otherwise, only locks that
182      * explicitly lock the object will be returned
183      *
184      * @return an Enumeration of NodeLock objects
185      *
186      * @exception ServiceAccessException low level service access exception
187      * @exception ObjectNotFoundException one of the objects referenced in
188      * the lock token were not found
189      * @exception LockTokenNotFoundException cannot find the lock in the
190      * lock store service
191      */

192     Enumeration JavaDoc enumerateLocks(SlideToken slideToken, String JavaDoc objectUri,
193                                boolean inherited)
194         throws ServiceAccessException, ObjectNotFoundException,
195         LockTokenNotFoundException;
196     
197     
198     /**
199      * Utility function for lock checking. Mirrors Security.checkCredentials.
200      *
201      * @param slideToken Credetials token
202      * @param object Object on which the action is performed
203      * @param action Action to test
204      * @exception ObjectLockedException Can't perform specified action
205      * on object
206      * @exception ServiceAccessException Low level service access exception
207      * @exception ObjectNotFoundException One of the objects referenced
208      * in the lock token were not found
209      */

210     void checkLock(SlideToken slideToken, ObjectNode object,
211                    ActionNode action)
212         throws ServiceAccessException, ObjectNotFoundException,
213         ObjectLockedException;
214     
215     
216     /**
217      * Check locking for a specific action and credential.
218      *
219      * @param slideToken Credetials token
220      * @param subject Subject to test
221      * @param user User to test
222      * @param action Action to test
223      * @exception ObjectLockedException Can't perform specified action
224      * on object
225      * @exception ServiceAccessException Low level service access exception
226      * @exception ObjectNotFoundException One of the objects referenced
227      * in the lock token were not found
228      */

229     void checkLock(SlideToken slideToken, ObjectNode subject,
230                    SubjectNode user, ActionNode action)
231         throws ServiceAccessException, ObjectNotFoundException,
232         ObjectLockedException;
233     
234     
235     /**
236      * Tests if an element is locked.
237      *
238      * @param slideToken Slide token
239      * @param subject Subject to test
240      * @param user User to test
241      * @param action Locked for action
242      * @return boolean True if the subject is locked
243      * @exception ServiceAccessException Low level service access exception
244      * @exception ObjectNotFoundException One of the objects referenced
245      * in the lock token were not found
246      */

247     boolean isLocked(SlideToken slideToken, ObjectNode subject,
248                      SubjectNode user, ActionNode action, boolean tryToLock)
249         throws ServiceAccessException, ObjectNotFoundException;
250     
251     
252     /**
253      * Tests if an element is locked.
254      *
255      * @param slideToken Slide token
256      * @param subject Subject to test
257      * @param user User to test
258      * @param action Locked for action
259      * @param inheritance Set to true if we want to check if any children
260      * is locked
261      * with an incompatible lock
262      * @param tryToLock True if the check is intended to check whether
263      * or not we can put a new lock
264      * @return boolean True if the subject is locked
265      * @exception ServiceAccessException Low level service access exception
266      * @exception ObjectNotFoundException One of the objects referenced in
267      * the lock token were not found
268      */

269     boolean isLocked(SlideToken slideToken, ObjectNode subject,
270                      SubjectNode user, ActionNode action, boolean inheritance,
271                      boolean tryToLock)
272         throws ServiceAccessException, ObjectNotFoundException;
273     
274     
275     /**
276      * Tests if an element is locked.
277      *
278      * @param token Lock token to test
279      * @return boolean True if locked
280      * @exception ServiceAccessException Low level service access exception
281      * @exception ObjectNotFoundException One of the objects referenced
282      * in the lock token were not found
283      */

284     boolean isLocked(SlideToken slideToken, NodeLock token,
285                      boolean tryToLock)
286         throws ServiceAccessException, ObjectNotFoundException;
287     
288     /**
289      * Clears the expired locks from the specified resource.
290      *
291      * @param slideToken a SlideToken
292      * @param objectUri a String
293      * @param listener an UnlockListener
294      * @throws SlideException
295      */

296     public void clearExpiredLocks( SlideToken slideToken, String JavaDoc objectUri, UnlockListener listener ) throws SlideException;
297     
298     /**
299      * Return true if a lock token for this lock has been given in the
300      * credentials token.
301      *
302      * @param slideToken Current credentials token
303      * @param token Lock token
304      */

305     public boolean checkLockToken(SlideToken slideToken, NodeLock token);
306
307     /**
308      * Returns true, if the principal from the credentials token is either the
309      * lock-owner of has kill-lock privileges
310      *
311      * @param slideToken a SlideToken
312      * @param token a NodeLock
313      * @return a boolean
314      *
315      * @throws ObjectNotFoundException
316      * @throws ServiceAccessException
317      */

318     public boolean checkLockOwner(SlideToken slideToken, NodeLock token) throws ObjectNotFoundException, ServiceAccessException;
319 }
320
Popular Tags