Search in sources :

Example 1 with SimpleStorageResourceLoader

use of org.springframework.cloud.aws.core.io.s3.SimpleStorageResourceLoader in project snomed-drools by IHTSDO.

the class RuleExecutor method newTestResourceProvider.

public TestResourceProvider newTestResourceProvider(String awsKey, String awsSecretKey, String bucket, String path) throws RuleExecutorException {
    try {
        AmazonS3 amazonS3 = AmazonS3ClientBuilder.standard().withRegion("us-east-1").withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(awsKey, awsSecretKey))).build();
        ManualResourceConfiguration resourceConfiguration = new ManualResourceConfiguration(true, true, null, new ResourceConfiguration.Cloud(bucket, path));
        ResourceManager resourceManager = new ResourceManager(resourceConfiguration, new SimpleStorageResourceLoader(amazonS3));
        TestResourceProvider testResourceProvider = new TestResourceProvider(resourceManager);
        testResourcesEmpty = !testResourceProvider.isAnyResourcesLoaded();
        return testResourceProvider;
    } catch (IOException e) {
        testResourcesEmpty = true;
        throw new RuleExecutorException("Failed to load test resources.", e);
    }
}
Also used : AmazonS3(com.amazonaws.services.s3.AmazonS3) AWSStaticCredentialsProvider(com.amazonaws.auth.AWSStaticCredentialsProvider) RuleExecutorException(org.ihtsdo.drools.exception.RuleExecutorException) BadRequestRuleExecutorException(org.ihtsdo.drools.exception.BadRequestRuleExecutorException) SimpleStorageResourceLoader(org.springframework.cloud.aws.core.io.s3.SimpleStorageResourceLoader) ResourceManager(org.ihtsdo.otf.resourcemanager.ResourceManager) IOException(java.io.IOException) ManualResourceConfiguration(org.ihtsdo.otf.resourcemanager.ManualResourceConfiguration) TestResourceProvider(org.ihtsdo.drools.service.TestResourceProvider) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) ResourceConfiguration(org.ihtsdo.otf.resourcemanager.ResourceConfiguration) ManualResourceConfiguration(org.ihtsdo.otf.resourcemanager.ManualResourceConfiguration)

Example 2 with SimpleStorageResourceLoader

use of org.springframework.cloud.aws.core.io.s3.SimpleStorageResourceLoader in project snomed-drools by IHTSDO.

the class DroolsRF2Validator method getTestResourceManager.

private static ResourceManager getTestResourceManager(boolean loadTestResources) throws IOException {
    if (loadTestResources) {
        Properties properties = new Properties();
        // Load bucket and path for test resources
        properties.load(DroolsRF2Validator.class.getResourceAsStream("/aws.properties"));
        ManualResourceConfiguration testResourcesConfiguration = new ManualResourceConfiguration(true, true, null, new ResourceConfiguration.Cloud(properties.getProperty("test-resources.cloud.bucket"), properties.getProperty("test-resources.cloud.path")));
        // This uses anonymous access
        return new ResourceManager(testResourcesConfiguration, new SimpleStorageResourceLoader(AmazonS3ClientBuilder.standard().withRegion("us-east-1").build()));
    } else {
        return new ResourceManager(BLANK_RESOURCES_CONFIGURATION, null);
    }
}
Also used : SimpleStorageResourceLoader(org.springframework.cloud.aws.core.io.s3.SimpleStorageResourceLoader) ResourceManager(org.ihtsdo.otf.resourcemanager.ResourceManager) ManualResourceConfiguration(org.ihtsdo.otf.resourcemanager.ManualResourceConfiguration) ResourceConfiguration(org.ihtsdo.otf.resourcemanager.ResourceConfiguration) ManualResourceConfiguration(org.ihtsdo.otf.resourcemanager.ManualResourceConfiguration)

Aggregations

ManualResourceConfiguration (org.ihtsdo.otf.resourcemanager.ManualResourceConfiguration)2 ResourceConfiguration (org.ihtsdo.otf.resourcemanager.ResourceConfiguration)2 ResourceManager (org.ihtsdo.otf.resourcemanager.ResourceManager)2 SimpleStorageResourceLoader (org.springframework.cloud.aws.core.io.s3.SimpleStorageResourceLoader)2 AWSStaticCredentialsProvider (com.amazonaws.auth.AWSStaticCredentialsProvider)1 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)1 AmazonS3 (com.amazonaws.services.s3.AmazonS3)1 IOException (java.io.IOException)1 BadRequestRuleExecutorException (org.ihtsdo.drools.exception.BadRequestRuleExecutorException)1 RuleExecutorException (org.ihtsdo.drools.exception.RuleExecutorException)1 TestResourceProvider (org.ihtsdo.drools.service.TestResourceProvider)1