Package com.amazonaws.services.s3.model

Examples of com.amazonaws.services.s3.model.Permission


    // Read S3 ACL list and build VFS ACL.
    Set<Grant> grants = s3Acl.getGrants();

    for (Grant item : grants) {
      // Map enums to jets3t ones
      Permission perm = item.getPermission();
      Acl.Permission[] rights;
      if (perm.equals(Permission.FullControl)) {
        rights = Acl.Permission.values();
      } else if (perm.equals(Permission.Read)) {
        rights = new Acl.Permission[1];
        rights[0] = Acl.Permission.READ;
      } else if (perm.equals(Permission.Write)) {
        rights = new Acl.Permission[1];
        rights[0] = Acl.Permission.WRITE;
      } else {
        // Skip unknown permission
        logger.error(String.format("Skip unknown permission %s", perm));
View Full Code Here


        // Skip empty rights
        continue;
      }

      // Set permission
      Permission perm;
      if (ArrayUtils.isEquals(rights, allRights)) {
        // Use ArrayUtils instead of native equals method.
        // JRE1.6 enum[].equals behavior is very strange:
        // Two equal by elements arrays are not equal
        // Yeah, AFAIK its like that for any array.
View Full Code Here

    AccessControlList aclList = s3client.getBucketAcl(bucketName);
    Set<Grant> grants = aclList.getGrants();

    Iterator<Grant> i = grants.iterator();
    while (i.hasNext()) {
      Permission permission = i.next().getPermission();
      if (permission.equals(Permission.Write)) {
        bWritePermission = true;
        break;
      }
    }
View Full Code Here

        ObjectMetadata objectMetadata = determineMetadata(exchange);

        File filePayload = null;
        Object obj = exchange.getIn().getMandatoryBody();
        PutObjectRequest putObjectRequest = null;
        // Need to check if the message body is WrappedFile
        if (obj instanceof WrappedFile) {
            obj = ((WrappedFile<?>)obj).getFile();
        }
        if (obj instanceof File) {
            filePayload = (File) obj;
            putObjectRequest = new PutObjectRequest(getConfiguration().getBucketName(), determineKey(exchange), filePayload);
        } else {
            putObjectRequest = new PutObjectRequest(getConfiguration().getBucketName(),
                determineKey(exchange), exchange.getIn().getMandatoryBody(InputStream.class), objectMetadata);
        }

        String storageClass = determineStorageClass(exchange);
        if (storageClass != null) {
            putObjectRequest.setStorageClass(storageClass);
        }

        String cannedAcl = exchange.getIn().getHeader(S3Constants.CANNED_ACL, String.class);
        if (cannedAcl != null) {
            CannedAccessControlList objectAcl = CannedAccessControlList.valueOf(cannedAcl);
            putObjectRequest.setCannedAcl(objectAcl);
        }

        AccessControlList acl = exchange.getIn().getHeader(S3Constants.ACL, AccessControlList.class);
        if (acl != null) {
            // note: if cannedacl and acl are both specified the last one will be used. refer to
            // PutObjectRequest#setAccessControlList for more details
            putObjectRequest.setAccessControlList(acl);
        }
        LOG.trace("Put object [{}] from exchange [{}]...", putObjectRequest, exchange);

        PutObjectResult putObjectResult = getEndpoint().getS3Client().putObject(putObjectRequest);

        LOG.trace("Received result [{}]", putObjectResult);

        Message message = getMessageForResponse(exchange);
        message.setHeader(S3Constants.E_TAG, putObjectResult.getETag());
        if (putObjectResult.getVersionId() != null) {
            message.setHeader(S3Constants.VERSION_ID, putObjectResult.getVersionId());
        }

        if (getConfiguration().isDeleteAfterWrite() && filePayload != null) {
            IOHelper.close(putObjectRequest.getInputStream());
            FileUtil.deleteFile(filePayload);
        }
    }
View Full Code Here

        Date lastModified = exchange.getIn().getHeader(S3Constants.LAST_MODIFIED, Date.class);
        if (lastModified != null) {
            objectMetadata.setLastModified(lastModified);
        }
       
        PutObjectRequest putObjectRequest = new PutObjectRequest(
                getConfiguration().getBucketName(),
                determineKey(exchange),
                exchange.getIn().getMandatoryBody(InputStream.class),
                objectMetadata);

        String storageClass = determineStorageClass(exchange);
        if (storageClass != null) {
            putObjectRequest.setStorageClass(storageClass);
        }

        LOG.trace("Put object [{}] from exchange [{}]...", putObjectRequest, exchange);
       
        PutObjectResult putObjectResult = getEndpoint().getS3Client().putObject(putObjectRequest);
View Full Code Here

       
        assertMockEndpointsSatisfied();
       
        assertResultExchange(result.getExchanges().get(0));
       
        PutObjectRequest putObjectRequest = client.putObjectRequests.get(0);
        assertEquals("REDUCED_REDUNDANCY", putObjectRequest.getStorageClass());
        assertEquals("mycamelbucket", putObjectRequest.getBucketName());
       
        assertResponseMessage(exchange.getIn());
    }
View Full Code Here

       
        assertMockEndpointsSatisfied();
       
        assertResultExchange(result.getExchanges().get(0));
       
        PutObjectRequest putObjectRequest = client.putObjectRequests.get(0);
        assertEquals("REDUCED_REDUNDANCY", putObjectRequest.getStorageClass());
        assertEquals("mycamelbucket", putObjectRequest.getBucketName());
       
        assertResponseMessage(exchange.getOut());
    }
View Full Code Here

       
        assertMockEndpointsSatisfied();
       
        assertResultExchange(result.getExchanges().get(0));
       
        PutObjectRequest putObjectRequest = client.putObjectRequests.get(0);
        assertEquals("STANDARD", putObjectRequest.getStorageClass());
        assertEquals("mycamelbucket", putObjectRequest.getBucketName());
        assertEquals(2L, putObjectRequest.getMetadata().getContentLength());
        assertEquals("text/html", putObjectRequest.getMetadata().getContentType());
        assertEquals("no-cache", putObjectRequest.getMetadata().getCacheControl());
        assertEquals("attachment;", putObjectRequest.getMetadata().getContentDisposition());
        assertEquals("gzip", putObjectRequest.getMetadata().getContentEncoding());
        assertEquals("TWF", putObjectRequest.getMetadata().getContentMD5());
        assertEquals(now, putObjectRequest.getMetadata().getLastModified());
       
        assertResponseMessage(exchange.getIn());
    }
View Full Code Here

    /* (non-Javadoc)
     * @see com.amazonaws.services.s3.AmazonS3#putObject(java.lang.String, java.lang.String, java.io.File)
     */
    public PutObjectResult putObject(String bucketName, String key, File file)
            throws AmazonClientException, AmazonServiceException {
        return putObject(new PutObjectRequest(bucketName, key, file)
            .withMetadata(new ObjectMetadata()));
    }
View Full Code Here

    /* (non-Javadoc)
     * @see com.amazonaws.services.s3.AmazonS3#putObject(java.lang.String, java.lang.String, java.io.InputStream, com.amazonaws.services.s3.model.S3ObjectMetadata)
     */
    public PutObjectResult putObject(String bucketName, String key, InputStream input, ObjectMetadata metadata)
            throws AmazonClientException, AmazonServiceException {
        return putObject(new PutObjectRequest(bucketName, key, input, metadata));
    }
View Full Code Here

TOP

Related Classes of com.amazonaws.services.s3.model.Permission

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.