Permalink
Browse files

initial project version

  • Loading branch information...
0 parents commit 94bcfbe8d0aaaa88d2f1183403c4d588890f26da @ahonor ahonor committed Aug 1, 2011
Showing with 28,275 additions and 0 deletions.
  1. +10 −0 application.properties
  2. +25 −0 grails-app/conf/BootStrap.groovy
  3. +31 −0 grails-app/conf/BuildConfig.groovy
  4. +110 −0 grails-app/conf/Config.groovy
  5. +32 −0 grails-app/conf/DataSource.groovy
  6. +6 −0 grails-app/conf/SecurityConfig.groovy
  7. +35 −0 grails-app/conf/UrlMappings.groovy
  8. +3 −0 grails-app/conf/spring/resources.groovy
  9. +134 −0 grails-app/controllers/LoginController.groovy
  10. +12 −0 grails-app/controllers/LogoutController.groovy
  11. +100 −0 grails-app/controllers/yana/attributes/AttributesController.groovy
  12. +32 −0 grails-app/controllers/yana/attributes/AttributesRestController.groovy
  13. +100 −0 grails-app/controllers/yana/attributes/ExternalAttributeController.groovy
  14. +100 −0 grails-app/controllers/yana/node/AttributeController.groovy
  15. +107 −0 grails-app/controllers/yana/node/NodeController.groovy
  16. +167 −0 grails-app/controllers/yana/node/NodeRestController.groovy
  17. +100 −0 grails-app/controllers/yana/node/TagController.groovy
  18. +14 −0 grails-app/domain/yana/SecRole.groovy
  19. +24 −0 grails-app/domain/yana/SecUser.groovy
  20. +52 −0 grails-app/domain/yana/SecUserSecRole.groovy
  21. +46 −0 grails-app/domain/yana/attributes/Attributes.groovy
  22. +18 −0 grails-app/domain/yana/attributes/BaseAttribute.groovy
  23. +21 −0 grails-app/domain/yana/attributes/ExternalAttribute.groovy
  24. +23 −0 grails-app/domain/yana/node/Attribute.groovy
  25. +105 −0 grails-app/domain/yana/node/Node.groovy
  26. +31 −0 grails-app/domain/yana/node/Tag.groovy
  27. +55 −0 grails-app/i18n/messages.properties
  28. +56 −0 grails-app/i18n/messages_da.properties
  29. +55 −0 grails-app/i18n/messages_de.properties
  30. +30 −0 grails-app/i18n/messages_es.properties
  31. +19 −0 grails-app/i18n/messages_fr.properties
  32. +19 −0 grails-app/i18n/messages_it.properties
  33. +19 −0 grails-app/i18n/messages_ja.properties
  34. +55 −0 grails-app/i18n/messages_nl.properties
  35. +34 −0 grails-app/i18n/messages_pt_BR.properties
  36. +34 −0 grails-app/i18n/messages_pt_PT.properties
  37. +31 −0 grails-app/i18n/messages_ru.properties
  38. +35 −0 grails-app/i18n/messages_th.properties
  39. +18 −0 grails-app/i18n/messages_zh_CN.properties
  40. +76 −0 grails-app/views/attribute/create.gsp
  41. +80 −0 grails-app/views/attribute/edit.gsp
  42. +61 −0 grails-app/views/attribute/list.gsp
  43. +72 −0 grails-app/views/attribute/show.gsp
  44. +49 −0 grails-app/views/attributes/create.gsp
  45. +69 −0 grails-app/views/attributes/edit.gsp
  46. +49 −0 grails-app/views/attributes/list.gsp
  47. +64 −0 grails-app/views/attributes/show.gsp
  48. +54 −0 grails-app/views/error.gsp
  49. +76 −0 grails-app/views/externalAttribute/create.gsp
  50. +80 −0 grails-app/views/externalAttribute/edit.gsp
  51. +61 −0 grails-app/views/externalAttribute/list.gsp
  52. +72 −0 grails-app/views/externalAttribute/show.gsp
  53. +90 −0 grails-app/views/index.gsp
  54. +32 −0 grails-app/views/layouts/main.gsp
  55. +79 −0 grails-app/views/login/auth.gsp
  56. +10 −0 grails-app/views/login/denied.gsp
  57. +76 −0 grails-app/views/node/create.gsp
  58. +121 −0 grails-app/views/node/edit.gsp
  59. +61 −0 grails-app/views/node/list.gsp
  60. +111 −0 grails-app/views/node/show.gsp
  61. +58 −0 grails-app/views/tag/create.gsp
  62. +62 −0 grails-app/views/tag/edit.gsp
  63. +53 −0 grails-app/views/tag/list.gsp
  64. +58 −0 grails-app/views/tag/show.gsp
  65. +6 −0 scratch/attribute.xml
  66. +9 −0 scratch/node.xml
  67. +9 −0 scratch/node2.xml
  68. +13 −0 scratch/node3.xml
  69. +15 −0 scratch/node4.xml
  70. +17 −0 scratch/node5.xml
  71. +23 −0 scratch/node6.xml
  72. +38 −0 scratch/node7.xml
  73. +41 −0 scratch/node8.xml
  74. +98 −0 src/groovy/yana/XmlParserUtil.groovy
  75. +4 −0 src/templates/artifacts/Controller.groovy
  76. +5 −0 src/templates/artifacts/DomainClass.groovy
  77. +17 −0 src/templates/artifacts/Filters.groovy
  78. +7 −0 src/templates/artifacts/Script.groovy
  79. +8 −0 src/templates/artifacts/Service.groovy
  80. +3 −0 src/templates/artifacts/TagLib.groovy
  81. +15 −0 src/templates/artifacts/Tests.groovy
  82. +54 −0 src/templates/artifacts/WebTest.groovy
  83. +18 −0 src/templates/artifacts/hibernate.cfg.xml
  84. +98 −0 src/templates/scaffolding/Controller.groovy
  85. +61 −0 src/templates/scaffolding/create.gsp
  86. +64 −0 src/templates/scaffolding/edit.gsp
  87. +61 −0 src/templates/scaffolding/list.gsp
  88. +174 −0 src/templates/scaffolding/renderEditor.template
  89. +64 −0 src/templates/scaffolding/show.gsp
  90. +102 −0 src/templates/war/web.xml
  91. +8,973 −0 stacktrace.log
  92. +17 −0 test/unit/yana/NodeServiceTests.groovy
  93. +17 −0 test/unit/yana/attributes/AttributeControllerTests.groovy
  94. +17 −0 test/unit/yana/attributes/AttributeSetControllerTests.groovy
  95. +17 −0 test/unit/yana/attributes/AttributesControllerTests.groovy
  96. +17 −0 test/unit/yana/attributes/ExternalAttributeControllerTests.groovy
  97. +17 −0 test/unit/yana/node/AttributeControllerTests.groovy
  98. +17 −0 test/unit/yana/node/NodeControllerTests.groovy
  99. +17 −0 test/unit/yana/node/TagControllerTests.groovy
  100. +42 −0 web-app/WEB-INF/applicationContext.xml
  101. +14 −0 web-app/WEB-INF/sitemesh.xml
  102. +563 −0 web-app/WEB-INF/tld/c.tld
  103. +671 −0 web-app/WEB-INF/tld/fmt.tld
  104. +550 −0 web-app/WEB-INF/tld/grails.tld
  105. +311 −0 web-app/WEB-INF/tld/spring.tld
  106. +273 −0 web-app/css/main.css
  107. +393 −0 web-app/css/yana.css
  108. BIN web-app/images/background.png
  109. BIN web-app/images/dto-logo-small.png
  110. BIN web-app/images/favicon.ico
  111. BIN web-app/images/grails_logo.jpg
  112. BIN web-app/images/grails_logo.png
  113. BIN web-app/images/headerlogo.png
  114. BIN web-app/images/icon-attribute-large.png
  115. BIN web-app/images/icon-node-large.png
  116. BIN web-app/images/leftnav_btm.png
  117. BIN web-app/images/leftnav_midstretch.png
  118. BIN web-app/images/leftnav_top.png
  119. BIN web-app/images/skin/database_add.png
  120. BIN web-app/images/skin/database_delete.png
  121. BIN web-app/images/skin/database_edit.png
  122. BIN web-app/images/skin/database_save.png
  123. BIN web-app/images/skin/database_table.png
  124. BIN web-app/images/skin/exclamation.png
  125. BIN web-app/images/skin/house.png
  126. BIN web-app/images/skin/information.png
  127. BIN web-app/images/skin/shadow.jpg
  128. BIN web-app/images/skin/sorted_asc.gif
  129. BIN web-app/images/skin/sorted_desc.gif
  130. BIN web-app/images/spinner.gif
  131. BIN web-app/images/springsource.png
  132. BIN web-app/images/yanafav.png
  133. +13 −0 web-app/js/application.js
  134. +7 −0 web-app/js/prototype/animation.js
  135. +136 −0 web-app/js/prototype/builder.js
  136. +965 −0 web-app/js/prototype/controls.js
  137. +974 −0 web-app/js/prototype/dragdrop.js
  138. +1,123 −0 web-app/js/prototype/effects.js
  139. +4,874 −0 web-app/js/prototype/prototype.js
  140. +2,691 −0 web-app/js/prototype/rico.js
  141. +68 −0 web-app/js/prototype/scriptaculous.js
  142. +275 −0 web-app/js/prototype/slider.js
  143. +59 −0 web-app/js/prototype/sound.js
  144. +568 −0 web-app/js/prototype/unittest.js
@@ -0,0 +1,10 @@
+#Grails Metadata file
+#Thu Jul 28 13:30:42 PDT 2011
+app.grails.version=1.3.7
+app.name=yana
+app.servlet.version=2.4
+app.version=0.1
+plugins.hibernate=1.3.7
+plugins.searchable=0.6.1
+plugins.spring-security-core=1.1.3
+plugins.tomcat=1.3.7
@@ -0,0 +1,25 @@
+import yana.SecRole
+import yana.SecUser
+import yana.SecUserSecRole
+
+class BootStrap {
+ def springSecurityService
+
+ def init = { servletContext ->
+
+ def userRole = SecRole.findByAuthority('ROLE_USER') ?: new SecRole(authority: 'ROLE_USER').save(failOnError: true)
+ def adminRole = SecRole.findByAuthority('ROLE_ADMIN') ?: new SecRole(authority: 'ROLE_ADMIN').save(failOnError: true)
+
+ def adminUser = SecUser.findByUsername('admin') ?: new SecUser(
+ username: 'admin',
+ password: springSecurityService.encodePassword('admin'),
+ enabled: true).save(failOnError: true)
+ if (!adminUser.authorities.contains(adminRole)) {
+ SecUserSecRole.create adminUser, adminRole
+ }
+
+
+ }
+ def destroy = {
+ }
+}
@@ -0,0 +1,31 @@
+grails.project.class.dir = "target/classes"
+grails.project.test.class.dir = "target/test-classes"
+grails.project.test.reports.dir = "target/test-reports"
+//grails.project.war.file = "target/${appName}-${appVersion}.war"
+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 {
+ grailsPlugins()
+ grailsHome()
+ 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.13'
+ }
+}
@@ -0,0 +1,110 @@
+import grails.plugins.springsecurity.SecurityConfigType
+
+// locations to search for config files that get merged into the main config
+// config files can either be Java properties files or ConfigSlurper scripts
+
+// grails.config.locations = [ "classpath:${appName}-config.properties",
+// "classpath:${appName}-config.groovy",
+// "file:${userHome}/.grails/${appName}-config.properties",
+// "file:${userHome}/.grails/${appName}-config.groovy"]
+
+// if(System.properties["${appName}.config.location"]) {
+// grails.config.locations << "file:" + System.properties["${appName}.config.location"]
+// }
+
+grails.project.groupId = appName // change this to alter the default package name and Maven publishing destination
+grails.mime.file.extensions = true // enables the parsing of file extensions from URLs into the request format
+grails.mime.use.accept.header = false
+grails.mime.types = [ html: ['text/html','application/xhtml+xml'],
+ //xml: ['text/xml', 'application/xml'],
+ text: 'text/plain',
+ js: 'text/javascript',
+ rss: 'application/rss+xml',
+ atom: 'application/atom+xml',
+ css: 'text/css',
+ csv: 'text/csv',
+ all: '*/*',
+ json: ['application/json','text/json'],
+ form: 'application/x-www-form-urlencoded',
+ multipartForm: 'multipart/form-data'
+ ]
+
+// URL Mapping Cache Max Size, defaults to 5000
+//grails.urlmapping.cache.maxsize = 1000
+
+// The default codec used to encode data with ${}
+grails.views.default.codec = "none" // none, html, base64
+grails.views.gsp.encoding = "UTF-8"
+grails.converters.encoding = "UTF-8"
+grails.converters.xml.default.deep = true
+grails.converters.json.default.deep = true
+
+// enable Sitemesh preprocessing of GSP pages
+grails.views.gsp.sitemesh.preprocess = true
+// scaffolding templates configuration
+grails.scaffolding.templates.domainSuffix = 'Instance'
+
+// Set to false to use the new Grails 1.2 JSONBuilder in the render method
+grails.json.legacy.builder = false
+// enabled native2ascii conversion of i18n properties files
+grails.enable.native2ascii = true
+// whether to install the java.util.logging bridge for sl4j. Disable for AppEngine!
+grails.logging.jul.usebridge = true
+// packages to include in Spring bean scanning
+grails.spring.bean.packages = []
+
+// request parameters to mask when logging exceptions
+grails.exceptionresolver.params.exclude = ['password']
+
+// set per-environment serverURL stem for creating absolute links
+environments {
+ production {
+ grails.serverURL = "http://www.changeme.com"
+ }
+ development {
+ grails.serverURL = "http://localhost:8080/${appName}"
+ }
+ test {
+ grails.serverURL = "http://localhost:8080/${appName}"
+ }
+
+}
+
+// log4j configuration
+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'
+}
+
+// Added by the Spring Security Core plugin:
+grails.plugins.springsecurity.userLookup.userDomainClassName = 'yana.SecUser'
+grails.plugins.springsecurity.userLookup.authorityJoinClassName = 'yana.SecUserSecRole'
+grails.plugins.springsecurity.authority.className = 'yana.SecRole'
+
+grails.plugins.springsecurity.securityConfigType = SecurityConfigType.InterceptUrlMap
+grails.plugins.springsecurity.interceptUrlMap = [
+ '/attributes': ['IS_AUTHENTICATED_FULLY'],
+ '/attributes/**': ['IS_AUTHENTICATED_FULLY'],
+ '/node': ['IS_AUTHENTICATED_FULLY'],
+ '/node/**': ['IS_AUTHENTICATED_FULLY'],
+ '/**': ['IS_AUTHENTICATED_ANONYMOUSLY']
+
+]
@@ -0,0 +1,32 @@
+dataSource {
+ pooled = true
+ driverClassName = "org.hsqldb.jdbcDriver"
+ username = "sa"
+ password = ""
+}
+hibernate {
+ cache.use_second_level_cache = true
+ cache.use_query_cache = true
+ cache.provider_class = 'net.sf.ehcache.hibernate.EhCacheProvider'
+}
+// environment specific settings
+environments {
+ development {
+ dataSource {
+ dbCreate = "create-drop" // one of 'create', 'create-drop','update'
+ url = "jdbc:hsqldb:mem:devDB"
+ }
+ }
+ test {
+ dataSource {
+ dbCreate = "update"
+ url = "jdbc:hsqldb:mem:testDb"
+ }
+ }
+ production {
+ dataSource {
+ dbCreate = "update"
+ url = "jdbc:hsqldb:file:prodDb;shutdown=true"
+ }
+ }
+}
@@ -0,0 +1,6 @@
+security {
+ active = true
+ loginUserDomainClass = "SecUser"
+ authorityDomainClass = "SecRole"
+ requestMapClass = "Requestmap"
+}
@@ -0,0 +1,35 @@
+
+class UrlMappings {
+
+ static mappings = {
+
+ "/$controller/$action?/$id?"{
+ constraints {
+ // apply constraints here
+ }
+ }
+
+ "/login/$action?"(controller: "login")
+ "/logout/$action?"(controller: "logout")
+
+ "/api/nodes"(controller: "nodeRest", parseRequest:true) {
+ action = [ GET: "list" , POST: "add" ]
+ }
+
+ "/api/nodes/$id"(controller: "nodeRest", parseRequest:true) {
+ action = [ GET: "show" , POST: "save" , DELETE: "delete" ]
+ }
+
+ "/api/attributes"(controller: "attributesRest") {
+ action = [ GET: "list" ]
+ }
+
+ "/api/attributes/$id"(controller: "attributesRest") {
+ action = [ GET: "show" ]
+ }
+
+
+ "/"(view:"/index")
+ "500"(view:'/error')
+ }
+}
@@ -0,0 +1,3 @@
+// Place your Spring DSL code here
+beans = {
+}
@@ -0,0 +1,134 @@
+import grails.converters.JSON
+
+import javax.servlet.http.HttpServletResponse
+
+import org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils
+
+import org.springframework.security.authentication.AccountExpiredException
+import org.springframework.security.authentication.CredentialsExpiredException
+import org.springframework.security.authentication.DisabledException
+import org.springframework.security.authentication.LockedException
+import org.springframework.security.core.context.SecurityContextHolder as SCH
+import org.springframework.security.web.WebAttributes
+import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter
+
+class LoginController {
+
+ /**
+ * Dependency injection for the authenticationTrustResolver.
+ */
+ def authenticationTrustResolver
+
+ /**
+ * Dependency injection for the springSecurityService.
+ */
+ def springSecurityService
+
+ /**
+ * Default action; redirects to 'defaultTargetUrl' if logged in, /login/auth otherwise.
+ */
+ def index = {
+ if (springSecurityService.isLoggedIn()) {
+ redirect uri: SpringSecurityUtils.securityConfig.successHandler.defaultTargetUrl
+ }
+ else {
+ redirect action: auth, params: params
+ }
+ }
+
+ /**
+ * Show the login page.
+ */
+ def auth = {
+
+ def config = SpringSecurityUtils.securityConfig
+
+ if (springSecurityService.isLoggedIn()) {
+ redirect uri: config.successHandler.defaultTargetUrl
+ return
+ }
+
+ String view = 'auth'
+ String postUrl = "${request.contextPath}${config.apf.filterProcessesUrl}"
+ render view: view, model: [postUrl: postUrl,
+ rememberMeParameter: config.rememberMe.parameter]
+ }
+
+ /**
+ * The redirect action for Ajax requests.
+ */
+ def authAjax = {
+ response.setHeader 'Location', SpringSecurityUtils.securityConfig.auth.ajaxLoginFormUrl
+ response.sendError HttpServletResponse.SC_UNAUTHORIZED
+ }
+
+ /**
+ * Show denied page.
+ */
+ def denied = {
+ if (springSecurityService.isLoggedIn() &&
+ authenticationTrustResolver.isRememberMe(SCH.context?.authentication)) {
+ // have cookie but the page is guarded with IS_AUTHENTICATED_FULLY
+ redirect action: full, params: params
+ }
+ }
+
+ /**
+ * Login page for users with a remember-me cookie but accessing a IS_AUTHENTICATED_FULLY page.
+ */
+ def full = {
+ def config = SpringSecurityUtils.securityConfig
+ render view: 'auth', params: params,
+ model: [hasCookie: authenticationTrustResolver.isRememberMe(SCH.context?.authentication),
+ postUrl: "${request.contextPath}${config.apf.filterProcessesUrl}"]
+ }
+
+ /**
+ * Callback after a failed login. Redirects to the auth page with a warning message.
+ */
+ def authfail = {
+
+ def username = session[UsernamePasswordAuthenticationFilter.SPRING_SECURITY_LAST_USERNAME_KEY]
+ String msg = ''
+ def exception = session[WebAttributes.AUTHENTICATION_EXCEPTION]
+ if (exception) {
+ if (exception instanceof AccountExpiredException) {
+ msg = SpringSecurityUtils.securityConfig.errors.login.expired
+ }
+ else if (exception instanceof CredentialsExpiredException) {
+ msg = SpringSecurityUtils.securityConfig.errors.login.passwordExpired
+ }
+ else if (exception instanceof DisabledException) {
+ msg = SpringSecurityUtils.securityConfig.errors.login.disabled
+ }
+ else if (exception instanceof LockedException) {
+ msg = SpringSecurityUtils.securityConfig.errors.login.locked
+ }
+ else {
+ msg = SpringSecurityUtils.securityConfig.errors.login.fail
+ }
+ }
+
+ if (springSecurityService.isAjax(request)) {
+ render([error: msg] as JSON)
+ }
+ else {
+ flash.message = msg
+ redirect action: auth, params: params
+ }
+ }
+
+ /**
+ * The Ajax success redirect url.
+ */
+ def ajaxSuccess = {
+ render([success: true, username: springSecurityService.authentication.name] as JSON)
+ }
+
+ /**
+ * The Ajax denied redirect url.
+ */
+ def ajaxDenied = {
+ render([error: 'access denied'] as JSON)
+ }
+}
Oops, something went wrong.

0 comments on commit 94bcfbe

Please sign in to comment.