private Long getStatusPageSessionId(SessionContext context)
     throws SectioningException, PageAccessException {
   UserContext user = context.getUser();
   if (user == null)
     throw new PageAccessException(
         context.isHttpSessionNew()
             ? MSG.exceptionHttpSessionExpired()
             : MSG.exceptionLoginRequired());
   if (user.getCurrentAcademicSessionId() == null) {
     Long sessionId = getLastSessionId(context);
     if (sessionId != null) return sessionId;
   } else {
     return user.getCurrentAcademicSessionId();
   }
   throw new SectioningException(MSG.exceptionNoAcademicSession());
 }
    @Override
    public boolean check(UserContext user, TimetableManager source) {
      for (Department d : source.getDepartments()) {
        if (d.getSessionId().equals(user.getCurrentAcademicSessionId())) {
          return permissionSession.check(user, d.getSession());
        }
      }

      return true;
    }
 public Long getLastSessionId(SessionContext context) {
   Long lastSessionId = (Long) context.getAttribute("sessionId");
   if (lastSessionId == null) {
     UserContext user = context.getUser();
     if (user != null) {
       Long sessionId = user.getCurrentAcademicSessionId();
       if (sessionId != null) lastSessionId = sessionId;
     }
   }
   return lastSessionId;
 }