Permalink
Browse files

cleanup

  • Loading branch information...
1 parent 70024ad commit 94f28cba749f3671230167d2c1437f2647c44464 @burtbeckwith burtbeckwith committed Apr 29, 2013
View
@@ -3,4 +3,7 @@ plugin.xml
*.log
target
target-eclipse
-.settings
+.settings
+._.DS_Store
+.DS_Store
+web-app
View
@@ -1,71 +1,14 @@
class RestrpcGrailsPlugin {
- // the plugin version
def version = "0.1"
- // the version or versions of Grails the plugin is designed for
def grailsVersion = "2.0 > *"
- // the other plugins this plugin depends on
- def dependsOn = [:]
- // resources that are excluded from plugin packaging
- def pluginExcludes = [
- "grails-app/views/error.gsp"
- ]
-
- // TODO Fill in these fields
- def title = "Restrpc Plugin" // Headline display name of the plugin
+ def title = "Restrpc Plugin"
def author = "Owen Rubel"
def authorEmail = "orubel@gmail.com"
- def description = '''
-RESTRPC is an interceptor api that allows the user to associate more than one method/function per request method while still being compliant with the REST standard thus creating a ONE-TO-MANY pairing.
-'''
-
- // URL to the plugin's documentation
+ def description = 'RESTRPC is an interceptor api that allows the user to associate more than one method/function per request method while still being compliant with the REST standard thus creating a ONE-TO-MANY pairing.'
def documentation = "http://grails.org/plugin/restrpc"
- // Extra (optional) plugin metadata
-
- // License: one of 'APACHE', 'GPL2', 'GPL3'
def license = "GPL2"
- // Details of company behind the plugin (if there is one)
-// def organization = [ name: "My Company", url: "http://www.my-company.com/" ]
-
- // Any additional developers beyond the author specified above.
-// def developers = [ [ name: "Joe Bloggs", email: "joe@bloggs.net" ]]
-
- // Location of the plugin's issue tracker.
// def issueManagement = [ system: "JIRA", url: "http://jira.grails.org/browse/GPMYPLUGIN" ]
-
- // Online location of the plugin's browseable source code.
// def scm = [ url: "http://svn.codehaus.org/grails-plugins/" ]
-
- def doWithWebDescriptor = { xml ->
- // TODO Implement additions to web.xml (optional), this event occurs before
- }
-
- def doWithSpring = {
- // TODO Implement runtime spring config (optional)
- }
-
- def doWithDynamicMethods = { ctx ->
- // TODO Implement registering dynamic methods to classes (optional)
- }
-
- def doWithApplicationContext = { applicationContext ->
- // TODO Implement post initialization spring config (optional)
- }
-
- def onChange = { event ->
- // TODO Implement code that is executed when any artefact that this plugin is
- // watching is modified and reloaded. The event contains: event.source,
- // event.application, event.manager, event.ctx, and event.plugin.
- }
-
- def onConfigChange = { event ->
- // TODO Implement code that is executed when the project configuration changes.
- // The event is the same as for 'onChange'.
- }
-
- def onShutdown = { event ->
- // TODO Implement code that is executed when the application shuts down (optional)
- }
}
View
@@ -1,5 +1 @@
-#Grails Metadata file
-#Sat Dec 22 15:36:07 PST 2012
app.grails.version=2.1.2
-app.name=restrpc
-plugins.hibernate=1.3.7
@@ -1,35 +1,16 @@
-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'
grails.project.dependency.resolution = {
- // inherit Grails' default dependencies
- inherits("global") {
- // uncomment to disable ehcache
- // excludes 'ehcache'
- }
- log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
+
+ inherits 'global'
+ log 'warn'
+
repositories {
grailsCentral()
- // uncomment the below to enable remote dependency resolution
- // from public Maven repositories
- //mavenLocal()
- //mavenCentral()
- //mavenRepo "http://snapshots.repository.codehaus.org"
- //mavenRepo "http://repository.codehaus.org"
- //mavenRepo "http://download.java.net/maven/2/"
- //mavenRepo "http://repository.jboss.com/maven2/"
- }
- dependencies {
- // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
-
- // runtime 'mysql:mysql-connector-java:5.1.18'
}
plugins {
- build(":tomcat:$grailsVersion",
- ":release:2.2.0",
- ":rest-client-builder:1.0.3") {
+ build ':release:2.2.1', ':rest-client-builder:1.0.3', {
export = false
}
}
@@ -1,24 +1,6 @@
-// configuration for plugin testing - will not be included in the plugin zip
-
log4j = {
- // Example of changing the log pattern for the default console
- // appender:
- //
- //appenders {
- // console name:'stdout', layout:pattern(conversionPattern: '%c{2} %m%n')
- //}
-
- error 'org.codehaus.groovy.grails.web.servlet', // controllers
- 'org.codehaus.groovy.grails.web.pages', // GSP
- 'org.codehaus.groovy.grails.web.sitemesh', // layouts
- 'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping
- 'org.codehaus.groovy.grails.web.mapping', // URL mapping
- 'org.codehaus.groovy.grails.commons', // core / classloading
- 'org.codehaus.groovy.grails.plugins', // plugins
- 'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration
- 'org.springframework',
- 'org.hibernate',
- 'net.sf.ehcache.hibernate'
-
- warn 'org.mortbay.log'
+ error 'org.codehaus.groovy.grails',
+ 'org.springframework',
+ 'org.hibernate',
+ 'net.sf.ehcache.hibernate'
}
@@ -1,11 +1,8 @@
-import net.nosegrind.restrpc.RestRPC
-import net.nosegrind.restrpc.RpcMethod
-import org.codehaus.groovy.grails.web.util.WebUtils
-
import grails.converters.JSON
import grails.converters.XML
-import org.codehaus.groovy.grails.commons.GrailsControllerClass
+import net.nosegrind.restrpc.RestRPC
+import net.nosegrind.restrpc.RpcMethod
class RestRPCFilters {
@@ -15,82 +12,84 @@ class RestRPCFilters {
restrpc(controller:'*', action:'*'){
after = { Map model ->
// IF THIS IS AN API REQUEST, WE PROCESS ELSE WE IGNORE
- if(restRPCService.isApiCall()){
- def controller = grailsApplication.getArtefactByLogicalPropertyName('Controller', controllerName)
- def action = controller?.getClazz()?.getDeclaredMethod(actionName)
- // IF THERE IS AN ACTION, WE PROCESS ELSE WE IGNORE
- if(action){
- // IF THERE IS AN ANNOTATION ON SAID ACTION WE CONTINUE TO PROCESS
- if(action.isAnnotationPresent(RestRPC)){
- def anno = action.getAnnotation(RestRPC)
-
- switch(anno.request()) {
- case RpcMethod.GET:
- def newModel = restRPCService.formatModel(model)
- if(restRPCService.isRequestMatch('GET')){
- if(!newModel.isEmpty()){
- switch(params.format){
- case 'JSON':
- render(text:newModel as JSON, contentType: "application/json")
- return false
- break
- case 'XML':
- render(text:newModel as XML, contentType: "application/xml")
- return false
- break
- }
- }
- }
- break
- case RpcMethod.PUT:
- def newModel = restRPCService.formatModel(model)
- if(restRPCService.isRequestMatch('PUT')){
- switch(params.format){
- case 'JSON':
- render(text:newModel as JSON, contentType: "application/json")
- break
- case 'XML':
- render(text:newModel as XML, contentType: "application/xml")
- return false
- break
- }
- }
- break
- case RpcMethod.POST:
- println("POST METHOD")
- def newModel = restRPCService.formatModel(model)
- if(restRPCService.isRequestMatch('POST')){
- switch(params.format){
- case 'JSON':
- render(text:newModel as JSON, contentType: "application/json")
- return false
- break
- case 'XML':
- render(text:newModel as XML, contentType: "application/xml")
- return false
- break
- }
- }
- break
- case RpcMethod.DELETE:
- if(restRPCService.isRequestMatch('DELETE')){
- switch(params.format){
- case 'JSON':
- case 'XML':
- return response.status
- break
- }
- }
- break
+ if (!restRPCService.isApiCall()) {
+ return
+ }
+
+ def controller = grailsApplication.getArtefactByLogicalPropertyName('Controller', controllerName)
+ def action = controller?.getClazz()?.getDeclaredMethod(actionName)
+ // IF THERE IS AN ACTION, WE PROCESS ELSE WE IGNORE
+ if (!action) {
+ return
+ }
+
+ // IF THERE IS AN ANNOTATION ON SAID ACTION WE CONTINUE TO PROCESS
+ if (!action.isAnnotationPresent(RestRPC)) {
+ return
+ }
+
+ def anno = action.getAnnotation(RestRPC)
+
+ switch(anno.request()) {
+ case RpcMethod.GET:
+ def newModel = restRPCService.formatModel(model)
+ if(restRPCService.isRequestMatch('GET')){
+ if(!newModel.isEmpty()){
+ switch(params.format){
+ case 'JSON':
+ render(text:newModel as JSON, contentType: "application/json")
+ return false
+ break
+ case 'XML':
+ render(text:newModel as XML, contentType: "application/xml")
+ return false
+ break
+ }
}
- return false
- } else {
- // ANNOTATION IS NOT PRESENT FOR ACTION $action.name
}
- }else{
- // ACTION IS NOT PRESENT
- }
+ break
+ case RpcMethod.PUT:
+ def newModel = restRPCService.formatModel(model)
+ if(restRPCService.isRequestMatch('PUT')){
+ switch(params.format){
+ case 'JSON':
+ render(text:newModel as JSON, contentType: "application/json")
+ break
+ case 'XML':
+ render(text:newModel as XML, contentType: "application/xml")
+ return false
+ break
+ }
+ }
+ break
+ case RpcMethod.POST:
+ println("POST METHOD")
+ def newModel = restRPCService.formatModel(model)
+ if(restRPCService.isRequestMatch('POST')){
+ switch(params.format){
+ case 'JSON':
+ render(text:newModel as JSON, contentType: "application/json")
+ return false
+ break
+ case 'XML':
+ render(text:newModel as XML, contentType: "application/xml")
+ return false
+ break
+ }
+ }
+ break
+ case RpcMethod.DELETE:
+ if(restRPCService.isRequestMatch('DELETE')){
+ switch(params.format){
+ case 'JSON':
+ case 'XML':
+ return response.status
+ break
+ }
+ }
+ break
}
+ return false
}
}
}
Oops, something went wrong.

0 comments on commit 94f28cb

Please sign in to comment.