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 * The service to lock objects in the database.
21 * @author Maria KRUCHININA
23 public class LockServiceImpl implements LockService {
28 private final static AppLogger LOG = AppLogger.getLogger(LockService.class); // RKV: NOPMD: TODO: Complete the service.
31 * Lock timeout period in milliseconds. A 24 hours by default.
33 private final long _timeoutPeriod = 86400000L; // RKV: NOPMD: TODO: Complete the service.
36 * Lock a data row or update lock on a data row for one user.
44 * @throws LockAlreadyExistsException
45 * when a lock already exists for row uid and another user id
47 public void lock(final String rowUid, final String tableUid,
48 final String userUid) throws LockAlreadyExistsException {
53 * Unlock a data row for one user.
61 * @throws LockNotExistsException
62 * when lock does not exist
63 * @throws LockProtectedException
64 * lock exists for another user
66 public void unlock(final String rowUid, final String tableUid,
67 final String userUid) throws LockNotExistsException,
68 LockProtectedException {
73 * Unlock all datas rox for one user.
79 public void unlockAll(final String userUid) {
80 // TODO Auto-generated method stub
85 * Check lock on a data row in a table for a user.
93 * @throws LockNotExistsException
94 * when lock does not exist
95 * @throws LockProtectedException
96 * lock exists for another user
97 * @throws LockOutdatedException
98 * when lock on object is in timeout but the owner of lock is another user
100 public void check(final String rowUid, final String tableUid,
101 final String userUid) throws LockNotExistsException,
102 LockProtectedException, LockOutdatedException {