List of usage examples for com.amazonaws.services.s3.model S3ObjectSummary getLastModified
public Date getLastModified()
From source file:org.springframework.integration.aws.support.filters.S3PersistentAcceptOnceFileListFilter.java
License:Apache License
@Override protected long modified(S3ObjectSummary file) { return (file != null) ? file.getLastModified().getTime() : 0L; }
From source file:org.symphonyoss.vb.mail.MailReader.java
License:Apache License
public List<SymMessage> getMessages(String bucket, String prefix) { AwsS3Client awsS3Client = new AwsS3Client(); List<SymMessage> messages = new ArrayList<>(); List<S3ObjectSummary> objectSummaries = awsS3Client.getAllObjects(System.getProperty(BotConfig.S3_BUCKET), System.getProperty(BotConfig.MAIL_S3_PREFIX_INCOMING)); for (S3ObjectSummary objectSummary : objectSummaries) { if (objectSummary.getKey().equals(prefix)) continue; logger.info("New mail file: {}:{}:{}", objectSummary.getKey(), objectSummary.getSize(), objectSummary.getLastModified()); try {/* www . java 2 s .c om*/ Message message = Mailer.getMessage(awsS3Client.getObject(objectSummary)); //Couldn't convert it. if (message == null) continue; try { SymMessage symMessage = getSymMessage(message); if (symMessage != null) { logger.info("New mail message: from: {}, subject: {}, body: {}", symMessage.getSymUser().getEmailAddress(), message.getSubject(), symMessage.getMessage()); messages.add(symMessage); } } catch (SymException ex) { logger.error("Could not convert email to SymMessage from file [{}]", objectSummary.getKey(), ex); } String destKey = objectSummary.getKey().substring(objectSummary.getKey().lastIndexOf("/") + 1); //logger.info("DEST FILE: {}", destKey); awsS3Client.moveObject(objectSummary, System.getProperty(BotConfig.S3_BUCKET), System.getProperty(BotConfig.MAIL_S3_PREFIX_PROCESSED) + destKey); } catch (Exception e) { logger.error("Failed to process incoming email [{}]", objectSummary.getKey(), e); } } return messages; }