Source Code Cross Referenced for PersonEditorForm.java in  » Project-Management » XPlanner-0.7b7 » com » technoetic » xplanner » forms » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Project Management » XPlanner 0.7b7 » com.technoetic.xplanner.forms 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.technoetic.xplanner.forms;
002:
003:        import java.util.ArrayList;
004:        import java.util.Collection;
005:        import java.util.Iterator;
006:        import javax.servlet.http.HttpServletRequest;
007:
008:        import org.apache.commons.collections.CollectionUtils;
009:        import org.apache.commons.collections.Predicate;
010:        import org.apache.commons.lang.StringUtils;
011:        import org.apache.struts.action.ActionErrors;
012:        import org.apache.struts.action.ActionMapping;
013:
014:        import com.technoetic.xplanner.domain.Role;
015:        import com.technoetic.xplanner.security.AuthenticationException;
016:        import com.technoetic.xplanner.security.auth.SystemAuthorizer;
017:
018:        public class PersonEditorForm extends AbstractEditorForm {
019:
020:            private String name;
021:            private String email;
022:            private String phone;
023:            private int personId;
024:            private String initials;
025:            private String userId;
026:            private String password;
027:            private String newPassword;
028:            private String newPasswordConfirm;
029:            private boolean isHidden;
030:            private ArrayList projectIds = new ArrayList();
031:            private ArrayList projectRoles = new ArrayList();
032:            private boolean isSystemAdmin;
033:            public static final String PASSWORD_MISMATCH_ERROR = "person.editor.password_mismatch";
034:
035:            public ActionErrors validate(ActionMapping mapping,
036:                    HttpServletRequest request) {
037:                ActionErrors errors = new ActionErrors();
038:                if (isSubmitted()) {
039:                    require(errors, name, "person.editor.missing_name");
040:                    require(errors, userId, "person.editor.missing_user_id");
041:                    require(errors, email, "person.editor.missing_email");
042:                    require(errors, initials, "person.editor.missing_initials");
043:                    if (StringUtils.isNotEmpty(newPassword)
044:                            && !StringUtils.equals(newPassword,
045:                                    newPasswordConfirm)) {
046:                        error(errors, PASSWORD_MISMATCH_ERROR);
047:                    }
048:                }
049:                return errors;
050:            }
051:
052:            public void reset(ActionMapping mapping, HttpServletRequest request) {
053:                super .reset(mapping, request);
054:                name = null;
055:                email = null;
056:                phone = null;
057:                initials = null;
058:                userId = null;
059:                personId = 0;
060:                newPassword = null;
061:                newPasswordConfirm = null;
062:                isHidden = false;
063:                isSystemAdmin = false;
064:            }
065:
066:            public String getContainerId() {
067:                return Integer.toString(personId);
068:            }
069:
070:            public void setName(String name) {
071:                this .name = name;
072:            }
073:
074:            public String getName() {
075:                return name;
076:            }
077:
078:            public void setEmail(String email) {
079:                this .email = email;
080:            }
081:
082:            public String getEmail() {
083:                return email;
084:            }
085:
086:            public void setPhone(String phone) {
087:                this .phone = phone;
088:            }
089:
090:            public String getPhone() {
091:                return phone;
092:            }
093:
094:            public void setPersonId(int personId) {
095:                this .personId = personId;
096:            }
097:
098:            public int getPersonId() {
099:                return personId;
100:            }
101:
102:            public void setInitials(String initials) {
103:                this .initials = initials;
104:            }
105:
106:            public String getInitials() {
107:                return initials;
108:            }
109:
110:            /** Alias for userId so field won't be filled in automatically by Mozilla, etc. */
111:            public String getUserIdentifier() {
112:                return getUserId();
113:            }
114:
115:            /** Alias for userId so field won't be filled in automatically by Mozilla, etc. */
116:            public void setUserIdentifier(String userId) {
117:                setUserId(userId);
118:            }
119:
120:            public String getUserId() {
121:                return userId;
122:            }
123:
124:            public void setUserId(String userId) {
125:                this .userId = userId;
126:            }
127:
128:            public String getNewPassword() {
129:                return newPassword;
130:            }
131:
132:            public void setNewPassword(String newPassword) {
133:                this .newPassword = newPassword;
134:            }
135:
136:            public String getNewPasswordConfirm() {
137:                return newPasswordConfirm;
138:            }
139:
140:            public void setNewPasswordConfirm(String newPasswordConfirm) {
141:                this .newPasswordConfirm = newPasswordConfirm;
142:            }
143:
144:            public String getPassword() {
145:                return password;
146:            }
147:
148:            public void setPassword(String password) {
149:                this .password = password;
150:            }
151:
152:            public boolean isHidden() {
153:                return isHidden;
154:            }
155:
156:            public void setHidden(boolean hidden) {
157:                isHidden = hidden;
158:            }
159:
160:            public void setProjectId(int index, String projectId) {
161:                ensureSize(projectIds, index + 1);
162:                projectIds.set(index, projectId);
163:
164:            }
165:
166:            public String getProjectId(int index) {
167:                return (String) projectIds.get(index);
168:            }
169:
170:            public int getProjectIdAsInt(int index) {
171:                return Integer.parseInt(getProjectId(index));
172:            }
173:
174:            public int getProjectCount() {
175:                return projectIds.size();
176:            }
177:
178:            public void setProjectRole(int index, String role) {
179:                ensureSize(projectRoles, index + 1);
180:                projectRoles.set(index, role);
181:            }
182:
183:            public String getProjectRole(int index) {
184:                return (String) projectRoles.get(index);
185:            }
186:
187:            public void setSystemAdmin(boolean isSystemAdmin) {
188:                this .isSystemAdmin = isSystemAdmin;
189:            }
190:
191:            public boolean isSystemAdmin() {
192:                return isSystemAdmin;
193:            }
194:
195:            // These helper functions should be refactored into the domain objects
196:
197:            private boolean hasRole(Collection roles, String name) {
198:                for (Iterator iterator = roles.iterator(); iterator.hasNext();) {
199:                    Role role = (Role) iterator.next();
200:                    if (role.getName().equals(name)) {
201:                        return true;
202:                    }
203:                }
204:                return false;
205:            }
206:
207:            // This is for 0.6. In the future there will be a more general role editing and
208:            // management framework.
209:            //DEBT remove all references to roles title. This hierarchy should be captured declaratively somewhere.
210:            private String getEffectiveRole(Collection roles) {
211:                if (hasRole(roles, "admin")) {
212:                    return "admin";
213:                } else if (hasRole(roles, "editor")) {
214:                    return "editor";
215:                } else if (hasRole(roles, "viewer")) {
216:                    return "viewer";
217:                } else {
218:                    return "none";
219:                }
220:            }
221:
222:            public String isRoleSelected(String role, int projectId)
223:                    throws AuthenticationException {
224:                return getEffectiveRole(getRoles(projectId)).equals(role) ? "selected='selected'"
225:                        : "";
226:            }
227:
228:            public Collection getRoles(int projectId)
229:                    throws AuthenticationException {
230:                return SystemAuthorizer.get().getRolesForPrincipalOnProject(
231:                        getId(), projectId, false);
232:            }
233:
234:            public ArrayList getProjectIds() {
235:                return projectIds;
236:            }
237:
238:            public void setProjectIds(ArrayList projectIds) {
239:                this .projectIds = projectIds;
240:            }
241:
242:            public ArrayList getProjectRoles() {
243:                return projectRoles;
244:            }
245:
246:            public void setProjectRoles(ArrayList projectRoles) {
247:                this .projectRoles = projectRoles;
248:            }
249:
250:            public boolean isSysAdmin() throws AuthenticationException {
251:                return CollectionUtils.find(getRoles(0), new Predicate() {
252:                    public boolean evaluate(Object o) {
253:                        return (((Role) o).getName().equals("sysadmin"));
254:                    }
255:                }) != null;
256:            }
257:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.