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: * --------------------------------------------------------------------------
022: * $Id: EditTransactionRecoveryAction.java 9680 2006-10-06 12:08:33Z danesa $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.webapp.jonasadmin.service.jtm;
027:
028: import java.io.IOException;
029: import java.util.ArrayList;
030:
031: import javax.management.ObjectName;
032: import javax.servlet.ServletException;
033: import javax.servlet.http.HttpServletRequest;
034: import javax.servlet.http.HttpServletResponse;
035:
036: import org.apache.struts.action.ActionForm;
037: import org.apache.struts.action.ActionForward;
038: import org.apache.struts.action.ActionMapping;
039: import org.objectweb.jonas.jmx.J2eeObjectName;
040: import org.objectweb.jonas.jmx.JonasManagementRepr;
041: import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction;
042: import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
043:
044: /**
045: * @author Tony Ortiz
046: */
047:
048: public class EditTransactionRecoveryAction extends JonasBaseAction {
049:
050: // --------------------------------------------------------- Public Methods
051:
052: public ActionForward executeAction(ActionMapping pMapping,
053: ActionForm pForm, HttpServletRequest pRequest,
054: HttpServletResponse pResponse) throws IOException,
055: ServletException {
056:
057: // Force the node selected in tree
058: m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_SERVER)
059: + WhereAreYou.NODE_SEPARATOR + "services"
060: + WhereAreYou.NODE_SEPARATOR + "transaction", true);
061:
062: // Form used
063: JtmServiceRecoveryForm oForm = (JtmServiceRecoveryForm) pForm;
064:
065: try {
066: // Get container list
067: String mys;
068: String sDate;
069: String sFullTrans;
070: String sTransaction;
071: String sResource;
072: String sState;
073: String sXidcount;
074: Object txObject;
075: String[] myTxInfo;
076: int txInfoSize;
077: ArrayList al = new ArrayList();
078:
079: // Object name used
080: String currentDomainName = m_WhereAreYou
081: .getCurrentDomainName();
082: String currentJonasServerName = m_WhereAreYou
083: .getCurrentJonasServerName();
084: String jtaResourceName = "JTAResource";
085: ObjectName jtaResourceObjectName = J2eeObjectName
086: .JTAResource(currentDomainName,
087: currentJonasServerName, jtaResourceName);
088:
089: txObject = JonasManagementRepr.invoke(
090: jtaResourceObjectName, "getAllRecoveryTx", null,
091: null, currentJonasServerName);
092:
093: myTxInfo = (String[]) txObject;
094:
095: if (txObject != null) {
096: txInfoSize = myTxInfo.length;
097:
098: for (int i = 0; i < txInfoSize; i++) {
099: mys = myTxInfo[i];
100: int myix1 = mys.indexOf("????");
101: sFullTrans = mys.substring(0, myix1);
102: int myix2 = mys.indexOf("????", myix1 + 4);
103: sTransaction = mys.substring(myix1 + 4, myix2);
104: int myix3 = mys.indexOf("????", myix2 + 4);
105: sDate = mys.substring(myix2 + 4, myix3);
106: sXidcount = mys.substring(myix3 + 4);
107: al.add(new TxRecovery(sFullTrans, sTransaction,
108: sDate, sXidcount));
109: }
110: }
111:
112: // Set list in the request
113: pRequest.setAttribute("listRecoveryEntries", al);
114: } catch (Throwable t) {
115: addGlobalError(t);
116: saveErrors(pRequest, m_Errors);
117: return (pMapping.findForward("Global Error"));
118: }
119:
120: // Forward to the jsp.
121: return (pMapping.findForward("Jtm Recovery"));
122: }
123: }
|