Categories
Grails Moving to Grails

Documentation – rest api

When resarching documentation for the previous blog posts I stumbled upon this project: https://github.com/grails/groovy-rest-doc where Sergio del Amo have writen a tool to help document a rest api. First I downloaded the whole code, and run integration test, then asciidoctor task. Now lets see how this works with a new project. Then create a domain […]

Categories
Moving to Grails

Documenting your Grails application – part 2

In this blog post I will try to make write some documentation with ascii-doctor work. Here’s the asciidoctor user manual: https://asciidoctor.org/docs/user-manual/ First test: Can I simply write adoc’s instead of gdoc’s? Let’s create a project and see what happens: Add the plugin to build.gradle: Reload the gradle project and the task docs will be awailable […]

Categories
Moving to Grails

Documenting your Grails application – part 1

The purpose of this post is to find out how the docs plugin works and figure out how to generate documentation close to the code. This will be done over several posts. The first post will be looking at grails-doc plugin. The second looking into asciidoctor. Finally a summary / conclusion. Here’s the quick reference […]

Categories
Moving to Grails

Changing log level at run-time

Sometimes you need to change log-level for parts of your application at run-time. Most likely for debugging. When researching this topic I found a useful trait that logs log-level. https://github.com/jfrosch/GrailsLoggingIssue With this I created a LogLevel controller to visualize and manipulate log-levels: The loggerList variable gets very long if not filtered. Here’s the logLevel/index.gsp: It […]

Categories
Moving to Grails

Customizing spring security userdetails

Lately I have been working on Spring security with this configuration: with groups database stored in tenant database First problem I detected was that the PerTenantUserDetailsService implemented in https://johnny.prpr.no/spring-security-multitenant/ was annotated with @CurrentTenant, which is wrong. Furthermore I wanted to add fullName to the UserDetails, for easy lookup. This was achieved by following the plugin […]

Categories
Moving to Grails

id generation in database tables

By default GORM uses the native id generation strategy of the database, whether that be an auto-increment column or a sequence. http://gorm.grails.org/latest/hibernate/manual/ Given a configuration with one database server this is good. However when adding replicas this could become problematic, since this is often auto-generated by the database server. For a fuller discussion se the links at […]

Categories
Moving to Grails

Spring security core and Postgres

I am using Postgres database server. In Postgres creating a table with then name user is not allowed. One way to solve this is to map the User domain to a table with another name than user. Domain User example that works with Postgres using the table uuser:

Categories
Moving to Grails

Analyzing your code with CodeNarc

CodeNarc analyzes Groovy code for defects, bad practices, inconsistencies, style issues and more. A flexible framework for rules, rulesets and custom rules means it’s easy to configure CodeNarc to fit into your project. Build tool, framework support, and report generation are all enterprise ready. This is the description you find on the CodeNarc home page: […]

Categories
Moving to Grails

Logging from a library

I sometimes create libraries with less overhead than the e.g. a grails plugin. Applying the same logging as grails is done with these steps: add dependencies add configuration files for testing build.gradle: Then create the src/test/resources directory: In this case I configured test logging with logback-test.xml. For some reason I could not make logback-test.groovy work. […]

Categories
Moving to Grails

Logging from tests

Following up on the logging blog post. When creating and later running tests it could be equally helpful with some good logs. Configuring test logging is done with either logback-test.groovy or logback-test.xml which should be placed in the resources directory within the test directory. logback-test.groovy And then setting up the integration test something like: @Slf4j […]