Class LockHandlerWithContext

  • All Implemented Interfaces:
    LockHandler

    @API(src=PRIVATE,
         type=EXTENDABLE)
    public abstract class LockHandlerWithContext
    extends LockHandlerBase

    A base-class to be extended to implement lock/unlock functionality.

    This class should be used with URLs, for whose protocol the URLStreamHandler implements URLStreamHandlerWithContext. It is this implementation which decides what contextId means.

    It is intended to be used in Oxygen XML Web Author. It provides similar functionality to LockHandlerBase, but is designed to work in a multi-user setting. Every method receives an extra parameter that identifies the user on behalf of which the resource should be locked. To make Web Author use this class, one should register a LockHandlerFactoryPluginExtension.

    Since:
    18
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract boolean isSaveAllowed​(java.lang.String contextId, java.net.URL url, int timeoutSeconds)
      Checks if save is allowed for a resource identified by its URL.
      boolean isSaveAllowed​(java.net.URL url, int timeoutSeconds)
      Checks if save is allowed for a resource identified by its URL.
      abstract void unlock​(java.lang.String contextId, java.net.URL resource)
      Unlock a specific resource
      void unlock​(java.net.URL resource)
      Unlock a specific resource
      abstract void updateLock​(java.lang.String contextId, java.net.URL resource, int timeoutSeconds)
      Lock a specific resource if it has never been locked before or refresh the lock.
      void updateLock​(java.net.URL resource, int timeoutSeconds)
      Lock a specific resource if it has never been locked before or refresh the lock.
      • Methods inherited from class java.lang.Object

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

      • LockHandlerWithContext

        public LockHandlerWithContext()
    • Method Detail

      • isSaveAllowed

        public final boolean isSaveAllowed​(java.net.URL url,
                                           int timeoutSeconds)
        Checks if save is allowed for a resource identified by its URL.
        Specified by:
        isSaveAllowed in class LockHandlerBase
        Parameters:
        url - The URL for which the check is performed.
        timeoutSeconds - The timeout in seconds to set for the lock .
        Returns:
        true if saving is allowed.
      • isSaveAllowed

        public abstract boolean isSaveAllowed​(java.lang.String contextId,
                                              java.net.URL url,
                                              int timeoutSeconds)
        Checks if save is allowed for a resource identified by its URL.
        Parameters:
        contextId - The ID of the user context, as defined by the URLStreamHandlerWithContext implementation for the URL's protocol.
        url - The URL for which the check is performed.
        timeoutSeconds - The timeout in seconds to set for the lock .
        Returns:
        true if saving is allowed.
      • unlock

        public final void unlock​(java.net.URL resource)
                          throws LockException
        Unlock a specific resource
        Parameters:
        resource - The URL to unlock
        Throws:
        LockException - When could not unlock properly.
      • unlock

        public abstract void unlock​(java.lang.String contextId,
                                    java.net.URL resource)
                             throws LockException
        Unlock a specific resource
        Parameters:
        contextId - The ID of the user context, as defined by the URLStreamHandlerWithContext implementation for the URL's protocol.
        resource - The URL to unlock
        Throws:
        LockException - When could not unlock properly.
      • updateLock

        public final void updateLock​(java.net.URL resource,
                                     int timeoutSeconds)
                              throws LockException
        Lock a specific resource if it has never been locked before or refresh the lock. This will get called at the beginning to lock the resource and after that periodically.
        Parameters:
        resource - The URL to lock.
        timeoutSeconds - The timeout in seconds to set for the lock (so that the lock expires after the timeout passes). The refresh on the lock is called about every (timeout/2) seconds.
        Throws:
        LockException - When could not lock properly.
      • updateLock

        public abstract void updateLock​(java.lang.String contextId,
                                        java.net.URL resource,
                                        int timeoutSeconds)
                                 throws LockException
        Lock a specific resource if it has never been locked before or refresh the lock. This will get called at the beginning to lock the resource and after that periodically.
        Parameters:
        contextId - The ID of the user context, as defined by the URLStreamHandlerWithContext implementation for the URL's protocol.
        resource - The URL to lock.
        timeoutSeconds - The timeout in seconds to set for the lock (so that the lock expires after the timeout passes). The refresh on the lock is called about every (timeout/2) seconds.
        Throws:
        LockException - When could not lock properly.