View Javadoc

1   /*
2    * This software was designed and created by Jason Carroll.
3    * Copyright (c) 2002, 2003, 2004 Jason Carroll.
4    * The author can be reached at jcarroll@cowsultants.com
5    * ITracker website: http://www.cowsultants.com
6    * ITracker forums: http://www.cowsultants.com/phpBB/index.php
7    *
8    * This program is free software; you can redistribute it and/or modify
9    * it only under the terms of the GNU General Public License as published by
10   * the Free Software Foundation; either version 2 of the License, or
11   * (at your option) any later version.
12   *
13   * This program is distributed in the hope that it will be useful,
14   * but WITHOUT ANY WARRANTY; without even the implied warranty of
15   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   * GNU General Public License for more details.
17   */
18  
19  package org.itracker.web.forms;
20  
21  import javax.servlet.http.HttpServletRequest;
22  
23  import org.apache.log4j.Logger;
24  import org.apache.struts.action.ActionErrors;
25  import org.apache.struts.action.ActionMapping;
26  import org.apache.struts.action.ActionMessage;
27  import org.apache.struts.action.ActionMessages;
28  import org.apache.struts.validator.ValidatorForm;
29  import org.itracker.web.actions.admin.project.EditProjectFormActionUtil;
30  import org.itracker.web.util.ServletContextUtils;
31  
32  /**
33   * This is the LoginForm Struts Form. It is used by Login form.
34   * 
35   * @author ready
36   * 
37   */
38  public class ProjectForm extends ValidatorForm {
39  	/**
40  	 * 
41  	 */
42  	private static final long serialVersionUID = 1L;
43  	private String action;
44  	private Integer id;
45  	private String name;
46  	private Integer status;
47  	private String description;
48  	private Integer[] owners;
49  	private Integer[] users;
50  	private Integer[] permissions;
51  	private Integer[] options;
52  	private Integer[] fields;
53  
54  	private static final Logger log = Logger.getLogger(ProjectForm.class);
55  
56  	public void reset(ActionMapping mapping, HttpServletRequest request) {
57  		action = null;
58  		id = null;
59  		name = null;
60  		status = null;
61  		description = null;
62  		owners = null;
63  		users = null;
64  		permissions = null;
65  		options = null;
66  		fields = null;
67  
68  	}
69  
70  	public ActionErrors validate(ActionMapping mapping,
71  			HttpServletRequest request) {
72  		ActionErrors errors = super.validate(mapping, request);
73  		if (log.isDebugEnabled()) {
74  			log.debug("ProjectForm validate called: mapping: " + mapping
75  					+ ", request: " + request + ", errors: " + errors);
76  		}
77  		if (ServletContextUtils.getItrackerServices().getProjectService()
78  				.isUniqueProjectName(getName(), getId())) {
79  		} else {
80  			errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
81  					"itracker.web.error.project.duplicate.name"));
82  			// throw new ProjectException(
83  			// "Project already exist with this name.");
84  		}
85  
86  		new EditProjectFormActionUtil().init(mapping, request, this);
87  		return errors;
88  	}
89  
90  	public String getAction() {
91  		return action;
92  	}
93  
94  	public void setAction(String action) {
95  		this.action = action;
96  	}
97  
98  	public String getDescription() {
99  		return description;
100 	}
101 
102 	public void setDescription(String description) {
103 		this.description = description;
104 	}
105 
106 	public Integer[] getFields() {
107 		if (null == fields)
108 			return null;
109 		return fields.clone();
110 	}
111 
112 	public void setFields(Integer[] fields) {
113 		if (null == fields)
114 			this.fields = null;
115 		else
116 			this.fields = fields.clone();
117 	}
118 
119 	public Integer getId() {
120 		return id;
121 	}
122 
123 	public void setId(Integer id) {
124 		this.id = id;
125 	}
126 
127 	public String getName() {
128 		return name;
129 	}
130 
131 	public void setName(String name) {
132 		this.name = name;
133 	}
134 
135 	public Integer[] getOptions() {
136 		if (null == options)
137 			return null;
138 		return options.clone();
139 	}
140 
141 	public void setOptions(Integer[] options) {
142 		if (null == options)
143 			this.options = null;
144 		else
145 			this.options = options.clone();
146 	}
147 
148 	public Integer[] getOwners() {
149 		if (null == owners)
150 			return null;
151 		return owners.clone();
152 	}
153 
154 	public void setOwners(Integer[] owners) {
155 		if (null == owners)
156 			this.owners = null;
157 		else
158 			this.owners = owners.clone();
159 	}
160 
161 	public Integer[] getPermissions() {
162 		if (null == permissions)
163 			return null;
164 
165 		return permissions.clone();
166 
167 	}
168 
169 	public void setPermissions(Integer[] permissions) {
170 		if (null == permissions)
171 			this.permissions = null;
172 		else
173 			this.permissions = permissions.clone();
174 	}
175 
176 	public Integer getStatus() {
177 		return status;
178 	}
179 
180 	public void setStatus(Integer status) {
181 		this.status = status;
182 	}
183 
184 	public Integer[] getUsers() {
185 		if (null == users)
186 			return null;
187 		return users.clone();
188 	}
189 
190 	public void setUsers(Integer[] users) {
191 		if (null == users)
192 			this.users = null;
193 		else
194 			this.users = users.clone();
195 	}
196 
197 }