KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.List JavaDoc;
27
28 import org.infoglue.cms.controllers.kernel.impl.simple.UserControllerProxy;
29 import org.infoglue.cms.controllers.kernel.impl.simple.UserPropertiesController;
30 import org.infoglue.cms.entities.management.RoleVO;
31 import org.infoglue.cms.entities.management.SystemUserVO;
32 import org.infoglue.cms.exception.SystemException;
33 import org.infoglue.cms.security.InfoGluePrincipal;
34 import org.infoglue.cms.util.CmsPropertyHandler;
35 import org.infoglue.cms.util.ConstraintExceptionBuffer;
36
37 /**
38  * @author Mattias Bogeblad
39  */

40
41 public class UpdateSystemUserAction extends ViewSystemUserAction //WebworkAbstractAction
42
{
43     private ConstraintExceptionBuffer ceb;
44     private SystemUserVO systemUserVO;
45     private RoleVO roleVO;
46     private InfoGluePrincipal infoGluePrincipal;
47     private String JavaDoc[] roller;
48     private List JavaDoc defRoles;
49     private String JavaDoc action;
50     private String JavaDoc oldPassword;
51     
52     
53     public UpdateSystemUserAction()
54     {
55         this(new SystemUserVO());
56     }
57     
58     public UpdateSystemUserAction(SystemUserVO systemUserVO)
59     {
60         this.systemUserVO = systemUserVO;
61         this.ceb = new ConstraintExceptionBuffer();
62     }
63     
64     public String JavaDoc doExecute() throws Exception JavaDoc
65     {
66         super.initialize(this.getInfoGluePrincipal().getName());
67                 
68         ceb = this.systemUserVO.validate();
69         ceb.throwIfNotEmpty();
70     
71         String JavaDoc[] roles = getRequest().getParameterValues("roleName");
72         String JavaDoc[] groups = getRequest().getParameterValues("groupName");
73         String JavaDoc[] contentTypeDefinitionIds = getRequest().getParameterValues("contentTypeDefinitionId");
74         
75         UserControllerProxy.getController().updateUser(this.systemUserVO, roles, groups);
76         if(contentTypeDefinitionIds != null && contentTypeDefinitionIds.length > 0 && !contentTypeDefinitionIds[0].equals(""))
77             UserPropertiesController.getController().updateContentTypeDefinitions(this.getUserName(), contentTypeDefinitionIds);
78         
79         return "success";
80
81     }
82
83     public String JavaDoc doSaveAndExit() throws Exception JavaDoc
84     {
85         doExecute();
86         
87         return "saveAndExit";
88     }
89
90     public String JavaDoc doChangePassword() throws Exception JavaDoc
91     {
92         if(this.systemUserVO.getUserName().equals(CmsPropertyHandler.getAnonymousUser()))
93             throw new SystemException("You must not change password on this user as it's needed by the system.");
94
95         UserControllerProxy.getController().updateUserPassword(this.systemUserVO.getUserName());
96         
97         return "passwordSentSuccess";
98     }
99     
100     private String JavaDoc[] getRoller()
101     {
102         return this.roller;
103     }
104        
105     public java.lang.String JavaDoc getFirstName()
106     {
107         return this.systemUserVO.getFirstName();
108     }
109         
110     public void setFirstName(java.lang.String JavaDoc firstName)
111     {
112         this.systemUserVO.setFirstName(firstName);
113     }
114
115     public java.lang.String JavaDoc getLastName()
116     {
117         return this.systemUserVO.getLastName();
118     }
119         
120     public void setLastName(java.lang.String JavaDoc lastName)
121     {
122         this.systemUserVO.setLastName(lastName);
123     }
124         
125     public String JavaDoc getUserName()
126     {
127         return this.systemUserVO.getUserName();
128     }
129     
130     public void setUserName(String JavaDoc userName)
131     {
132         this.systemUserVO.setUserName(userName);
133     }
134
135     public java.lang.String JavaDoc getEmail()
136     {
137         return this.systemUserVO.getEmail();
138     }
139
140
141     public void setEmail(java.lang.String JavaDoc email) throws Exception JavaDoc
142     {
143         this.systemUserVO.setEmail(email);
144     }
145
146     public java.lang.String JavaDoc getPassword()
147     {
148         return this.systemUserVO.getPassword();
149     }
150
151     public void setPassword(java.lang.String JavaDoc password)
152     {
153         this.systemUserVO.setPassword(password);
154     }
155
156     public void setOldPassword(java.lang.String JavaDoc oldPassword)
157     {
158         this.oldPassword = oldPassword;
159     }
160
161     public void setAction(String JavaDoc action)
162     {
163         this.action = action;
164     }
165     
166     public String JavaDoc getAction()
167     {
168         return this.action;
169     }
170
171
172
173
174 }
175
Popular Tags