@Test void lastModified_fileDoestNotExist_reportsError() throws Exception { AmazonS3 amazonS3 = mock(AmazonS3.class); when(amazonS3.getObjectMetadata(any(GetObjectMetadataRequest.class))) .thenReturn(null); SimpleStorageResource simpleStorageResource = new SimpleStorageResource(amazonS3, "bucket", "object", new SyncTaskExecutor()); assertThatThrownBy(simpleStorageResource::lastModified) .isInstanceOf(FileNotFoundException.class) .hasMessageContaining("not found"); }
private ObjectMetadata getObjectMetadata() { if (this.objectMetadata == null) { try { GetObjectMetadataRequest metadataRequest = new GetObjectMetadataRequest( this.bucketName, this.objectName); if (this.versionId != null) { metadataRequest.setVersionId(this.versionId); } this.objectMetadata = this.amazonS3.getObjectMetadata(metadataRequest); } catch (AmazonS3Exception e) { if (e.getStatusCode() == 404 || e.getStatusCode() == 301) { this.objectMetadata = null; } else { throw e; } } } return this.objectMetadata; }
SimpleStorageResource extends AbstractResource implements WritableResource { private ObjectMetadata getObjectMetadata() { if (this.objectMetadata == null) { try { GetObjectMetadataRequest metadataRequest = new GetObjectMetadataRequest( this.bucketName, this.objectName); if (this.versionId != null) { metadataRequest.setVersionId(this.versionId); } this.objectMetadata = this.amazonS3.getObjectMetadata(metadataRequest); } catch (AmazonS3Exception e) { if (e.getStatusCode() == 404 || e.getStatusCode() == 301) { this.objectMetadata = null; } else { throw e; } } } return this.objectMetadata; } }
SimpleStorageResource extends AbstractResource implements WritableResource { private ObjectMetadata getObjectMetadata() { if (this.objectMetadata == null) { try { GetObjectMetadataRequest metadataRequest = new GetObjectMetadataRequest( this.bucketName, this.objectName); if (this.versionId != null) { metadataRequest.setVersionId(this.versionId); } this.objectMetadata = this.amazonS3.getObjectMetadata(metadataRequest); } catch (AmazonS3Exception e) { if (e.getStatusCode() == 404 || e.getStatusCode() == 301) { this.objectMetadata = null; } else { throw e; } } } return this.objectMetadata; } SimpleStorageResource(AmazonS3 amazonS3, String bucketName, String objectName,
			TaskExecutor taskExecutor);  SimpleStorageResource(AmazonS3 amazonS3, String bucketName, String objectName,
			TaskExecutor taskExecutor, String versionId); }
SimpleStorageResource extends AbstractResource implements WritableResource { private ObjectMetadata getObjectMetadata() { if (this.objectMetadata == null) { try { GetObjectMetadataRequest metadataRequest = new GetObjectMetadataRequest( this.bucketName, this.objectName); if (this.versionId != null) { metadataRequest.setVersionId(this.versionId); } this.objectMetadata = this.amazonS3.getObjectMetadata(metadataRequest); } catch (AmazonS3Exception e) { if (e.getStatusCode() == 404 || e.getStatusCode() == 301) { this.objectMetadata = null; } else { throw e; } } } return this.objectMetadata; } SimpleStorageResource(AmazonS3 amazonS3, String bucketName, String objectName,
			TaskExecutor taskExecutor);  SimpleStorageResource(AmazonS3 amazonS3, String bucketName, String objectName,
			TaskExecutor taskExecutor, String versionId); @Override String getDescription(); @Override InputStream getInputStream(); @Override boolean exists(); @Override long contentLength(); @Override long lastModified(); @Override String getFilename(); @Override URL getURL(); URI getS3Uri(); @Override File getFile(); @Override boolean isWritable(); @Override OutputStream getOutputStream(); @Override SimpleStorageResource createRelative(String relativePath); AmazonS3 getAmazonS3(); }
SimpleStorageResource extends AbstractResource implements WritableResource { private ObjectMetadata getObjectMetadata() { if (this.objectMetadata == null) { try { GetObjectMetadataRequest metadataRequest = new GetObjectMetadataRequest( this.bucketName, this.objectName); if (this.versionId != null) { metadataRequest.setVersionId(this.versionId); } this.objectMetadata = this.amazonS3.getObjectMetadata(metadataRequest); } catch (AmazonS3Exception e) { if (e.getStatusCode() == 404 || e.getStatusCode() == 301) { this.objectMetadata = null; } else { throw e; } } } return this.objectMetadata; } SimpleStorageResource(AmazonS3 amazonS3, String bucketName, String objectName,
			TaskExecutor taskExecutor);  SimpleStorageResource(AmazonS3 amazonS3, String bucketName, String objectName,
			TaskExecutor taskExecutor, String versionId); @Override String getDescription(); @Override InputStream getInputStream(); @Override boolean exists(); @Override long contentLength(); @Override long lastModified(); @Override String getFilename(); @Override URL getURL(); URI getS3Uri(); @Override File getFile(); @Override boolean isWritable(); @Override OutputStream getOutputStream(); @Override SimpleStorageResource createRelative(String relativePath); AmazonS3 getAmazonS3();  }