001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999-2004 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: SetupWhereAreYouAction.java 9680 2006-10-06 12:08:33Z danesa $
023: * --------------------------------------------------------------------------
024: */package org.objectweb.jonas.webapp.jonasadmin;
025:
026: import java.io.IOException;
027:
028: import javax.servlet.ServletException;
029: import javax.servlet.http.HttpServletRequest;
030: import javax.servlet.http.HttpServletResponse;
031:
032: import org.apache.struts.action.ActionMessage;
033: import org.apache.struts.action.ActionForm;
034: import org.apache.struts.action.ActionForward;
035: import org.apache.struts.action.ActionMapping;
036: import org.objectweb.jonas.common.JProp;
037: import org.objectweb.jonas.common.Log;
038: import org.objectweb.jonas.jmx.JonasManagementRepr;
039: import org.objectweb.jonas.jmx.ManagementReprLoader;
040: import org.objectweb.util.monolog.api.BasicLevel;
041: import org.objectweb.util.monolog.api.Logger;
042:
043: /**
044: * @author Michel-Ange ANTON (initial developer)
045: * @author Florent Benoit (changes for struts 1.2.2)
046: */
047: public class SetupWhereAreYouAction extends JonasBaseAction {
048:
049: // --------------------------------------------------------- Public Methods
050:
051: public ActionForward executeAction(ActionMapping p_Mapping,
052: ActionForm p_Form, HttpServletRequest p_Request,
053: HttpServletResponse p_Response) throws IOException,
054: ServletException {
055: // nothing to do
056: return null;
057: }
058:
059: public ActionForward execute(ActionMapping p_Mapping,
060: ActionForm p_Form, HttpServletRequest p_Request,
061: HttpServletResponse p_Response) throws IOException,
062: ServletException {
063:
064: // Initialize the instance variables
065: initialize(p_Request);
066:
067: try {
068: if (JonasManagementRepr.noServerRepr()) {
069: String serverName = null;
070: try {
071: // Get the name of the Jonas Server who is running the application
072: JProp oJProp = JProp.getInstance();
073: serverName = oJProp.getValue(JProp.JONAS_NAME);
074: } catch (Exception e) {
075: // Current Jonas not found, can't run jonasAdmin
076: throw new JonasAdminException(
077: WhereAreYou.EXCEPTION_JONASSERVER_NOTFOUND,
078: e.getMessage(), e);
079: }
080: ManagementReprLoader.loadServerRepr(serverName);
081: }
082: if (m_WhereAreYou == null) {
083: m_WhereAreYou = new WhereAreYou();
084: m_WhereAreYou.initialize(getServlet(), p_Request);
085: m_Session.setAttribute(WhereAreYou.SESSION_NAME,
086: m_WhereAreYou);
087: } else {
088: m_WhereAreYou.refreshServers(p_Request);
089: }
090: } catch (JonasAdminException e) {
091:
092: String message = m_Resources.getMessage(e.getId());
093: //getServlet().log(message);
094: Logger logger = Log.getLogger(Log.JONAS_ADMIN_PREFIX);
095: if (logger.isLoggable(BasicLevel.DEBUG)) {
096: logger.log(BasicLevel.DEBUG, message);
097: }
098: m_Errors.add(e.getId(), new ActionMessage(e.getId()));
099: saveErrors(p_Request, m_Errors);
100: return (p_Mapping.findForward("Global Error"));
101: }
102: return (p_Mapping.findForward("Frame Main"));
103: }
104:
105: }
|