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: ArchiveConfigAdvancedAction.java 9680 2006-10-06 12:08:33Z danesa $
023: * --------------------------------------------------------------------------
024: */package org.objectweb.jonas.webapp.jonasadmin.xml;
025:
026: import java.io.IOException;
027: import java.util.HashMap;
028: import java.util.TreeMap;
029:
030: import javax.management.ObjectName;
031: import javax.servlet.ServletException;
032: import javax.servlet.http.HttpServletRequest;
033: import javax.servlet.http.HttpServletResponse;
034:
035: import org.apache.struts.action.ActionForm;
036: import org.apache.struts.action.ActionForward;
037: import org.apache.struts.action.ActionMapping;
038: import org.apache.struts.action.ActionMessage;
039: import org.objectweb.jonas.jmx.JonasManagementRepr;
040: import org.objectweb.jonas.webapp.jonasadmin.JonasAdminJmx;
041: import org.objectweb.jonas.webapp.jonasadmin.deploy.BaseDeployAction;
042:
043: /**
044: * Action to load the raw XML for a given archive and deployment descriptor and
045: * forward to the advanced view JSP.
046: *
047: * @author Patrick Smith
048: * @author Gregory Lapouchnian
049: */
050: public class ArchiveConfigAdvancedAction extends BaseDeployAction {
051:
052: /**
053: * Executes the struts action.
054: * @param p_Mapping the struts action mapping.
055: * @param p_Form the struts action form.
056: * @param p_Request the HttpServletRequest.
057: * @param p_Response the HttpServletResponse.
058: * @throws IOException
059: * @throws ServletException
060: * @return the action forward to forward to.
061: */
062: public ActionForward executeAction(ActionMapping p_Mapping,
063: ActionForm p_Form, HttpServletRequest p_Request,
064: HttpServletResponse p_Response) throws IOException,
065: ServletException {
066:
067: String sForward = "Archive Config Advanced";
068:
069: ArchiveConfigForm oForm = (ArchiveConfigForm) p_Form;
070:
071: String serverName = m_WhereAreYou.getCurrentJonasServerName();
072:
073: // find out which XML file within the archive is being requested
074: if (p_Request.getParameter("file") != null
075: && p_Request.getParameter("file").length() > 0) {
076: oForm.setPathName(p_Request.getParameter("file"));
077: }
078:
079: // retrieve the XML document
080: ObjectName on = JonasAdminJmx
081: .getRarConfigObjectName(serverName);
082: Object[] params = new Object[] { oForm.getArchiveName(),
083: oForm.getPathName() };
084: String[] sig = new String[] { "java.lang.String",
085: "java.lang.String" };
086:
087: String xml;
088: try {
089: xml = (String) JonasManagementRepr.invoke(on, "extractXML",
090: params, sig, serverName);
091: oForm.setXml(xml);
092: } catch (Exception e) {
093: m_Errors.add("error.archiveconfig.load.fail",
094: new ActionMessage("error.archiveconfig.load.fail",
095: oForm.getPathName()));
096: saveErrors(p_Request, m_Errors);
097:
098: // forward back to the selection JSP
099: return (p_Mapping.findForward("Archive Config Select"));
100: }
101:
102: // reset the values, not to reuse anything from the previous document
103: oForm.setValuesMap(new TreeMap());
104: oForm.setMapping(new HashMap());
105:
106: // specify the two types of xml files that can be configured, these are
107: // used as parameters to <html:link> when switching from file to file
108: oForm.setValues("raXmlFileName", "META-INF/ra.xml");
109: oForm.setValues("jonasRaXmlFileName", "META-INF/jonas-ra.xml");
110:
111: // save the contents of the document to the form
112: oForm.setValues("fileName", oForm.getPathName());
113: oForm.setValues("pathName", oForm.getArchiveName());
114: oForm.setXml(xml);
115: oForm.setIsDomain(isDomain());
116:
117: // Forward to the jsp.
118: return (p_Mapping.findForward(sForward));
119: }
120: }
|