Examples of WriteRequest


Examples of com.amazonaws.services.dynamodb.model.WriteRequest

            if ( !requestItems.containsKey(tableName) ) {
                requestItems.put(tableName, new LinkedList<WriteRequest>());
            }

            requestItems.get(tableName).add(
                    new WriteRequest().withPutRequest(new PutRequest().withItem(attributeValues)));
        }

        for ( Object toDelete : objectsToDelete ) {
            Class<?> clazz = toDelete.getClass();

            String tableName = getTableName(clazz, config);

            Method hashKeyGetter = reflector.getHashKeyGetter(clazz);
            AttributeValue hashKeyElement = getHashKeyElement(safeInvoke(hashKeyGetter, toDelete), hashKeyGetter);

            AttributeValue rangeKeyElement = null;
            Method rangeKeyGetter = reflector.getRangeKeyGetter(clazz);
            if ( rangeKeyGetter != null ) {
                rangeKeyElement = getRangeKeyElement(safeInvoke(rangeKeyGetter, toDelete), rangeKeyGetter);
            }

            Key objectKey = new Key().withHashKeyElement(hashKeyElement).withRangeKeyElement(rangeKeyElement);

            if ( !requestItems.containsKey(tableName) ) {
                requestItems.put(tableName, new LinkedList<WriteRequest>());
            }

            requestItems.get(tableName).add(
                    new WriteRequest().withDeleteRequest(new DeleteRequest().withKey(objectKey)));
        }

        // Break into chunks of 25 items and make service requests to DynamoDB
        while ( !requestItems.isEmpty() ) {
            HashMap<String, List<WriteRequest>> batch = new HashMap<String, List<WriteRequest>>();
            int i = 0;
            Iterator<Entry<String, List<WriteRequest>>> tableIter = requestItems.entrySet().iterator();
            while ( tableIter.hasNext() && i < 25 ) {
                Entry<String, List<WriteRequest>> tableRequest = tableIter.next();
                batch.put(tableRequest.getKey(), new LinkedList<WriteRequest>());
                Iterator<WriteRequest> writeRequestIter = tableRequest.getValue().iterator();
                while ( writeRequestIter.hasNext() && i++ < 25 ) {
                    WriteRequest writeRequest = writeRequestIter.next();
                    batch.get(tableRequest.getKey()).add(writeRequest);
                    writeRequestIter.remove();
                }

                // If we've processed all the write requests for this table,
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.model.WriteRequest

            if ( !requestItems.containsKey(tableName) ) {
                requestItems.put(tableName, new LinkedList<WriteRequest>());
            }

            requestItems.get(tableName).add(
                    new WriteRequest().withPutRequest(new PutRequest().withItem(transformAttributes(clazz, attributeValues))));
        }

        for ( Object toDelete : objectsToDelete ) {
            Class<?> clazz = toDelete.getClass();

            String tableName = getTableName(clazz, config);

            Map<String, AttributeValue> key = getKey(toDelete);

            if ( !requestItems.containsKey(tableName) ) {
                requestItems.put(tableName, new LinkedList<WriteRequest>());
            }

            requestItems.get(tableName).add(
                    new WriteRequest().withDeleteRequest(new DeleteRequest().withKey(key)));
        }

        // Break into chunks of 25 items and make service requests to DynamoDB
        while ( !requestItems.isEmpty() ) {
            HashMap<String, List<WriteRequest>> batch = new HashMap<String, List<WriteRequest>>();
            int i = 0;
            Iterator<Entry<String, List<WriteRequest>>> tableIter = requestItems.entrySet().iterator();
            while ( tableIter.hasNext() && i < 25 ) {
                Entry<String, List<WriteRequest>> tableRequest = tableIter.next();
                batch.put(tableRequest.getKey(), new LinkedList<WriteRequest>());
                Iterator<WriteRequest> writeRequestIter = tableRequest.getValue().iterator();
                while ( writeRequestIter.hasNext() && i++ < 25 ) {
                    WriteRequest writeRequest = writeRequestIter.next();
                    batch.get(tableRequest.getKey()).add(writeRequest);
                    writeRequestIter.remove();
                }

                // If we've processed all the write requests for this table,
View Full Code Here

Examples of org.apache.ftpserver.usermanager.WriteRequest

        StringBuffer sb = new StringBuffer(128);
        sb.append("\n");
        sb.append("userid          : ").append(user.getName()).append("\n");
        sb.append("userpassword    : ********\n");
        sb.append("homedirectory   : ").append(user.getHomeDirectory()).append("\n");
        sb.append("writepermission : ").append(user.authorize(new WriteRequest())).append("\n");
        sb.append("enableflag      : ").append(user.getEnabled()).append("\n");
        sb.append("idletime        : ").append(user.getMaxIdleTime()).append("\n");
       
        TransferRateRequest transferRateRequest = new TransferRateRequest();
        transferRateRequest = (TransferRateRequest) session.getUser().authorize(transferRateRequest);
View Full Code Here

Examples of org.apache.ftpserver.usermanager.impl.WriteRequest

    /**
     * Check file write permission.
     */
    public boolean isWritable() {
        LOG.debug("Checking authorization for " + getAbsolutePath());
        if (user.authorize(new WriteRequest(getAbsolutePath())) == null) {
            LOG.debug("Not authorized");
            return false;
        }

        LOG.debug("Checking if file exists");
View Full Code Here

Examples of org.apache.ftpserver.usermanager.impl.WriteRequest

         * be deleted when their parent directory is writable.
        */
        String fullName = getAbsolutePath();

        // we check FTPServer's write permission for this file.
        if (user.authorize(new WriteRequest(fullName)) == null) {
            return false;
        }
        // In order to maintain consistency, when possible we delete the last '/' character in the String
        int indexOfSlash = fullName.lastIndexOf('/');
        String parentFullName;
View Full Code Here

Examples of org.apache.ftpserver.usermanager.impl.WriteRequest

        sb.append("userid          : ").append(user.getName()).append("\n");
        sb.append("userpassword    : ********\n");
        sb.append("homedirectory   : ").append(user.getHomeDirectory()).append(
                "\n");
        sb.append("writepermission : ").append(
                user.authorize(new WriteRequest()) != null).append("\n");
        sb.append("enableflag      : ").append(user.getEnabled()).append("\n");
        sb.append("idletime        : ").append(user.getMaxIdleTime()).append(
                "\n");

        TransferRateRequest transferRateRequest = new TransferRateRequest();
View Full Code Here

Examples of org.apache.ftpserver.usermanager.impl.WriteRequest

        return request instanceof WriteRequest;
    }

    public AuthorizationRequest authorize(final AuthorizationRequest request) {
        if ((request instanceof WriteRequest) && this.acm != null) {
            WriteRequest writeRequest = (WriteRequest) request;
            String requestFile = writeRequest.getFile();

            try {
                if (this.acm.hasPrivileges(requestFile, this.write)) {
                    return writeRequest;
                }
View Full Code Here

Examples of org.apache.mina.common.IoFilter.WriteRequest

    {
        protected boolean argumentMatches( Object expected, Object actual )
        {
            if( expected instanceof WriteRequest && expected instanceof WriteRequest )
            {
                WriteRequest w1 = ( WriteRequest ) expected;
                WriteRequest w2 = ( WriteRequest ) actual;
               
                return w1.getMessage().equals( w2.getMessage() )
                    && w1.getFuture().isWritten() == w2.getFuture().isWritten();
            }
            return super.argumentMatches( expected, actual );
        }
View Full Code Here

Examples of org.apache.mina.common.IoFilter.WriteRequest

    public void testWriteEmptyStream() throws Exception
    {
        StreamWriteFilter filter = new StreamWriteFilter();
       
        InputStream stream = new ByteArrayInputStream( new byte[ 0 ] );
        WriteRequest writeRequest = new WriteRequest( stream );
       
        /*
         * Record expectations
         */
        nextFilter.messageSent( session, stream );
       
        /*
         * Replay.
         */
        mockNextFilter.replay();
        mockSession.replay();
       
        filter.filterWrite( nextFilter, session, writeRequest );
       
        /*
         * Verify.
         */
        mockNextFilter.verify();
        mockSession.verify();
       
        assertTrue( writeRequest.getFuture().isWritten() );
    }
View Full Code Here

Examples of org.apache.mina.common.IoFilter.WriteRequest

    public void testWriteNonStreamMessage() throws Exception
    {
        StreamWriteFilter filter = new StreamWriteFilter();
       
        Object message = new Object();
        WriteRequest writeRequest = new WriteRequest( message );
       
        /*
         * Record expectations
         */
        nextFilter.filterWrite( session, writeRequest );
        session.getAttribute( StreamWriteFilter.CURRENT_STREAM );
        mockSession.setReturnValue( null );
        nextFilter.messageSent( session, message );
       
        /*
         * Replay.
         */
        mockNextFilter.replay();
        mockSession.replay();
       
        filter.filterWrite( nextFilter, session, writeRequest );
        filter.messageSent( nextFilter, session, message );
       
        /*
         * Verify.
         */
        mockNextFilter.verify();
        mockSession.verify();
       
        assertTrue( writeRequest.getFuture().isWritten() );
    }
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.