Permalink
Browse files

cleanup

  • Loading branch information...
1 parent c4f9cee commit 89948010fbd7148d3f5bf743c3264aa26694c925 Burt Beckwith committed Nov 26, 2012
View
@@ -1,44 +1,24 @@
-# .gitignore for Grails 1.2 and 1.3
-
# web application files
/web-app/WEB-INF
# IDE support files
-/.classpath
/.launch
-/.project
/.settings
/*.launch
/*.tmproj
/ivy*
/eclipse
-# default HSQL database files for production mode
-/prodDb.*
-
-# general HSQL database files
-*Db.properties
-*Db.script
-
# logs
/stacktrace.log
/test/reports
/logs
-# project release file
-/*.war
-
# plugin release file
/*.zip
-# older plugin install locations
-/plugins
-/web-app/plugins
-/web-app/WEB-INF/classes
-
# "temporary" build files
/target
# other
*.iws
-
@@ -1,54 +1,30 @@
-class MailOnExceptionGrailsPlugin {
- // the plugin version
- def version = "0.1"
- // the version or versions of Grails the plugin is designed for
- def grailsVersion = "2.1 > *"
- // the other plugins this plugin depends on
- def dependsOn = [:]
- // resources that are excluded from plugin packaging
- def pluginExcludes = [
- "grails-app/views/error.gsp"
- ]
-
- def title = "Mail On Exception Plugin" // Headline display name of the plugin
- def author = "François Terrier"
- def authorEmail = "fterrier@gmail.com"
- def description = '''\
-This plugin allows one to specify an email address where all frontend exceptions will be sent.
-'''
-
- // URL to the plugin's documentation
- def documentation = "http://grails.org/plugin/mail-on-exception"
+import org.chai.exception.ExceptionHandler
- // Extra (optional) plugin metadata
+class MailOnExceptionGrailsPlugin {
+ def version = "0.1"
+ def grailsVersion = "2.1 > *"
+ def title = "Mail On Exception Plugin"
+ def author = "François Terrier"
+ def authorEmail = "fterrier@gmail.com"
+ def description = 'Allows one to specify an email address where all frontend exceptions will be sent.'
+ def documentation = "http://grails.org/plugin/mail-on-exception"
- // License: one of 'APACHE', 'GPL2', 'GPL3'
def license = "BSD3"
-
- // Details of company behind the plugin (if there is one)
def organization = [ name: "Clinton Health Access Initiative", url: "http://www.clintonhealthaccess.org/" ]
+ def issueManagement = [system: 'Github', url: 'https://github.com/fterrier/grails-mail-on-exception/issues']
+ def scm = [url: "http://github.com/fterrier/grails-mail-on-exception"]
- // Any additional developers beyond the author specified above.
-// def developers = [ [ name: "Joe Bloggs", email: "joe@bloggs.net" ]]
+ def loadAfter = ['services']
- // 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://github.com/fterrier/grails-mail-on-exception" ]
-
- def loadAfter = ['services']
-
- def doWithSpring = {
+ def doWithSpring = {
def mailOnExceptionConfig = application.config.mailOnException
-
- exceptionHandler(org.chai.exception.ExceptionHandler){
- // this is required so that calls to super work
- exceptionMappings = ['java.lang.Exception': mailOnExceptionConfig.error.view]
+
+ exceptionHandler(ExceptionHandler) {
+ // this is required so that calls to super work
+ exceptionMappings = ['java.lang.Exception': mailOnExceptionConfig.error.view]
defaultErrorView = '/error'
mailService = ref("mailService")
- grailsApplication = ref("grailsApplication")
- }
- }
-
+ grailsApplication = ref("grailsApplication")
+ }
+ }
}
View
@@ -1,4 +1 @@
-#Grails Metadata file
-#Mon Nov 26 11:08:25 CAT 2012
app.grails.version=2.1.0
-app.name=mail-on-exception
@@ -1,38 +1,20 @@
-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.source.level = 1.6
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'
- 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'
- }
+ inherits 'global'
+ log 'warn'
- plugins {
- build(":tomcat:$grailsVersion",
- ":release:2.0.3",
- ":rest-client-builder:1.0.2") {
- export = false
- }
+ repositories {
+ grailsCentral()
+ }
- compile ":mail:1.0"
- }
+ plugins {
+ build(':release:2.1.0', ':rest-client-builder:1.0.2') {
+ export = false
+ }
+
+ compile ":mail:1.0.1"
+ }
}
@@ -1,26 +1,8 @@
-// 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'
}
mailOnException.email.to = "to@example.com"
@@ -1,43 +1,14 @@
dataSource {
- pooled = true
- driverClassName = "org.h2.Driver"
- username = "sa"
- password = ""
+ pooled = true
+ driverClassName = 'org.h2.Driver'
+ username = 'sa'
+ password = ''
+ dbCreate = 'update'
+ url = 'jdbc:h2:mem:testDb'
}
+
hibernate {
- cache.use_second_level_cache = true
- cache.use_query_cache = false
- cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
-}
-// environment specific settings
-environments {
- development {
- dataSource {
- dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
- url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
- }
- }
- test {
- dataSource {
- dbCreate = "update"
- url = "jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
- }
- }
- production {
- dataSource {
- dbCreate = "update"
- url = "jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
- pooled = true
- properties {
- maxActive = -1
- minEvictableIdleTimeMillis=1800000
- timeBetweenEvictionRunsMillis=1800000
- numTestsPerEvictionRun=3
- testOnBorrow=true
- testWhileIdle=true
- testOnReturn=true
- validationQuery="SELECT 1"
- }
- }
- }
+ cache.use_second_level_cache = false
+ cache.use_query_cache = false
+ cache.provider_class = 'org.hibernate.cache.EhCacheProvider'
}
@@ -15,7 +15,7 @@ package org.chai.exception
* * Neither the name of the Clinton Health Access Initiative nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -28,33 +28,31 @@ package org.chai.exception
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import grails.util.GrailsUtil
+
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse
import org.codehaus.groovy.grails.web.errors.GrailsExceptionResolver
-
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
import org.springframework.web.servlet.ModelAndView
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import grails.util.GrailsUtil
-
class ExceptionHandler extends GrailsExceptionResolver {
- private static final Log log = LogFactory.getLog(ExceptionHandler.class);
+ private static final Logger log = LoggerFactory.getLogger(ExceptionHandler)
def mailService
def grailsApplication
-
- ModelAndView resolveException(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, Exception exception) {
- if (log.debugEnabled) log.debug("resolveException(request=${arg0}, response=${arg1}, handler=${arg2}, exception=${exception})")
-
+
+ ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception exception) {
+ if (log.debugEnabled) log.debug("resolveException(request=${request}, response=${response}, handler=${handler}, exception=${exception})")
+
def adminEmail = grailsApplication.config.mailOnException.email.to
def fromEmail = grailsApplication.config.mailOnException.email.from
def g = grailsApplication.mainContext.getBean('org.codehaus.groovy.grails.plugins.web.taglib.RenderTagLib')
g.metaClass.prettyPrintStatus = { return '' }
-
+
try {
mailService.sendMail {
multipart true
@@ -66,8 +64,7 @@ class ExceptionHandler extends GrailsExceptionResolver {
} catch (Exception e) {
if (log.errorEnabled) log.error("could not send email after exception", e)
}
-
- return super.resolveException(arg0, arg1, arg2, exception)
+
+ return super.resolveException(request, response, handler, exception)
}
-
}

0 comments on commit 8994801

Please sign in to comment.