Package com.simplicite.util
Class ObjectUsage
- java.lang.Object
-
- com.simplicite.util.ObjectUsage
-
- All Implemented Interfaces:
java.io.Serializable
public class ObjectUsage extends java.lang.Object implements java.io.Serializable
Object usage services to manage who is updating what at a same time.- System parameter USE_OBJECT_USAGE has to be true,
- Usage applies only on UI instances of objects,
- One usage is given to a user with a session updating a record of object,
- The keep-alive calls update the last access, and the cron deadlockTimestamp remove the dead connections,
- If the object has a blocking timestamp on only one usage can be created at a same time,
- The list of users accessing one record is returned to UI thru the keep-alive calls (pull by the UI),
- An optional websocket (if protocol available) also create/remove usage on the fly (server push to people using the record),
- Session startWorkin/stopWorking removes the user's remaining usages,
- A full clear-cache or a platform restart will clear the table of usages.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ObjectUsage()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
clear()
Remove all usagesstatic java.lang.String[]
getUserLogins(Grant g, java.lang.String object, java.lang.String rowId, boolean all, boolean writeOnly)
Get users using one objectstatic java.lang.String[]
getUserLogins(ObjectDB obj, boolean all, boolean writeOnly)
Get users using one objectstatic boolean
isEnabled(ObjectDB obj)
Checks if USE_OBJECT_USAGE is true and the object is a UI instancestatic java.lang.String
jsonUsers(Grant g, java.lang.String object, java.lang.String rowId, boolean all, boolean writeOnly, boolean embedded)
Get users using one objectstatic java.lang.String
jsonUsers(ObjectDB obj, java.lang.String rowId, boolean all, boolean writeOnly, boolean embedded)
Get users using one objectstatic java.lang.String
keepAlive(Grant g, java.lang.String param)
Keep alive servicestatic void
remove(Grant g, java.lang.String object, java.lang.String rowId)
Remove one object from one user usagestatic void
removeObject(Grant g, java.lang.String object, java.lang.String rowId, java.lang.String[] logins)
Remove one object usagesstatic void
removeUser(Grant g)
Remove user's usage trackerstatic long
unlock(int duration)
Remove locks whose last access exceeds a certain durationstatic boolean
use(Grant g, java.lang.String object, java.lang.String rowId, java.lang.String userId, java.lang.String sessionId, java.lang.Boolean write)
Object usagestatic boolean
use(ObjectDB object, java.lang.String rowId, boolean write)
Object usage.
-
-
-
Method Detail
-
isEnabled
public static boolean isEnabled(ObjectDB obj)
Checks if USE_OBJECT_USAGE is true and the object is a UI instance- Parameters:
obj
- Object- Returns:
- true when the usage service is enabled
-
clear
public static void clear()
Remove all usages
-
use
public static boolean use(ObjectDB object, java.lang.String rowId, boolean write)
Object usage. Only 1 update context is available at a same time for blocking timestamp.- Parameters:
object
- ObjectrowId
- Object row Idwrite
- With write access?- Returns:
- true if write access has been accepted, false if already locked by another user
-
use
public static boolean use(Grant g, java.lang.String object, java.lang.String rowId, java.lang.String userId, java.lang.String sessionId, java.lang.Boolean write)
Object usage- Parameters:
g
- Grantobject
- Object namerowId
- Object row IduserId
- User IdsessionId
- Session Idwrite
- With write access?
-
remove
public static void remove(Grant g, java.lang.String object, java.lang.String rowId)
Remove one object from one user usage- Parameters:
g
- Grantobject
- Object namerowId
- Object Row Id
-
removeObject
public static void removeObject(Grant g, java.lang.String object, java.lang.String rowId, java.lang.String[] logins)
Remove one object usages- Parameters:
g
- Grantobject
- Object namerowId
- Object row Idlogins
- List of user to notify
-
removeUser
public static final void removeUser(Grant g)
Remove user's usage tracker- Parameters:
g
- Grant with session
-
keepAlive
public static java.lang.String keepAlive(Grant g, java.lang.String param)
Keep alive service- Parameters:
g
- Grantparam
- internal parameter _OBJUSG|<object:id>[|del]- Returns:
- JSON array of users using the object (except current user)
-
jsonUsers
public static final java.lang.String jsonUsers(ObjectDB obj, java.lang.String rowId, boolean all, boolean writeOnly, boolean embedded)
Get users using one object- Parameters:
obj
- Business objectrowId
- Object row Idall
- All people or exclude this granted object?writeOnly
- Only write access?embedded
- Return a simple/embedded response?- Returns:
- JSON array of users { login, firstname, lastname, lang, picture }
-
jsonUsers
public static java.lang.String jsonUsers(Grant g, java.lang.String object, java.lang.String rowId, boolean all, boolean writeOnly, boolean embedded)
Get users using one object- Parameters:
g
- Grantobject
- Object namerowId
- Object row Idall
- All people or exclude this granted user?writeOnly
- Only write access?embedded
- Return a simple/embedded response?- Returns:
- JSON array of users { login, firstname, lastname, lang, picture, session }
-
getUserLogins
public static final java.lang.String[] getUserLogins(ObjectDB obj, boolean all, boolean writeOnly)
Get users using one object- Parameters:
obj
- Objectall
- All people or exclude this object user?writeOnly
- Only write access?- Returns:
- Array of logins
-
getUserLogins
public static java.lang.String[] getUserLogins(Grant g, java.lang.String object, java.lang.String rowId, boolean all, boolean writeOnly)
Get users using one object- Parameters:
g
- Grantobject
- Object namerowId
- Object row Idall
- All people or exclude this granted user?writeOnly
- Only write access?- Returns:
- Array of logins
-
unlock
public static long unlock(int duration)
Remove locks whose last access exceeds a certain duration- Parameters:
duration
- positive duration in seconds- Returns:
- Number of removed locks
-
-