001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019:
020: package org.apache.axis2.transport.http;
021:
022: import org.apache.axis2.AxisFault;
023: import org.apache.axis2.Constants;
024: import org.apache.axis2.context.ConfigurationContext;
025: import org.apache.axis2.context.ServiceGroupContext;
026: import org.apache.axis2.context.ServiceContext;
027: import org.apache.axis2.deployment.util.PhasesInfo;
028: import org.apache.axis2.description.AxisModule;
029: import org.apache.axis2.description.AxisOperation;
030: import org.apache.axis2.description.AxisService;
031: import org.apache.axis2.description.Parameter;
032: import org.apache.axis2.engine.AxisConfiguration;
033: import org.apache.commons.fileupload.FileItem;
034: import org.apache.commons.fileupload.FileItemFactory;
035: import org.apache.commons.fileupload.RequestContext;
036: import org.apache.commons.fileupload.disk.DiskFileItemFactory;
037: import org.apache.commons.fileupload.servlet.ServletFileUpload;
038: import org.apache.commons.fileupload.servlet.ServletRequestContext;
039: import org.apache.commons.logging.Log;
040: import org.apache.commons.logging.LogFactory;
041:
042: import javax.servlet.ServletException;
043: import javax.servlet.http.HttpServletRequest;
044: import javax.servlet.http.HttpServletResponse;
045: import javax.xml.namespace.QName;
046: import java.io.File;
047: import java.io.IOException;
048: import java.util.*;
049:
050: /**
051: * Provides methods to process axis2 admin requests.
052: */
053: public class AdminAgent extends AbstractAgent {
054: private static final Log log = LogFactory
055: .getLog(AbstractAgent.class);
056: /**
057: * Field LIST_MULTIPLE_SERVICE_JSP_NAME
058: */
059: private static final String LIST_SERVICE_GROUP_JSP = "ListServiceGroup.jsp";
060: private static final String LIST_SERVICES_JSP_NAME = "listService.jsp";
061: private static final String LIST_SINGLE_SERVICES_JSP_NAME = "listSingleService.jsp";
062: private static final String SELECT_SERVICE_JSP_NAME = "SelectService.jsp";
063: private static final String IN_ACTIVATE_SERVICE_JSP_NAME = "InActivateService.jsp";
064: private static final String ACTIVATE_SERVICE_JSP_NAME = "ActivateService.jsp";
065:
066: /**
067: * Field LIST_SINGLE_SERVICE_JSP_NAME
068: */
069: private static final String LIST_PHASES_JSP_NAME = "viewphases.jsp";
070: private static final String LIST_GLOABLLY_ENGAGED_MODULES_JSP_NAME = "globalModules.jsp";
071: private static final String LIST_AVAILABLE_MODULES_JSP_NAME = "listModules.jsp";
072: private static final String ENGAGING_MODULE_TO_SERVICE_JSP_NAME = "engagingtoaservice.jsp";
073: private static final String ENGAGING_MODULE_TO_SERVICE_GROUP_JSP_NAME = "EngageToServiceGroup.jsp";
074: private static final String ENGAGING_MODULE_GLOBALLY_JSP_NAME = "engagingglobally.jsp";
075: public static final String ADMIN_JSP_NAME = "admin.jsp";
076: private static final String VIEW_GLOBAL_HANDLERS_JSP_NAME = "ViewGlobalHandlers.jsp";
077: private static final String VIEW_SERVICE_HANDLERS_JSP_NAME = "ViewServiceHandlers.jsp";
078: private static final String SERVICE_PARA_EDIT_JSP_NAME = "ServiceParaEdit.jsp";
079: private static final String ENGAGE_TO_OPERATION_JSP_NAME = "engagingtoanoperation.jsp";
080: private static final String LOGIN_JSP_NAME = "Login.jsp";
081:
082: private File serviceDir;
083:
084: public AdminAgent(ConfigurationContext aConfigContext) {
085: super (aConfigContext);
086: try {
087: if (configContext.getAxisConfiguration().getRepository() != null) {
088: File repoDir = new File(configContext
089: .getAxisConfiguration().getRepository()
090: .getFile());
091: serviceDir = new File(repoDir, "services");
092: if (!serviceDir.exists()) {
093: serviceDir.mkdirs();
094: }
095: }
096: } catch (Exception e) {
097: log.info(e.getMessage(), e);
098: } catch (Throwable e) {
099: log.error(e.getMessage(), e);
100: }
101: }
102:
103: public void handle(HttpServletRequest httpServletRequest,
104: HttpServletResponse httpServletResponse)
105: throws IOException, ServletException {
106:
107: // We forward to login page if axis2 security is enabled
108: // and the user is not authorized
109: // TODO Fix workaround for login test
110: if (axisSecurityEnabled()
111: && authorizationRequired(httpServletRequest)) {
112: renderView(LOGIN_JSP_NAME, httpServletRequest,
113: httpServletResponse);
114: } else {
115: super .handle(httpServletRequest, httpServletResponse);
116: }
117: }
118:
119: protected void processIndex(HttpServletRequest req,
120: HttpServletResponse res) throws IOException,
121: ServletException {
122: renderView(ADMIN_JSP_NAME, req, res);
123: }
124:
125: // supported web operations
126:
127: protected void processUpload(HttpServletRequest req,
128: HttpServletResponse res) throws IOException,
129: ServletException {
130: String hasHotDeployment = (String) configContext
131: .getAxisConfiguration().getParameterValue(
132: "hotdeployment");
133: String hasHotUpdate = (String) configContext
134: .getAxisConfiguration().getParameterValue("hotupdate");
135: req.setAttribute("hotDeployment", (hasHotDeployment
136: .equals("true")) ? "enabled" : "disabled");
137: req.setAttribute("hotUpdate",
138: (hasHotUpdate.equals("true")) ? "enabled" : "disabled");
139: RequestContext reqContext = new ServletRequestContext(req);
140:
141: boolean isMultipart = ServletFileUpload
142: .isMultipartContent(reqContext);
143: if (isMultipart) {
144:
145: try {
146: //Create a factory for disk-based file items
147: FileItemFactory factory = new DiskFileItemFactory();
148: //Create a new file upload handler
149: ServletFileUpload upload = new ServletFileUpload(
150: factory);
151: List items = upload.parseRequest(req);
152: // Process the uploaded items
153: Iterator iter = items.iterator();
154: while (iter.hasNext()) {
155: FileItem item = (FileItem) iter.next();
156: if (!item.isFormField()) {
157:
158: String fileName = item.getName();
159: String fileExtesion = fileName;
160: fileExtesion = fileExtesion.toLowerCase();
161: if (!(fileExtesion.endsWith(".jar") || fileExtesion
162: .endsWith(".aar"))) {
163: req.setAttribute("status", "failure");
164: req.setAttribute("cause",
165: "Unsupported file type "
166: + fileExtesion);
167: } else {
168:
169: String fileNameOnly;
170: if (fileName.indexOf("\\") < 0) {
171: fileNameOnly = fileName.substring(
172: fileName.lastIndexOf("/") + 1,
173: fileName.length());
174: } else {
175: fileNameOnly = fileName.substring(
176: fileName.lastIndexOf("\\") + 1,
177: fileName.length());
178: }
179:
180: File uploadedFile = new File(serviceDir,
181: fileNameOnly);
182: item.write(uploadedFile);
183: req.setAttribute("status", "success");
184: req.setAttribute("filename", fileNameOnly);
185: }
186: }
187: }
188: } catch (Exception e) {
189: req.setAttribute("status", "failure");
190: req.setAttribute("cause", e.getMessage());
191:
192: }
193: }
194: renderView("upload.jsp", req, res);
195: }
196:
197: protected void processLogin(HttpServletRequest req,
198: HttpServletResponse res) throws IOException,
199: ServletException {
200: String username = req.getParameter("userName");
201: String password = req.getParameter("password");
202:
203: if ((username == null) || (password == null)
204: || username.trim().length() == 0
205: || password.trim().length() == 0) {
206: req.setAttribute("errorMessage",
207: "Invalid auth credentials!");
208: renderView(LOGIN_JSP_NAME, req, res);
209: return;
210: }
211:
212: String adminUserName = (String) configContext
213: .getAxisConfiguration().getParameter(
214: Constants.USER_NAME).getValue();
215: String adminPassword = (String) configContext
216: .getAxisConfiguration()
217: .getParameter(Constants.PASSWORD).getValue();
218:
219: if (username.equals(adminUserName)
220: && password.equals(adminPassword)) {
221: req.getSession().setAttribute(Constants.LOGGED, "Yes");
222: renderView(ADMIN_JSP_NAME, req, res);
223: } else {
224: req.setAttribute("errorMessage",
225: "Invalid auth credentials!");
226: renderView(LOGIN_JSP_NAME, req, res);
227: }
228: }
229:
230: protected void processEditServicePara(HttpServletRequest req,
231: HttpServletResponse res) throws IOException,
232: ServletException {
233: String serviceName = req.getParameter("axisService");
234: if (req.getParameter("changePara") != null) {
235: AxisService service = configContext.getAxisConfiguration()
236: .getService(serviceName);
237: if (service != null) {
238: ArrayList service_para = service.getParameters();
239:
240: for (int i = 0; i < service_para.size(); i++) {
241: Parameter parameter = (Parameter) service_para
242: .get(i);
243: String para = req.getParameter(serviceName + "_"
244: + parameter.getName());
245: service.addParameter(new Parameter(parameter
246: .getName(), para));
247: }
248:
249: for (Iterator iterator = service.getOperations(); iterator
250: .hasNext();) {
251: AxisOperation axisOperation = (AxisOperation) iterator
252: .next();
253: String op_name = axisOperation.getName()
254: .getLocalPart();
255: ArrayList operation_para = axisOperation
256: .getParameters();
257:
258: for (int i = 0; i < operation_para.size(); i++) {
259: Parameter parameter = (Parameter) operation_para
260: .get(i);
261: String para = req.getParameter(op_name + "_"
262: + parameter.getName());
263:
264: axisOperation.addParameter(new Parameter(
265: parameter.getName(), para));
266: }
267: }
268: }
269: res.setContentType("text/html");
270: req.setAttribute("status",
271: "Parameters Changed Successfully.");
272: req.getSession().removeAttribute(Constants.SERVICE);
273: } else {
274: AxisService serviceTemp = configContext
275: .getAxisConfiguration().getServiceForActivation(
276: serviceName);
277: if (serviceTemp.isActive()) {
278:
279: if (serviceName != null) {
280: req.getSession().setAttribute(
281: Constants.SERVICE,
282: configContext.getAxisConfiguration()
283: .getService(serviceName));
284: }
285: } else {
286: req
287: .setAttribute(
288: "status",
289: "Service "
290: + serviceName
291: + " is not an active service"
292: + ". \n Only parameters of active services can be edited.");
293: }
294: }
295: renderView(SERVICE_PARA_EDIT_JSP_NAME, req, res);
296: }
297:
298: protected void processEngagingGlobally(HttpServletRequest req,
299: HttpServletResponse res) throws IOException,
300: ServletException {
301: HashMap modules = configContext.getAxisConfiguration()
302: .getModules();
303:
304: req.getSession().setAttribute(Constants.MODULE_MAP, modules);
305:
306: String moduleName = req.getParameter("modules");
307:
308: req.getSession().setAttribute(Constants.ENGAGE_STATUS, null);
309:
310: if (moduleName != null) {
311: try {
312: configContext.getAxisConfiguration().engageModule(
313: moduleName);
314: req
315: .getSession()
316: .setAttribute(
317: Constants.ENGAGE_STATUS,
318: moduleName
319: + " module engaged globally successfully");
320: } catch (AxisFault axisFault) {
321: req.getSession().setAttribute(Constants.ENGAGE_STATUS,
322: axisFault.getMessage());
323: }
324: }
325:
326: req.getSession().setAttribute("modules", null);
327: renderView(ENGAGING_MODULE_GLOBALLY_JSP_NAME, req, res);
328:
329: }
330:
331: protected void processListOperations(HttpServletRequest req,
332: HttpServletResponse res) throws IOException,
333: ServletException {
334: HashMap modules = configContext.getAxisConfiguration()
335: .getModules();
336:
337: req.getSession().setAttribute(Constants.MODULE_MAP, modules);
338:
339: String moduleName = req.getParameter("modules");
340:
341: req.getSession().setAttribute(Constants.ENGAGE_STATUS, null);
342: req.getSession().setAttribute("modules", null);
343:
344: String serviceName = req.getParameter("axisService");
345:
346: if (serviceName != null) {
347: req.getSession().setAttribute("service", serviceName);
348: } else {
349: serviceName = (String) req.getSession().getAttribute(
350: "service");
351: }
352:
353: req.getSession().setAttribute(
354: Constants.OPERATION_MAP,
355: configContext.getAxisConfiguration().getService(
356: serviceName).getOperations());
357: req.getSession().setAttribute(Constants.ENGAGE_STATUS, null);
358:
359: String operationName = req.getParameter("axisOperation");
360:
361: if ((serviceName != null) && (moduleName != null)
362: && (operationName != null)) {
363: try {
364: AxisOperation od = configContext.getAxisConfiguration()
365: .getService(serviceName).getOperation(
366: new QName(operationName));
367:
368: od.engageModule(configContext.getAxisConfiguration()
369: .getModule(moduleName));
370: req
371: .getSession()
372: .setAttribute(
373: Constants.ENGAGE_STATUS,
374: moduleName
375: + " module engaged to the operation successfully");
376: } catch (AxisFault axisFault) {
377: req.getSession().setAttribute(Constants.ENGAGE_STATUS,
378: axisFault.getMessage());
379: }
380: }
381:
382: req.getSession().setAttribute("operation", null);
383: renderView(ENGAGE_TO_OPERATION_JSP_NAME, req, res);
384: }
385:
386: protected void processEngageToService(HttpServletRequest req,
387: HttpServletResponse res) throws IOException,
388: ServletException {
389: HashMap modules = configContext.getAxisConfiguration()
390: .getModules();
391:
392: req.getSession().setAttribute(Constants.MODULE_MAP, modules);
393: populateSessionInformation(req);
394:
395: String moduleName = req.getParameter("modules");
396:
397: req.getSession().setAttribute(Constants.ENGAGE_STATUS, null);
398: req.getSession().setAttribute("modules", null);
399:
400: String serviceName = req.getParameter("axisService");
401:
402: req.getSession().setAttribute(Constants.ENGAGE_STATUS, null);
403:
404: if ((serviceName != null) && (moduleName != null)) {
405: try {
406: configContext.getAxisConfiguration().getService(
407: serviceName).engageModule(
408: configContext.getAxisConfiguration().getModule(
409: moduleName));
410: req
411: .getSession()
412: .setAttribute(
413: Constants.ENGAGE_STATUS,
414: moduleName
415: + " module engaged to the service successfully");
416: } catch (AxisFault axisFault) {
417: req.getSession().setAttribute(Constants.ENGAGE_STATUS,
418: axisFault.getMessage());
419: }
420: }
421:
422: req.getSession().setAttribute("axisService", null);
423: renderView(ENGAGING_MODULE_TO_SERVICE_JSP_NAME, req, res);
424: }
425:
426: protected void processEngageToServiceGroup(HttpServletRequest req,
427: HttpServletResponse res) throws IOException,
428: ServletException {
429: HashMap modules = configContext.getAxisConfiguration()
430: .getModules();
431:
432: req.getSession().setAttribute(Constants.MODULE_MAP, modules);
433:
434: Iterator services = configContext.getAxisConfiguration()
435: .getServiceGroups();
436:
437: req.getSession().setAttribute(Constants.SERVICE_GROUP_MAP,
438: services);
439:
440: String moduleName = req.getParameter("modules");
441:
442: req.getSession().setAttribute(Constants.ENGAGE_STATUS, null);
443: req.getSession().setAttribute("modules", null);
444:
445: String serviceName = req.getParameter("axisService");
446:
447: req.getSession().setAttribute(Constants.ENGAGE_STATUS, null);
448:
449: if ((serviceName != null) && (moduleName != null)) {
450: configContext.getAxisConfiguration().getServiceGroup(
451: serviceName).engageModule(
452: configContext.getAxisConfiguration().getModule(
453: moduleName));
454: req
455: .getSession()
456: .setAttribute(
457: Constants.ENGAGE_STATUS,
458: moduleName
459: + " module engaged to the service group successfully");
460: }
461:
462: req.getSession().setAttribute("axisService", null);
463: renderView(ENGAGING_MODULE_TO_SERVICE_GROUP_JSP_NAME, req, res);
464: }
465:
466: protected void processLogout(HttpServletRequest req,
467: HttpServletResponse res) throws IOException,
468: ServletException {
469: req.getSession().invalidate();
470: renderView("index.jsp", req, res);
471: }
472:
473: protected void processviewServiceGroupConetxt(
474: HttpServletRequest req, HttpServletResponse res)
475: throws IOException, ServletException {
476: String type = req.getParameter("TYPE");
477: String sgID = req.getParameter("ID");
478: ServiceGroupContext sgContext = configContext
479: .getServiceGroupContext(sgID);
480: req.getSession().setAttribute("ServiceGroupContext", sgContext);
481: req.getSession().setAttribute("TYPE", type);
482: req.getSession().setAttribute("ConfigurationContext",
483: configContext);
484: renderView("viewServiceGroupContext.jsp", req, res);
485: }
486:
487: protected void processviewServiceContext(HttpServletRequest req,
488: HttpServletResponse res) throws IOException,
489: ServletException {
490: String type = req.getParameter("TYPE");
491: String sgID = req.getParameter("PID");
492: String ID = req.getParameter("ID");
493: ServiceGroupContext sgContext = configContext
494: .getServiceGroupContext(sgID);
495: if (sgContext != null) {
496: AxisService service = sgContext.getDescription()
497: .getService(ID);
498: ServiceContext serviceContext = sgContext
499: .getServiceContext(service);
500: req.setAttribute("ServiceContext", serviceContext);
501: req.setAttribute("TYPE", type);
502: } else {
503: req.setAttribute("ServiceContext", null);
504: req.setAttribute("TYPE", type);
505: }
506: renderView("viewServiceContext.jsp", req, res);
507: }
508:
509: protected void processSelectServiceParaEdit(HttpServletRequest req,
510: HttpServletResponse res) throws IOException,
511: ServletException {
512: populateSessionInformation(req);
513: req.getSession().setAttribute(Constants.SELECT_SERVICE_TYPE,
514: "SERVICE_PARAMETER");
515: renderView(SELECT_SERVICE_JSP_NAME, req, res);
516: }
517:
518: protected void processListOperation(HttpServletRequest req,
519: HttpServletResponse res) throws IOException,
520: ServletException {
521: populateSessionInformation(req);
522: req.getSession().setAttribute(Constants.SELECT_SERVICE_TYPE,
523: "MODULE");
524:
525: renderView(SELECT_SERVICE_JSP_NAME, req, res);
526: }
527:
528: protected void processActivateService(HttpServletRequest req,
529: HttpServletResponse res) throws IOException,
530: ServletException {
531: if (req.getParameter("submit") != null) {
532: String serviceName = req.getParameter("axisService");
533: String turnon = req.getParameter("turnon");
534: if (serviceName != null) {
535: if (turnon != null) {
536: configContext.getAxisConfiguration().startService(
537: serviceName);
538: }
539: }
540: }
541: populateSessionInformation(req);
542: renderView(ACTIVATE_SERVICE_JSP_NAME, req, res);
543: }
544:
545: protected void processDeactivateService(HttpServletRequest req,
546: HttpServletResponse res) throws IOException,
547: ServletException {
548: if (req.getParameter("submit") != null) {
549: String serviceName = req.getParameter("axisService");
550: String turnoff = req.getParameter("turnoff");
551: if (serviceName != null) {
552: if (turnoff != null) {
553: configContext.getAxisConfiguration().stopService(
554: serviceName);
555: }
556: populateSessionInformation(req);
557: }
558: } else {
559: populateSessionInformation(req);
560: }
561:
562: renderView(IN_ACTIVATE_SERVICE_JSP_NAME, req, res);
563: }
564:
565: protected void processViewGlobalHandlers(HttpServletRequest req,
566: HttpServletResponse res) throws IOException,
567: ServletException {
568: req.getSession().setAttribute(Constants.GLOBAL_HANDLERS,
569: configContext.getAxisConfiguration());
570:
571: renderView(VIEW_GLOBAL_HANDLERS_JSP_NAME, req, res);
572: }
573:
574: protected void processViewServiceHandlers(HttpServletRequest req,
575: HttpServletResponse res) throws IOException,
576: ServletException {
577: String service = req.getParameter("axisService");
578:
579: if (service != null) {
580: req.getSession().setAttribute(
581: Constants.SERVICE_HANDLERS,
582: configContext.getAxisConfiguration().getService(
583: service));
584: }
585:
586: renderView(VIEW_SERVICE_HANDLERS_JSP_NAME, req, res);
587: }
588:
589: protected void processListPhases(HttpServletRequest req,
590: HttpServletResponse res) throws IOException,
591: ServletException {
592: PhasesInfo info = configContext.getAxisConfiguration()
593: .getPhasesInfo();
594: req.getSession().setAttribute(Constants.PHASE_LIST, info);
595: renderView(LIST_PHASES_JSP_NAME, req, res);
596: }
597:
598: protected void processListServiceGroups(HttpServletRequest req,
599: HttpServletResponse res) throws IOException,
600: ServletException {
601: Iterator serviceGroups = configContext.getAxisConfiguration()
602: .getServiceGroups();
603: populateSessionInformation(req);
604: req.getSession().setAttribute(Constants.SERVICE_GROUP_MAP,
605: serviceGroups);
606:
607: renderView(LIST_SERVICE_GROUP_JSP, req, res);
608: }
609:
610: protected void processListService(HttpServletRequest req,
611: HttpServletResponse res) throws IOException,
612: ServletException {
613: populateSessionInformation(req);
614: req.getSession().setAttribute(
615: Constants.ERROR_SERVICE_MAP,
616: configContext.getAxisConfiguration()
617: .getFaultyServices());
618:
619: renderView(LIST_SERVICES_JSP_NAME, req, res);
620: }
621:
622: protected void processListSingleService(HttpServletRequest req,
623: HttpServletResponse res) throws IOException,
624: ServletException {
625: req.getSession().setAttribute(Constants.IS_FAULTY, ""); //Clearing out any old values.
626: String serviceName = req.getParameter("serviceName");
627: if (serviceName != null) {
628: AxisService service = configContext.getAxisConfiguration()
629: .getService(serviceName);
630: req.getSession().setAttribute(Constants.SINGLE_SERVICE,
631: service);
632: }
633: renderView(LIST_SINGLE_SERVICES_JSP_NAME, req, res);
634: }
635:
636: protected void processListContexts(HttpServletRequest req,
637: HttpServletResponse res) throws IOException,
638: ServletException {
639: req.getSession().setAttribute(Constants.CONFIG_CONTEXT,
640: configContext);
641: renderView("ViewContexts.jsp", req, res);
642: }
643:
644: protected void processglobalModules(HttpServletRequest req,
645: HttpServletResponse res) throws IOException,
646: ServletException {
647: Collection modules = configContext.getAxisConfiguration()
648: .getEngagedModules();
649:
650: req.getSession().setAttribute(Constants.MODULE_MAP, modules);
651:
652: renderView(LIST_GLOABLLY_ENGAGED_MODULES_JSP_NAME, req, res);
653: }
654:
655: protected void processListModules(HttpServletRequest req,
656: HttpServletResponse res) throws IOException,
657: ServletException {
658: HashMap modules = configContext.getAxisConfiguration()
659: .getModules();
660:
661: req.getSession().setAttribute(Constants.MODULE_MAP, modules);
662: req.getSession()
663: .setAttribute(
664: Constants.ERROR_MODULE_MAP,
665: configContext.getAxisConfiguration()
666: .getFaultyModules());
667:
668: renderView(LIST_AVAILABLE_MODULES_JSP_NAME, req, res);
669: }
670:
671: protected void processdisengageModule(HttpServletRequest req,
672: HttpServletResponse res) throws IOException,
673: ServletException {
674: String type = req.getParameter("type");
675: String serviceName = req.getParameter("serviceName");
676: String moduleName = req.getParameter("module");
677: AxisConfiguration axisConfiguration = configContext
678: .getAxisConfiguration();
679: AxisService service = axisConfiguration.getService(serviceName);
680: AxisModule module = axisConfiguration.getModule(moduleName);
681: if (type.equals("operation")) {
682: if (service.isEngaged(module.getName())
683: || axisConfiguration.isEngaged(module.getName())) {
684: req
685: .getSession()
686: .setAttribute(
687: "status",
688: "Can not disengage module "
689: + moduleName
690: + ". This module is engaged at a higher level.");
691: } else {
692: String opName = req.getParameter("operation");
693: AxisOperation op = service.getOperation(new QName(
694: opName));
695: op.disengageModule(module);
696: req.getSession().setAttribute(
697: "status",
698: "Module " + moduleName
699: + " was disengaged from "
700: + "operation " + opName
701: + " in service " + serviceName + ".");
702: }
703: } else {
704: if (axisConfiguration.isEngaged(module.getName())) {
705: req
706: .getSession()
707: .setAttribute(
708: "status",
709: "Can not disengage module "
710: + moduleName
711: + ". "
712: + "This module is engaged at a higher level.");
713: } else {
714: service.disengageModule(axisConfiguration
715: .getModule(moduleName));
716: req.getSession().setAttribute(
717: "status",
718: "Module " + moduleName + " was disengaged from"
719: + " service " + serviceName + ".");
720: }
721: }
722: renderView("disengage.jsp", req, res);
723: }
724:
725: protected void processSelectService(HttpServletRequest req,
726: HttpServletResponse res) throws IOException,
727: ServletException {
728: populateSessionInformation(req);
729: req.getSession().setAttribute(Constants.SELECT_SERVICE_TYPE,
730: "VIEW");
731:
732: renderView(SELECT_SERVICE_JSP_NAME, req, res);
733: }
734:
735: private boolean authorizationRequired(
736: HttpServletRequest httpServletRequest) {
737: return httpServletRequest.getSession().getAttribute(
738: Constants.LOGGED) == null
739: && !httpServletRequest.getRequestURI()
740: .endsWith("login");
741: }
742:
743: private boolean axisSecurityEnabled() {
744: Parameter parameter = configContext.getAxisConfiguration()
745: .getParameter(Constants.ADMIN_SECURITY_DISABLED);
746: return parameter == null
747: || !"true".equals(parameter.getValue());
748: }
749:
750: }
|