mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
wrap calls in db session
This commit is contained in:
@@ -27,10 +27,15 @@ public class CustomCssServlet extends HttpServlet {
|
|||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
protected void doGet(final HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||||
resp.setContentType("text/css");
|
resp.setContentType("text/css");
|
||||||
|
|
||||||
final Optional<User> user = userService.login(req.getSession());
|
final Optional<User> user = new UnitOfWork<Optional<User>>(sessionFactory) {
|
||||||
|
@Override
|
||||||
|
protected Optional<User> runInSession() throws Exception {
|
||||||
|
return userService.login(req.getSession());
|
||||||
|
}
|
||||||
|
}.run();
|
||||||
if (!user.isPresent()) {
|
if (!user.isPresent()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,11 +43,16 @@ public class NextUnreadServlet extends HttpServlet {
|
|||||||
private final CommaFeedConfiguration config;
|
private final CommaFeedConfiguration config;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
protected void doGet(final HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||||
final String categoryId = req.getParameter(PARAM_CATEGORYID);
|
final String categoryId = req.getParameter(PARAM_CATEGORYID);
|
||||||
String orderParam = req.getParameter(PARAM_READINGORDER);
|
String orderParam = req.getParameter(PARAM_READINGORDER);
|
||||||
|
|
||||||
final Optional<User> user = userService.login(req.getSession());
|
final Optional<User> user = new UnitOfWork<Optional<User>>(sessionFactory) {
|
||||||
|
@Override
|
||||||
|
protected Optional<User> runInSession() throws Exception {
|
||||||
|
return userService.login(req.getSession());
|
||||||
|
}
|
||||||
|
}.run();
|
||||||
if (!user.isPresent()) {
|
if (!user.isPresent()) {
|
||||||
resp.sendRedirect(resp.encodeRedirectURL(config.getApplicationSettings().getPublicUrl()));
|
resp.sendRedirect(resp.encodeRedirectURL(config.getApplicationSettings().getPublicUrl()));
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user