1 | import org.codehaus.groovy.grails.commons.GrailsApplication |
---|
2 | import grails.util.GrailsUtil |
---|
3 | |
---|
4 | /** |
---|
5 | * Application Bootstrapper |
---|
6 | * @Author Jeroen Wesbeek |
---|
7 | * @Since 20091021 |
---|
8 | * |
---|
9 | * Revision information: |
---|
10 | * $Rev: 16 $ |
---|
11 | * $Author: gajula $ |
---|
12 | * $Date: 2009-10-21 11:07:28 +0000 (wo, 21 okt 2009) $ |
---|
13 | */ |
---|
14 | class BootStrap { |
---|
15 | def init = { servletContext -> |
---|
16 | // check if we're in development |
---|
17 | if (GrailsUtil.environment == GrailsApplication.ENV_DEVELOPMENT) { |
---|
18 | printf("development bootstrapping....\n\n"); |
---|
19 | |
---|
20 | // add roles |
---|
21 | def AuthRole1 = new AuthRole(name:'Administrator', description:'Super user').save(); |
---|
22 | def AuthRole2 = new AuthRole(name:'Group Administrator', description:'Group Super user').save(); |
---|
23 | def AuthRole3 = new AuthRole(name:'Study Owner', description:'The creator of a study').save(); |
---|
24 | |
---|
25 | // add actions |
---|
26 | def AuthAction1 = new AuthAction(controller:'test', action:'index').save(); |
---|
27 | def AuthAction2 = new AuthAction(controller:'test', action:'sayHello').save(); |
---|
28 | def AuthAction3 = new AuthAction(controller:'test', action:'sayWeather').save(); |
---|
29 | |
---|
30 | // authorize super user for everything |
---|
31 | AuthRole1.addToActions(AuthAction1).save(); |
---|
32 | AuthRole1.addToActions(AuthAction2).save(); |
---|
33 | AuthRole1.addToActions(AuthAction3).save(); |
---|
34 | |
---|
35 | // authorize group admin only for index and hello |
---|
36 | AuthRole2.addToActions(AuthAction1).save(); |
---|
37 | AuthRole2.addToActions(AuthAction2).save(); |
---|
38 | |
---|
39 | // authorize study owner only for index |
---|
40 | AuthRole3.addToActions(AuthAction1).save(); |
---|
41 | |
---|
42 | // add users |
---|
43 | def User1 = new AuthUser(username:'admin', password:'admin', firstName:'super', lastName:'User', email:'info@osx.eu').save(); |
---|
44 | def User2 = new AuthUser(username:'duh', password:'duh', firstname:'Jeroen', lastname:'Wesbeek', email:'j.a.m.wesbeek@umail.leidenuniv.nl').save(); |
---|
45 | |
---|
46 | // add group structure |
---|
47 | def AuthGroup1 = new AuthGroup(name:'root', description:'the root of everything').save(); |
---|
48 | def AuthGroup2 = new AuthGroup(name:'TNO', description:'TNO - nation wide company').save(); |
---|
49 | def AuthGroup3 = new AuthGroup(name:'KVL', description:'TNO - quality of life').save(); |
---|
50 | def AuthGroup4 = new AuthGroup(name:'BSC', description:'BioSciences').save(); |
---|
51 | |
---|
52 | // create group tree 4 -> 3 -> 2 -> 1 |
---|
53 | AuthGroup4.addToGroups(AuthGroup3).save(); |
---|
54 | AuthGroup3.addToGroups(AuthGroup2).save(); |
---|
55 | AuthGroup2.addToGroups(AuthGroup1).save(); |
---|
56 | |
---|
57 | // add users to groups |
---|
58 | //User1.addToGroups(AuthGroup1).save(); |
---|
59 | //User2.addToGroups(AuthGroup4).save(); |
---|
60 | |
---|
61 | |
---|
62 | } |
---|
63 | } |
---|
64 | def destroy = { |
---|
65 | } |
---|
66 | } |
---|