KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > webapp > jonasadmin > JonasBaseAction


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999-2004 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * 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: JonasBaseAction.java,v 1.23 2005/07/25 22:51:11 vivekl Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.webapp.jonasadmin;
27
28 import java.io.IOException JavaDoc;
29 import java.util.ArrayList JavaDoc;
30 import java.util.List JavaDoc;
31 import java.util.Properties JavaDoc;
32 import java.util.StringTokenizer JavaDoc;
33
34 import javax.management.ObjectName JavaDoc;
35 import javax.servlet.ServletException JavaDoc;
36 import javax.servlet.http.HttpServletRequest JavaDoc;
37 import javax.servlet.http.HttpServletResponse JavaDoc;
38 import javax.servlet.http.HttpSession JavaDoc;
39
40 import org.apache.struts.Globals;
41 import org.apache.struts.action.Action;
42 import org.apache.struts.action.ActionMessage;
43 import org.apache.struts.action.ActionMessages;
44 import org.apache.struts.action.ActionForm;
45 import org.apache.struts.action.ActionForward;
46 import org.apache.struts.action.ActionMapping;
47 import org.apache.struts.util.MessageResources;
48
49 import org.objectweb.jonas.common.Log;
50 import org.objectweb.jonas.jmx.JonasManagementRepr;
51 import org.objectweb.jonas.webapp.taglib.TreeControl;
52 import org.objectweb.jonas.webapp.taglib.TreeControlNode;
53 import org.objectweb.util.monolog.api.BasicLevel;
54 import org.objectweb.util.monolog.api.Logger;
55
56 /**
57  * @author Michel-Ange ANTON
58  * @author Florent Benoit (changes for struts 1.2.2)
59  */

60
61 public abstract class JonasBaseAction extends Action {
62
63 // ----------------------------------------------------- Constants
64

65     public static final int DEPTH_DOMAIN = 1;
66     public static final int DEPTH_SERVER = 2;
67
68 // --------------------------------------------------------- Instance Variables
69

70     /**
71      * The MessageResources we will be retrieving messages from.
72      */

73     protected MessageResources m_Resources = null;
74     protected HttpSession JavaDoc m_Session = null;
75     protected ActionMessages m_Errors = null;
76     protected WhereAreYou m_WhereAreYou = null;
77
78 // --------------------------------------------------------- Public Methods
79

80     public abstract ActionForward executeAction(ActionMapping p_Mapping, ActionForm p_Form
81         , HttpServletRequest JavaDoc p_Request, HttpServletResponse JavaDoc p_Response)
82         throws IOException JavaDoc, ServletException JavaDoc;
83
84     /**
85      * Process the specified HTTP request, and create the corresponding HTTP
86      * response (or forward to another web component that will create it).
87      * Return an <code>ActionForward</code> instance describing where and how
88      * control should be forwarded, or <code>null</code> if the response has
89      * already been completed.
90      *
91      * @param p_Mapping The ActionMapping used to select this instance
92      * @param p_Form The optional ActionForm bean for this request (if any)
93      * @param p_Request The HTTP request we are processing
94      * @param p_Response The HTTP response we are creating
95      *
96      * @return The forward where redirect
97      *
98      * @exception IOException if an input/output error occurs
99      * @exception ServletException if a servlet exception occurs
100      */

101     public ActionForward execute(ActionMapping p_Mapping, ActionForm p_Form
102         , HttpServletRequest JavaDoc p_Request, HttpServletResponse JavaDoc p_Response)
103         throws IOException JavaDoc, ServletException JavaDoc {
104
105         ActionForward oActionForward = null;
106
107         // Instance variables
108
initialize(p_Request);
109
110         // Verify that a instance of WhereAreYou object exists
111
if (m_WhereAreYou == null) {
112             oActionForward = (p_Mapping.findForward("Main Index"));
113         } else {
114             oActionForward = executeAction(p_Mapping, p_Form, p_Request, p_Response);
115         }
116         return oActionForward;
117     }
118
119     /**
120      * Initialize the instance variables.
121      * @param p_Request The HTTP request we are processing
122      */

123     protected void initialize(HttpServletRequest JavaDoc p_Request) {
124         // Acquire the resources that we need
125
m_Session = p_Request.getSession();
126         if (m_Resources == null) {
127             m_Resources = (MessageResources) getServlet().getServletContext().getAttribute(Globals.MESSAGES_KEY);
128         }
129         m_Errors = new ActionMessages();
130         m_WhereAreYou = (WhereAreYou) m_Session.getAttribute(WhereAreYou.SESSION_NAME);
131
132     }
133
134     /**
135      * Return the name of the branch in the tree for the selected node.
136      *
137      * @param p_Width Depth of the branch
138      * @return The branch name
139      */

140     protected String JavaDoc getTreeBranchName(int p_Width) {
141         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
142         try {
143             StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(m_WhereAreYou.getSelectedNameNode()
144                 , WhereAreYou.NODE_SEPARATOR);
145             for (int i = 0; (st.hasMoreTokens() && (i < p_Width)); i++) {
146                 if (i > 0) {
147                     sb.append(WhereAreYou.NODE_SEPARATOR);
148                 }
149                 sb.append(st.nextToken());
150             }
151         } catch (NullPointerException JavaDoc e) {
152             // none action
153
}
154         return sb.toString();
155     }
156
157     /**
158      * Add a global error in <code>m_Errors</code>instance of <code>m_ErrorsActionMessages</code>
159      * and log it.
160      *
161      * @param p_Throwable Error to add
162      */

163     protected void addGlobalError(Throwable JavaDoc p_Throwable) {
164         String JavaDoc sMessResource;
165         String JavaDoc sMessageError = p_Throwable.getMessage();
166         if (sMessageError == null) {
167             sMessResource = m_Resources.getMessage("error.global.log"
168                 , p_Throwable.getClass().getName());
169             //getServlet().log(sMessResource, p_Throwable);
170
Logger logger = Log.getLogger(Log.JONAS_ADMIN_PREFIX);
171             if (logger.isLoggable(BasicLevel.DEBUG)) {
172                 logger.log(BasicLevel.DEBUG, sMessResource);
173             }
174             m_Errors.add("error.global", new ActionMessage("error.global"
175                 , p_Throwable.getClass().getName()));
176         } else {
177             sMessResource = m_Resources.getMessage("error.global.message.log"
178                 , p_Throwable.getClass().getName(), sMessageError);
179             //getServlet().log(sMessResource, p_Throwable);
180
Logger logger = Log.getLogger(Log.JONAS_ADMIN_PREFIX);
181             if (logger.isLoggable(BasicLevel.DEBUG)) {
182                 logger.log(BasicLevel.DEBUG, sMessResource);
183             }
184             m_Errors.add("error.global", new ActionMessage("error.global.message"
185                 , p_Throwable.getClass().getName(), sMessageError));
186         }
187     }
188
189     /**
190      * MBean <code>ObjectName</code> accessor.
191      *
192      * @param p_ObjectName Instance of ObjectName to access to MBean
193      * @param ps_AttrName Attribute name of MBean
194      * @return The value of attribute
195      */

196     protected String JavaDoc getStringAttribute(ObjectName JavaDoc p_ObjectName, String JavaDoc ps_AttrName) {
197         String JavaDoc s = (String JavaDoc) JonasManagementRepr.getAttribute(p_ObjectName, ps_AttrName);
198         return s;
199     }
200
201    /**
202      * MBean <code>ObjectName</code> accessor.
203      *
204      * @param p_ObjectName Instance of ObjectName to access to MBean
205      * @param ps_AttrName Attribute name of MBean
206      * @return The value of attribute
207      */

208     protected String JavaDoc[] getStringArrayAttribute(ObjectName JavaDoc p_ObjectName, String JavaDoc ps_AttrName) {
209         String JavaDoc[] s = (String JavaDoc[]) JonasManagementRepr.getAttribute(p_ObjectName, ps_AttrName);
210         return s;
211     }
212     
213     /**
214      * MBean <code>ObjectName</code> accessor.
215      *
216      * @param p_ObjectName Instance of ObjectName to access to MBean
217      * @param ps_AttrName Attribute name of MBean
218      * @param p_Value Value to write
219      */

220     protected void setStringAttribute(ObjectName JavaDoc p_ObjectName, String JavaDoc ps_AttrName, String JavaDoc p_Value) {
221         JonasManagementRepr.setAttribute(p_ObjectName, ps_AttrName, p_Value);
222     }
223
224     /**
225      * MBean <code>ObjectName</code> accessor.
226      *
227      * @param p_ObjectName Instance of ObjectName to access to MBean
228      * @param ps_AttrName Attribute name of MBean
229      * @return The value of attribute
230      */

231     protected int getIntegerAttribute(ObjectName JavaDoc p_ObjectName, String JavaDoc ps_AttrName) {
232         try {
233             Integer JavaDoc o = (Integer JavaDoc) JonasManagementRepr.getAttribute(p_ObjectName, ps_AttrName);
234             return o.intValue();
235         } catch (Exception JavaDoc e) {
236             // None
237
}
238         return 0;
239     }
240
241     /**
242      * MBean <code>ObjectName</code> accessor.
243      *
244      * @param p_ObjectName Instance of ObjectName to access to MBean
245      * @param ps_AttrName Attribute name of MBean
246      * @return The value of attribute
247      */

248     protected String JavaDoc toStringIntegerAttribute(ObjectName JavaDoc p_ObjectName, String JavaDoc ps_AttrName) {
249         try {
250             Integer JavaDoc o = (Integer JavaDoc) JonasManagementRepr.getAttribute(p_ObjectName, ps_AttrName);
251             return o.toString();
252         } catch (Exception JavaDoc e) {
253             // None
254
}
255         return null;
256     }
257
258     /**
259      * MBean <code>ObjectName</code> accessor.
260      *
261      * @param p_ObjectName Instance of ObjectName to access to MBean
262      * @param ps_AttrName Attribute name of MBean
263      * @param p_Value Value to write
264      */

265     protected void setIntegerAttribute(ObjectName JavaDoc p_ObjectName, String JavaDoc ps_AttrName, int p_Value) {
266         JonasManagementRepr.setAttribute(p_ObjectName, ps_AttrName, new Integer JavaDoc(p_Value));
267     }
268
269     /**
270      * MBean <code>ObjectName</code> accessor.
271      *
272      * @param p_ObjectName Instance of ObjectName to access to MBean
273      * @param ps_AttrName Attribute name of MBean
274      * @param p_Value Value to write
275      */

276     protected void setIntegerAttribute(ObjectName JavaDoc p_ObjectName, String JavaDoc ps_AttrName, String JavaDoc p_Value) {
277         if ((p_Value != null) && (p_Value.length() > 0)) {
278             JonasManagementRepr.setAttribute(p_ObjectName, ps_AttrName, new Integer JavaDoc(p_Value));
279         }
280     }
281
282     /**
283      * MBean <code>ObjectName</code> accessor.
284      *
285      * @param p_ObjectName Instance of ObjectName to access to MBean
286      * @param ps_AttrName Attribute name of MBean
287      * @return The value of attribute
288      */

289     protected long getLongAttribute(ObjectName JavaDoc p_ObjectName, String JavaDoc ps_AttrName) {
290         try {
291             Long JavaDoc o = (Long JavaDoc) JonasManagementRepr.getAttribute(p_ObjectName, ps_AttrName);
292             return o.longValue();
293         } catch (Exception JavaDoc e) {
294             // None
295
}
296         return 0;
297     }
298
299     /**
300      * MBean <code>ObjectName</code> accessor.
301      *
302      * @param p_ObjectName Instance of ObjectName to access to MBean
303      * @param ps_AttrName Attribute name of MBean
304      * @return The value of attribute
305      */

306     protected String JavaDoc toStringLongAttribute(ObjectName JavaDoc p_ObjectName, String JavaDoc ps_AttrName) {
307         try {
308             Long JavaDoc o = (Long JavaDoc) JonasManagementRepr.getAttribute(p_ObjectName, ps_AttrName);
309             return o.toString();
310         } catch (Exception JavaDoc e) {
311             // None
312
}
313         return null;
314     }
315
316     /**
317      * MBean <code>ObjectName</code> accessor.
318      *
319      * @param p_ObjectName Instance of ObjectName to access to MBean
320      * @param ps_AttrName Attribute name of MBean
321      * @param p_Value Value to write
322      */

323     protected void setLongAttribute(ObjectName JavaDoc p_ObjectName, String JavaDoc ps_AttrName, long p_Value) {
324         JonasManagementRepr.setAttribute(p_ObjectName, ps_AttrName, new Long JavaDoc(p_Value));
325     }
326
327     /**
328      * MBean <code>ObjectName</code> accessor.
329      *
330      * @param p_ObjectName Instance of ObjectName to access to MBean
331      * @param ps_AttrName Attribute name of MBean
332      * @return The value of attribute
333      */

334     protected long getShortAttribute(ObjectName JavaDoc p_ObjectName, String JavaDoc ps_AttrName) {
335         try {
336             Short JavaDoc o = (Short JavaDoc) JonasManagementRepr.getAttribute(p_ObjectName, ps_AttrName);
337             return o.longValue();
338         } catch (Exception JavaDoc e) {
339             // None
340
}
341         return 0;
342     }
343
344     /**
345      * MBean <code>ObjectName</code> accessor.
346      *
347      * @param p_ObjectName Instance of ObjectName to access to MBean
348      * @param ps_AttrName Attribute name of MBean
349      * @return The value of attribute
350      */

351     protected String JavaDoc toStringShortAttribute(ObjectName JavaDoc p_ObjectName, String JavaDoc ps_AttrName) {
352         try {
353             Short JavaDoc o = (Short JavaDoc) JonasManagementRepr.getAttribute(p_ObjectName, ps_AttrName);
354             return o.toString();
355         } catch (Exception JavaDoc e) {
356             // None
357
}
358         return null;
359     }
360
361     /**
362      * MBean <code>ObjectName</code> accessor.
363      *
364      * @param p_ObjectName Instance of ObjectName to access to MBean
365      * @param ps_AttrName Attribute name of MBean
366      * @param p_Value Value to write
367      */

368     protected void setShortAttribute(ObjectName JavaDoc p_ObjectName, String JavaDoc ps_AttrName, long p_Value) {
369         JonasManagementRepr.setAttribute(p_ObjectName, ps_AttrName, new Long JavaDoc(p_Value));
370     }
371
372     /**
373      * MBean <code>ObjectName</code> accessor.
374      *
375      * @param p_ObjectName Instance of ObjectName to access to MBean
376      * @param ps_AttrName Attribute name of MBean
377      * @return The value of attribute
378      */

379     protected boolean getBooleanAttribute(ObjectName JavaDoc p_ObjectName, String JavaDoc ps_AttrName) {
380         try {
381             Boolean JavaDoc o = (Boolean JavaDoc) JonasManagementRepr.getAttribute(p_ObjectName, ps_AttrName);
382             return o.booleanValue();
383         } catch (Exception JavaDoc e) {
384             // None
385
}
386         return false;
387     }
388
389     /**
390      * MBean <code>ObjectName</code> accessor.
391      *
392      * @param p_ObjectName Instance of ObjectName to access to MBean
393      * @param ps_AttrName Attribute name of MBean
394      * @return The value of attribute
395      */

396     protected String JavaDoc toStringBooleanAttribute(ObjectName JavaDoc p_ObjectName, String JavaDoc ps_AttrName) {
397         try {
398             Boolean JavaDoc o = (Boolean JavaDoc) JonasManagementRepr.getAttribute(p_ObjectName, ps_AttrName);
399             return o.toString();
400         } catch (Exception JavaDoc e) {
401             // None
402
}
403         return null;
404     }
405
406     /**
407      * MBean <code>ObjectName</code> accessor.
408      *
409      * @param p_ObjectName Instance of ObjectName to access to MBean
410      * @param ps_AttrName Attribute name of MBean
411      * @param p_Value Value to write
412      */

413     protected void setBooleanAttribute(ObjectName JavaDoc p_ObjectName, String JavaDoc ps_AttrName, boolean p_Value) {
414         JonasManagementRepr.setAttribute(p_ObjectName, ps_AttrName, new Boolean JavaDoc(p_Value));
415     }
416
417     /**
418      * MBean <code>ObjectName</code> accessor.
419      *
420      * @param p_ObjectName Instance of ObjectName to access to MBean
421      * @param ps_AttrName Attribute name of MBean
422      * @return The value of attribute
423      */

424     protected List JavaDoc getListAttribute(ObjectName JavaDoc p_ObjectName, String JavaDoc ps_AttrName) {
425         try {
426             return ((List JavaDoc) JonasManagementRepr.getAttribute(p_ObjectName, ps_AttrName));
427         } catch (Exception JavaDoc e) {
428             // None
429
}
430         return new ArrayList JavaDoc();
431     }
432
433     /**
434      * Properties accessor.
435      *
436      * @param p_Props Instance of Properties
437      * @param ps_AttrName Attribute name of Properties
438      * @return The value of attribute
439      */

440     protected String JavaDoc getStringAttribute(Properties JavaDoc p_Props, String JavaDoc ps_AttrName) {
441         return p_Props.getProperty(ps_AttrName);
442     }
443
444     /**
445      * Properties accessor.
446      *
447      * @param p_Props Instance of Properties
448      * @param ps_AttrName Attribute name of Properties
449      * @param p_Default The returned value if the attribute don't exists in the properties
450      * @return The value of attribute
451      */

452     protected String JavaDoc getStringAttribute(Properties JavaDoc p_Props, String JavaDoc ps_AttrName, String JavaDoc p_Default) {
453         return p_Props.getProperty(ps_AttrName, p_Default);
454     }
455
456     /**
457      * Properties accessor.
458      *
459      * @param p_Props Instance of Properties
460      * @param ps_AttrName Attribute name of Properties
461      * @param p_Value Value to write
462      */

463     protected void setStringAttribute(Properties JavaDoc p_Props, String JavaDoc ps_AttrName, String JavaDoc p_Value) {
464         if (p_Value != null) {
465             p_Props.setProperty(ps_AttrName, p_Value);
466         }
467     }
468
469     /**
470      * Properties accessor.
471      *
472      * @param p_Props Instance of Properties
473      * @param ps_AttrName Attribute name of Properties
474      * @param p_Value Value to write
475      * @param p_Default The forced value if the value is null or empty
476      */

477     protected void setStringAttribute(Properties JavaDoc p_Props, String JavaDoc ps_AttrName, String JavaDoc p_Value
478         , String JavaDoc p_Default) {
479         if ((p_Value != null) && (p_Value.length() == 0)) {
480             p_Props.setProperty(ps_AttrName, p_Default);
481         } else {
482             p_Props.setProperty(ps_AttrName, p_Value);
483         }
484     }
485
486     /**
487      * Properties accessor.
488      *
489      * @param p_Props Instance of Properties
490      * @param ps_AttrName Attribute name of Properties
491      * @return The value of attribute (return 0 if attribute don't exists)
492      */

493     protected int getIntegerAttribute(Properties JavaDoc p_Props, String JavaDoc ps_AttrName) {
494         return getIntegerAttribute(p_Props, ps_AttrName, 0);
495     }
496
497     /**
498      * Properties accessor.
499      *
500      * @param p_Props Instance of Properties
501      * @param ps_AttrName Attribute name of Properties
502      * @param p_Default The returned value if the attribute don't exists in the properties
503      * @return The value of attribute
504      */

505     protected int getIntegerAttribute(Properties JavaDoc p_Props, String JavaDoc ps_AttrName, int p_Default) {
506         try {
507             String JavaDoc s = getStringAttribute(p_Props, ps_AttrName);
508             if (s != null) {
509                 return Integer.parseInt(s);
510             }
511         } catch (Exception JavaDoc e) {
512             // None
513
}
514         return p_Default;
515     }
516
517     /**
518      * Properties accessor.
519      *
520      * @param p_Props Instance of Properties
521      * @param ps_AttrName Attribute name of Properties
522      * @param p_Value Value to write
523      */

524     protected void setIntegerAttribute(Properties JavaDoc p_Props, String JavaDoc ps_AttrName, int p_Value) {
525         p_Props.setProperty(ps_AttrName, String.valueOf(p_Value));
526     }
527
528     /**
529      * Properties accessor.
530      *
531      * @param p_Props Instance of Properties
532      * @param ps_AttrName Attribute name of Properties
533      * @return The value of attribute (return 0 if attribute don't exists)
534      */

535     protected long getLongAttribute(Properties JavaDoc p_Props, String JavaDoc ps_AttrName) {
536         return getLongAttribute(p_Props, ps_AttrName, 0L);
537     }
538
539     /**
540      * Properties accessor.
541      *
542      * @param p_Props Instance of Properties
543      * @param ps_AttrName Attribute name of Properties
544      * @param p_Default The returned value if the attribute don't exists in the properties
545      * @return The value of attribute
546      */

547     protected long getLongAttribute(Properties JavaDoc p_Props, String JavaDoc ps_AttrName, long p_Default) {
548         try {
549             String JavaDoc s = getStringAttribute(p_Props, ps_AttrName);
550             if (s != null) {
551                 return Long.parseLong(s);
552             }
553         } catch (Exception JavaDoc e) {
554             // None
555
}
556         return p_Default;
557     }
558
559     /**
560      * Properties accessor.
561      *
562      * @param p_Props Instance of Properties
563      * @param ps_AttrName Attribute name of Properties
564      * @param p_Value Value to write
565      */

566     protected void setLongAttribute(Properties JavaDoc p_Props, String JavaDoc ps_AttrName, long p_Value) {
567         p_Props.setProperty(ps_AttrName, String.valueOf(p_Value));
568     }
569
570     /**
571      * Properties accessor.
572      *
573      * @param p_Props Instance of Properties
574      * @param ps_AttrName Attribute name of Properties
575      * @return The value of attribute (return false if attribute don't exists)
576      */

577     protected boolean getBooleanAttribute(Properties JavaDoc p_Props, String JavaDoc ps_AttrName) {
578         return getBooleanAttribute(p_Props, ps_AttrName, false);
579     }
580
581     /**
582      * Properties accessor.
583      *
584      * @param p_Props Instance of Properties
585      * @param ps_AttrName Attribute name of Properties
586      * @param p_Default The returned value if the attribute don't exists in the properties
587      * @return The value of attribute
588      */

589     protected boolean getBooleanAttribute(Properties JavaDoc p_Props, String JavaDoc ps_AttrName, boolean p_Default) {
590         try {
591             String JavaDoc s = getStringAttribute(p_Props, ps_AttrName);
592             if (s != null) {
593                 return Boolean.getBoolean(s);
594             }
595         } catch (Exception JavaDoc e) {
596             // None
597
}
598         return p_Default;
599     }
600
601     /**
602      * Properties accessor.
603      *
604      * @param p_Props Instance of Properties
605      * @param ps_AttrName Attribute name of Properties
606      * @param p_Value Value to write
607      */

608     protected void setBooleanAttribute(Properties JavaDoc p_Props, String JavaDoc ps_AttrName, boolean p_Value) {
609         p_Props.setProperty(ps_AttrName, String.valueOf(p_Value));
610     }
611
612     protected Properties JavaDoc getPropsFromString(String JavaDoc ps_Props) {
613         // Clean the string
614
String JavaDoc sProps = ps_Props.trim();
615         sProps = removeChar(sProps, '\r');
616         sProps = removeChar(sProps, '\n');
617         Properties JavaDoc sp = new Properties JavaDoc();
618         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(sProps, ",");
619         while (st.hasMoreTokens()) {
620             String JavaDoc token = st.nextToken();
621             int pos = token.indexOf("=");
622             String JavaDoc propName = token.substring(0, pos);
623             String JavaDoc propValue = token.substring(pos + 1);
624             sp.setProperty(propName, propValue);
625         }
626         return sp;
627     }
628
629     /**
630      * Remove a specific character in a String
631      * Do not use replaceAll as it is a JDK 1.4 method
632      * @param string the given string
633      * @param c character to remove in the String
634      * @return a string
635      */

636     protected static String JavaDoc removeChar(String JavaDoc string, char c) {
637         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
638         sb.setLength(string.length());
639         int i = 0;
640         for (int j = 0; j < string.length(); j++) {
641             char cur = string.charAt(j);
642             if (cur != c) {
643                 sb.setCharAt(i++, cur);
644             }
645         }
646         return sb.toString();
647     }
648     /**
649      * Refresh the management tree.
650      *
651      * @throws Exception
652      */

653     protected void refreshServerTree(HttpServletRequest JavaDoc p_Request) throws Exception JavaDoc {
654         // Get current tree
655
TreeControl oControl = m_WhereAreYou.getTreeControl();
656         // ??
657
TreeControlNode domainNode = oControl.findNode("domain");
658         if (domainNode != null) {
659             // Enable auto-refresh mode
660
oControl.enableAutoRefresh();
661             // Remove node
662
domainNode.remove();
663             // Build node and his children
664
JonasTreeBuilder oBuilder = new JonasTreeBuilder();
665             oBuilder.getDomain(oControl.getRoot(), m_Resources, p_Request);
666             // Disable auto-refresh mode
667
oControl.disableAutoRefresh();
668         }
669     }
670
671     /**
672      * Refresh the domain deployment nodes of the tree.
673      * @param p_Request
674      * @throws Exception
675      */

676     protected void refreshDomainDeployTree(HttpServletRequest JavaDoc p_Request) throws Exception JavaDoc {
677         // Get current tree
678
TreeControl oControl = m_WhereAreYou.getTreeControl();
679         TreeControlNode domainNode = oControl.findNode("domain");
680         if (domainNode != null) {
681             // Enable auto-refresh mode
682
oControl.enableAutoRefresh();
683             // Remove node
684
// Build node and his children
685
JonasTreeBuilder oBuilder = new JonasTreeBuilder();
686             oBuilder.getDomainDeploy(oControl.findNode("domain"), m_Resources, p_Request);
687             // Disable auto-refresh mode
688
oControl.disableAutoRefresh();
689         }
690     
691     }
692
693 }
694
Popular Tags