Skip to content
This repository has been archived by the owner on Aug 6, 2018. It is now read-only.

Commit

Permalink
simplify with value annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
mrandi committed Apr 27, 2015
1 parent 7544c6a commit 133f084
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 46 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,5 @@
*/
@Configuration
@ComponentScan(basePackages = {"org.zalando.stups.fullstop.controller"})
@EnableConfigurationProperties({FullstopLoggingProperties.class})
public class FullstopTimemachineAutoconfiguration {
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
Expand Down Expand Up @@ -64,25 +65,24 @@ public class S3Controller {

private PluginEventsProcessor pluginEventsProcessor;

private FullstopLoggingProperties fullstopLoggingProperties;

private final CloudTrailProcessingLibraryProperties cloudTrailProcessingLibraryProperties;

@Value("${fullstop.logging.dir}")
private String fullstopLoggingDir;

@Autowired
public S3Controller(final PluginEventsProcessor pluginEventsProcessor,
final FullstopLoggingProperties fullstopLoggingProperties,
final CloudTrailProcessingLibraryProperties cloudTrailProcessingLibraryProperties) {
this.pluginEventsProcessor = pluginEventsProcessor;
this.fullstopLoggingProperties = fullstopLoggingProperties;
this.cloudTrailProcessingLibraryProperties = cloudTrailProcessingLibraryProperties;
}

@RequestMapping(method = RequestMethod.GET, value = "/read")
public void fetchS3() throws CallbackException, FileNotFoundException {

log.info("Reading fullstop directory here: {}", fullstopLoggingProperties.getDir());
log.info("Reading fullstop directory here: {}", fullstopLoggingDir);

File directory = new File(fullstopLoggingProperties.getDir());
File directory = new File(fullstopLoggingDir);

File[] files;

Expand Down Expand Up @@ -110,9 +110,9 @@ public void downloadFiles(@RequestParam(value = "bucket") final String bucket,
@RequestParam(value = "page") final int page) {

try {
log.info("Creating fullstop directory here: {}", fullstopLoggingProperties.getDir());
log.info("Creating fullstop directory here: {}", fullstopLoggingDir);

boolean mkdirs = new File(fullstopLoggingProperties.getDir()).mkdirs();
boolean mkdirs = new File(fullstopLoggingDir).mkdirs();
} catch (SecurityException e) {
// do nothing
}
Expand Down Expand Up @@ -144,7 +144,7 @@ public void downloadFiles(@RequestParam(value = "bucket") final String bucket,
S3Object object = amazonS3Client.getObject(new GetObjectRequest(bucketName, key));
InputStream inputStream = object.getObjectContent();

File file = new File(fullstopLoggingProperties.getDir(),
File file = new File(fullstopLoggingDir,
object.getBucketName() + object.getObjectMetadata().getETag() + JSON_GZ);

copyInputStreamToFile(inputStream, file);
Expand Down

0 comments on commit 133f084

Please sign in to comment.