public synchronized ActiveLock createLock()

in openmeetings-service/src/main/java/org/apache/jackrabbit/webdav/lock/SimpleLockManager.java [99:135]


    public synchronized ActiveLock createLock(LockInfo lockInfo,
                                              DavResource resource)
            throws DavException {
        if (lockInfo == null || resource == null) {
            throw new IllegalArgumentException("Neither lockInfo nor resource must be null.");
        }

        String resourcePath = resource.getResourcePath();
        // test if there is already a lock present on this resource
        ActiveLock lock = locks.get(resourcePath);
        if (lock != null && lock.isExpired()) {
            locks.remove(resourcePath);
            lock = null;
        }
        if (lock != null) {
            throw new DavException(DavServletResponse.SC_LOCKED, "Resource '" + resource.getResourcePath() + "' already holds a lock.");
        }
        // test if the new lock would conflict with any lock inherited from the
        // collection or with a lock present on any member resource.
        for (String key : locks.keySet()) {
            // TODO: is check for lock on internal-member correct?
            if (isDescendant(key, resourcePath)) {
                ActiveLock l = locks.get(key);
                if (l.isDeep() || (key.equals(getParentPath(resourcePath)) && !resource.isCollection())) {
                    throw new DavException(DavServletResponse.SC_LOCKED, "Resource '" + resource.getResourcePath() + "' already inherits a lock by its collection.");
                }
            } else if (isDescendant(resourcePath, key)) {
                if (lockInfo.isDeep() || isInternalMember(resource, key)) {
                    throw new DavException(DavServletResponse.SC_CONFLICT, "Resource '" + resource.getResourcePath() + "' cannot be locked due to a lock present on the member resource '" + key + "'.");
                }

            }
        }
        lock = new DefaultActiveLock(lockInfo);
        locks.put(resource.getResourcePath(), lock);
        return lock;
    }