KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jmanage > webui > actions > config > RemoveMBeanConfigAction


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.config;
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.forms.MBeanConfigForm;
22 import org.jmanage.core.config.ApplicationConfig;
23 import org.jmanage.core.config.ApplicationConfigManager;
24 import org.jmanage.core.util.UserActivityLogger;
25 import org.jmanage.core.services.AccessController;
26 import org.apache.struts.action.ActionForward;
27 import org.apache.struts.action.ActionMapping;
28 import org.apache.struts.action.ActionForm;
29
30 import javax.servlet.http.HttpServletRequest JavaDoc;
31 import javax.servlet.http.HttpServletResponse JavaDoc;
32
33 /**
34  *
35  * date: Jul 21, 2004
36  * @author Rakesh Kalra, Shashank Bellary
37  */

38 public class RemoveMBeanConfigAction extends BaseAction {
39
40     public ActionForward execute(WebContext context,
41                                  ActionMapping mapping,
42                                  ActionForm actionForm,
43                                  HttpServletRequest JavaDoc request,
44                                  HttpServletResponse JavaDoc response)
45             throws Exception JavaDoc {
46         AccessController.checkAccess(context.getServiceContext(),
47                 ACL_EDIT_MBEAN_CONFIG);
48         String JavaDoc logMsg = null;
49         MBeanConfigForm mbeanConfigForm = (MBeanConfigForm)actionForm;
50         ApplicationConfig applicationConfig = context.getApplicationConfig();
51         if(applicationConfig.removeMBean(mbeanConfigForm.getObjectName())
52                 != null){
53             ApplicationConfigManager.updateApplication(applicationConfig);
54             logMsg = "Removed mbean " + mbeanConfigForm.getObjectName() +
55                         " from application "+ applicationConfig.getName();
56         }else{
57             ApplicationConfig clusterConfig =
58                     applicationConfig.getClusterConfig();
59             if(clusterConfig != null){
60                 clusterConfig.removeMBean(mbeanConfigForm.getObjectName());
61                 ApplicationConfigManager.updateApplication(clusterConfig);
62                 logMsg = "Removed mbean " + mbeanConfigForm.getObjectName() +
63                     " from application cluster "+ clusterConfig.getName();
64             }
65         }
66
67         if(logMsg != null){
68             UserActivityLogger.getInstance().logActivity(
69                     context.getUser().getUsername(),
70                     logMsg);
71         }
72         return mapping.findForward(Forwards.SUCCESS);
73     }
74 }
Popular Tags