01: /**
02: * Copyright 2004-2005 jManage.org
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: */package org.jmanage.webui.actions.app;
16:
17: import org.jmanage.webui.actions.BaseAction;
18: import org.jmanage.webui.util.WebContext;
19: import org.jmanage.webui.util.Forwards;
20: import org.jmanage.webui.util.Utils;
21: import org.jmanage.core.services.MBeanService;
22: import org.jmanage.core.services.ServiceFactory;
23: import org.jmanage.core.services.ServiceException;
24: import org.jmanage.core.data.AttributeListData;
25: import org.jmanage.core.util.ErrorCodes;
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;
31: import javax.servlet.http.HttpServletResponse;
32:
33: /**
34: *
35: * date: Jun 21, 2004
36: * @author Rakesh Kalra
37: * @author Shashank Bellary
38: */
39: public class UpdateMBeanAttributesAction extends BaseAction {
40:
41: /**
42: * Updates MBean attributes at a stand alone application level or at a
43: * cluster level.
44: *
45: * @param context
46: * @param mapping
47: * @param actionForm
48: * @param request
49: * @param response
50: * @return
51: * @throws Exception
52: */
53: public ActionForward execute(WebContext context,
54: ActionMapping mapping, ActionForm actionForm,
55: HttpServletRequest request, HttpServletResponse response)
56: throws Exception {
57:
58: MBeanService mbeanService = ServiceFactory.getMBeanService();
59: AttributeListData[] attrListData = mbeanService.setAttributes(
60: Utils.getServiceContext(context), request
61: .getParameterMap());
62: StringBuffer erroneousApps = new StringBuffer();
63: for (int i = 0; i < attrListData.length; i++) {
64: if (attrListData[i].isError()) {
65: if (erroneousApps.length() > 0) {
66: erroneousApps.append(", ");
67: }
68: erroneousApps.append(attrListData[i].getAppName());
69: }
70: }
71: if (erroneousApps.length() > 0) {
72: throw new ServiceException(ErrorCodes.ERRONEOUS_APPS,
73: erroneousApps);
74: }
75: return mapping.findForward(Forwards.SUCCESS);
76: }
77: }
|