1 /*****************************************************************************
5 * Creation date 02.10.2012
8 *****************************************************************************/
10 package org.splat.service;
12 import org.splat.exception.LockAlreadyExistsException;
13 import org.splat.exception.LockNotExistsException;
14 import org.splat.exception.LockOutdatedException;
15 import org.splat.exception.LockProtectedException;
16 import org.splat.log.AppLogger;
19 * @author Maria KRUCHININA
22 public class LockServiceImpl implements LockService {
27 private final static AppLogger LOG = AppLogger.getLogger(LockService.class);
30 * Lock timeout period in milliseconds. A 24 hours by default.
32 private long _timeoutPeriod = 86400000L;
35 * Lock a data row or update lock on a data row for one user.
36 * @param rowUid Row uid
37 * @param tableUid Table uid
38 * @param userUid User uid
39 * @throws LockAlreadyExistsException when a lock already exists for row uid and another user id
41 public void lock(final String rowUid, final String tableUid, final String userUid) throws LockAlreadyExistsException {
46 * Unlock a data row for one user.
47 * @param rowUid Row uid
48 * @param tableUid Table uid
49 * @param userUid User uid
50 * @throws LockNotExistsException when lock does not exist
51 * @throws LockProtectedException lock exists for another user
53 public void unlock(final String rowUid, final String tableUid, final String userUid) throws LockNotExistsException, LockProtectedException {
58 * Unlock all datas rox for one user.
59 * @param userUid User uid
62 public void unlockAll(String userUid) {
63 // TODO Auto-generated method stub
68 * Check lock on a data row in a table for a user.
69 * @param rowUid Row uid
70 * @param tableUid Table uid
71 * @param userUid User uid
72 * @throws LockNotExistsException when lock does not exist
73 * @throws LockProtectedException lock exists for another user
74 * @throws LockOutdatedException when lock on object is in timeout but the
75 * owner of lock is another user
77 public void check(final String rowUid, final String tableUid, final String userUid) throws LockNotExistsException, LockProtectedException, LockOutdatedException {