Package org.apache.slide.lock

Examples of org.apache.slide.lock.NodeLock


        NodeRevisionDescriptors revisionDescriptors = null;
        NodeRevisionDescriptor revisionDescriptor = null;
       
        boolean isCollection = false;
       
        NodeLock objectLockToken = null;
       
        try {
            Element hrefElement = new Element(E_HREF, DNSP);
           
            VersioningHelper vHelp =  VersioningHelper.getVersioningHelper(
View Full Code Here


            if (property != null) {
                rNrd.setProperty(property);
            }
           
            if (isAutoVersionCheckout) {
                NodeLock writeLock = getWriteLock(readonlySlideToken(), rNrds);
                if (writeLock != null) {
                    NodeProperty p =
                        new NodeProperty(I_CHECKIN_LOCKTOKEN,
                                         writeLock.getLockId(),
                                         NamespaceCache.SLIDE_URI);
                    p.setKind( NodeProperty.Kind.PROTECTED );
                    rNrd.setProperty( p );
                }
            }
View Full Code Here

     * @return     the write lock of the resource.
     */
    private NodeLock getWriteLock(SlideToken slideToken, NodeRevisionDescriptors revisionDescriptors)
        throws ServiceAccessException {
       
        NodeLock writeLock = null;
        try {
            Enumeration lockEnum = lock.enumerateLocks(slideToken, revisionDescriptors.getUri());
            if (lockEnum != null && lockEnum.hasMoreElements()) {
                // there are no other types of locks beside write locks ... so take the first one if there
                writeLock = (NodeLock)lockEnum.nextElement();
View Full Code Here

                Vector locksVector = null;
                if (value == null) {
                    locksVector = new Vector();
                    Enumeration lockList = lockStore.enumerateLocks(uri);
                    while (lockList.hasMoreElements()) {
                        NodeLock tempLock = (NodeLock) lockList.nextElement();
                        tempLock.validate(uri.toString());
                        locksVector.addElement(tempLock);
                    }
                    locksCache.put(uri.toString(), locksVector);
                } else {
                    locksVector = (Vector) value;
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

                        // Creating the revision descriptor
                        content.create(slideToken, lockInfo_lockSubject,
                                       revisionDescriptor, null);
                    }
                   
                    NodeLock lockToken = null;
                   
                    inheritance = (depth != 0);
                    boolean exclusive =
                        !(lockInfo_lockScope.equals(E_SHARED));
                   
                    if (lockDate == null)
                        lockDate = new Date((new Date()).getTime()
                                                + ((long)lockDuration * 1000L));
                   
                    lockToken =
                        new NodeLock(toLockSubject, (SubjectNode)security.getPrincipal(slideToken),
                                     namespaceConfig.getCreateObjectAction(),
                                     lockDate, inheritance, exclusive, lockInfo_lockOwner);
                    lock.lock(slideToken, lockToken);
                   
                    // Set the lock-token header
                    // [RFC 2518, 9.5] " The Lock-Token response header is used
                    // with the LOCK method to indicate the lock token created as
                    // a result of a successful LOCK request to create a new
                    // lock."
                    resp.setHeader("Lock-Token",
                                   "<"+S_LOCK_TOKEN+lockToken.getLockId()+">");
                   
                    resp.setStatus(WebdavStatus.SC_OK);
                   
                    // The lock token on which the DAV module will have the info
                   
                    showLockDiscoveryInfo(lockToken);
                   
                } catch (ObjectIsAlreadyLockedException e) {
                    if (inheritance && generateMultiStatusResponse(isCollection, e, requestUri)) {
                        // error is on the resource which we attempted to lock
                        String errorMessage = generateErrorMessage(e);
                        // Write it on the servlet writer
                        resp.setContentType(TEXT_XML_UTF_8);
                        resp.setStatus(WebdavStatus.SC_MULTI_STATUS);
                        try {
                            resp.getWriter().write(errorMessage);
                        } catch(IOException ex) {
                            // Critical error ... Servlet container is dead or something
                            int statusCode = WebdavStatus.SC_INTERNAL_SERVER_ERROR;
                            sendError( statusCode, e );
                            throw new WebdavException( statusCode );
                        }
                    } else {
                        // Returning 207 on non-collection requests is generally
                        // considered bad. So let's not do it, since this way
                        // makes clients generally behave better.
                        resp.setStatus(WebdavStatus.SC_LOCKED);
                    }
                    //
                    // make sure the transaction is aborted
                    // throw any WebDAV exception to indicate the transaction wants to be aborted
                    //
                    throw new WebdavException(WebdavStatus.SC_ACCEPTED, false);
                } catch (Exception e) {
                    int statusCode = getErrorCode( e );
                    sendError( statusCode, e );
                    throw new WebdavException( statusCode );
                }
               
                break;
               
            case LOCK_REFRESH:
               
                try {
                   
                    Enumeration lockTokens =
                        lock.enumerateLocks(slideToken, lockInfo_lockSubject, false);
                   
                    NodeLock currentLockToken = null;
                    Date newExpirationDate =
                        new Date((new Date()).getTime() + ((long)lockDuration * 1000L));
                    while (lockTokens.hasMoreElements()) {
                        currentLockToken = (NodeLock) lockTokens.nextElement();
                        lock.renew(slideToken, currentLockToken,
View Full Code Here

            Vector locksVector = null;
            if (value == null) {
                locksVector = new Vector();
                Enumeration lockList = lockStore.enumerateLocks(uri);
                while (lockList.hasMoreElements()) {
                    NodeLock tempLock = (NodeLock) lockList.nextElement();
                    tempLock.validate(uri.toString());
                    locksVector.addElement(tempLock);
                }
                locksCache.put(uri.toString(), locksVector);
            } else {
                locksVector = (Vector) value;
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

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.