use of com.ibm.watson.visual_recognition.v4.model.ObjectMetadata in project BridgeServer2 by Sage-Bionetworks.
the class UploadServiceTest method uploadCompleteConcurrentModificationException.
@Test
public void uploadCompleteConcurrentModificationException() throws Exception {
UploadRequest uploadRequest = constructUploadRequest();
DynamoUpload2 upload = new DynamoUpload2(uploadRequest, HEALTH_CODE);
upload.setUploadId(ORIGINAL_UPLOAD_ID);
upload.setRecordId(RECORD_ID);
ObjectMetadata metadata = new ObjectMetadata();
metadata.setSSEAlgorithm(AES_256_SERVER_SIDE_ENCRYPTION);
when(mockS3Client.getObjectMetadata(UPLOAD_BUCKET_NAME, ORIGINAL_UPLOAD_ID)).thenReturn(metadata);
doThrow(new ConcurrentModificationException("error")).when(mockUploadDao).uploadComplete(S3_WORKER, upload);
svc.uploadComplete(TEST_APP_ID, S3_WORKER, upload, true);
verify(mockUploadDao).uploadComplete(S3_WORKER, upload);
verify(mockUploadValidationService, never()).validateUpload(TEST_APP_ID, upload);
}
use of com.ibm.watson.visual_recognition.v4.model.ObjectMetadata in project BridgeServer2 by Sage-Bionetworks.
the class UploadServiceTest method uploadComplete.
@Test
public void uploadComplete() throws Exception {
App app = App.create();
app.setExporter3Enabled(false);
when(mockAppService.getApp(TEST_APP_ID)).thenReturn(app);
UploadRequest uploadRequest = constructUploadRequest();
DynamoUpload2 upload = new DynamoUpload2(uploadRequest, HEALTH_CODE);
upload.setUploadId(ORIGINAL_UPLOAD_ID);
upload.setRecordId(RECORD_ID);
ObjectMetadata metadata = new ObjectMetadata();
metadata.setSSEAlgorithm(AES_256_SERVER_SIDE_ENCRYPTION);
when(mockS3Client.getObjectMetadata(UPLOAD_BUCKET_NAME, ORIGINAL_UPLOAD_ID)).thenReturn(metadata);
svc.uploadComplete(TEST_APP_ID, S3_WORKER, upload, true);
verify(mockUploadDao).uploadComplete(S3_WORKER, upload);
verify(mockUploadValidationService).validateUpload(TEST_APP_ID, upload);
}
use of com.ibm.watson.visual_recognition.v4.model.ObjectMetadata in project BridgeServer2 by Sage-Bionetworks.
the class HibernateTemplateRevisionDao method createTemplateRevision.
@Override
public void createTemplateRevision(TemplateRevision revision) {
checkNotNull(revision);
try {
String storagePath = getStoragePath(revision.getTemplateGuid(), revision.getCreatedOn());
ObjectMetadata metadata = new ObjectMetadata();
metadata.setSSEAlgorithm(AES_256_SERVER_SIDE_ENCRYPTION);
s3Helper.writeBytesToS3(publicationsBucket, storagePath, revision.getDocumentContent().getBytes(defaultCharset()), metadata);
} catch (IOException ioe) {
throw new BridgeServiceException("Error persisting template revision document", ioe);
}
hibernateHelper.create(revision);
}
use of com.ibm.watson.visual_recognition.v4.model.ObjectMetadata in project quality-measure-and-cohort-service by Alvearie.
the class ValueSetImporter method putToS3.
private static void putToS3(ValueSetImporterArguments arguments, FhirContext fhirContext, ValueSet vs, String vsFileName, AmazonS3 S3Client) {
ObjectMetadata metadata = new ObjectMetadata();
byte[] arr = fhirContext.newJsonParser().encodeResourceToString(vs).getBytes();
metadata.setContentLength(arr.length);
PutObjectRequest put = new PutObjectRequest(arguments.bucket, vsFileName, new ByteArrayInputStream(arr), metadata);
S3Client.putObject(put);
}
use of com.ibm.watson.visual_recognition.v4.model.ObjectMetadata in project refonte-implicaction by dyno-nuggets.
the class S3CloudServiceImpl method uploadFile.
@Override
public FileModel uploadFile(MultipartFile file) {
final String originalFilename = file.getOriginalFilename();
final String filenameExtension = StringUtils.getFilenameExtension(originalFilename);
final String key = UUID.randomUUID() + filenameExtension;
final ObjectMetadata metadata = new ObjectMetadata();
final long fileSize = file.getSize();
final String contentType = file.getContentType();
metadata.setContentLength(fileSize);
metadata.setContentType(contentType);
try {
if (!client.doesBucketExist(BUCKET_NAME)) {
client.createBucket(BUCKET_NAME);
}
client.putObject(BUCKET_NAME, key, file.getInputStream(), metadata);
client.setObjectAcl(BUCKET_NAME, key, CannedAccessControlList.PublicRead);
return FileModel.builder().filename(file.getOriginalFilename()).contentType(contentType).url(client.getResourceUrl(BUCKET_NAME, key)).objectKey(key).build();
} catch (IOException exception) {
throw new ResponseStatusException(INTERNAL_SERVER_ERROR, String.format(UNKNOWN_FILE_UPLOAD_MESSAGE, originalFilename));
}
}
Aggregations