01: /**
02: * JOnAS: Java(TM) Open Application Server
03: * Copyright (C) 2005 Bull S.A.
04: * Contact: jonas-team@objectweb.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19: * USA
20: *
21: * --------------------------------------------------------------------------
22: * $Id: ArchiveUtilAction.java 7521 2005-10-19 02:14:21Z pasmith $
23: * --------------------------------------------------------------------------
24: */package org.objectweb.jonas.webapp.jonasadmin.xml;
25:
26: import java.io.IOException;
27: import java.util.HashMap;
28: import java.util.Iterator;
29: import java.util.Map;
30: import java.util.TreeMap;
31:
32: import javax.servlet.ServletException;
33: import javax.servlet.http.HttpServletRequest;
34: import javax.servlet.http.HttpServletResponse;
35:
36: import org.apache.struts.action.ActionForm;
37: import org.apache.struts.action.ActionForward;
38: import org.apache.struts.action.ActionMapping;
39: import org.objectweb.jonas.webapp.jonasadmin.deploy.BaseDeployAction;
40: import org.objectweb.jonas.webapp.jonasadmin.xml.xs.ElementRestrictions;
41: import org.objectweb.jonas.webapp.jonasadmin.xml.xs.SchemaRestrictions;
42: import org.objectweb.jonas.webapp.jonasadmin.xml.xs.SchemaRestrictionsFactory;
43:
44: /**
45: * Action to extract the XML parsed into a Document object from the archive
46: * and forward to the form view JSP configuration page.
47: *
48: * @author Patrick Smith
49: * @author Gregory Lapouchnian
50: */
51: public class ArchiveUtilAction extends BaseDeployAction {
52:
53: /**
54: * Executes the struts action.
55: * @param p_Mapping the struts action mapping.
56: * @param p_Form the struts action form.
57: * @param p_Request the HttpServletRequest.
58: * @param p_Response the HttpServletResponse.
59: * @throws IOException
60: * @throws ServletException
61: * @return the action forward to forward to.
62: */
63: public ActionForward executeAction(ActionMapping p_Mapping,
64: ActionForm p_Form, HttpServletRequest p_Request,
65: HttpServletResponse p_Response) throws IOException,
66: ServletException {
67:
68: String sForward = "Archive Config AJAX";
69: ArchiveConfigForm oForm = (ArchiveConfigForm) p_Form;
70: oForm.setChildren(new HashMap());
71:
72: String name = p_Request.getParameter("elementName");
73:
74: if (name != null && name.length() > 0) {
75:
76: SchemaRestrictionsFactory factory = new SchemaRestrictionsFactory();
77: SchemaRestrictions restrictions = factory
78: .getSchemaRestrictions(SchemaRestrictions.RAR_TYPE);
79: ElementRestrictions er = restrictions
80: .getElementRestrictions(name);
81:
82: // set the list of allowed children
83: Map children = new TreeMap();
84: Iterator i = er.getChildren().iterator();
85: while (i.hasNext()) {
86: children.put(i.next(), "0");
87: }
88:
89: oForm.setChildren(children);
90:
91: p_Response.setHeader("Cache-Control", "no-cache");
92: }
93:
94: // Forward to the jsp.
95: return (p_Mapping.findForward(sForward));
96: }
97: }
|