KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jmanage > webui > actions > app > UpdateMBeanAttributesAction


1 /**
2  * Copyright 2004-2005 jManage.org
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.jmanage.webui.actions.app;
17
18 import org.jmanage.webui.actions.BaseAction;
19 import org.jmanage.webui.util.WebContext;
20 import org.jmanage.webui.util.Forwards;
21 import org.jmanage.webui.util.Utils;
22 import org.jmanage.core.services.MBeanService;
23 import org.jmanage.core.services.ServiceFactory;
24 import org.jmanage.core.services.ServiceException;
25 import org.jmanage.core.data.AttributeListData;
26 import org.jmanage.core.util.ErrorCodes;
27 import org.apache.struts.action.ActionForward;
28 import org.apache.struts.action.ActionMapping;
29 import org.apache.struts.action.ActionForm;
30
31 import javax.servlet.http.HttpServletRequest JavaDoc;
32 import javax.servlet.http.HttpServletResponse JavaDoc;
33
34 /**
35  *
36  * date: Jun 21, 2004
37  * @author Rakesh Kalra
38  * @author Shashank Bellary
39  */

40 public class UpdateMBeanAttributesAction extends BaseAction {
41
42
43     /**
44      * Updates MBean attributes at a stand alone application level or at a
45      * cluster level.
46      *
47      * @param context
48      * @param mapping
49      * @param actionForm
50      * @param request
51      * @param response
52      * @return
53      * @throws Exception
54      */

55     public ActionForward execute(WebContext context,
56                                  ActionMapping mapping,
57                                  ActionForm actionForm,
58                                  HttpServletRequest JavaDoc request,
59                                  HttpServletResponse JavaDoc response)
60             throws Exception JavaDoc {
61
62         MBeanService mbeanService = ServiceFactory.getMBeanService();
63         AttributeListData[] attrListData =
64                 mbeanService.setAttributes(Utils.getServiceContext(context),
65                         request.getParameterMap());
66         StringBuffer JavaDoc erroneousApps = new StringBuffer JavaDoc();
67         for(int i=0; i<attrListData.length; i++){
68             if(attrListData[i].isError()){
69                 if(erroneousApps.length() > 0){
70                     erroneousApps.append(", ");
71                 }
72                 erroneousApps.append(attrListData[i].getAppName());
73             }
74         }
75         if(erroneousApps.length() > 0){
76             throw new ServiceException(ErrorCodes.ERRONEOUS_APPS, erroneousApps);
77         }
78         return mapping.findForward(Forwards.SUCCESS);
79     }
80 }
81
Popular Tags