Package com.bradmcevoy.http

Examples of com.bradmcevoy.http.LockToken


    return memcache.delete( "token-" + id);
  }
 
 
    public LockResult lock( LockTimeout timeout, LockInfo lockInfo, LockableResource r ) {
        LockToken currentLock = currentLock( r );
        if( currentLock != null ) {
            return LockResult.failed( LockResult.FailureReason.ALREADY_LOCKED );
        }

        LockToken newToken = new LockToken( UUID.randomUUID().toString(), lockInfo, timeout );
        CurrentLock newLock = new CurrentLock( r.getUniqueId(), newToken, lockInfo.lockedByUser );
        putByUniqueId(r.getUniqueId(), newLock );
        putByTokenId(newToken.tokenId, newLock );
        return LockResult.success( newToken );
    }
View Full Code Here


        curLock.token.setFrom( new Date() );
        return LockResult.success( curLock.token );
    }

    public void unlock( String tokenId, LockableResource r ) throws NotAuthorizedException {
        LockToken lockToken = currentLock( r );
        if( lockToken == null ) {
            log.finer( "not locked" );
            return;
        }
        if( lockToken.tokenId.equals( tokenId ) ) {
View Full Code Here

    }

    private LockToken currentLock( LockableResource resource ) {
        CurrentLock curLock = getByUniqueId( resource.getUniqueId() );
        if( curLock == null ) return null;
        LockToken token = curLock.token;
        if( token.isExpired() ) {
            removeLock( token );
            return null;
        } else {
            return token;
        }
View Full Code Here

    }

    public LockToken getCurrentToken( LockableResource r ) {
        CurrentLock lock = getByUniqueId( r.getUniqueId() );
        if( lock == null ) return null;
        LockToken token = new LockToken();
        token.info = new LockInfo( LockInfo.LockScope.EXCLUSIVE, LockInfo.LockType.WRITE, lock.lockedByUser, LockInfo.LockDepth.ZERO );
        token.info.lockedByUser = lock.lockedByUser;
        token.timeout = lock.token.timeout;
        token.tokenId = lock.token.tokenId;
        return token;
View Full Code Here

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

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

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

        curLock.token.setFrom( new Date() );
        return LockResult.success( curLock.token );
    }

    public synchronized void unlock( String tokenId, LockableResource r ) throws NotAuthorizedException {
        LockToken lockToken = currentLock( r );
        if( lockToken == null ) {
            log.debug( "not locked" );
            return;
        }
        if( lockToken.tokenId.equals( tokenId ) ) {
View Full Code Here

    }

    private LockToken currentLock( LockableResource resource ) {
        CurrentLock curLock = locksByUniqueId.get( resource.getUniqueId() );
        if( curLock == null ) return null;
        LockToken token = curLock.token;
        if( token.isExpired() ) {
            removeLock( token );
            return null;
        } else {
            return token;
        }
View Full Code Here

    }

    public LockToken getCurrentToken( LockableResource r ) {
        CurrentLock lock = locksByUniqueId.get( r.getUniqueId() );
        if( lock == null ) return null;
        LockToken token = new LockToken();
        token.info = new LockInfo( LockInfo.LockScope.EXCLUSIVE, LockInfo.LockType.WRITE, lock.lockedByUser, LockInfo.LockDepth.ZERO );
        token.info.lockedByUser = lock.lockedByUser;
        token.timeout = lock.token.timeout;
        token.tokenId = lock.token.tokenId;
        return token;
View Full Code Here

        return this.hashCode() + "";
    }

    public LockToken getCurrentLock() {
        if( this.lock == null ) return null;
        LockToken token = new LockToken();
        token.info = this.lock.lockInfo;
        token.timeout = new LockTimeout( this.lock.seconds );
        token.tokenId = this.lock.lockId;

View Full Code Here

        LockTimeout.DateAndSeconds lockedUntil = timeout.getLockedUntil( 60l, 3600l );

        this.lock = new TLock( lockedUntil.date, UUID.randomUUID().toString(), lockedUntil.seconds, lockInfo );

        LockToken token = new LockToken();
        token.info = lockInfo;
        token.timeout = new LockTimeout( lockedUntil.seconds );
        token.tokenId = this.lock.lockId;

        return LockResult.success( token );
View Full Code Here

TOP

Related Classes of com.bradmcevoy.http.LockToken

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.