From 0c2803b09b75b5aac26ad9d1e5061f77bf003d64 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 5 Apr 2017 14:50:48 +0300 Subject: juick-www: GetMapping and PostMapping --- .../main/java/com/juick/www/controllers/FacebookLogin.java | 5 ++--- juick-www/src/main/java/com/juick/www/controllers/Help.java | 4 ++-- juick-www/src/main/java/com/juick/www/controllers/Home.java | 11 +++-------- .../src/main/java/com/juick/www/controllers/NewMessage.java | 12 +++++------- juick-www/src/main/java/com/juick/www/controllers/PM.java | 10 +++++----- .../src/main/java/com/juick/www/controllers/Settings.java | 8 ++++---- .../src/main/java/com/juick/www/controllers/SignUp.java | 8 ++++---- juick-www/src/main/java/com/juick/www/controllers/Tags.java | 5 ++--- .../main/java/com/juick/www/controllers/TwitterAuth.java | 5 ++--- juick-www/src/main/java/com/juick/www/controllers/User.java | 13 +++++-------- .../src/main/java/com/juick/www/controllers/UserThread.java | 5 ++--- .../main/java/com/juick/www/controllers/VKontakteLogin.java | 5 ++--- .../src/main/java/com/juick/www/controllers/XMPPPost.java | 5 ++--- 13 files changed, 40 insertions(+), 56 deletions(-) (limited to 'juick-www/src/main/java/com/juick/www/controllers') diff --git a/juick-www/src/main/java/com/juick/www/controllers/FacebookLogin.java b/juick-www/src/main/java/com/juick/www/controllers/FacebookLogin.java index 178f6762..0067dbc6 100644 --- a/juick-www/src/main/java/com/juick/www/controllers/FacebookLogin.java +++ b/juick-www/src/main/java/com/juick/www/controllers/FacebookLogin.java @@ -36,8 +36,7 @@ import org.slf4j.LoggerFactory; import org.springframework.core.env.Environment; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import javax.inject.Inject; @@ -76,7 +75,7 @@ public class FacebookLogin { serviceBuilder = new ServiceBuilder(); } - @RequestMapping(value = "/_fblogin", method = RequestMethod.GET) + @GetMapping("/_fblogin") protected String doGet(HttpServletRequest request, @RequestParam(required = false) String code, @RequestParam(required = false) String state, diff --git a/juick-www/src/main/java/com/juick/www/controllers/Help.java b/juick-www/src/main/java/com/juick/www/controllers/Help.java index 8256b4be..847f5d88 100644 --- a/juick-www/src/main/java/com/juick/www/controllers/Help.java +++ b/juick-www/src/main/java/com/juick/www/controllers/Help.java @@ -7,8 +7,8 @@ import com.juick.www.HelpService; import com.juick.www.WebApp; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; import javax.inject.Inject; import javax.servlet.http.HttpServletRequest; @@ -31,7 +31,7 @@ public class Help { @Inject private WebApp webApp; - @RequestMapping({"/help/", "/help", "/help/{langOrPage}", "/help/{lang}/{page}"}) + @GetMapping({"/help/", "/help", "/help/{langOrPage}", "/help/{lang}/{page}"}) public String showHelp( HttpServletRequest request, HttpServletResponse response, diff --git a/juick-www/src/main/java/com/juick/www/controllers/Home.java b/juick-www/src/main/java/com/juick/www/controllers/Home.java index 4f597d5a..a362901c 100644 --- a/juick-www/src/main/java/com/juick/www/controllers/Home.java +++ b/juick-www/src/main/java/com/juick/www/controllers/Home.java @@ -29,10 +29,7 @@ import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.*; import javax.inject.Inject; import javax.servlet.http.HttpServletRequest; @@ -59,7 +56,7 @@ public class Home { @Inject WebApp webApp; - @RequestMapping(value = "/{anything}/**", method = RequestMethod.GET) + @GetMapping("/{anything}/**") protected void parseAnyThing(HttpServletResponse response, @PathVariable String anything, @RequestParam(required = false, defaultValue = "0") int before) throws IOException { if (before == 0) { @@ -88,14 +85,12 @@ public class Home { com.juick.User user = userService.getUserByName(anything); if (user.getUid() > 0) { Utils.sendPermanentRedirect(response, "/" + user.getName() + "/?before=" + before); - return; } else { response.sendError(HttpServletResponse.SC_NOT_FOUND); - return; } } - @RequestMapping(value = "/", method = RequestMethod.GET) + @GetMapping("/") protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { String tag = request.getParameter("tag"); if (tag != null) { diff --git a/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java b/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java index fcd27710..2c92f9d8 100644 --- a/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java +++ b/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java @@ -35,9 +35,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.core.env.Environment; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import rocks.xmpp.addr.Jid; import rocks.xmpp.core.stanza.model.Message; @@ -86,7 +84,7 @@ public class NewMessage { private static final Logger logger = LoggerFactory.getLogger(NewMessage.class); - @RequestMapping(value = "/post", method = RequestMethod.GET) + @GetMapping("/post") protected void doGetNewMessage(HttpServletRequest request, HttpServletResponse response) throws IOException { com.juick.User visitor = UserUtils.getCurrentUser(); if (visitor.getUid() == 0) { @@ -181,7 +179,7 @@ public class NewMessage { out.println("

"); } - @RequestMapping(value = "/post", method = RequestMethod.POST) + @PostMapping("/post") public void doPostMessage(HttpServletRequest request, HttpServletResponse response, @RequestParam(required = false) String img, @RequestParam(required = false) MultipartFile attach) throws IOException { @@ -314,7 +312,7 @@ public class NewMessage { } } - @RequestMapping(value = "/comment", method = RequestMethod.POST) + @PostMapping("/comment") public void doPostComment(HttpServletRequest request, HttpServletResponse response, @RequestParam(required = false) String img, @RequestParam(required = false) MultipartFile attach) throws IOException { @@ -432,7 +430,7 @@ public class NewMessage { Utils.sendTemporaryRedirect(response, "/" + msg.getUser().getName() + "/" + mid + "#" + ridnew); } - @RequestMapping(value = "/like", method = RequestMethod.POST) + @PostMapping("/like") public void doPostRecomm(HttpServletRequest request, HttpServletResponse response) throws IOException { com.juick.User visitor = UserUtils.getCurrentUser(); if (visitor.getUid() == 0) { diff --git a/juick-www/src/main/java/com/juick/www/controllers/PM.java b/juick-www/src/main/java/com/juick/www/controllers/PM.java index 9cc29129..ab772443 100644 --- a/juick-www/src/main/java/com/juick/www/controllers/PM.java +++ b/juick-www/src/main/java/com/juick/www/controllers/PM.java @@ -31,8 +31,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import rocks.xmpp.addr.Jid; import rocks.xmpp.core.stanza.model.Message; @@ -61,7 +61,7 @@ public class PM { @Inject WebApp webApp; - @RequestMapping(value = "/pm/inbox", method = RequestMethod.GET) + @GetMapping("/pm/inbox") protected String doGetInbox(HttpServletRequest request, HttpServletResponse response, ModelMap model) { com.juick.User visitor = UserUtils.getCurrentUser(); if (visitor.getUid() == 0) { @@ -78,7 +78,7 @@ public class PM { return "views/pm_inbox"; } - @RequestMapping(value = "/pm/sent", method = RequestMethod.GET) + @GetMapping("/pm/sent") protected String doGetSent(HttpServletRequest request, HttpServletResponse response, ModelMap model) { com.juick.User visitor = UserUtils.getCurrentUser(); if (visitor.getUid() == 0) { @@ -101,7 +101,7 @@ public class PM { return "views/pm_sent"; } - @RequestMapping(value = "/pm/send", method = RequestMethod.POST) + @PostMapping("/pm/send") public void doPostPM(HttpServletRequest request, HttpServletResponse response) throws IOException { com.juick.User visitor = UserUtils.getCurrentUser(); if (visitor.getUid() == 0 || visitor.isBanned()) { diff --git a/juick-www/src/main/java/com/juick/www/controllers/Settings.java b/juick-www/src/main/java/com/juick/www/controllers/Settings.java index 43215c62..ad5d3d27 100644 --- a/juick-www/src/main/java/com/juick/www/controllers/Settings.java +++ b/juick-www/src/main/java/com/juick/www/controllers/Settings.java @@ -31,8 +31,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.multipart.MultipartFile; @@ -84,7 +84,7 @@ public class Settings { @Inject MessagesService messagesService; - @RequestMapping(value = "/settings", method = RequestMethod.GET) + @GetMapping("/settings") protected String doGet(HttpServletRequest request, HttpServletResponse response, ModelMap model) throws IOException { com.juick.User visitor = UserUtils.getCurrentUser(); if (visitor.getUid() == 0) { @@ -124,7 +124,7 @@ public class Settings { return String.format("views/settings_%s", page); } - @RequestMapping(value = "/settings", method = RequestMethod.POST) + @PostMapping("/settings") protected String doPost(HttpServletRequest request, HttpServletResponse response, @RequestParam(required = false) MultipartFile avatar, ModelMap model) diff --git a/juick-www/src/main/java/com/juick/www/controllers/SignUp.java b/juick-www/src/main/java/com/juick/www/controllers/SignUp.java index 4c20e513..d07c3227 100644 --- a/juick-www/src/main/java/com/juick/www/controllers/SignUp.java +++ b/juick-www/src/main/java/com/juick/www/controllers/SignUp.java @@ -27,8 +27,8 @@ import com.juick.www.Utils; import com.juick.www.WebApp; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import javax.inject.Inject; import javax.servlet.http.Cookie; @@ -52,7 +52,7 @@ public class SignUp { MessagesService messagesService; - @RequestMapping(value = "/signup", method = RequestMethod.GET) + @GetMapping("/signup") protected String doGet(HttpServletRequest request, HttpServletResponse response, ModelMap model) { com.juick.User visitor = UserUtils.getCurrentUser(); @@ -91,7 +91,7 @@ public class SignUp { return "views/signup"; } - @RequestMapping(value = "/signup", method = RequestMethod.POST) + @PostMapping("/signup") protected String doPost(HttpServletRequest request, HttpServletResponse response) { com.juick.User visitor = UserUtils.getCurrentUser(); int uid = 0; diff --git a/juick-www/src/main/java/com/juick/www/controllers/Tags.java b/juick-www/src/main/java/com/juick/www/controllers/Tags.java index a0682a45..3116fd93 100644 --- a/juick-www/src/main/java/com/juick/www/controllers/Tags.java +++ b/juick-www/src/main/java/com/juick/www/controllers/Tags.java @@ -27,9 +27,8 @@ import org.apache.commons.lang3.CharEncoding; import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import javax.inject.Inject; @@ -57,7 +56,7 @@ public class Tags { @Inject PageTemplates templates; - @RequestMapping(value = "/tag/{tagName}", method = RequestMethod.GET) + @GetMapping("/tag/{tagName}") protected void doGet(HttpServletRequest request, @PathVariable String tagName, @RequestParam(required = false, defaultValue = "0") int before, diff --git a/juick-www/src/main/java/com/juick/www/controllers/TwitterAuth.java b/juick-www/src/main/java/com/juick/www/controllers/TwitterAuth.java index 33f266b2..8ccaecfa 100644 --- a/juick-www/src/main/java/com/juick/www/controllers/TwitterAuth.java +++ b/juick-www/src/main/java/com/juick/www/controllers/TwitterAuth.java @@ -12,8 +12,7 @@ import com.juick.service.UserService; import org.apache.commons.lang3.StringUtils; import org.springframework.core.env.Environment; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import javax.inject.Inject; import javax.servlet.http.Cookie; @@ -44,7 +43,7 @@ public class TwitterAuth { this.consumerSecret = env.getProperty("twitter_consumer_secret"); } - @RequestMapping(value = "/_twitter", method = RequestMethod.GET) + @GetMapping("/_twitter") protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ExecutionException, InterruptedException { String hash = StringUtils.EMPTY, request_token = StringUtils.EMPTY, request_token_secret = StringUtils.EMPTY; diff --git a/juick-www/src/main/java/com/juick/www/controllers/User.java b/juick-www/src/main/java/com/juick/www/controllers/User.java index 28a91298..3e566df9 100644 --- a/juick-www/src/main/java/com/juick/www/controllers/User.java +++ b/juick-www/src/main/java/com/juick/www/controllers/User.java @@ -28,10 +28,7 @@ import org.apache.commons.lang3.CharEncoding; import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.*; import javax.inject.Inject; import javax.servlet.ServletException; @@ -62,7 +59,7 @@ public class User { @Inject PageTemplates templates; - @RequestMapping("/{uname}/") + @GetMapping("/{uname}/") protected void doGetBlog(HttpServletRequest request, HttpServletResponse response, @PathVariable String uname, @RequestParam(required = false, defaultValue = "0") Integer before) throws IOException { @@ -177,7 +174,7 @@ public class User { } } - @RequestMapping(value = "/{uname}/tags", method = RequestMethod.GET) + @GetMapping("/{uname}/tags") protected void doGetTags(HttpServletRequest request, HttpServletResponse response, @PathVariable String uname) throws IOException { com.juick.User user = userService.getUserByName(uname); @@ -203,7 +200,7 @@ public class User { } } - @RequestMapping(value = "/{uname}/friends", method = RequestMethod.GET) + @GetMapping("/{uname}/friends") protected void doGetFriends(HttpServletRequest request, HttpServletResponse response, @PathVariable String uname) throws ServletException, IOException { com.juick.User user = userService.getUserByName(uname); @@ -241,7 +238,7 @@ public class User { } } - @RequestMapping(value = "/{uname}/readers", method = RequestMethod.GET) + @GetMapping("/{uname}/readers") protected void doGetReaders(HttpServletRequest request, HttpServletResponse response, @PathVariable String uname) throws ServletException, IOException { com.juick.User user = userService.getUserByName(uname); diff --git a/juick-www/src/main/java/com/juick/www/controllers/UserThread.java b/juick-www/src/main/java/com/juick/www/controllers/UserThread.java index 27788d9b..0aeac4c6 100644 --- a/juick-www/src/main/java/com/juick/www/controllers/UserThread.java +++ b/juick-www/src/main/java/com/juick/www/controllers/UserThread.java @@ -30,9 +30,8 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import javax.inject.Inject; import javax.servlet.ServletException; @@ -61,7 +60,7 @@ public class UserThread { @Inject PageTemplates templates; - @RequestMapping(value = "/{uname}/{mid}", method = RequestMethod.GET) + @GetMapping("/{uname}/{mid}") protected void doGetThread(HttpServletRequest request, HttpServletResponse response, @PathVariable String uname, @PathVariable int mid) throws ServletException, IOException { diff --git a/juick-www/src/main/java/com/juick/www/controllers/VKontakteLogin.java b/juick-www/src/main/java/com/juick/www/controllers/VKontakteLogin.java index efc86f7c..c8b45691 100644 --- a/juick-www/src/main/java/com/juick/www/controllers/VKontakteLogin.java +++ b/juick-www/src/main/java/com/juick/www/controllers/VKontakteLogin.java @@ -36,8 +36,7 @@ import org.slf4j.LoggerFactory; import org.springframework.core.env.Environment; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import javax.inject.Inject; @@ -75,7 +74,7 @@ public class VKontakteLogin { @Inject private ObjectMapper jsonMapper; - @RequestMapping(value = "/_vklogin", method = RequestMethod.GET) + @GetMapping("/_vklogin") protected String doGet(HttpServletRequest request, @RequestParam(required = false) String code, @RequestParam(required = false) String state, diff --git a/juick-www/src/main/java/com/juick/www/controllers/XMPPPost.java b/juick-www/src/main/java/com/juick/www/controllers/XMPPPost.java index f4b8717a..888d25c4 100644 --- a/juick-www/src/main/java/com/juick/www/controllers/XMPPPost.java +++ b/juick-www/src/main/java/com/juick/www/controllers/XMPPPost.java @@ -9,8 +9,7 @@ import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.multipart.MultipartFile; import rocks.xmpp.addr.Jid; @@ -37,7 +36,7 @@ public class XMPPPost { @Inject TagService tagService; - @RequestMapping(value = "/post2", method = RequestMethod.POST) + @PostMapping("/post2") public void doPostMessage(HttpServletRequest request, HttpServletResponse response, @RequestParam(required = false) String img, @RequestParam(required = false) MultipartFile attach) throws IOException { -- cgit v1.2.3