Class 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 usages
      static java.lang.String[] getUserLogins​(Grant g, java.lang.String object, java.lang.String rowId, boolean all, boolean writeOnly)
      Get users using one object
      static java.lang.String[] getUserLogins​(ObjectDB obj, boolean all, boolean writeOnly)
      Get users using one object
      static boolean isEnabled​(ObjectDB obj)
      Checks if USE_OBJECT_USAGE is true and the object is a UI instance
      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
      static java.lang.String jsonUsers​(ObjectDB obj, java.lang.String rowId, boolean all, boolean writeOnly, boolean embedded)
      Get users using one object
      static java.lang.String keepAlive​(Grant g, java.lang.String param)
      Keep alive service
      static void remove​(Grant g, java.lang.String object, java.lang.String rowId)
      Remove one object from one user usage
      static void removeObject​(Grant g, java.lang.String object, java.lang.String rowId, java.lang.String[] logins)
      Remove one object usages
      static void removeUser​(Grant g)
      Remove user's usage tracker
      static long unlock​(int duration)
      Remove locks whose last access exceeds a certain duration
      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
      static boolean use​(ObjectDB object, java.lang.String rowId, boolean write)
      Object usage.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ObjectUsage

        public ObjectUsage()
    • 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 - Object
        rowId - Object row Id
        write - 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 - Grant
        object - Object name
        rowId - Object row Id
        userId - User Id
        sessionId - Session Id
        write - 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 - Grant
        object - Object name
        rowId - 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 - Grant
        object - Object name
        rowId - Object row Id
        logins - 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 - Grant
        param - 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 object
        rowId - Object row Id
        all - 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 - Grant
        object - Object name
        rowId - Object row Id
        all - 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 - Object
        all - 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 - Grant
        object - Object name
        rowId - Object row Id
        all - 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