Package org.apache.slide.lock

Examples of org.apache.slide.lock.NodeLock


                                              (LOCKS_EXPIRATIONDATE));
                    expirationDate = new Date(timeValue.longValue());
                } catch (NumberFormatException e) {
                    expirationDate = new Date();
                }
                NodeLock lock =
                    new NodeLock(res.getString(LOCKS_ID),
                                 res.getString(LOCKS_OBJECT),
                                 res.getString(LOCKS_SUBJECT),
                                 res.getString(LOCKS_TYPE),
                                 expirationDate,
                                 (res.getInt(LOCKS_INHERITABLE) == 1),
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

            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

            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

        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

                boolean aInheritable = new Boolean(aChild.getAttributeValue("inheritance")).booleanValue();
                boolean aNegative = new Boolean(aChild.getAttributeValue("exclusive")).booleanValue();
                String aLockId = aChild.getAttributeValue("lockId");
                String ownerInfo = aChild.getAttributeValue("owner");

                locks.addElement(new NodeLock(aLockId, uri, aSubject, aType, aDateExpiration, aInheritable, aNegative, ownerInfo));
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new ServiceAccessException(null, e);
        }
View Full Code Here

                    expirationDate = new Date(timeValue.longValue());
                } catch (NumberFormatException e) {
                    getLogger().log(e, LOG_CHANNEL, Logger.WARNING);
                    expirationDate = new Date();
                }
                NodeLock lock =
                    new NodeLock(
                        res.getString("LCK"),
                        uri.toString(),
                        res.getString("SUBJECT"),
                        res.getString("TYPE"),
                        expirationDate,
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());
            aElementLock.setAttribute("owner",aLock.getOwnerInfo());
            aElementLocks.addContent(aElementLock);
        }
        return aElementLocks;
    }
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.