@Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    try {
      //            String username = request.getParameter("username");
      //            String role = request.getParameter("role");

      String username = "******";
      String role = "student";

      Group group = groupManager.getGroup(role);
      if (group == null) {
        group = new Group();
        group.setName(role);
        groupManager.saveGroup(group);
      }

      User user = userManager.getUser(username);
      if (user == null) {
        user = new User();
        user.setName(username);
        user.setPassword(Encryption.digest(DUMMY_PASSWORD, EncryptionType.MD5));
        Set<Group> groups = new HashSet<>();
        groups.add(group);
        user.setGroups(groups);
        userManager.saveUser(user);
      }

      request.logout();

      StudentInformation newStudent = new StudentInformation();
      newStudent.setUserName(username);
      newStudent.setPassword(Encryption.digest(DUMMY_PASSWORD, EncryptionType.MD5));

      HttpSession currentSession = request.getSession();
      currentSession.setAttribute("currentUser", newStudent);

      request.login(username, DUMMY_PASSWORD);

      String tos = termsOfServiceManager.getTermsOfServiceById(1).getTermsOfService();
      currentSession.setAttribute("tos", tos);

      response.sendRedirect(request.getContextPath());

    } catch (ServletException e) {
      e.printStackTrace();
      request.getRequestDispatcher("/WEB-INF/login/login_error.jsp").forward(request, response);
    }
  }
示例#2
0
 @Override
 public Object convert(Object entity) {
   Group result = new Group();
   Groups object = (Groups) entity;
   result.setDescription(object.getDescription());
   // result.setGroupId(object.getGroupId());
   result.setName(object.getName());
   // result.setTime(object.getTime());
   Place pl = new Place();
   GroupType group = new GroupType();
   Collection<Participant> coll = new ArrayList();
   result.setPlaceId(pl);
   result.setParticipantsCollection(coll);
   result.setTypeId(group);
   // pl.setId(object.getPlaceId().getId());
   // group.setId(object.getTypeId().getId());
   /* for (Iterator<Participants> it = object.getParticipantsCollection().iterator(); it.hasNext();) {
       Participant curr = new Participant();
       curr.setId(it.next().getId());
       coll.add(curr);
   }*/
   return result;
 }