001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 2005 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: * --------------------------------------------------------------------------
022: * $Id: ArchiveConfigForm.java 9642 2006-09-29 14:01:14Z danesa $
023: * --------------------------------------------------------------------------
024: */package org.objectweb.jonas.webapp.jonasadmin.xml;
025:
026: import java.io.File;
027: import java.util.ArrayList;
028: import java.util.HashMap;
029: import java.util.Map;
030: import java.util.TreeMap;
031:
032: import javax.servlet.http.HttpServletRequest;
033:
034: import org.apache.struts.action.ActionErrors;
035: import org.apache.struts.action.ActionForm;
036: import org.apache.struts.action.ActionMapping;
037: import org.w3c.dom.Document;
038:
039: /**
040: * Struts form used by the archive configuration pages.
041: * @author Patrick Smith
042: * @author Gregory Lapouchnian
043: */
044:
045: public class ArchiveConfigForm extends ActionForm {
046:
047: // --------------------------------------------------------- Constants
048:
049: /** The form was used. */
050: public static int FORM = 0;
051:
052: /** Advanced mode was used. */
053: public static int ADVANCED = 1;
054:
055: // --------------------------------------------------------- Properties variables
056:
057: /**
058: * List of deployable archives that can be selected for configuration.
059: */
060: private ArrayList deployable;
061:
062: /**
063: * The content of the archive's deployment descriptor used to create the form view.
064: */
065: private Document document;
066:
067: /**
068: * The raw XML contents of the archive's deployment descriptor used in the advanced view.
069: */
070: private String xml;
071:
072: /**
073: * A mapping of IDs used in the HTML form to Node objects they represent.
074: */
075: private Map mapping = new HashMap();
076:
077: /**
078: * Map used to store the input of all the textfields when the user submits the form view.
079: */
080: private Map values = new TreeMap();
081:
082: /**
083: * Submit button.
084: */
085: private String submit;
086:
087: /**
088: * Which configuration type is being used right now. Form or Advanced.
089: */
090: private int configType;
091:
092: /**
093: * Switch To ... button.
094: */
095: private String switchTo;
096:
097: /**
098: * Cancel button.
099: */
100: private String cancel;
101:
102: /**
103: * The name of the current archive.
104: */
105: private String archiveName;
106:
107: /**
108: * The path to the XML file within the current archive.
109: */
110: private String pathName;
111:
112: /**
113: * Used for returning values requested using the XMLHTTPRequest
114: * on the UI side. These values are used to construct a select list
115: * of allowed children for a given element.
116: */
117: private Map children;
118:
119: /**
120: * Is this a domain operation.
121: */
122: private boolean isDomain;
123:
124: /**
125: * The managed server's JONAS_BASE
126: */
127: private String jonasBase;
128:
129: // --------------------------------------------------------- Public Methods
130:
131: /**
132: * Reset all properties to their default values.
133: *
134: * @param mapping The mapping used to select this instance
135: * @param request The servlet request we are processing
136: */
137:
138: public void reset(ActionMapping mapping, HttpServletRequest request) {
139:
140: }
141:
142: /**
143: * Validate the properties that have been set from this HTTP request,
144: * and return an <code>ActionErrors</code> object that encapsulates any
145: * validation errors that have been found. If no errors are found, return
146: * <code>null</code> or an <code>ActionErrors</code> object with no
147: * recorded error messages.
148: *
149: * @param mapping The mapping used to select this instance
150: * @param request The servlet request we are processing
151: * @return the errors.
152: */
153: public ActionErrors validate(ActionMapping mapping,
154: HttpServletRequest request) {
155: ActionErrors oErrors = new ActionErrors();
156: return oErrors;
157: }
158:
159: /**
160: * Returns a String represetnation of the values.
161: * @return a string representation of the values.
162: */
163: public String toString() {
164: StringBuffer sb = new StringBuffer();
165: sb.append(values.toString());
166:
167: return sb.toString();
168: }
169:
170: /**
171: * Resets this form.
172: *
173: */
174: public void reset() {
175: archiveName = null;
176: pathName = null;
177: document = null;
178: xml = null;
179: mapping = new HashMap();
180: values = new TreeMap();
181: jonasBase = null;
182: }
183:
184: // --------------------------------------------------------- Properties Methods
185:
186: /**
187: * Returns the document.
188: * @return the document.
189: */
190: public Document getDocument() {
191: return document;
192: }
193:
194: /**
195: * Sets the document of this form
196: * @param document the value to set.
197: */
198: public void setDocument(Document document) {
199: this .document = document;
200: }
201:
202: /**
203: * Sets a value within the values map.
204: * @param key the key of the mapping.
205: * @param value the value of the mapping.
206: */
207: public void setValues(String key, Object value) {
208: values.put(key, value);
209: }
210:
211: /**
212: * Returns the object at key's spot of the mapping.
213: * @param key the key for the mapping.
214: * @return the value in the map that matches key.
215: */
216: public Object getValues(String key) {
217: return values.get(key);
218: }
219:
220: /**
221: * Sets the values map.
222: */
223: public void setValuesMap(Map values) {
224: this .values = values;
225: }
226:
227: /**
228: * Returns the values map.
229: * @return the values map.
230: */
231: public Map getValuesMap() {
232: return values;
233: }
234:
235: /**
236: * Sets the map.
237: * @param mapping the value to set.
238: */
239: public void setMapping(Map mapping) {
240: this .mapping = mapping;
241: }
242:
243: /**
244: * Returns the map.
245: * @return the map.
246: */
247: public Map getMapping() {
248: return this .mapping;
249: }
250:
251: /**
252: * Return the XML document as a string.
253: * @return the XML document as a string.
254: */
255: public String getXml() {
256: return xml;
257: }
258:
259: /**
260: * Sets the XML string.
261: * @param xml the value to set.
262: */
263: public void setXml(String xml) {
264: this .xml = xml;
265: }
266:
267: /**
268: * What submission form was done.
269: * @return the of submission.
270: */
271: public String getSubmit() {
272: return submit;
273: }
274:
275: /**
276: * Sets the submission.
277: * @param submit the submission to set.
278: */
279: public void setSubmit(String submit) {
280: this .submit = submit;
281: }
282:
283: /**
284: * Returns the config type.
285: * @return the config type.
286: */
287: public int getConfigType() {
288: return configType;
289: }
290:
291: /**
292: * Sets the config type.
293: * @param configType the type to set.
294: */
295: public void setConfigType(int configType) {
296: this .configType = configType;
297: }
298:
299: /**
300: * The target of switching done.
301: * @return the target of switching.
302: */
303: public String getSwitchTo() {
304: return switchTo;
305: }
306:
307: /**
308: * Sets the target of switching
309: * @param switchTo the target to set.
310: */
311: public void setSwitchTo(String switchTo) {
312: this .switchTo = switchTo;
313: }
314:
315: /**
316: * Returns the archive name in the form.
317: * @return the archive name.
318: */
319: public String getArchiveName() {
320: return archiveName;
321: }
322:
323: /**
324: * Sets the archive name for the form.
325: * @param archiveName the archive name to set.
326: */
327: public void setArchiveName(String archiveName) {
328: this .archiveName = jonasBase + "rars" + File.separator
329: + archiveName;
330: }
331:
332: /**
333: * Returns the path of the XML file.
334: * @return the path of the XML file.
335: */
336: public String getPathName() {
337: return pathName;
338: }
339:
340: /**
341: * Sets the path.
342: * @param pathName the path to set.
343: */
344: public void setPathName(String pathName) {
345: this .pathName = pathName;
346: }
347:
348: /**
349: * The list of deployable archives.
350: * @return the list of deployable archives.
351: */
352: public ArrayList getDeployable() {
353: return deployable;
354: }
355:
356: /**
357: * Sets the list of deployable archives.
358: * @param deployable the list to set.
359: */
360: public void setDeployable(ArrayList deployable) {
361: this .deployable = deployable;
362: }
363:
364: /**
365: * The target of the cancel op.
366: * @return the target of the cancel op.
367: */
368: public String getCancel() {
369: return cancel;
370: }
371:
372: /**
373: * Sets the cancel string
374: * @param cancel the string to set.
375: */
376: public void setCancel(String cancel) {
377: this .cancel = cancel;
378: }
379:
380: /**
381: * Return the map of children
382: * @return the map of children.
383: */
384: public Map getChildren() {
385: return children;
386: }
387:
388: /**
389: * Sets the children map.
390: * @param childValues the map to set.
391: */
392: public void setChildren(Map childValues) {
393: this .children = childValues;
394: }
395:
396: /**
397: * Return if the action is a domain management operation.
398: * @return if the action is a domain management operation.
399: */
400: public boolean getIsDomain() {
401: return this .isDomain;
402: }
403:
404: /**
405: * Sets if the action is a domain management operation.
406: * @param isDomain if the action is a domain management operation.
407: */
408: public void setIsDomain(boolean isDomain) {
409: this .isDomain = isDomain;
410: }
411:
412: public String getJonasBase() {
413: return jonasBase;
414: }
415:
416: public void setJonasBase(String jonasBase) {
417: this.jonasBase = jonasBase;
418: }
419:
420: }
|