Package com.amazonaws.services.s3.model

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


        }

        @Override
        public void startElement(String uri, String name, String qName, Attributes attrs) {
            if (name.equals("Contents")) {
                currentObject = new S3ObjectSummary();
                currentObject.setBucketName(bucketName);
            } else if (name.equals("Owner")) {
                currentOwner = new Owner();
                currentObject.setOwner(currentOwner);
            } else if (name.equals("CommonPrefixes")) {
View Full Code Here


                        return new S3FileInput(new S3ClientHelper() {
                            @Override
                            protected AmazonS3 initClient(String accessKey, String secretKey) throws IOException {
                                AmazonS3 client = mock(AmazonS3Client.class);
                                ObjectListing objectListing = mock(ObjectListing.class);
                                S3ObjectSummary summary = mock(S3ObjectSummary.class);
                                S3Object s3Object = mock(S3Object.class);

                                S3ObjectInputStream inputStream = mock(S3ObjectInputStream.class);

                                when(client.listObjects(anyString(), anyString())).thenReturn(objectListing);
                                when(objectListing.getObjectSummaries()).thenReturn(Arrays.asList(summary));
                                when(summary.getKey()).thenReturn("foo");
                                when(client.getObject("fakebucket", "foo")).thenReturn(s3Object);
                                when(s3Object.getObjectContent()).thenReturn(inputStream);
                                when(inputStream.read(new byte[anyInt()], anyInt(), anyByte())).thenReturn(-1);
                                when(client.listNextBatchOfObjects(any(ObjectListing.class))).thenReturn(objectListing);
                                when(objectListing.isTruncated()).thenReturn(false);
View Full Code Here

     */
    @Test
    public void showsDirectoryListing() throws Exception {
        final AmazonS3 client = Mockito.mock(AmazonS3.class);
        final ObjectListing listing = Mockito.mock(ObjectListing.class);
        final S3ObjectSummary summary = new S3ObjectSummary();
        final String name = "foo/bar/boo";
        summary.setKey(name);
        Mockito.doReturn(Collections.singletonList(summary))
            .when(listing).getObjectSummaries();
        final AmazonServiceException ex =
            new AmazonServiceException("No such key.");
        ex.setErrorCode("NoSuchKey");
View Full Code Here

            .getCommonPrefixes();
        final String[] names = {"baa.txt", "bee.jpg", "boo.png"};
        final ImmutableList.Builder<S3ObjectSummary> builder =
            ImmutableList.builder();
        for (final String key : names) {
            @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
            final S3ObjectSummary summary = new S3ObjectSummary();
            summary.setKey(key);
            summary.setSize(Tv.TEN);
            builder.add(summary);
        }
        Mockito.doReturn(builder.build()).when(listing).getObjectSummaries();
        final String prefix = "foo/bar/";
        MatcherAssert.assertThat(
View Full Code Here

            boolean hasNewFiles = false;
            boolean hasTags = false;
            long lastProcessed = lastProcessTime(AwsUtils.monthDateFormat.print(dataTime));

            for (BillingFile billingFile: filesToProcess.get(dataTime)) {
                S3ObjectSummary objectSummary = billingFile.s3ObjectSummary;
                if (objectSummary.getLastModified().getTime() < lastProcessed) {
                    logger.info("data has been processed. ignoring " + objectSummary.getKey() + "...");
                    continue;
                }
                hasNewFiles = true;
            }

            if (!hasNewFiles) {
                logger.info("data has been processed. ignoring all files at " + AwsUtils.monthDateFormat.print(dataTime));
                continue;
            }

            long processTime = new DateTime(DateTimeZone.UTC).getMillis();
            for (BillingFile billingFile: filesToProcess.get(dataTime)) {

                S3ObjectSummary objectSummary = billingFile.s3ObjectSummary;
                String fileKey = objectSummary.getKey();

                File file = new File(config.localDir, fileKey.substring(billingFile.prefix.length()));
                logger.info("trying to download " + fileKey + "...");
                boolean downloaded = AwsUtils.downloadFileIfChangedSince(objectSummary.getBucketName(), billingFile.prefix, file, lastProcessed,
                        billingFile.accountId, billingFile.accessRoleName, billingFile.externalId);
                if (downloaded)
                    logger.info("downloaded " + fileKey);
                else {
                    logger.info("file already downloaded " + fileKey + "...");
                }

                logger.info("processing " + fileKey + "...");
                boolean withTags = fileKey.contains("with-resources-and-tags");
                hasTags = hasTags || withTags;
                processingMonitor = false;
                processBillingZipFile(file, withTags);
                logger.info("done processing " + fileKey);
            }

            if (monitorFilesToProcess.get(dataTime) != null) {
                for (BillingFile monitorBillingFile: monitorFilesToProcess.get(dataTime)) {

                    S3ObjectSummary monitorObjectSummary = monitorBillingFile.s3ObjectSummary;
                    if (monitorObjectSummary != null) {
                        String monitorFileKey = monitorObjectSummary.getKey();
                        logger.info("processing " + monitorFileKey + "...");
                        File monitorFile = new File(config.localDir, monitorFileKey.substring(monitorFileKey.lastIndexOf("/") + 1));
                        logger.info("trying to download " + monitorFileKey + "...");
                        boolean downloaded = AwsUtils.downloadFileIfChangedSince(monitorObjectSummary.getBucketName(), monitorBillingFile.prefix, monitorFile, lastProcessed,
                                monitorBillingFile.accountId, monitorBillingFile.accessRoleName, monitorBillingFile.externalId);
                        if (downloaded)
                            logger.info("downloaded " + monitorFile);
                        else
                            logger.warn(monitorFile + "already downloaded...");
View Full Code Here

    @Override
    public QSTaskModel getAvailableTask() {
        if (!iterator.hasNext()) {
            pageForward();
        }
        S3ObjectSummary obj = iterator.next();
        assert obj != null;
        return new QSTaskModel(listingBatchId, IdSupplier.newId(), taskHandlerIdentifier, 5, ObjectMappers.valueToTree(obj));
    }
View Full Code Here

        }

        @Override
        public void startElement(String uri, String name, String qName, Attributes attrs) {
            if (name.equals("Contents")) {
                currentObject = new S3ObjectSummary();
                currentObject.setBucketName(bucketName);
            } else if (name.equals("Owner")) {
                currentOwner = new Owner();
                currentObject.setOwner(currentOwner);
            } else if (name.equals("CommonPrefixes")) {
View Full Code Here

      final List<S3ObjectSummary> list = listing.getObjectSummaries();
      final Iterator<S3ObjectSummary> it = list.iterator();
      while (it.hasNext()) {

        final S3ObjectSummary os = it.next();
        String key = os.getKey();

        final int childDepth = getDepth(os.getKey());

        if (childDepth != depth) {
          continue;
        }

        // Remove the prefix
        if (bop.hasObject()) {
          if (key.startsWith(bop.getObject())) {
            key = key.substring(bop.getObject().length());
          }

          // This has been the prefix itself
          if (key.isEmpty()) {
            continue;
          }
        }

        final long modificationDate = dateToLong(os.getLastModified());

        S3FileStatus fileStatus;
        if (objectRepresentsDirectory(os)) {
          fileStatus = new S3FileStatus(extendPath(f, key), 0, true, modificationDate, 0L);
        } else {
          fileStatus = new S3FileStatus(extendPath(f, key), os.getSize(), false, modificationDate, 0L);
        }

        resultList.add(fileStatus);
      }
View Full Code Here

        try {
            for (int part = 1; filePosition < contentLength; part++) {
                partSize = Math.min(partSize, contentLength - filePosition);

                UploadPartRequest uploadRequest = new UploadPartRequest()
                        .withBucketName(getConfiguration().getBucketName()).withKey(keyName)
                        .withUploadId(initResponse.getUploadId()).withPartNumber(part)
                        .withFileOffset(filePosition)
                        .withFile(filePayload)
                        .withPartSize(partSize);
View Full Code Here

    }

    private void doItForJob(String jobId) throws InterruptedException {
        logger.info("Beginning download of "+jobId);
        String bucketName= getLast(on("/").omitEmptyStrings().split(awsLogUri));
        Transfer that=transferManager.downloadDirectory(bucketName, jobId, new File(localLogTarget));
        that.waitForCompletion();
    }
View Full Code Here

TOP

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

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.