public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
CoreUtil.clearFlow(request);
ShutdownForm shutdownForm = (ShutdownForm) form;
PolicyDatabase policyDatabase = PolicyDatabaseFactory.getInstance();
if (shutdownForm.getAlreadyPerforming()) {
shutdownForm.setShutdownType(ShutdownForm.SHUTTING_DOWN);
} else if (policyDatabase.isPermitted(resourceType, new Permission[] { PolicyConstants.PERM_SHUTDOWN,
PolicyConstants.PERM_RESTART }, getSessionInfo(request).getUser(), true) && ContextHolder.getContext().isRestartAvailableMode()) {
// Both
shutdownForm.setShutdownType(ShutdownForm.BOTH);
shutdownForm.setShutdownOperation(ShutdownForm.RESTART);
} else if (policyDatabase.isPermitted(resourceType,
new Permission[] { PolicyConstants.PERM_SHUTDOWN },
getSessionInfo(request).getUser(),
true)) {
// Shutdown
shutdownForm.setShutdownType(ShutdownForm.SHUTDOWN);
shutdownForm.setShutdownOperation(ShutdownForm.SHUTDOWN);
} else if (policyDatabase.isPermitted(resourceType,
new Permission[] { PolicyConstants.PERM_RESTART },
getSessionInfo(request).getUser(),
true) && ContextHolder.getContext().isRestartAvailableMode()) {
// Restart
shutdownForm.setShutdownOperation(ShutdownForm.RESTART);
shutdownForm.setShutdownType(ShutdownForm.RESTART);
} else {
throw new NoPermissionException("Cannot shutdown or restart.");
}
/*
* Hack to prevent getting in a loop if sending and message then
* cancelling
*/
String referer = CoreUtil.getReferer(request);
if (referer != null && referer.indexOf("/sendMessage.do") == -1) {
shutdownForm.setReferer(referer);
}
int users = LogonControllerFactory.getInstance().getActiveSessions().size();
if (users > 1) {
ActionMessages msgs = new ActionMessages();