Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
burtbeckwith committed May 5, 2015
1 parent 49189e2 commit f248016
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 103 deletions.
13 changes: 5 additions & 8 deletions .gitignore
@@ -1,20 +1,17 @@
# GRAILS files
/web-app/WEB-INF
# Grails files
/grails-aws-sdk-*.zip
/grails-aws-sdk-*.zip.sha1
/plugin.xml
/target
/target-eclipse
/web-app

# IDE files
.classpath
.idea/
.project
.settings
/*.launch
/*.tmproj

*.log
*.zip
*.iml
/out
plugin.xml
.DS_Store
*.sha1
5 changes: 2 additions & 3 deletions AwsSdkGrailsPlugin.groovy
Expand Up @@ -15,7 +15,6 @@ Using the SDK, developers can build solutions for Amazon Simple Storage Service
def documentation = "http://agorapulse.github.io/grails-aws-sdk/guide/"
def license = "APACHE"
def organization = [ name: "AgoraPulse", url: "http://www.agorapulse.com/" ]
def issueManagement = [ system: "github", url: "https://github.com/agorapulse/grails-aws-sdk/issues" ]
def scm = [ url: "https://github.com/agorapulse/grails-aws-sdk" ]

def issueManagement = [ url: "https://github.com/agorapulse/grails-aws-sdk/issues" ]
def scm = [ url: "https://github.com/agorapulse/grails-aws-sdk" ]
}
33 changes: 16 additions & 17 deletions README.md
Expand Up @@ -24,22 +24,22 @@ Declare the plugin dependency in the BuildConfig.groovvy file, as shown here:

```groovy
grails.project.dependency.resolution = {
inherits("global") { }
log "info"
repositories {
//your repositories
}
dependencies {
// Workaround to resolve dependency issue with aws-java-sdk and http-builder (dependent on httpcore:4.0)
build 'org.apache.httpcomponents:httpcore:4.2'
build 'org.apache.httpcomponents:httpclient:4.2'
runtime 'org.apache.httpcomponents:httpcore:4.2'
runtime 'org.apache.httpcomponents:httpclient:4.2'
}
plugins {
//here go your plugin dependencies
runtime ':aws-sdk:1.9.33'
}
inherits "global"
log "info"
repositories {
// your repositories
}
dependencies {
// Workaround to resolve dependency issue with aws-java-sdk and http-builder (dependent on httpcore:4.0)
build 'org.apache.httpcomponents:httpcore:4.2'
build 'org.apache.httpcomponents:httpclient:4.2'
runtime 'org.apache.httpcomponents:httpcore:4.2'
runtime 'org.apache.httpcomponents:httpclient:4.2'
}
plugins {
// here go your plugin dependencies
runtime ':aws-sdk:1.9.33'
}
}
```

Expand Down Expand Up @@ -182,4 +182,3 @@ We decided to write our own AWS plugin because it did not meet our requirements:
2. only [AWS SDK for Java](http://aws.amazon.com/sdkforjava/) with a consistent way to access **ALL** AWS services,
3. fast release update with 100% compatibility with [AWS SDK for Java](http://aws.amazon.com/sdkforjava/), as it is just a simple lightweight wrapper around the official java clients,
4. no need for additional DSL/methods injection, since we found the [AWS SDK for Java](http://aws.amazon.com/sdkforjava/) clients pretty straightforward to use

3 changes: 0 additions & 3 deletions application.properties
@@ -1,5 +1,2 @@
#Grails Metadata file
#Mon Apr 28 16:34:26 CEST 2014
app.grails.version=2.4.4
app.name=grails-aws-sdk
app.servlet.version=3.0
26 changes: 9 additions & 17 deletions grails-app/conf/BuildConfig.groovy
@@ -1,27 +1,18 @@
grails.servlet.version = '3.0' // Change depending on target container compliance (2.5 or 3.0)
grails.project.class.dir = 'target/classes'
grails.project.test.class.dir = 'target/test-classes'
grails.project.test.reports.dir = 'target/test-reports'
grails.project.work.dir = 'target/work'
grails.project.target.level = 1.6
grails.project.source.level = 1.6

grails.project.dependency.resolver = 'maven'
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits('global') {
// specify dependency exclusions here; for example, uncomment this to disable ehcache:
// excludes 'ehcache'
}
log 'error' // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility
inherits 'global'
log 'error'
checksums true
legacyResolve false

repositories {
grailsCentral()
mavenLocal()
mavenCentral()
}

dependencies {
// Latest httpcore and httpmime for Coveralls plugin
build 'org.apache.httpcomponents:httpcore:4.3.2'
Expand All @@ -30,10 +21,11 @@ grails.project.dependency.resolution = {
// AWS SDK lib
compile 'com.amazonaws:aws-java-sdk:1.9.33'
}

plugins {
build(':release:3.0.1',
':rest-client-builder:1.0.3',
':coveralls:0.1') {
build(':release:3.1.1',
':rest-client-builder:2.1.1',
':coveralls:0.1') {
export = false
}
test(':code-coverage:2.0.3-3') {
Expand Down
16 changes: 8 additions & 8 deletions grails-app/services/grails/plugin/awssdk/AmazonWebService.groovy
Expand Up @@ -84,7 +84,7 @@ import com.amazonaws.services.storagegateway.AWSStorageGatewayClient
class AmazonWebService {

static final String DEFAULT_REGION = 'us-east-1'

static transactional = false

def grailsApplication
Expand Down Expand Up @@ -401,7 +401,7 @@ class AmazonWebService {

// PRIVATE

private def getAwsConfig() {
private getAwsConfig() {
grailsApplication.config.grails?.plugin?.awssdk
}

Expand Down Expand Up @@ -432,12 +432,12 @@ class AmazonWebService {
protocol: defaultConfig.protocol ?: '',
socketTimeout: defaultConfig.socketTimeout ?: 0,
userAgent: defaultConfig.userAgent ?: '',
proxyDomain: defaultConfig.proxyDomain ?: '',
proxyHost: defaultConfig.proxyHost ?: '',
proxyPassword: defaultConfig.proxyPassword ?: '',
proxyPort: defaultConfig.proxyPort ?: 0,
proxyUsername: defaultConfig.proxyUsername ?: '',
proxyWorkstation: defaultConfig.proxyWorkstation ?: ''
proxyDomain: defaultConfig.proxyDomain ?: '',
proxyHost: defaultConfig.proxyHost ?: '',
proxyPassword: defaultConfig.proxyPassword ?: '',
proxyPort: defaultConfig.proxyPort ?: 0,
proxyUsername: defaultConfig.proxyUsername ?: '',
proxyWorkstation: defaultConfig.proxyWorkstation ?: ''
]
if (serviceConfig) {
if (serviceConfig.connectionTimeout) config.connectionTimeout = serviceConfig.connectionTimeout
Expand Down
8 changes: 4 additions & 4 deletions src/docs/guide/amazonWebService.gdoc
@@ -1,4 +1,4 @@
Reference @amazonWebService@ from any of your grails artefacts (controllers, domain, services...) to automatically inject it.
Reference @amazonWebService@ from any of your Grails artefacts (controllers, domain, services...) to automatically inject it.

{code}
def amazonWebService
Expand All @@ -7,7 +7,7 @@ def amazonWebService
Or get it from @ctx@ if you want to test it in Grails console.

{code}
def amazonWebService = ctx.getBean('amazonWebService')
def amazonWebService = ctx.amazonWebService
{code}

You can then access any services directly from @amazonWebService@.
Expand Down Expand Up @@ -53,7 +53,7 @@ amazonWebService.swf
amazonWebService.transferManager
{code}

It will return an instance of java client class extending "AmazonWebServiceClient":http://docs.amazonwebservices.com/AWSJavaSDK/latest/javadoc/com/amazonaws/AmazonWebServiceClient.html with default region endpoint (defined in our @Config.groovy@).
It will return an instance of Java client class extending "AmazonWebServiceClient":http://docs.amazonwebservices.com/AWSJavaSDK/latest/javadoc/com/amazonaws/AmazonWebServiceClient.html with default region endpoint (defined in our @Config.groovy@).

You can then call any available client methods.

Expand Down Expand Up @@ -84,4 +84,4 @@ amazonWebService.getSqsAsync('eu-west-1').sendMessageAsync(new SendMessageReques

h3. Exception handling

You should surround all your @amazonWebService@ client calls around try/catch block, in order to catch @AmazonServiceException@ or @AmazonClientException@.
You should surround all your @amazonWebService@ client calls around try/catch block, in order to catch @AmazonServiceException@ or @AmazonClientException@.
32 changes: 16 additions & 16 deletions src/docs/guide/installation.gdoc
Expand Up @@ -2,21 +2,21 @@ Declare the plugin dependency in the @BuildConfig.groovy@ file, as shown here:

{code}
grails.project.dependency.resolution = {
inherits("global") { }
log "info"
repositories {
//your repositories
}
dependencies {
// Workaround to resolve dependency issue with aws-java-sdk and http-builder (dependent on httpcore:4.0)
build 'org.apache.httpcomponents:httpcore:4.3.2'
build 'org.apache.httpcomponents:httpclient:4.3.2'
runtime 'org.apache.httpcomponents:httpcore:4.3.2'
runtime 'org.apache.httpcomponents:httpclient:4.3.2'
}
plugins {
//here go your plugin dependencies
runtime ':aws-sdk:1.9.33'
}
inherits "global"
log "info"
repositories {
// your repositories
}
dependencies {
// Workaround to resolve dependency issue with aws-java-sdk and http-builder (dependent on httpcore:4.0)
build 'org.apache.httpcomponents:httpcore:4.3.2'
build 'org.apache.httpcomponents:httpclient:4.3.2'
runtime 'org.apache.httpcomponents:httpcore:4.3.2'
runtime 'org.apache.httpcomponents:httpclient:4.3.2'
}
plugins {
// here go your plugin dependencies
runtime ':aws-sdk:1.9.33'
}
}
{code}
39 changes: 12 additions & 27 deletions test/unit/grails/plugin/awssdk/AmazonWebServiceTests.groovy
Expand Up @@ -72,57 +72,42 @@ import com.amazonaws.services.sqs.AmazonSQSClient
import com.amazonaws.services.sqs.buffered.AmazonSQSBufferedAsyncClient
import com.amazonaws.services.storagegateway.AWSStorageGatewayAsyncClient
import com.amazonaws.services.storagegateway.AWSStorageGatewayClient
import grails.test.mixin.TestFor
import grails.test.mixin.TestMixin
import grails.test.mixin.support.GrailsUnitTestMixin

import java.security.KeyPair
import java.security.KeyPairGenerator
import java.security.SecureRandom

/**
* See the API for {@link grails.test.mixin.support.GrailsUnitTestMixin} for usage instructions
*/
@TestMixin(GrailsUnitTestMixin)
@TestFor(AmazonWebService)
class AmazonWebServiceTests {

void setUp() {
protected ConfigObject getAwsConfig() {
grailsApplication.config.grails.plugin.awssdk
}

void tearDown() {
}

AmazonWebService getServiceWithCredentials() {
def amazonWebService = new AmazonWebService()

grailsApplication.config.grails.plugin.awssdk.accessKey = "abcdefghi"
grailsApplication.config.grails.plugin.awssdk.secretKey = "123456789"
protected AmazonWebService getServiceWithCredentials() {
awsConfig.accessKey = "abcdefghi"
awsConfig.secretKey = "123456789"

amazonWebService.grailsApplication = grailsApplication

amazonWebService
new AmazonWebService(grailsApplication: grailsApplication)
}

AmazonWebService getServiceWithCredentialsAndEncryptionMaterials() {
protected AmazonWebService getServiceWithCredentialsAndEncryptionMaterials() {
def amazonWebService = serviceWithCredentials

KeyPairGenerator keyGenerator = KeyPairGenerator.getInstance("RSA")
keyGenerator.initialize(1024, new SecureRandom())
KeyPair myKeyPair = keyGenerator.generateKeyPair()
EncryptionMaterials encryptionMaterials = new EncryptionMaterials(myKeyPair)

amazonWebService.grailsApplication.config.grails.plugin.awssdk.encryptionMaterials = encryptionMaterials
awsConfig.encryptionMaterials = encryptionMaterials

amazonWebService
}

AmazonWebService getServiceWithoutCredentials() {
def amazonWebService = new AmazonWebService()

amazonWebService.grailsApplication = grailsApplication

amazonWebService
protected AmazonWebService getServiceWithoutCredentials() {
new AmazonWebService(grailsApplication: grailsApplication)
}

void testAutoScalingClientWithCredentials() {
Expand Down Expand Up @@ -968,7 +953,7 @@ class AmazonWebServiceTests {

void testStorageGatewayClientWithoutCredentials() {
def amazonWebService = getServiceWithoutCredentials()

assert amazonWebService.getStorageGatewayAsync().class == AWSStorageGatewayAsyncClient
assert amazonWebService.getStorageGatewayAsync('eu-west-1').class == AWSStorageGatewayAsyncClient
assert amazonWebService.getStorageGateway().class == AWSStorageGatewayClient
Expand Down Expand Up @@ -1055,7 +1040,7 @@ class AmazonWebServiceTests {
def otherRegion1
def otherRegion2

// check if the cache returns the same object if requested twice,
// check if the cache returns the same object if requested twice,
// also make sure other calls and regions don't corrupt the cache
service1 = amazonWebService.getEc2Async()
otherRegion1 = amazonWebService.getEc2Async('eu-west-1')
Expand Down

0 comments on commit f248016

Please sign in to comment.