Example #1
0
 @RequestMapping(
     value = "/jobs/{jobId}/finalList",
     method = {RequestMethod.GET})
 public String visitFinalListPage(
     @PathVariable String jobId, HttpServletRequest request, ModelMap model) {
   User user = (User) request.getSession().getAttribute("user");
   if (user == null || !user.getRole().equals("manager")) {
     model.addAttribute("errorMsg", "User has no permission");
     return "login";
   }
   try {
     Job j = JobsDao.instance.getById(jobId);
     if (!j.getStatus().equals(RecruitmentStatus.SENT_INVITATIONS)) {
       return "redirect:/jobs";
     }
     List<Application> validApplications = new ArrayList<Application>();
     List<Application> applications =
         ApplicationsDao.instance.getByJob(ORSKEY, user.getShortKey(), jobId);
     for (Application a : applications) {
       if (a.getStatus().equals(ApplicationStatus.ACCEPTED_INVITATION)) {
         validApplications.add(a);
       }
     }
     model.addAttribute("applications", validApplications);
     model.addAttribute("job", j);
     return "finalList";
   } catch (Exception e) {
     e.printStackTrace();
     model.addAttribute("errorMsg", e.getMessage());
     return "error";
   }
 }
Example #2
0
 @RequestMapping(
     value = "/jobs/{jobId}/finalList",
     method = {RequestMethod.POST})
 public String submitfinalList(
     @PathVariable String jobId, HttpServletRequest request, ModelMap model) {
   User user = (User) request.getSession().getAttribute("user");
   if (user == null || !user.getRole().equals("manager")) {
     model.addAttribute("errorMsg", "User has no permission");
     return "login";
   }
   try {
     Job j = JobsDao.instance.getById(jobId);
     if (!j.getStatus().equals(RecruitmentStatus.SENT_INVITATIONS)) {
       return "redirect:/jobs";
     }
     List<Application> applications =
         ApplicationsDao.instance.getByJob(ORSKEY, user.getShortKey(), jobId);
     if (request.getParameter("selectedCandidate") != null) {
       for (Application a : applications) {
         if (a.getStatus().equals(ApplicationStatus.ARCHIVED)) {
           continue;
         }
         if (request.getParameter("selectedCandidate").equals(a.get_appId())) {
           // TODO send notifications
         } else {
           // TODO send notifications
         }
         a.setStatus(ApplicationStatus.FINALISED);
         ApplicationsDao.instance.update(a);
       }
       j.setStatus(RecruitmentStatus.FINALISED);
       JobsDao.instance.update(ORSKEY, user.getShortKey(), j);
     }
     return "redirect:/jobs";
   } catch (Exception e) {
     e.printStackTrace();
     model.addAttribute("errorMsg", e.getMessage());
     return "error";
   }
 }
  /**
   * Remove an application
   *
   * @param application
   * @param user
   * @return
   * @throws ServiceException
   */
  @Override
  @Transactional
  public Application remove(Application application, User user)
      throws ServiceException, CheckException {

    try {
      logger.info("Starting removing application " + application.getName());

      // Delete all modules
      List<Module> listModules = application.getModules();
      for (Module module : listModules) {
        try {
          moduleService.remove(application, user, module, false, application.getStatus());
        } catch (ServiceException | CheckException e) {
          application.setStatus(Status.FAIL);
          logger.error(
              "ApplicationService Error : failed to remove module "
                  + module.getName()
                  + " for application "
                  + application.getName()
                  + " : "
                  + e);
          e.printStackTrace();
        }
      }

      // Delete all alias
      List<String> aliases = new ArrayList<>();
      aliases.addAll(application.getAliases());
      for (String alias : aliases) {
        removeAlias(application, alias);
      }

      // Delete all servers
      List<Server> listServers = application.getServers();
      for (Server server : listServers) {
        serverService.remove(server.getName());
        if (listServers.indexOf(server) == listServers.size() - 1) {
          hipacheRedisUtils.removeRedisAppKey(application);
          applicationDAO.delete(server.getApplication());
          portUtils.releaseProxyPorts(application);
        }
      }

      logger.info("ApplicationService : Application successfully removed ");

    } catch (PersistenceException e) {
      setStatus(application, Status.FAIL);
      logger.error(
          "ApplicationService Error : failed to remove " + application.getName() + " : " + e);

      throw new ServiceException(e.getLocalizedMessage(), e);
    } catch (ServiceException e) {
      setStatus(application, Status.FAIL);
      logger.error(
          "ApplicationService Error : failed to remove application "
              + application.getName()
              + " : "
              + e);
    }
    return application;
  }