Examples of LockToken


Examples of com.bradmcevoy.http.LockToken

    public LockResult refreshLock( String token ) {
        if( lock == null ) throw new RuntimeException( "not locked" );
        if( !lock.lockId.equals( token ) )
            throw new RuntimeException( "invalid lock id" );
        this.lock = lock.refresh();
        LockToken tok = makeToken();
        return LockResult.success( tok );
    }
View Full Code Here

Examples of com.bradmcevoy.http.LockToken

            throw new RuntimeException( "Invalid lock token" );
        this.lock = null;
    }

    LockToken makeToken() {
        LockToken token = new LockToken();
        token.info = lock.lockInfo;
        token.timeout = new LockTimeout( lock.seconds );
        token.tokenId = lock.lockId;
        return token;
    }
View Full Code Here

Examples of com.bradmcevoy.http.LockToken

   
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    XmlWriter xmlWriter = new XmlWriter(out);
    LockInfo lockInfo = new LockInfo(LockInfo.LockScope.EXCLUSIVE, LockInfo.LockType.READ, null, LockInfo.LockDepth.ZERO);
    LockTimeout lockTimeout = new LockTimeout(1000l);
    LockToken token = new LockToken("abc123", lockInfo, lockTimeout);
    Map<String,String> prefixes = new HashMap<String, String>();
   
    valueWriter.writeValue(xmlWriter, "uri", "ns", "aName", locks, "/test", prefixes);
   
    xmlWriter.flush();
View Full Code Here

Examples of com.bradmcevoy.http.LockToken

  public void testWriteValue() {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    XmlWriter xmlWriter = new XmlWriter(out);
    LockInfo lockInfo = new LockInfo(LockInfo.LockScope.EXCLUSIVE, LockInfo.LockType.READ, null, LockInfo.LockDepth.ZERO);
    LockTimeout lockTimeout = new LockTimeout(1000l);
    LockToken token = new LockToken("abc123", lockInfo, lockTimeout);
    Map<String,String> prefixes = new HashMap<String, String>();
   
    valueWriter.writeValue(xmlWriter, "ns", "pre", "lock", token, "/test", prefixes);
   
    xmlWriter.flush();
View Full Code Here

Examples of com.bradmcevoy.http.LockToken

        printer.print( s );
    }

    public final LockResult lock( LockTimeout lockTimeout, LockInfo lockInfo ) {
        log.trace( "Lock : " + lockTimeout + " info : " + lockInfo + " on resource : " + getName() + " in : " + parent );
        LockToken token = new LockToken();
        token.info = lockInfo;
        token.timeout = LockTimeout.parseTimeout( "30" );
        token.tokenId = UUID.randomUUID().toString();
        currentLock = token;
        return LockResult.success( token );
View Full Code Here

Examples of com.bradmcevoy.http.LockToken

    }

    public final LockResult refreshLock( String tokenId ) {
        log.trace( "RefreshLock : " + tokenId + " on resource : " + getName() + " in : " + parent );
        //throw new UnsupportedOperationException("Not supported yet.");
        LockToken token = new LockToken();
        token.info = null;
        token.timeout = LockTimeout.parseTimeout( "30" );
        token.tokenId = currentLock.tokenId;
        currentLock = token;
        return LockResult.success( token );
View Full Code Here

Examples of com.bradmcevoy.http.LockToken

    class LockDiscoveryPropertyWriter implements StandardProperty<LockToken> {

        public LockToken getValue( PropFindableResource res ) {
            if( !( res instanceof LockableResource ) ) return null;
            LockableResource lr = (LockableResource) res;
            LockToken token = lr.getCurrentLock();
            return token;
        }
View Full Code Here

Examples of com.bradmcevoy.http.LockToken

    public boolean supports( String nsUri, String localName, Class c ) {
        return LockToken.class.isAssignableFrom( c );
    }

    public void writeValue( XmlWriter writer, String nsUri, String prefix, String localName, Object val, String href, Map<String, String> nsPrefixes ) {
        LockToken token = (LockToken) val;
        Element lockDiscovery = writer.begin( "D:lockdiscovery" ).open();   
        if( token != null ) {
      Element activeLock = writer.begin( "D:activelock" ).open();
            LockInfo info = token.info;
            lockWriterHelper.appendType( writer, info.type );
View Full Code Here

Examples of com.bradmcevoy.http.LockToken

        locksByToken = new HashMap<String, CurrentLock>();
    }

    public synchronized LockResult lock( LockTimeout timeout, LockInfo lockInfo, LockableResource r ) {
        FsResource resource = (FsResource) r;
        LockToken currentLock = currentLock( resource );
        if( currentLock != null ) {
            return LockResult.failed( LockResult.FailureReason.ALREADY_LOCKED );
        }

        LockToken newToken = new LockToken( UUID.randomUUID().toString(), lockInfo, timeout );
        CurrentLock newLock = new CurrentLock( resource.getFile(), newToken, lockInfo.lockedByUser );
        locksByFile.put( resource.getFile(), newLock );
        locksByToken.put( newToken.tokenId, newLock );
        return LockResult.success( newToken );
    }
View Full Code Here

Examples of com.bradmcevoy.http.LockToken

        }
    }

    public synchronized void unlock( String tokenId, LockableResource r ) throws NotAuthorizedException {
        FsResource resource = (FsResource) r;
        LockToken lockToken = currentLock( resource );
        if( lockToken == null ) {
            log.debug( "not locked" );
            return;
        }
        if( lockToken.tokenId.equals( tokenId ) ) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.