001: /*
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * Initial developer(s): Michel-Ange ANTON
022: * --------------------------------------------------------------------------
023: * $Id: GroupMemoryRealmForm.java 6599 2005-04-21 08:59:54Z kemlerp $
024: * --------------------------------------------------------------------------
025: */
026:
027: package org.objectweb.jonas.webapp.jonasadmin.security;
028:
029: import java.util.ArrayList;
030:
031: import javax.servlet.http.HttpServletRequest;
032:
033: import org.apache.struts.action.ActionMessage;
034: import org.apache.struts.action.ActionErrors;
035: import org.apache.struts.action.ActionForm;
036: import org.apache.struts.action.ActionMapping;
037: import org.objectweb.jonas.webapp.jonasadmin.Jlists;
038:
039: public class GroupMemoryRealmForm extends ActionForm {
040:
041: // --------------------------------------------------------- Constants
042:
043: // --------------------------------------------------------- Properties variables
044:
045: private String action = null;
046: private String group = null;
047: private String description = null;
048: private java.util.ArrayList listRolesGroup = new ArrayList();
049: private java.util.ArrayList listRolesRealm = new ArrayList();
050: private java.util.ArrayList listRolesUsed = new ArrayList();
051: private java.util.ArrayList listRolesNotused = new ArrayList();
052: private String rolesUsed = null;
053: private String rolesNotused = null;
054: private String[] rolesNotusedSelected = new String[0];
055: private String[] rolesUsedSelected = new String[0];
056:
057: // --------------------------------------------------------- Public Methods
058:
059: /**
060: * Reset all properties to their default values.
061: *
062: * @param mapping The mapping used to select this instance
063: * @param request The servlet request we are processing
064: */
065: public void reset(ActionMapping mapping, HttpServletRequest request) {
066: rolesUsed = null;
067: rolesNotused = null;
068: // Mandatory !
069: rolesNotusedSelected = new String[0];
070: rolesUsedSelected = new String[0];
071: }
072:
073: /**
074: * Validate the properties that have been set from this HTTP request,
075: * and return an <code>ActionErrors</code> object that encapsulates any
076: * validation errors that have been found. If no errors are found, return
077: * <code>null</code> or an <code>ActionErrors</code> object with no
078: * recorded error messages.
079: *
080: * @param mapping The mapping used to select this instance
081: * @param request The servlet request we are processing
082: */
083: public ActionErrors validate(ActionMapping mapping,
084: HttpServletRequest request) {
085: ActionErrors oErrors = new ActionErrors();
086: // Create errors
087: if (action.equals("create") == true) {
088: group = group.trim();
089: if (group.length() == 0) {
090: oErrors
091: .add(
092: "group",
093: new ActionMessage(
094: "error.security.factory.memory.realm.group.name.required"));
095: }
096: }
097: // Replace the elements in their good place
098: if (oErrors.size() > 0) {
099: listRolesUsed = Jlists.getArrayList(rolesUsed,
100: Jlists.SEPARATOR);
101: listRolesNotused = Jlists.getArrayList(rolesNotused,
102: Jlists.SEPARATOR);
103: }
104: return oErrors;
105: }
106:
107: // --------------------------------------------------------- Properties Methods
108:
109: public String getGroup() {
110: return group;
111: }
112:
113: public void setGroup(String group) {
114: this .group = group;
115: }
116:
117: public String getDescription() {
118: return description;
119: }
120:
121: public void setDescription(String description) {
122: this .description = description;
123: }
124:
125: public java.util.ArrayList getListRolesGroup() {
126: return listRolesGroup;
127: }
128:
129: public void setListRolesGroup(java.util.ArrayList listRolesGroup) {
130: this .listRolesGroup = listRolesGroup;
131: }
132:
133: public java.util.ArrayList getListRolesRealm() {
134: return listRolesRealm;
135: }
136:
137: public void setListRolesRealm(java.util.ArrayList listRolesRealm) {
138: this .listRolesRealm = listRolesRealm;
139: }
140:
141: public java.util.ArrayList getListRolesUsed() {
142: return listRolesUsed;
143: }
144:
145: public void setListRolesUsed(java.util.ArrayList listRolesUsed) {
146: this .listRolesUsed = listRolesUsed;
147: }
148:
149: public java.util.ArrayList getListRolesNotused() {
150: return listRolesNotused;
151: }
152:
153: public void setListRolesNotused(java.util.ArrayList listRolesNotused) {
154: this .listRolesNotused = listRolesNotused;
155: }
156:
157: public String getRolesUsed() {
158: return rolesUsed;
159: }
160:
161: public void setRolesUsed(String rolesUsed) {
162: this .rolesUsed = rolesUsed;
163: }
164:
165: public String getRolesNotused() {
166: return rolesNotused;
167: }
168:
169: public void setRolesNotused(String rolesNotused) {
170: this .rolesNotused = rolesNotused;
171: }
172:
173: public String[] getRolesNotusedSelected() {
174: return rolesNotusedSelected;
175: }
176:
177: public void setRolesNotusedSelected(String[] rolesNotusedSelected) {
178: this .rolesNotusedSelected = rolesNotusedSelected;
179: }
180:
181: public String[] getRolesUsedSelected() {
182: return rolesUsedSelected;
183: }
184:
185: public void setRolesUsedSelected(String[] rolesUsedSelected) {
186: this .rolesUsedSelected = rolesUsedSelected;
187: }
188:
189: public String getAction() {
190: return action;
191: }
192:
193: public void setAction(String action) {
194: this.action = action;
195: }
196:
197: }
|