Posts

Showing posts from 2009

Mohana- the witch of bring-a-thing

Image
This week we were asked something to bring a thing for "Bring A Thing", a kind of charity activity at work.
I brought a kind of jack in the box witch. Then I was asked to write a  story about it.
I thing it got out pretty well and I wanted to share it with you
To fully understand the story you should watch South Park , listen to some Manowar and live in Romania. It is still funny if you haven't done any of this, but...

Here it is:

Once upon a time in the land of far away yet so close you could feel it lived little Timmy.
He was a handicapped kid walking around in his wheel chair and singing Abba all day.
Timmy’s life was quite boring and ordinary, except when playing tanki online. He was a true champion then.
One day his parents wanted to surprise Timmy. So they sent little Timmy to leave with aunt whom he had never seen or heard of, Florgonzola.
Oh boy, finally an adventure, thought the child.
And finally he arrived. The weather was not so nice. It was autumn and rai…

Ways to map and query many-to-many in GORM

I played with many-to-many relations in grails and found some interesting ways to work with them.
First the domain definitions.
For the purpose of this demo I chose the classic example with books and authors. A book may have many authors and an author may have many books.

class Author {
String name
}

class Book {
String name
}

What I consider the silliest way to define your domains I found here http://www.grails.org/Many-to-Many+Mapping+without+Hibernate+XML
They suggest mapping the join table using a domain object and creating the links by hand.
On 'books and authors' it would look like

class Book {
String name
static hasMany = [ memberships: Membership]

List authors() {
return memberships.collect {it.author}
}

List addToAuthors(Author author) {
Membership.link(this, author)
return authors()
}

List removeFromAuthors(Author author) {
Membership.unlink(this, author)
return authors()
}
}

class Author {
String name
static hasMany = [memberships: Membership]

List…

JSecurity and active directory in grails

This was done as a way to force domain users to log in before using the applications.
The old implementation used the jcifs library with jetty, but after upgrading to glashfish, jcifs started to fail randomly, especially when the application was accessed using IE.
And, after reading on their web site that the httpfilter is no longer supported, I started looking for free alternatives to Jcifs.
On the JSecurity plugin home it said it works with ldap, but the configuration they gave seemed complicated and I didn't really get it.
On the other hand I found this nice blog entry of how to use java/jndi and active directory.
http://mhimu.wordpress.com/2009/03/18/active-directory-authentication-using-javajndi/

This is how o put them together:

1. install the jsecurity plugin in your grails app

grails install-plugin jsecurity


2. generate the ldap realm and the auth controller. This comes default with jsecurity.

grails create-ldap-realm
grails create-auth-controller


3. Create a filter to redirect all…

Alternate way to run/debug Griffon applications from an IDE

Image
This is a way I use to to debug my griffon apps since before ide support. I am using this with idea 8, but I think it can be used with every ide. I think Eclipse can run griffon apps like this.
I was looking at the new support from IntelliJ and Netbeans and it looks great. But I think the way I am going to describe also has benefits.

Let's begin from scratch.
So these are the steps:
1. Create an empty project in Idea.

2. Create your griffon application somewhere on the hard drive.

griffon create-app demo1

Ok, now we have an empty project and an empty app.

3. We will add the app in idea as a java module.

On the next screen we choose not to create a source directory. Click next, do not add any facets and finish.

4.Next we set up the sources folders for our project. It should look like in the picture. The blue folders are sources. The green one are test sources.



5. Let's add the griffon libraries to our module. Basically what I do here is add all the jars from the folders containing jar…