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);