Package org.apache.slide.lock

Examples of org.apache.slide.lock.NodeLock


     */
    public Enumeration getSourceLocks() throws SourceException {
        try {
            Vector sourcelocks = new Vector();

            NodeLock lock;

            for (Enumeration locks = this.lock.enumerateLocks(this.slideToken,
                this.config.getFilesPath()+this.path, false);
                locks.hasMoreElements(); ) {
                lock = (NodeLock) locks.nextElement();

                sourcelocks.addElement(new SourceLock(lock.getSubjectUri(),
                                                      lock.getTypeUri(),
                                                      lock.getExpirationDate(),
                                                      lock.isInheritable(),
                                                      lock.isExclusive()));
            }

            return sourcelocks.elements();
        } catch (SlideException se) {
            throw new SourceException("Could not retrieve locks", se);
View Full Code Here


     */
    private XMLValue computeLockDiscovery(NodeRevisionDescriptors revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath, String servletPath) throws ServiceAccessException, LinkedObjectNotFoundException, ObjectNotFoundException, LockTokenNotFoundException {
       
        XMLValue xmlValue = new XMLValue();
        Lock lock = nsaToken.getLockHelper();
        NodeLock objectLockToken = null;
        Enumeration lockTokens = lock.enumerateLocks(readonlySlideToken(), revisionDescriptors.getUri(), true);
        Set addedLockIDs = new HashSet();
        while (lockTokens.hasMoreElements()) {
            objectLockToken = (NodeLock) lockTokens.nextElement();
            if (revisionDescriptors.getUri().equals(objectLockToken.getObjectUri()) ||
                objectLockToken.isInheritable()
               ) {
               
                if (!addedLockIDs.contains(objectLockToken.getLockId())) {
                    Element activelock = createActiveLockElement(objectLockToken,servletPath, contextPath);
                    if (activelock != null) {
                        xmlValue.add(activelock);
                        addedLockIDs.add(objectLockToken.getLockId());
                    }
                }
            }
        }
       
View Full Code Here

               
                while (locksList.hasMoreElements()) {
                    writer.print("<tr" + (shade ? " bgcolor=\"eeeeee\""
                                              : " bgcolor=\"dddddd\"") +
                                     ">\r\n");
                    NodeLock currentLock = (NodeLock) locksList.nextElement();
                    writer.print("<td align=\"left\"><tt>");
                    writer.print(currentLock.getSubjectUri());
                    writer.print("</tt></td>\r\n");
                    writer.print("<td align=\"left\"><tt>");
                    writer.print(currentLock.getTypeUri());
                    writer.print("</tt></td>\r\n");
                    writer.print("<td align=\"right\"><tt>");
                    writer.print
                        (formatter.format(currentLock.getExpirationDate()));
                    writer.print("</tt></td>\r\n");
                    writer.print("<td align=\"right\"><tt>");
                    writer.print(currentLock.isInheritable());
                    writer.print("</tt></td>\r\n");
                    writer.print("<td align=\"right\"><tt>");
                    writer.print(currentLock.isExclusive());
                    writer.print("</tt></td>\r\n");
                }
            }
        }
    }
View Full Code Here

        Enumeration locksAll = lock.enumerateLocks(slideToken, resourcePath, true);
        if (!locksAll.hasMoreElements()) {
            return;
        }
       
        NodeLock nodeLock = findMatchingNodeLock(false);
       
        if (nodeLock != null) {
            if (!lock.checkLockOwner(slideToken, nodeLock)) {
                throw new PreconditionViolationException(
                    new ViolatedPrecondition("lock-owner-or-unlock-privilege",
                                             WebdavStatus.SC_FORBIDDEN,
                                             UNLOCK_NOT_ALLOWED),
                    resourcePath
                );
            }
        }
        else {
            nodeLock = findMatchingNodeLock(true);
            if (nodeLock != null) {
                throw new PreconditionViolationException(
                    new ViolatedPrecondition("lock-root",
                                             WebdavStatus.SC_CONFLICT,
                                             IS_NOT_LOCK_ROOT+getFullPath(nodeLock.getObjectUri())),
                    resourcePath
                );
            }
            else {
                throw new PreconditionViolationException(
View Full Code Here

            }
        }
    }
   
    private NodeLock findMatchingNodeLock(boolean inherited) throws ObjectNotFoundException, LockTokenNotFoundException, ServiceAccessException {
        NodeLock nodeLock = null;
        Enumeration locks = lock.enumerateLocks(slideToken, resourcePath, inherited);
        while ( nodeLock == null && locks.hasMoreElements() ) {
            NodeLock nl = (NodeLock) locks.nextElement();
            if (nl.getLockId().equals(lockId)) {
                nodeLock = nl;
            }
        }
        return nodeLock;
    }
View Full Code Here

            super.putLock(uri, lock);
        }
        else {
            try {
                ResourceId resourceId = obtainResourceId(uri);
                NodeLock lockClone = lock.cloneObject();
                lockClone.setObjectUri(resourceId.getUuri()); // switch to uuri
                resourceId.getStore().putLock(resourceId, lockClone);
            }
            catch (ObjectNotFoundException e) {
                throw new ServiceAccessException(this, e);
            }
View Full Code Here

            super.renewLock(uri, lock);
        }
        else {
            try {
                ResourceId resourceId = obtainResourceId(uri);
                NodeLock lockClone = lock.cloneObject();
                lockClone.setObjectUri(resourceId.getUuri()); // switch to uuri
                resourceId.getStore().renewLock(resourceId, lockClone);
            }
            catch (ObjectNotFoundException e) {
                throw new ServiceAccessException(this, e);
            }
View Full Code Here

            super.removeLock(uri, lock);
        }
        else {
            try {
                ResourceId resourceId = obtainResourceId(uri);
                NodeLock lockClone = lock.cloneObject();
                lockClone.setObjectUri(resourceId.getUuri()); // switch to uuri
                resourceId.getStore().removeLock(resourceId, lockClone);
            }
            catch (ObjectNotFoundException e) {
                throw new ServiceAccessException(this, e);
            }
View Full Code Here

            super.killLock(uri, lock);
        }
        else {
            try {
                ResourceId resourceId = obtainResourceId(uri);
                NodeLock lockClone = lock.cloneObject();
                lockClone.setObjectUri(resourceId.getUuri()); // switch to uuri
                resourceId.getStore().killLock(resourceId, lockClone);
            }
            catch (ObjectNotFoundException e) {
                throw new ServiceAccessException(this, e);
            }
View Full Code Here

            try {
                ResourceId resourceId = obtainResourceId(uri);
                Enumeration locks = resourceId.getStore().enumerateLocks(resourceId);
                Vector result = new Vector();
                while (locks.hasMoreElements()) {
                    NodeLock l = ((NodeLock)locks.nextElement()).cloneObject();
                    l.setObjectUri(uri.toString()); // switch to uri
                    result.add(l);
                }
                return result.elements();
            }
            catch (ObjectNotFoundException e) {
View Full Code Here

TOP

Related Classes of org.apache.slide.lock.NodeLock

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.