KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cms > applications > managementtool > actions > UpdateRoleAction


1 /* ===============================================================================
2  *
3  * Part of the InfoGlue Content Management Platform (www.infoglue.org)
4  *
5  * ===============================================================================
6  *
7  * Copyright (C)
8  *
9  * This program is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License version 2, as published by the
11  * Free Software Foundation. See the file LICENSE.html for more information.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
19  * Place, Suite 330 / Boston, MA 02111-1307 / USA.
20  *
21  * ===============================================================================
22  */

23
24 package org.infoglue.cms.applications.managementtool.actions;
25
26 import org.infoglue.cms.controllers.kernel.impl.simple.RoleControllerProxy;
27 import org.infoglue.cms.controllers.kernel.impl.simple.RolePropertiesController;
28 import org.infoglue.cms.entities.management.RoleVO;
29 import org.infoglue.cms.util.ConstraintExceptionBuffer;
30
31 /**
32  * @author Mattias Bogeblad
33  */

34
35 public class UpdateRoleAction extends ViewRoleAction //WebworkAbstractAction
36
{
37     private ConstraintExceptionBuffer ceb;
38     private RoleVO roleVO;
39     
40     public UpdateRoleAction()
41     {
42         this(new RoleVO());
43     }
44     
45     public UpdateRoleAction(RoleVO RoleVO)
46     {
47         this.roleVO = RoleVO;
48         this.ceb = new ConstraintExceptionBuffer();
49     }
50     
51     public String JavaDoc doExecute() throws Exception JavaDoc
52     {
53         super.initialize(getRoleName());
54         
55         ceb.add(this.roleVO.validate());
56         ceb.throwIfNotEmpty();
57
58         String JavaDoc[] values = getRequest().getParameterValues("userName");
59         String JavaDoc[] contentTypeDefinitionIds = getRequest().getParameterValues("contentTypeDefinitionId");
60
61         RoleControllerProxy.getController().updateRole(this.roleVO, values);
62         
63         if(contentTypeDefinitionIds != null && contentTypeDefinitionIds.length > 0 && !contentTypeDefinitionIds[0].equals(""))
64             RolePropertiesController.getController().updateContentTypeDefinitions(this.getRoleName(), contentTypeDefinitionIds);
65         
66         return "success";
67     }
68     
69     public String JavaDoc doSaveAndExit() throws Exception JavaDoc
70     {
71         doExecute();
72                         
73         return "saveAndExit";
74     }
75
76     public void setRoleName(String JavaDoc roleName)
77     {
78         this.roleVO.setRoleName(roleName);
79     }
80     
81     public String JavaDoc getRoleName()
82     {
83         return this.roleVO.getRoleName();
84     }
85     
86     public void setDescription(java.lang.String JavaDoc description)
87     {
88         this.roleVO.setDescription(description);
89     }
90
91     public String JavaDoc getDescription()
92     {
93         return this.roleVO.getDescription();
94     }
95     
96
97 }
98
Popular Tags