Package org.apache.slide.lock

Examples of org.apache.slide.lock.NodeLock


                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 SourceLock[] getSourceLocks() throws SourceException {
        try {
            List result = new ArrayList();

            NodeLock lock;
            Enumeration locks = m_lock.enumerateLocks(m_slideToken,m_uri, false);
            while (locks.hasMoreElements()) {
                lock = (NodeLock) locks.nextElement();
                result.add(new SourceLock(lock.getSubjectUri(),
                                          lock.getTypeUri(),
                                          lock.getExpirationDate(),
                                          lock.isInheritable(),
                                          lock.isExclusive()));
            }

            return (SourceLock[]) result.toArray(new SourceLock[result.size()]);
        } catch (SlideException se) {
            throw new SourceException("Could not retrieve locks", se);
View Full Code Here

       SlideToken slideToken = new SlideTokenImpl(new CredentialsToken(caller));
       Lock lock = nat.getLockHelper();
      
       try {
           nat.begin();
           lock.lock(slideToken,new NodeLock(uri,subject,type,expire,isExclusive,isInherit));
           nat.commit();
       }
       catch (Exception e) {
           try {
               nat.rollback();
View Full Code Here

                                              (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

                    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

        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() == null ? "" : aLock.getOwnerInfo());
            aElementLocks.addContent(aElementLock);
        }
        return aElementLocks;
    }
View Full Code Here

                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

                rNrd.setProperty(property);
            }
           
            if (isAutoVersionCheckout &&
                !(E_CHECKOUT_IGNORE_UNLOCK.equals(getAutoVersionElementName(rNrd)))) {
                NodeLock writeLock = getWriteLock(sToken, 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

        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(
            new ViolatedPrecondition("valid-lock-token",
                WebdavStatus.SC_CONFLICT, INVALID_LOCK_TOKEN),
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.