Package org.apache.slide.lock

Examples of org.apache.slide.lock.NodeLock


        NodeRevisionDescriptors revisionDescriptors = null;
        NodeRevisionDescriptor revisionDescriptor = null;
       
        boolean isCollection = false;
       
        NodeLock objectLockToken = null;
        String serverURL = HTTP_PROTOCOL + req.getServerName()+ ":" + req.getServerPort();
       
        try {
            Element hrefElement = new Element(E_HREF, DNSP);
           
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

                        lockDate = new Date((new Date()).getTime()
                                                + ((long)MAX_TIMEOUT * 1000L));
                       
                    }
                   
                    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

    public Element encodeLocks() {
        Element aElementLocks=new Element("locks");
        if (locks==null) return aElementLocks;
       
        for (int aSize=locks.size(),i=0;i<aSize;i++) {
            NodeLock aLock=(NodeLock)locks.elementAt(i);
            Element aElementLock=new Element("lock");
            aElementLock.setAttribute("subjectUri",aLock.getSubjectUri());
            aElementLock.setAttribute("typeUri",aLock.getTypeUri());
            aElementLock.setAttribute("date",dateFormat.format(aLock.getExpirationDate()));
            aElementLock.setAttribute("inheritance",booleanToString(aLock.isInheritable()));
            aElementLock.setAttribute("exclusive",booleanToString(aLock.isExclusive()));
            aElementLock.setAttribute("lockId",aLock.getLockId());
            aElementLocks.addContent(aElementLock);
        }
        return aElementLocks;
    }
View Full Code Here

                Date aDateExpiration=dateFormat.parse(aChild.getAttributeValue("date"));
                boolean aInheritable=new Boolean(aChild.getAttributeValue("inheritance")).booleanValue();
                boolean aNegative=new Boolean(aChild.getAttributeValue("exclusive")).booleanValue();
                String aLockId=aChild.getAttributeValue("lockId");
                locks.addElement(
                    new NodeLock(aLockId,object.getUri(),aSubject,aType,aDateExpiration,aInheritable,aNegative)
                );
            }
        }
        catch (Exception e) {
            e.printStackTrace();
View Full Code Here

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

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

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

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

       
        try {
            Enumeration locks = super.enumerateLocks(obtainResourceId(uri));
            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.