Skip to content

Instantly share code, notes, and snippets.

@Eugeny
Created September 23, 2012 16:40
Show Gist options
  • Save Eugeny/3772252 to your computer and use it in GitHub Desktop.
Save Eugeny/3772252 to your computer and use it in GitHub Desktop.
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