source: branches/TaskRewrite/src/plugins/acegi-0.5.1/src/templates/manager/controllers/_RoleController.groovy @ 58

Last change on this file since 58 was 58, checked in by gav, 15 years ago

Configure BootStrap? with latest concepts.
Install and setup Acegi plugin with custom views.
Test Fixture plugin in a test app but couldn't get it to work with Acegi encodePassword() so gave up.

File size: 2.7 KB
Line 
1${authorityClassImport}
2${requestmapClassImport}
3
4/**
5 * Authority Controller.
6 */
7class ${authorityClassName}Controller {
8
9        // the delete, save and update actions only accept POST requests
10        static Map allowedMethods = [delete: 'POST', save: 'POST', update: 'POST']
11
12        def authenticateService
13
14        def index = {
15                redirect action: list, params: params
16        }
17
18        /**
19         * Display the list authority page.
20         */
21        def list = {
22                if (!params.max) {
23                        params.max = 10
24                }
25                [authorityList: ${authorityClassName}.list(params)]
26        }
27
28        /**
29         * Display the show authority page.
30         */
31        def show = {
32                def authority = ${authorityClassName}.get(params.id)
33                if (!authority) {
34                        flash.message = "${authorityClassName} not found with id \$params.id"
35                        redirect action: list
36                        return
37                }
38
39                [authority: authority]
40        }
41
42        /**
43         * Delete an authority.
44         */
45        def delete = {
46                def authority = ${authorityClassName}.get(params.id)
47                if (!authority) {
48                        flash.message = "${authorityClassName} not found with id \$params.id"
49                        redirect action: list
50                        return
51                }
52
53                authenticateService.deleteRole(authority)
54
55                flash.message = "${authorityClassName} \$params.id deleted."
56                redirect action: list
57        }
58
59        /**
60         * Display the edit authority page.
61         */
62        def edit = {
63                def authority = ${authorityClassName}.get(params.id)
64                if (!authority) {
65                        flash.message = "${authorityClassName} not found with id \$params.id"
66                        redirect action: list
67                        return
68                }
69
70                [authority: authority]
71        }
72
73        /**
74         * Authority update action.
75         */
76        def update = {
77
78                def authority = ${authorityClassName}.get(params.id)
79                if (!authority) {
80                        flash.message = "${authorityClassName} not found with id \$params.id"
81                        redirect action: edit, id: params.id
82                        return
83                }
84
85                long version = params.version.toLong()
86                if (authority.version > version) {
87                        authority.errors.rejectValue 'version', 'authority.optimistic.locking.failure',
88                                'Another user has updated this ${authorityClassName} while you were editing.'
89                        render view: 'edit', model: [authority: authority]
90                        return
91                }
92
93                if (authenticateService.updateRole(authority, params)) {
94                        authenticateService.clearCachedRequestmaps()
95                        redirect action: show, id: authority.id
96                }
97                else {
98                        render view: 'edit', model: [authority: authority]
99                }
100        }
101
102        /**
103         * Display the create new authority page.
104         */
105        def create = {
106                [authority: new ${authorityClassName}()]
107        }
108
109        /**
110         * Save a new authority.
111         */
112        def save = {
113
114                def authority = new ${authorityClassName}()
115                authority.properties = params
116                if (authority.save()) {
117                        redirect action: show, id: authority.id
118                }
119                else {
120                        render view: 'create', model: [authority: authority]
121                }
122        }
123}
Note: See TracBrowser for help on using the repository browser.