Class LockHandlerWithContext

java.lang.Object
ro.sync.exml.plugin.lock.LockHandlerBase
ro.sync.ecss.extensions.api.webapp.plugin.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
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract boolean
    isSaveAllowed(String contextId, URL url, int timeoutSeconds)
    Checks if save is allowed for a resource identified by its URL.
    final boolean
    isSaveAllowed(URL url, int timeoutSeconds)
    Checks if save is allowed for a resource identified by its URL.
    abstract void
    unlock(String contextId, URL resource)
    Unlock a specific resource
    final void
    unlock(URL resource)
    Unlock a specific resource
    abstract void
    updateLock(String contextId, URL resource, int timeoutSeconds)
    Lock a specific resource if it has never been locked before or refresh the lock.
    final void
    updateLock(URL resource, int timeoutSeconds)
    Lock a specific resource if it has never been locked before or refresh the lock.

    Methods inherited from class ro.sync.exml.plugin.lock.LockHandlerBase

    isLockEnabled

    Methods inherited from class java.lang.Object

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

    • LockHandlerWithContext

      public LockHandlerWithContext()
  • Method Details

    • isSaveAllowed

      public final boolean isSaveAllowed(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(String contextId, 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(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(String contextId, 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(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(String contextId, 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.