Skip to content

Commit

Permalink
🎨 Cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Oct 2, 2018
1 parent 4736a0c commit eace1e1
Show file tree
Hide file tree
Showing 26 changed files with 75 additions and 149 deletions.
5 changes: 1 addition & 4 deletions src/main/java/org/b3log/symphony/model/UserExt.java
Original file line number Diff line number Diff line change
Expand Up @@ -660,11 +660,8 @@ public static boolean isReservedUserName(final String userName) {
}
}

if (StringUtils.containsIgnoreCase(userName, UserExt.ANONYMOUS_USER_NAME)) {
return true;
}
return StringUtils.containsIgnoreCase(userName, UserExt.ANONYMOUS_USER_NAME);

return false;
}

/**
Expand Down
15 changes: 5 additions & 10 deletions src/main/java/org/b3log/symphony/processor/ActivityProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,11 @@ public class ActivityProcessor {
* @param context the specified context
* @param request the specified request
* @param response the specified response
* @throws Exception exception
*/
@RequestProcessing(value = "/activity/character", method = HTTPRequestMethod.GET)
@Before(adviceClass = {StopwatchStartAdvice.class, LoginCheck.class})
@After(adviceClass = {CSRFToken.class, PermissionGrant.class, StopwatchEndAdvice.class})
public void showCharacter(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
public void showCharacter(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response) {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(request);
context.setRenderer(renderer);
renderer.setTemplateName("activity/character.ftl");
Expand Down Expand Up @@ -211,12 +210,11 @@ public void submitCharacter(final HTTPRequestContext context, final HttpServletR
* @param context the specified context
* @param request the specified request
* @param response the specified response
* @throws Exception exception
*/
@RequestProcessing(value = "/activities", method = HTTPRequestMethod.GET)
@Before(adviceClass = {StopwatchStartAdvice.class, LoginCheck.class})
@After(adviceClass = {PermissionGrant.class, StopwatchEndAdvice.class})
public void showActivities(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
public void showActivities(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response) {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(request);
context.setRenderer(renderer);
renderer.setTemplateName("home/activities.ftl");
Expand Down Expand Up @@ -335,12 +333,11 @@ public void yesterdayLivenessReward(final HttpServletRequest request, final Http
* @param context the specified context
* @param request the specified request
* @param response the specified response
* @throws Exception exception
*/
@RequestProcessing(value = "/activity/1A0001", method = HTTPRequestMethod.GET)
@Before(adviceClass = {StopwatchStartAdvice.class, LoginCheck.class})
@After(adviceClass = {CSRFToken.class, PermissionGrant.class, StopwatchEndAdvice.class})
public void show1A0001(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
public void show1A0001(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response) {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(request);
context.setRenderer(renderer);
renderer.setTemplateName("activity/1A0001.ftl");
Expand Down Expand Up @@ -475,12 +472,11 @@ public void collect1A0001(final HTTPRequestContext context, final HttpServletReq
* @param context the specified context
* @param request the specified request
* @param response the specified response
* @throws Exception exception
*/
@RequestProcessing(value = "/activity/eating-snake", method = HTTPRequestMethod.GET)
@Before(adviceClass = {StopwatchStartAdvice.class, LoginCheck.class})
@After(adviceClass = {CSRFToken.class, PermissionGrant.class, StopwatchEndAdvice.class})
public void showEatingSnake(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
public void showEatingSnake(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response) {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(request);
context.setRenderer(renderer);
renderer.setTemplateName("activity/eating-snake.ftl");
Expand Down Expand Up @@ -562,12 +558,11 @@ public void collectEatingSnake(final HTTPRequestContext context, final HttpServl
* @param context the specified context
* @param request the specified request
* @param response the specified response
* @throws Exception exception
*/
@RequestProcessing(value = "/activity/gobang", method = HTTPRequestMethod.GET)
@Before(adviceClass = {StopwatchStartAdvice.class, LoginCheck.class})
@After(adviceClass = {CSRFToken.class, PermissionGrant.class, StopwatchEndAdvice.class})
public void showGobang(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
public void showGobang(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response) {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(request);
context.setRenderer(renderer);
renderer.setTemplateName("activity/gobang.ftl");
Expand Down
34 changes: 9 additions & 25 deletions src/main/java/org/b3log/symphony/processor/AdminProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -537,12 +537,11 @@ public void removeBreezemoon(final HttpServletRequest request, final HttpServlet
* Removes unused tags.
*
* @param context the specified context
* @throws Exception exception
*/
@RequestProcessing(value = "/admin/tags/remove-unused", method = HTTPRequestMethod.POST)
@Before(adviceClass = {StopwatchStartAdvice.class, PermissionCheck.class})
@After(adviceClass = StopwatchEndAdvice.class)
public void removeUnusedTags(final HTTPRequestContext context) throws Exception {
public void removeUnusedTags(final HTTPRequestContext context) {
context.renderJSON(true);

tagMgmtService.removeUnusedTags();
Expand Down Expand Up @@ -606,14 +605,12 @@ public void updateRolePermissions(final HTTPRequestContext context,
* @param request the specified request
* @param response the specified response
* @param roleId the specified role id
* @throws Exception exception
*/
@RequestProcessing(value = "/admin/role/{roleId}/permissions", method = HTTPRequestMethod.GET)
@Before(adviceClass = {StopwatchStartAdvice.class, PermissionCheck.class})
@After(adviceClass = {PermissionGrant.class, StopwatchEndAdvice.class})
public void showRolePermissions(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response,
final String roleId)
throws Exception {
final String roleId) {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(request);
context.setRenderer(renderer);
renderer.setTemplateName("admin/role-permissions.ftl");
Expand Down Expand Up @@ -737,13 +734,11 @@ public void updateBanner(final HTTPRequestContext context,
* @param context the specified context
* @param request the specified request
* @param response the specified response
* @throws Exception exception
*/
@RequestProcessing(value = "/admin/ad", method = HTTPRequestMethod.GET)
@Before(adviceClass = {StopwatchStartAdvice.class, PermissionCheck.class})
@After(adviceClass = {PermissionGrant.class, StopwatchEndAdvice.class})
public void showAd(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response)
throws Exception {
public void showAd(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response) {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(request);
context.setRenderer(renderer);
renderer.setTemplateName("admin/ad.ftl");
Expand Down Expand Up @@ -771,13 +766,11 @@ public void showAd(final HTTPRequestContext context, final HttpServletRequest re
* @param context the specified context
* @param request the specified request
* @param response the specified response
* @throws Exception exception
*/
@RequestProcessing(value = "/admin/add-tag", method = HTTPRequestMethod.GET)
@Before(adviceClass = {StopwatchStartAdvice.class, PermissionCheck.class})
@After(adviceClass = {PermissionGrant.class, StopwatchEndAdvice.class})
public void showAddTag(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response)
throws Exception {
public void showAddTag(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response) {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(request);
context.setRenderer(renderer);
renderer.setTemplateName("admin/add-tag.ftl");
Expand Down Expand Up @@ -1024,13 +1017,11 @@ public void updateInvitecode(final HTTPRequestContext context, final HttpServlet
* @param context the specified context
* @param request the specified request
* @param response the specified response
* @throws Exception exception
*/
@RequestProcessing(value = "/admin/add-article", method = HTTPRequestMethod.GET)
@Before(adviceClass = {StopwatchStartAdvice.class, PermissionCheck.class})
@After(adviceClass = {PermissionGrant.class, StopwatchEndAdvice.class})
public void showAddArticle(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response)
throws Exception {
public void showAddArticle(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response) {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(request);
context.setRenderer(renderer);
renderer.setTemplateName("admin/add-article.ftl");
Expand Down Expand Up @@ -1171,13 +1162,11 @@ public void addReservedWord(final HTTPRequestContext context, final HttpServletR
* @param context the specified context
* @param request the specified request
* @param response the specified response
* @throws Exception exception
*/
@RequestProcessing(value = "/admin/add-reserved-word", method = HTTPRequestMethod.GET)
@Before(adviceClass = {StopwatchStartAdvice.class, PermissionCheck.class})
@After(adviceClass = {PermissionGrant.class, StopwatchEndAdvice.class})
public void showAddReservedWord(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response)
throws Exception {
public void showAddReservedWord(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response) {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(request);
context.setRenderer(renderer);
renderer.setTemplateName("admin/add-reserved-word.ftl");
Expand Down Expand Up @@ -1251,13 +1240,12 @@ public void showReservedWords(final HTTPRequestContext context, final HttpServle
* @param request the specified request
* @param response the specified response
* @param id the specified reserved word id
* @throws Exception exception
*/
@RequestProcessing(value = "/admin/reserved-word/{id}", method = HTTPRequestMethod.GET)
@Before(adviceClass = {StopwatchStartAdvice.class, PermissionCheck.class})
@After(adviceClass = {PermissionGrant.class, StopwatchEndAdvice.class})
public void showReservedWord(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response,
final String id) throws Exception {
final String id) {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(request);
context.setRenderer(renderer);
renderer.setTemplateName("admin/reserved-word.ftl");
Expand Down Expand Up @@ -1435,13 +1423,11 @@ public void showUser(final HTTPRequestContext context, final HttpServletRequest
* @param context the specified context
* @param request the specified request
* @param response the specified response
* @throws Exception exception
*/
@RequestProcessing(value = "/admin/add-user", method = HTTPRequestMethod.GET)
@Before(adviceClass = {StopwatchStartAdvice.class, PermissionCheck.class})
@After(adviceClass = {PermissionGrant.class, StopwatchEndAdvice.class})
public void showAddUser(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response)
throws Exception {
public void showAddUser(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response) {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(request);
context.setRenderer(renderer);
renderer.setTemplateName("admin/add-user.ftl");
Expand Down Expand Up @@ -2516,13 +2502,11 @@ public void updateDomain(final HTTPRequestContext context, final HttpServletRequ
* @param context the specified context
* @param request the specified request
* @param response the specified response
* @throws Exception exception
*/
@RequestProcessing(value = "/admin/add-domain", method = HTTPRequestMethod.GET)
@Before(adviceClass = {StopwatchStartAdvice.class, PermissionCheck.class})
@After(adviceClass = {PermissionGrant.class, StopwatchEndAdvice.class})
public void showAddDomain(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response)
throws Exception {
public void showAddDomain(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response) {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(request);
context.setRenderer(renderer);
renderer.setTemplateName("admin/add-domain.ftl");
Expand Down
10 changes: 3 additions & 7 deletions src/main/java/org/b3log/symphony/processor/ArticleProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ public void getArticleImage(final HTTPRequestContext context, final String artic

final JSONObject ret = new JSONObject();
ret.put(Keys.STATUS_CODE, true);
ret.put(Common.URL, (Object) url);
ret.put(Common.URL, url);

context.renderJSON(ret);
}
Expand Down Expand Up @@ -422,13 +422,11 @@ public void getArticleRevisions(final HTTPRequestContext context, final String i
* @param context the specified context
* @param request the specified request
* @param response the specified response
* @throws Exception exception
*/
@RequestProcessing(value = "/pre-post", method = HTTPRequestMethod.GET)
@Before(adviceClass = {StopwatchStartAdvice.class, LoginCheck.class})
@After(adviceClass = {CSRFToken.class, PermissionGrant.class, StopwatchEndAdvice.class})
public void showPreAddArticle(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response)
throws Exception {
public void showPreAddArticle(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response) {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(request);
context.setRenderer(renderer);

Expand Down Expand Up @@ -482,13 +480,11 @@ private void fillDomainsWithTags(final Map<String, Object> dataModel) {
* @param context the specified context
* @param request the specified request
* @param response the specified response
* @throws Exception exception
*/
@RequestProcessing(value = "/post", method = HTTPRequestMethod.GET)
@Before(adviceClass = {StopwatchStartAdvice.class, LoginCheck.class})
@After(adviceClass = {CSRFToken.class, PermissionGrant.class, StopwatchEndAdvice.class})
public void showAddArticle(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response)
throws Exception {
public void showAddArticle(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response) {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(request);
context.setRenderer(renderer);
renderer.setTemplateName("home/post.ftl");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,11 @@ public class ChargeProcessor {
* @param context the specified context
* @param request the specified request
* @param response the specified response
* @throws Exception exception
*/
@RequestProcessing(value = "/charge/point", method = HTTPRequestMethod.GET)
@Before(adviceClass = {StopwatchStartAdvice.class, AnonymousViewCheck.class})
@After(adviceClass = {PermissionGrant.class, StopwatchEndAdvice.class})
public void showChargePoint(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response)
throws Exception {
public void showChargePoint(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response) {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(request);
context.setRenderer(renderer);
renderer.setTemplateName("charge-point.ftl");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,11 @@ public synchronized void addChatRoomMsg(final HTTPRequestContext context, final
* @param context the specified context
* @param request the specified request
* @param response the specified response
* @throws Exception exception
*/
@RequestProcessing(value = "/cr", method = HTTPRequestMethod.GET)
@Before(adviceClass = {StopwatchStartAdvice.class, AnonymousViewCheck.class})
@After(adviceClass = {PermissionGrant.class, StopwatchEndAdvice.class})
public void showChatRoom(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
public void showChatRoom(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response) {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(request);
context.setRenderer(renderer);
renderer.setTemplateName("chat-room.ftl");
Expand Down
Loading

0 comments on commit eace1e1

Please sign in to comment.