@Override
 public String execute(HttpServletRequest req, HttpServletResponse resp)
     throws ApplicationException {
   LOG.debug("RegisterUserFormCommand starts.");
   String forwardPage = configurationManager.getProperty(PAGE_REGISTER_USER);
   LOG.debug("RegisterUserFormCommand finish.");
   return forwardPage;
 }
/**
 * @author Dmytro Liakhov
 * @since 2016-02-10
 */
public class RegisterUserFormCommand extends Command {

  private static final Logger LOG = Logger.getLogger(RegisterUserFormCommand.class);
  private ConfigurationManager configurationManager = ConfigurationManager.getInstance();

  @Override
  public String execute(HttpServletRequest req, HttpServletResponse resp)
      throws ApplicationException {
    LOG.debug("RegisterUserFormCommand starts.");
    String forwardPage = configurationManager.getProperty(PAGE_REGISTER_USER);
    LOG.debug("RegisterUserFormCommand finish.");
    return forwardPage;
  }
}
/**
 * @author Dmytro Liakhov
 * @since 2016-02-20
 */
public class ControlSystemCommand extends Command {

  private static final Logger LOG = Logger.getLogger(ControlSystemCommand.class);

  private ConfigurationManager configurationManager = ConfigurationManager.getInstance();

  private ResourceManager resourceManager = ResourceManager.getInstance();

  private DaoFactory daoFactory;

  private SessionDao sessionDao;

  @Override
  public String execute(HttpServletRequest req, HttpServletResponse resp)
      throws ApplicationException, IOException {
    LOG.debug("ControlSystemCommand starts work.");
    String forwardPage = configurationManager.getProperty(PAGE_ADMIN_CONTROL_SYSTEM);

    String action = req.getParameter("action");
    if (action == null || action.isEmpty()) {
      return forwardPage;
    }

    daoFactory = DaoFactory.getInstance();

    sessionDao = daoFactory.getSessionDao();

    boolean isSystemWork = sessionDao.isSystemWork();
    LOG.trace("Is system work --> " + isSystemWork);

    if (action.equals("start-work") && !isSystemWork) {
      sessionDao.startWorkSystem();
      LOG.trace("System started work!");
    } else if (action.equals("end-work") && isSystemWork) {
      sessionDao.stopWorkSystem();
      LOG.trace("System stopped work!");
    }

    sessionDao = daoFactory.getSessionDao();
    boolean isSystemActive = sessionDao.isSystemWork();
    req.getSession().setAttribute("isSystemWork", isSystemActive);
    LOG.trace("State system set in session --> " + isSystemActive);

    forwardPage = configurationManager.getProperty(PAGE_LIST_FACULTIES);

    LOG.debug("ControlSystemCommand finish work.");
    return forwardPage;
  }
}