Created
September 23, 2012 16:40
-
-
Save Eugeny/3772252 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (request.getParameter("addBroadcast") != null) { | |
User u = Authenticator.authenticate(request); | |
Gson gson = new Gson(); | |
response.setCharacterEncoding("utf8"); | |
if (u == null) { | |
response.getWriter().write("Denied"); | |
} else { | |
if (u.getUserRole() != UserRole.GROUP_MONITOR) { | |
response.getWriter().write("Not available"); | |
return; | |
} | |
ScheduleBroadcastDao dao = ContextDao.get(ScheduleBroadcastDao.class); | |
StudentDao studentDao = ContextDao.get(StudentDao.class); | |
ScheduleBroadcast broadcast = new ScheduleBroadcast(); | |
broadcast.setText(request.getParameter("text")); | |
broadcast.setExpires(new Date(Long.parseLong(request.getParameter("expires")))); | |
broadcast.setGroupList(new String[]{studentDao.getByUser(u).getGroupNumber()}); | |
dao.create(broadcast); | |
response.getWriter().write("OK"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment