public void reportSchemaRegistryStatus()

in src/main/java/com/amazonaws/schemamanager/reports/SchemaManagerReporterS3.java [45:101]


	public void reportSchemaRegistryStatus(CheckChangesResponse response) {
		
		List<ReportRecord> records = convertToRecords(response);
		
		Regions region = Regions.DEFAULT_REGION;
		String regionStr = config.getRegion();
		if (regionStr != null && !regionStr.isEmpty()) {
			try {
				region = Regions.valueOf(regionStr);
			}catch(Exception e) {
				log.error("Cannot use region: "+ regionStr, e);
			}
		}
		
        String bucketName = config.getBucketName();
        String key = config.getPrefixDir() + String.format(config.getFilenamePattern(), "status", getFileDate());
        
        try {
        	AmazonS3 s3Client = AmazonS3ClientBuilder.standard()
                    .withCredentials(new ProfileCredentialsProvider())
                    .withRegion(region)
                    .build();
	
        	// Set the pre-signed URL to expire after one hour.
        	java.util.Date expiration = new java.util.Date();
            long expTimeMillis = expiration.getTime();
            expTimeMillis += 1000 * 60 * 60;
            expiration.setTime(expTimeMillis);
            
            GeneratePresignedUrlRequest generatePresignedUrlRequest = new GeneratePresignedUrlRequest(bucketName, key)
                    .withMethod(HttpMethod.PUT)
                    .withExpiration(expiration);
            URL url = s3Client.generatePresignedUrl(generatePresignedUrlRequest);

            // Create the connection and use it to upload the new object using the pre-signed URL.
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setDoOutput(true);
            connection.setRequestMethod("PUT");
            
            OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream());
            for (ReportRecord r: records) {
            	out.write(r.toJson()+ "\n");
            }
            out.close();
            
            connection.getResponseCode();
            
            log.info("Create Object HTTP response code: " + connection.getResponseCode());
            
            // validation
            S3Object object = s3Client.getObject(bucketName, key);
            log.info("Object " + object.getKey() + " created in bucket " + object.getBucketName());

        }catch(Exception e) {
        	 e.printStackTrace();
        }
	}