Package projectatlast.tracking

Source Code of projectatlast.tracking.CancelCurrentActivityServlet

package projectatlast.tracking;

import projectatlast.student.AuthController;
import projectatlast.student.Student;
import projectatlast.student.StudentController;
import projectatlast.tracking.Activity;

import java.io.IOException;

import javax.servlet.http.*;

/**
* This servlet cancels the current activity of the logged in student.
*
* <p>Preconditions:</p>
* <ul><li>The student is logged in.</li></ul>
*
* @author Erik De Smedt
* @web.servlet
*   name=CancelCurrentActivity
*/
public class CancelCurrentActivityServlet extends HttpServlet {
  private static final long serialVersionUID = 1L;

  @Override
  public void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws IOException {

    Student student = AuthController.getCurrentStudent();
    Activity activity = StudentController.getCurrentActivity(student);

    // Remove current activity in student
    StudentController.setCurrentActivity(student, null);

    // Cancel current activity
    if (activity != null) {
      ActivityController.removeActivity(activity);
    }

    // Redirect to home page
    resp.sendRedirect("/home");
  }
}
TOP

Related Classes of projectatlast.tracking.CancelCurrentActivityServlet

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.