public class LockHelper extends Object
Modifier and Type | Field and Description |
---|---|
protected static ThreadLocal<Boolean> |
isWOPIRequest
Flag to know if the request originated from a WOPI client.
|
Modifier and Type | Method and Description |
---|---|
static void |
addLock(String fileId,
String lock)
Stores the given WOPI lock for the given file id with a timestamp for expiration purpose.
|
static void |
addLock(String fileId,
String repository,
String docId,
String lock) |
static void |
doPrivilegedOnLockDirectory(Consumer<Session> consumer)
Performs the given consumer with a privileged session on the lock directory.
|
static <R> R |
doPrivilegedOnLockDirectory(Function<Session,R> function)
Applies the given function with a privileged session on the lock directory.
|
static void |
flagWOPIRequest()
Flags the request as originating from a WOPI client.
|
protected static Map<String,List<DocumentModel>> |
getExpiredLocks(Session session,
String repository) |
static Map<String,List<DocumentModel>> |
getExpiredLocksByRepository(Session session)
Returns the list of expired stored WOPI locks according to the
Constants.LOCK_TTL for each repository. |
static String |
getLock(String fileId)
Gets the WOPI lock stored for the given file id if it exists, returns
null otherwise. |
static boolean |
isLocked(String fileId)
Checks if a WOPI lock is stored for the given file id.
|
static boolean |
isLocked(String repository,
String docId)
Checks if a WOPI lock is stored for the given repository and doc id, no matter the xpath.
|
static boolean |
isWOPIRequest()
Returns
true if the request originated from a WOPI client. |
protected static Session |
openLockDirectorySession() |
static void |
refreshLock(String fileId)
Updates the WOPI lock stored for the given file id with a fresh timestamp.
|
static void |
removeLock(String fileId)
Removes the WOPI lock stored for the given file id.
|
static void |
removeLocks(String repository,
String docId)
Removes all the WOPI locks stored for the given repository and doc id.
|
static void |
unflagWOPIRequest()
Unflags the request as originating from a WOPI client.
|
static void |
updateLock(String fileId,
String lock)
Updates the WOPI lock stored for the given file id with the given lock and a fresh timestamp.
|
protected static ThreadLocal<Boolean> isWOPIRequest
public static void addLock(String fileId, String lock)
public static void addLock(String fileId, String repository, String docId, String lock)
addLock(String, String)
public static String getLock(String fileId)
null
otherwise.public static boolean isLocked(String repository, String docId)
public static boolean isLocked(String fileId)
public static void updateLock(String fileId, String lock)
public static void refreshLock(String fileId)
public static void removeLock(String fileId)
public static void removeLocks(String repository, String docId)
public static void doPrivilegedOnLockDirectory(Consumer<Session> consumer)
public static <R> R doPrivilegedOnLockDirectory(Function<Session,R> function)
public static Map<String,List<DocumentModel>> getExpiredLocksByRepository(Session session)
Constants.LOCK_TTL
for each repository.
The given session must be privileged.
public static boolean isWOPIRequest()
true
if the request originated from a WOPI client.public static void flagWOPIRequest()
public static void unflagWOPIRequest()
protected static Map<String,List<DocumentModel>> getExpiredLocks(Session session, String repository)
protected static Session openLockDirectorySession()
Copyright © 2019 Nuxeo. All rights reserved.