From 4ecd57fc21236cc54463fa229f6422f39124dfbb Mon Sep 17 00:00:00 2001 From: standpoint Date: Tue, 20 Jan 2015 18:43:26 +0200 Subject: [PATCH 001/433] Revert "JC-2004 TypeMismatchException to be DEBUG" This reverts commit e5d1569ab35fdc3505d18ade1bce20ea23cb8e15. --- .../exception/PrettyLogExceptionResolver.java | 62 ++----------------- 1 file changed, 6 insertions(+), 56 deletions(-) diff --git a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/exception/PrettyLogExceptionResolver.java b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/exception/PrettyLogExceptionResolver.java index d45c667904..4348d294d4 100644 --- a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/exception/PrettyLogExceptionResolver.java +++ b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/exception/PrettyLogExceptionResolver.java @@ -17,21 +17,17 @@ import org.jtalks.jcommune.plugin.api.exceptions.NotFoundException; import org.springframework.beans.TypeMismatchException; import org.springframework.security.access.AccessDeniedException; -import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver; import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.security.Principal; -import java.util.Enumeration; -import java.util.Properties; /** * Catches all the exceptions thrown in controllers, logs them and directs to the error pages. The standard - * {@link org.springframework.web.servlet.handler.SimpleMappingExceptionResolver} wasn't sufficient because it was logging all exceptions as warnings while + * {@link SimpleMappingExceptionResolver} wasn't sufficient because it was logging all exceptions as warnings while * some of them are expected and should be logged as INFO (such as 404 topic not found). * * @author Vitaliy Kravchenko @@ -48,9 +44,9 @@ public class PrettyLogExceptionResolver extends SimpleMappingExceptionResolver { @Override protected void logException(Exception ex, HttpServletRequest request) { if (ex instanceof NotFoundException) { - logger.info(getLogMessage(request, ex)); + logger.info(ex.getMessage()); } else if (ex instanceof TypeMismatchException) { - logger.info(getLogMessage(request, ex)); + logger.info(ex.getMessage()); } else if (ex instanceof AccessDeniedException) { String url = request.getRequestURL().toString(); Principal principal = request.getUserPrincipal(); @@ -60,17 +56,16 @@ protected void logException(Exception ex, HttpServletRequest request) { } else { super.logException(ex, request); } + logger.info(getLogMessage(request)); } /** * Get info about occured exception: request method, url, cookies and data. * @param request request - * @param ex exception * @return log message */ - private String getLogMessage(HttpServletRequest request, Exception ex) { + private String getLogMessage(HttpServletRequest request) { String data = ""; - String exceptionMessage = ex.getMessage(); try { BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream())); String line; @@ -78,7 +73,7 @@ private String getLogMessage(HttpServletRequest request, Exception ex) { while ((line=reader.readLine()) != null ) { stringBuilder.append(line).append("\n"); } - data = stringBuilder.append(exceptionMessage).toString(); + data = stringBuilder.toString(); } catch (IOException e) { logger.warn("Could not parse data from request"); } @@ -89,49 +84,4 @@ private String getLogMessage(HttpServletRequest request, Exception ex) { } return String.format("[%s][%s][%s][%s]", request.getMethod(), url, request.getHeader("Cookie"), data); } - - /** - * {@inheritDoc} - */ - @Override - public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, - Object handler, Exception ex) { - if (shouldApplyTo(request, handler)) { - logException(ex, request); - prepareResponse(ex, response); - return doResolveException(request, response, handler, ex); - } - else { - return null; - } - } - - /** - * {@inheritDoc} - */ - @Override - protected ModelAndView getModelAndView(String viewName, Exception ex) { - return new ModelAndView(viewName); - } - - /** - * {@inheritDoc} - */ - @Override - protected String findMatchingViewName(Properties exceptionMappings, Exception ex) { - String viewName = null; - String dominantMapping = null; - int deepest = Integer.MAX_VALUE; - for (Enumeration names = exceptionMappings.propertyNames(); names.hasMoreElements();) { - String exceptionMapping = (String) names.nextElement(); - int depth = getDepth(exceptionMapping, ex); - if (depth >= 0 && (depth < deepest || (depth == deepest && - dominantMapping != null && exceptionMapping.length() > dominantMapping.length()))) { - deepest = depth; - dominantMapping = exceptionMapping; - viewName = exceptionMappings.getProperty(exceptionMapping); - } - } - return viewName; - } } From 7270498122fba0d94d65badc88a8ee216195f5d0 Mon Sep 17 00:00:00 2001 From: Mikhail Stryzhonok Date: Tue, 20 Jan 2015 22:41:16 +0300 Subject: [PATCH 002/433] #JC-2031 Fixed remarks from QA Posts in question now are sorted by rating (post with the highest rating showed on top) and creation date (newer post higher). Question is excluded form sorting Now vote buttons not reacts on repeated push in one second Fixed error message localization for anonymous user. JCLocaleResolver moved to plugin API to allow resolve locale in plugins using same mechanism as forum --- .../api}/web/locale/JcLocaleResolver.java | 22 ++- .../plugin/api}/web/locale/package-info.java | 2 +- .../api}/web/locale/JcLocaleResolverTest.java | 23 ++-- .../QuestionsAndAnswersController.java | 42 +++++- .../messages_ru.properties | 3 +- .../template/js/question.js | 126 ++++++++++-------- .../questionsandanswers/template/question.vm | 7 +- .../QuestionsAndAnswersControllerTest.java | 10 +- .../WEB-INF/spring-dispatcher-servlet.xml | 5 +- 9 files changed, 150 insertions(+), 90 deletions(-) rename {jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune => jcommune-plugin-api/src/main/java/org/jtalks/jcommune/plugin/api}/web/locale/JcLocaleResolver.java (78%) rename {jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune => jcommune-plugin-api/src/main/java/org/jtalks/jcommune/plugin/api}/web/locale/package-info.java (94%) rename {jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune => jcommune-plugin-api/src/test/java/org/jtalks/jcommune/plugin/api}/web/locale/JcLocaleResolverTest.java (79%) diff --git a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/locale/JcLocaleResolver.java b/jcommune-plugin-api/src/main/java/org/jtalks/jcommune/plugin/api/web/locale/JcLocaleResolver.java similarity index 78% rename from jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/locale/JcLocaleResolver.java rename to jcommune-plugin-api/src/main/java/org/jtalks/jcommune/plugin/api/web/locale/JcLocaleResolver.java index eea81b7a6a..45a92b8727 100644 --- a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/locale/JcLocaleResolver.java +++ b/jcommune-plugin-api/src/main/java/org/jtalks/jcommune/plugin/api/web/locale/JcLocaleResolver.java @@ -12,11 +12,12 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package org.jtalks.jcommune.web.locale; +package org.jtalks.jcommune.plugin.api.web.locale; import org.jtalks.jcommune.model.entity.JCUser; -import org.jtalks.jcommune.service.UserService; +import org.jtalks.jcommune.plugin.api.service.UserReader; +import org.springframework.web.servlet.LocaleResolver; import org.springframework.web.servlet.i18n.CookieLocaleResolver; import javax.servlet.http.HttpServletRequest; @@ -29,10 +30,19 @@ */ public class JcLocaleResolver extends CookieLocaleResolver { - private UserService userService; + private static final LocaleResolver INSTANCE = new JcLocaleResolver(); - public JcLocaleResolver(UserService userService) { - this.userService = userService; + private UserReader userReader; + + private JcLocaleResolver() { + } + + public static LocaleResolver getInstance() { + return INSTANCE; + } + + public void setUserReader(UserReader userReader) { + this.userReader = userReader; } /** @@ -49,7 +59,7 @@ public Locale resolveLocale(HttpServletRequest request) { return locale; } - JCUser currentUser = userService.getCurrentUser(); + JCUser currentUser = userReader.getCurrentUser(); if (currentUser.isAnonymous()) { locale = super.resolveLocale(request); } else { diff --git a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/locale/package-info.java b/jcommune-plugin-api/src/main/java/org/jtalks/jcommune/plugin/api/web/locale/package-info.java similarity index 94% rename from jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/locale/package-info.java rename to jcommune-plugin-api/src/main/java/org/jtalks/jcommune/plugin/api/web/locale/package-info.java index 30ed0ddff9..12bdb089e8 100644 --- a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/locale/package-info.java +++ b/jcommune-plugin-api/src/main/java/org/jtalks/jcommune/plugin/api/web/locale/package-info.java @@ -15,4 +15,4 @@ /** * Provides package with custom locale resolvers */ -package org.jtalks.jcommune.web.locale; \ No newline at end of file +package org.jtalks.jcommune.plugin.api.web.locale; \ No newline at end of file diff --git a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/locale/JcLocaleResolverTest.java b/jcommune-plugin-api/src/test/java/org/jtalks/jcommune/plugin/api/web/locale/JcLocaleResolverTest.java similarity index 79% rename from jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/locale/JcLocaleResolverTest.java rename to jcommune-plugin-api/src/test/java/org/jtalks/jcommune/plugin/api/web/locale/JcLocaleResolverTest.java index f636dfbbf3..583f689953 100644 --- a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/locale/JcLocaleResolverTest.java +++ b/jcommune-plugin-api/src/test/java/org/jtalks/jcommune/plugin/api/web/locale/JcLocaleResolverTest.java @@ -12,12 +12,12 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package org.jtalks.jcommune.web.locale; +package org.jtalks.jcommune.plugin.api.web.locale; import org.jtalks.jcommune.model.entity.AnonymousUser; import org.jtalks.jcommune.model.entity.JCUser; import org.jtalks.jcommune.model.entity.Language; -import org.jtalks.jcommune.service.UserService; +import org.jtalks.jcommune.plugin.api.service.UserReader; import org.springframework.web.servlet.i18n.CookieLocaleResolver; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -38,23 +38,24 @@ */ public class JcLocaleResolverTest { @Mock - private UserService userService; + private UserReader userReader; @Mock private HttpServletRequest request; @BeforeMethod public void init() { initMocks(this); + JcLocaleResolver resolver = (JcLocaleResolver) JcLocaleResolver.getInstance(); + resolver.setUserReader(userReader); } @Test public void resolveLocaleShouldReturnUserLocaleIfUserLoggedIn() { - JcLocaleResolver localeResolver = new JcLocaleResolver(userService); JCUser currentUser = new JCUser("username", "email@mail.ru", "password"); currentUser.setLanguage(Language.ENGLISH); - when(userService.getCurrentUser()).thenReturn(currentUser); + when(userReader.getCurrentUser()).thenReturn(currentUser); - Locale result = localeResolver.resolveLocale(request); + Locale result = JcLocaleResolver.getInstance().resolveLocale(request); assertEquals(result, currentUser.getLanguage().getLocale()); verify(request).setAttribute(CookieLocaleResolver.LOCALE_REQUEST_ATTRIBUTE_NAME, Locale.ENGLISH); @@ -62,14 +63,13 @@ public void resolveLocaleShouldReturnUserLocaleIfUserLoggedIn() { @Test public void resolveLocaleShouldReturnRequestLocaleIfUserAnonymous() { - JcLocaleResolver localeResolver = new JcLocaleResolver(userService); AnonymousUser user = new AnonymousUser(); user.setLanguage(Language.SPANISH); Locale defaultLocale = Language.ENGLISH.getLocale(); - when(userService.getCurrentUser()).thenReturn(user); + when(userReader.getCurrentUser()).thenReturn(user); when(request.getLocale()).thenReturn(defaultLocale); - Locale result = localeResolver.resolveLocale(request); + Locale result = JcLocaleResolver.getInstance().resolveLocale(request); assertEquals(result, defaultLocale); } @@ -80,13 +80,12 @@ public void resolveLocaleShouldReturnRequestLocaleIfUserAnonymous() { */ @Test public void resolveLocaleShouldNotRetrieveCurrentUserIfRequestLocaleAttributeNotNull() { - JcLocaleResolver localeResolver = new JcLocaleResolver(userService); Locale locale = Locale.ENGLISH; when(request.getAttribute(CookieLocaleResolver.LOCALE_REQUEST_ATTRIBUTE_NAME)).thenReturn(locale); - Locale result = localeResolver.resolveLocale(request); + Locale result = JcLocaleResolver.getInstance().resolveLocale(request); assertEquals(result, locale); - verify(userService, never()).getCurrentUser(); + verify(userReader, never()).getCurrentUser(); } } diff --git a/jcommune-plugins/questions-n-answers-plugin/src/main/java/org/jtalks/jcommune/plugin/questionsandanswers/controller/QuestionsAndAnswersController.java b/jcommune-plugins/questions-n-answers-plugin/src/main/java/org/jtalks/jcommune/plugin/questionsandanswers/controller/QuestionsAndAnswersController.java index d1de009bfc..168fdf74c3 100644 --- a/jcommune-plugins/questions-n-answers-plugin/src/main/java/org/jtalks/jcommune/plugin/questionsandanswers/controller/QuestionsAndAnswersController.java +++ b/jcommune-plugins/questions-n-answers-plugin/src/main/java/org/jtalks/jcommune/plugin/questionsandanswers/controller/QuestionsAndAnswersController.java @@ -34,6 +34,7 @@ import org.jtalks.jcommune.plugin.api.web.PluginController; import org.jtalks.jcommune.plugin.api.web.dto.PostDto; import org.jtalks.jcommune.plugin.api.web.dto.TopicDto; +import org.jtalks.jcommune.plugin.api.web.locale.JcLocaleResolver; import org.jtalks.jcommune.plugin.api.web.util.BreadcrumbBuilder; import org.jtalks.jcommune.plugin.api.web.velocity.tool.JodaDateTimeTool; import org.jtalks.jcommune.plugin.api.web.velocity.tool.PermissionTool; @@ -47,6 +48,7 @@ import org.springframework.ui.velocity.VelocityEngineUtils; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; +import org.springframework.web.servlet.LocaleResolver; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -189,7 +191,7 @@ public String showQuestion(HttpServletRequest request, Model model, @PathVariabl getTypeAwarePluginTopicService().checkViewTopicPermission(topic.getBranch().getId()); Map data = getDefaultModel(request); data.put(QUESTION, topic); - data.put(POST_PAGE, new PageImpl<>(topic.getPosts())); + data.put(POST_PAGE, new PageImpl<>(getSortedPosts(topic.getPosts()))); data.put(BREADCRUMB_LIST, breadcrumbBuilder.getForumBreadcrumb(topic)); data.put(SUBSCRIBED, false); data.put(CONVERTER, BbToHtmlConverter.getInstance()); @@ -416,6 +418,21 @@ public String deleteAnswer(@PathVariable Long answerId) + "#" + neighborAnswer.getId(); } + /** + * Gets copy of specified collection of posts sorted by rating and creation date + * + * @param posts collection of posts to sort + * + * @return collection of posts sorted by rating and creation date + */ + private List getSortedPosts(List posts) { + List result = new ArrayList<>(posts); + Post question = result.remove(0); + Collections.sort(result, new PostComparator()); + result.add(0, question); + return result; + } + /** * Writes icon to response and set apropriate response geaders * @@ -451,12 +468,12 @@ private void processIconRequest(HttpServletRequest request, HttpServletResponse /** * Gets resource bundle with locale of current user * - * @param currentUser current user + * @param request http servlet request * * @return resource bundle with locale of current user */ - private ResourceBundle getLocalizedMessagesBundle(JCUser currentUser) { - return ResourceBundle.getBundle(MESSAGE_PATH, currentUser.getLanguage().getLocale()); + private ResourceBundle getLocalizedMessagesBundle(HttpServletRequest request) { + return ResourceBundle.getBundle(MESSAGE_PATH, getLocaleResolver().resolveLocale(request)); } /** @@ -499,7 +516,7 @@ private Map getDefaultModel(HttpServletRequest request) { JCUser currentUser = getUserReader().getCurrentUser(); PermissionTool tool = new PermissionTool(applicationContext); model.put("currentUser", currentUser); - model.put("messages", getLocalizedMessagesBundle(currentUser)); + model.put("messages", getLocalizedMessagesBundle(request)); model.put("permissionTool", tool); return model; } @@ -511,6 +528,13 @@ public void setApiPath(String apiPath) { this.apiPath = apiPath; } + /** + * Needed for mocking + */ + LocaleResolver getLocaleResolver() { + return JcLocaleResolver.getInstance(); + } + /** * Needed for mocking */ @@ -566,4 +590,12 @@ PluginLocationService getLocationService() { void setBreadcrumbBuilder(BreadcrumbBuilder breadcrumbBuilder) { this.breadcrumbBuilder = breadcrumbBuilder; } + + private static class PostComparator implements Comparator { + @Override + public int compare(Post o1, Post o2) { + return o1.getRating() == o2.getRating() ? o2.getCreationDate().compareTo(o1.getCreationDate()) : + o2.getRating() - o1.getRating(); + } + } } diff --git a/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/messages_ru.properties b/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/messages_ru.properties index 18a78c32d4..6c1cf60f41 100644 --- a/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/messages_ru.properties +++ b/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/messages_ru.properties @@ -31,8 +31,7 @@ label.question=\u0412\u043E\u043F\u0440\u043E\u0441 label.question.details=\u041F\u043E\u0434\u0440\u043E\u0431\u043D\u0435\u0435 label.ask=\u0421\u043F\u0440\u043E\u0441\u0438\u0442\u044C label.answer.placeholder=\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043E\u0442\u0432\u0435\u0442 \u0437\u0434\u0435\u0441\u044C -label.vote.error.not.registered=\u0413\u043E\u043B\u043E\u0441\u043E\u0432\u0430\u043D\u0438\u0435 \u0434\u043E\u0441\u0442\u0443\u043F\u043D\u043E \u0442\u043E\u043B\u044C\u043A\u043E \u0434\u043B\u044F \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0445 \u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u0435\u043B\u0435\u0439\ +label.vote.error.not.registered=\u0413\u043E\u043B\u043E\u0441\u043E\u0432\u0430\u043D\u0438\u0435 \u0434\u043E\u0441\u0442\u0443\u043F\u043D\u043E \u0442\u043E\u043B\u044C\u043A\u043E \u0434\u043B\u044F \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0445 \u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u0435\u043B\u0435\u0439 label.vote.error.no.permissions=\u0423 \u0412\u0430\u0441 \u043D\u0435\u0434\u043E\u0441\u0442\u0430\u0442\u043E\u0447\u043D\u043E \u043F\u0440\u0430\u0432 \u0434\u043B\u044F \u0433\u043E\u043B\u043E\u0441\u043E\u0432\u0430\u043D\u0438\u044F \u0432 \u044D\u0442\u043E\u0439 \u0432\u0435\u0442\u043A\u0435 label.vote.error.own.post=\u0412\u044B \u043D\u0435 \u043C\u043E\u0436\u0435\u0442\u0435 \u0433\u043E\u043B\u043E\u0441\u043E\u0432\u0430\u0442\u044C \u0437\u0430 \u0441\u0432\u043E\u0439 \u0432\u043E\u043F\u0440\u043E\u0441/\u043E\u0442\u0432\u0435\u0442 -label.vote.error.no.permissions=\u0423 \u0412\u0430\u0441 \u043D\u0435\u0434\u043E\u0441\u0442\u0430\u0442\u043E\u0447\u043D\u043E \u043F\u0440\u0430\u0432 \u0434\u043B\u044F \u0433\u043E\u043B\u043E\u0441\u043E\u0432\u0430\u043D\u0438\u044F \u0432 \u044D\u0442\u043E\u0439 \u0432\u0435\u0442\u043A\u0435\ diff --git a/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/js/question.js b/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/js/question.js index b3db208edb..0b8796b042 100644 --- a/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/js/question.js +++ b/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/js/question.js @@ -44,64 +44,9 @@ $(function () { } }); - $(".vote-up").mouseup(function(e){ - if (e.which != 1) { - return; - } - var postId = getVotedPostId($(this).attr('id')); - if (isOwnPost(postId)) { - showErrorPopUp(postId, labelVoteErrorOwnPost); - return; - } - if (isVotedUp(postId)) { - return; - } - $.ajax({ - url: baseUrl + "/posts/" + postId + "/voteup", - type: "GET", - success: function(data) { - console.log("success"); - if (isVotedDown(postId)) { - changeRating($("#" + postId + "-rating"), 2); - } else { - changeRating($("#" + postId + "-rating"), 1); - } - markVoteUpAsPressed(postId); - }, - error: function() { - showErrorPopUp(postId, labelVoteErrorNoPermissions); - } - }); - }); + $(".vote-up").mouseup(voteUpHandler); - $(".vote-down").mouseup(function(e){ - if (e.which != 1) { - return; - } - var postId = getVotedPostId($(this).attr('id')); - if (isOwnPost(postId)) { - showErrorPopUp(postId, labelVoteErrorOwnPost); - return; - } - if (isVotedDown(postId)) { - return; - } - $.ajax({ - url: baseUrl + "/posts/" + postId + "/votedown", - type: "GET", - success: function() { - if (isVotedUp(postId)) { - changeRating($("#" + postId + "-rating"), -2); - } else { - changeRating($("#" + postId + "-rating"), -1); - } - markVoteDownAsPressed(postId); - }, - error: function() { - showErrorPopUp(postId, labelVoteErrorNoPermissions); - } - }); - }); + $(".vote-down").mouseup(voteDownHandler); $('#answer').click(function(e){ e.preventDefault(); @@ -113,6 +58,73 @@ $(function () { } }); +var voteUpHandler = function voteUp(e) { + if (e.which != 1) { + return; + } + var postId = getVotedPostId($(this).attr('id')); + if (isOwnPost(postId)) { + showErrorPopUp(postId, labelVoteErrorOwnPost); + return; + } + if (isVotedUp(postId)) { + return; + } + $(".vote-up").unbind("mouseup"); + $.ajax({ + url: baseUrl + "/posts/" + postId + "/voteup", + type: "GET", + success: function(data) { + console.log("success"); + if (isVotedDown(postId)) { + changeRating($("#" + postId + "-rating"), 2); + } else { + changeRating($("#" + postId + "-rating"), 1); + } + markVoteUpAsPressed(postId); + }, + error: function() { + showErrorPopUp(postId, labelVoteErrorNoPermissions); + } + }); + setTimeout(function() { + $(".vote-up").mouseup(voteUpHandler); + }, 1000); +} + +var voteDownHandler = function voteDown(e) { + if (e.which != 1) { + return; + } + var postId = getVotedPostId($(this).attr('id')); + if (isOwnPost(postId)) { + showErrorPopUp(postId, labelVoteErrorOwnPost); + return; + } + if (isVotedDown(postId)) { + return; + } + $(".vote-down").unbind("mouseup"); + $.ajax({ + url: baseUrl + "/posts/" + postId + "/votedown", + type: "GET", + success: function() { + if (isVotedUp(postId)) { + changeRating($("#" + postId + "-rating"), -2); + } else { + changeRating($("#" + postId + "-rating"), -1); + } + markVoteDownAsPressed(postId); + }, + error: function() { + showErrorPopUp(postId, labelVoteErrorNoPermissions); + } + }); + setTimeout(function() { + $(".vote-down").mouseup(voteDownHandler); + }, 1000); +} + /** * Shows pop-up with vote error message * diff --git a/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/question.vm b/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/question.vm index dc459f347e..78d7f69df6 100644 --- a/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/question.vm +++ b/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/question.vm @@ -21,11 +21,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #parse("org/jtalks/jcommune/jcommune-plugin-api/web/templates/userStats.vm") diff --git a/jcommune-plugins/questions-n-answers-plugin/src/test/java/org/jtalks/jcommune/plugin/questionsandanswers/controller/QuestionsAndAnswersControllerTest.java b/jcommune-plugins/questions-n-answers-plugin/src/test/java/org/jtalks/jcommune/plugin/questionsandanswers/controller/QuestionsAndAnswersControllerTest.java index 78b014ba56..8e07a050ae 100644 --- a/jcommune-plugins/questions-n-answers-plugin/src/test/java/org/jtalks/jcommune/plugin/questionsandanswers/controller/QuestionsAndAnswersControllerTest.java +++ b/jcommune-plugins/questions-n-answers-plugin/src/test/java/org/jtalks/jcommune/plugin/questionsandanswers/controller/QuestionsAndAnswersControllerTest.java @@ -34,6 +34,7 @@ import org.springframework.ui.ExtendedModelMap; import org.springframework.ui.Model; import org.springframework.validation.BindingResult; +import org.springframework.web.servlet.LocaleResolver; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -41,6 +42,7 @@ import javax.servlet.http.HttpServletResponse; import java.util.Collections; import java.util.Date; +import java.util.Locale; import java.util.Properties; import static org.mockito.Matchers.any; @@ -76,6 +78,9 @@ public class QuestionsAndAnswersControllerTest { private BindingResult result; @Mock private PluginLocationService locationService; + @Mock + private LocaleResolver localeResolver; + @Spy private QuestionsAndAnswersController controller = new QuestionsAndAnswersController(); private String content = "some html"; @@ -91,6 +96,8 @@ public void init() { when(controller.getProperties()).thenReturn(new Properties()); when(controller.getUserReader()).thenReturn(userReader); when(controller.getLocationService()).thenReturn(locationService); + when(controller.getLocaleResolver()).thenReturn(localeResolver); + when(localeResolver.resolveLocale(any(HttpServletRequest.class))).thenReturn(Locale.ENGLISH); when(userReader.getCurrentUser()).thenReturn(new JCUser("name", "example@mail.ru", "pwd")); controller.setApplicationContext(context); controller.setBreadcrumbBuilder(breadcrumbBuilder); @@ -164,7 +171,7 @@ public void createQuestionShouldThrowExceptionIfBranchNotFound() throws Exceptio @Test public void showQuestionSuccessTest() throws Exception { Branch branch = new Branch("name", "description"); - Topic topic = new Topic(); + Topic topic = createTopic(); topic.setBranch(branch); Model model = new ExtendedModelMap(); @@ -445,6 +452,7 @@ private Topic createTopic() { Topic topic = new Topic(); topic.setId(42L); topic.setBranch(branch); + topic.addPost(new Post(null, null)); return topic; } diff --git a/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/spring-dispatcher-servlet.xml b/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/spring-dispatcher-servlet.xml index 24e451479d..8a30b8c5d0 100644 --- a/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/spring-dispatcher-servlet.xml +++ b/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/spring-dispatcher-servlet.xml @@ -67,10 +67,11 @@ - + - + Date: Wed, 21 Jan 2015 13:13:21 +0200 Subject: [PATCH 003/433] JC-2004 TypeMismatchException to be DEBUG 1) There were overridden 3 methods at PrettyLogExceptionResolver: - public ModelAndView resolveException(...) from AbstractHandlerExceptionResolver class; - protected ModelAndView getModelAndView(...) from SimpleMappingExceptionResolver class; - protected String findMatchingViewName(...) from SimpleMappingExceptionResolver class; These ones are implemented in this way that there were suppressed all redundant logging that are in the base methods. Also some minor changes have been made at methods logException and getLogMessage to correct displaying of messages in logs when exceptions occur. 2) In PrettyLogExceptionResolverTest class there are some methods have been changed according to last changes in PrettyLogExceptionResolver. Has been added test method for exception "TypeMismatchException": testLogExceptionWithIncomingTypeMismatchException() --- .../exception/PrettyLogExceptionResolver.java | 66 ++++++++++++++++--- .../PrettyLogExceptionResolverTest.java | 21 +++++- 2 files changed, 77 insertions(+), 10 deletions(-) diff --git a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/exception/PrettyLogExceptionResolver.java b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/exception/PrettyLogExceptionResolver.java index 4348d294d4..68cd1ede64 100644 --- a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/exception/PrettyLogExceptionResolver.java +++ b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/exception/PrettyLogExceptionResolver.java @@ -17,13 +17,17 @@ import org.jtalks.jcommune.plugin.api.exceptions.NotFoundException; import org.springframework.beans.TypeMismatchException; import org.springframework.security.access.AccessDeniedException; +import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.security.Principal; +import java.util.Enumeration; +import java.util.Properties; /** * Catches all the exceptions thrown in controllers, logs them and directs to the error pages. The standard @@ -37,16 +41,15 @@ public class PrettyLogExceptionResolver extends SimpleMappingExceptionResolver { private static final String ACCESS_DENIED_MESSAGE = "Access was denied for user [%s] trying to %s %s"; /** Constant for anonymous user */ private static final String NOT_AUTHORIZED_USERNAME = "anonymousUser"; - /** * {@inheritDoc} */ @Override protected void logException(Exception ex, HttpServletRequest request) { if (ex instanceof NotFoundException) { - logger.info(ex.getMessage()); + logger.info(getLogMessage(request, ex)); } else if (ex instanceof TypeMismatchException) { - logger.info(ex.getMessage()); + logger.info(getLogMessage(request, ex)); } else if (ex instanceof AccessDeniedException) { String url = request.getRequestURL().toString(); Principal principal = request.getUserPrincipal(); @@ -55,17 +58,19 @@ protected void logException(Exception ex, HttpServletRequest request) { logger.info(accessDeniedMessage); } else { super.logException(ex, request); + logger.info(getLogMessage(request, ex)); } - logger.info(getLogMessage(request)); } /** - * Get info about occured exception: request method, url, cookies and data. + * Get info about occurred exception: request method, url, cookies and data. * @param request request + * @param ex exception * @return log message */ - private String getLogMessage(HttpServletRequest request) { + private String getLogMessage(HttpServletRequest request, Exception ex) { String data = ""; + String exceptionMessage = ex.getMessage(); try { BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream())); String line; @@ -73,7 +78,7 @@ private String getLogMessage(HttpServletRequest request) { while ((line=reader.readLine()) != null ) { stringBuilder.append(line).append("\n"); } - data = stringBuilder.toString(); + data = stringBuilder.append(exceptionMessage).toString(); } catch (IOException e) { logger.warn("Could not parse data from request"); } @@ -84,4 +89,49 @@ private String getLogMessage(HttpServletRequest request) { } return String.format("[%s][%s][%s][%s]", request.getMethod(), url, request.getHeader("Cookie"), data); } -} + + /** + * {@inheritDoc} + */ + @Override + public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, + Object handler, Exception ex) { + if (shouldApplyTo(request, handler)) { + logException(ex, request); + prepareResponse(ex, response); + return doResolveException(request, response, handler, ex); + } + else { + return null; + } + } + + /** + * {@inheritDoc} + */ + @Override + protected ModelAndView getModelAndView(String viewName, Exception ex) { + return new ModelAndView(viewName); + } + + /** + * {@inheritDoc} + */ + @Override + protected String findMatchingViewName(Properties exceptionMappings, Exception ex) { + String viewName = null; + String dominantMapping = null; + int deepest = Integer.MAX_VALUE; + for (Enumeration names = exceptionMappings.propertyNames(); names.hasMoreElements();) { + String exceptionMapping = (String) names.nextElement(); + int depth = getDepth(exceptionMapping, ex); + if (depth >= 0 && (depth < deepest || (depth == deepest && + dominantMapping != null && exceptionMapping.length() > dominantMapping.length()))) { + deepest = depth; + dominantMapping = exceptionMapping; + viewName = exceptionMappings.getProperty(exceptionMapping); + } + } + return viewName; + } +} \ No newline at end of file diff --git a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/exception/PrettyLogExceptionResolverTest.java b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/exception/PrettyLogExceptionResolverTest.java index 4d189f1e33..46b160a565 100644 --- a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/exception/PrettyLogExceptionResolverTest.java +++ b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/exception/PrettyLogExceptionResolverTest.java @@ -17,6 +17,7 @@ import org.apache.commons.logging.Log; import org.jtalks.jcommune.plugin.api.exceptions.NotFoundException; +import org.springframework.beans.TypeMismatchException; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.security.access.AccessDeniedException; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; @@ -43,12 +44,27 @@ public void setUp() throws Exception { @Test public void testLogExceptionWithIncomingNotFoundException() throws Exception { Log mockLog = replaceLoggerWithMock(prettyLogExceptionResolver); - NotFoundException notFoundException = new NotFoundException("Entity not found"); MockHttpServletRequest request = new MockHttpServletRequest("GET", "/"); + NotFoundException notFoundException = new NotFoundException("Entity not found"); + String logMessage = String.format("[%s][%s][%s][%s]", request.getMethod(), request.getRequestURL().toString(), + request.getHeader("Cookie"), "Entity not found"); request.setContent("".getBytes()); prettyLogExceptionResolver.logException(notFoundException, request); - verify(mockLog).info("Entity not found"); + verify(mockLog).info(logMessage); + } + + @Test + public void testLogExceptionWithIncomingTypeMismatchException() throws Exception { + Log mockLog = replaceLoggerWithMock(prettyLogExceptionResolver); + MockHttpServletRequest request = new MockHttpServletRequest("GET", "/"); + TypeMismatchException typeMismatchException = new TypeMismatchException("Not a number", Number.class); + String logMessage = String.format("[%s][%s][%s][%s]", request.getMethod(), request.getRequestURL().toString(), + request.getHeader("Cookie"), typeMismatchException.getMessage()); + request.setContent("".getBytes()); + prettyLogExceptionResolver.logException(typeMismatchException, request); + + verify(mockLog).info(logMessage); } @Test @@ -82,6 +98,7 @@ public void testLogExceptionWithoutNotFoundException() throws Exception { private Log replaceLoggerWithMock(PrettyLogExceptionResolver resolver) throws Exception { Log mockLog = mock(Log.class); Field loggerField = ReflectionUtils.findField(PrettyLogExceptionResolver.class, "logger"); + assert loggerField != null; loggerField.setAccessible(true); loggerField.set(resolver, mockLog); return mockLog; From 5f2650ab541e83cb452a10034848b8c684e2f973 Mon Sep 17 00:00:00 2001 From: Mikhail Stryzhonok Date: Wed, 21 Jan 2015 15:27:23 +0300 Subject: [PATCH 004/433] #JC-2029 Fixed remarks Corrected url leading to question from edit answer page Removed debug logging for javascript --- .../jcommune/plugin/questionsandanswers/template/answerForm.vm | 2 +- .../jcommune/plugin/questionsandanswers/template/js/question.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/answerForm.vm b/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/answerForm.vm index 743c4bba43..e8856d1ed8 100644 --- a/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/answerForm.vm +++ b/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/answerForm.vm @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-

+

${questionTitle}

diff --git a/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/js/question.js b/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/js/question.js index 0b8796b042..a2a9cb00b4 100644 --- a/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/js/question.js +++ b/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/js/question.js @@ -75,7 +75,6 @@ var voteUpHandler = function voteUp(e) { url: baseUrl + "/posts/" + postId + "/voteup", type: "GET", success: function(data) { - console.log("success"); if (isVotedDown(postId)) { changeRating($("#" + postId + "-rating"), 2); } else { From f5bbc925771032b19f4134949629ff207578b891 Mon Sep 17 00:00:00 2001 From: Mikhail Stryzhonok Date: Thu, 22 Jan 2015 12:39:32 +0300 Subject: [PATCH 005/433] #JC-2038 Added plugin aware post url resolution Now post controller checks whatever post belongs to plugable topic and redirects to plugable topic view if approrpiate plugin is installed and enabled. Independently of topic type all post can be accessed by uniformed url "/post/postId" --- .../web/controller/PostController.java | 21 +++++++++------- .../web/controller/PostControllerTest.java | 25 +++++++++++++------ 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/PostController.java b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/PostController.java index d2e8aaba20..98ac3ee830 100644 --- a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/PostController.java +++ b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/PostController.java @@ -25,6 +25,7 @@ import org.jtalks.jcommune.service.nontransactional.LocationService; import org.jtalks.jcommune.plugin.api.web.dto.PostDto; import org.jtalks.jcommune.plugin.api.web.dto.TopicDto; +import org.jtalks.jcommune.web.dto.EntityToDtoConverter; import org.jtalks.jcommune.web.dto.json.JsonResponse; import org.jtalks.jcommune.web.dto.json.JsonResponseStatus; import org.jtalks.jcommune.plugin.api.web.util.BreadcrumbBuilder; @@ -74,7 +75,7 @@ public class PostController { private UserService userService; private LocationService locationService; private SessionRegistry sessionRegistry; - + private EntityToDtoConverter converter; @Autowired(required = true) private ViewResolver viewResolver; @@ -100,12 +101,15 @@ public void initBinder(WebDataBinder binder) { * @param bbCodeService to create valid quotes * @param lastReadPostService not to track user posts as updates for himself * @param userService to get the current user information + * @param converter instance of {@link org.jtalks.jcommune.web.dto.EntityToDtoConverter} needed to + * obtain link to the topic */ @Autowired public PostController(PostService postService, BreadcrumbBuilder breadcrumbBuilder, TopicFetchService topicFetchService, TopicModificationService topicModificationService, BBCodeService bbCodeService, LastReadPostService lastReadPostService, - UserService userService, LocationService locationService, SessionRegistry sessionRegistry) { + UserService userService, LocationService locationService, SessionRegistry sessionRegistry, + EntityToDtoConverter converter) { this.postService = postService; this.breadcrumbBuilder = breadcrumbBuilder; this.topicFetchService = topicFetchService; @@ -115,6 +119,7 @@ public PostController(PostService postService, BreadcrumbBuilder breadcrumbBuild this.userService = userService; this.locationService = locationService; this.sessionRegistry = sessionRegistry; + this.converter = converter; } /** @@ -274,6 +279,9 @@ private Post replyToTopicWithLockHandling(PostDto postDto, Long topicId) throws * Method clients should not wary about paging at all, post id * is enough to be transferred to the proper page. * + * If post belongs to plugable topic and appropriated plugin is enabled redirects + * to plugable topic view. + * * @param postId unique post identifier * @return redirect view to the certain topic page * @throws NotFoundException is the is no post for the identifier given @@ -282,13 +290,8 @@ private Post replyToTopicWithLockHandling(PostDto postDto, Long topicId) throws public String redirectToPageWithPost(@PathVariable Long postId) throws NotFoundException { Post post = postService.get(postId); int page = postService.calculatePageForPost(post); - return new StringBuilder("redirect:/topics/") - .append(post.getTopic().getId()) - .append("?page=") - .append(page) - .append("#") - .append(postId) - .toString(); + String topicUrl = converter.convertTopicToDto(post.getTopic()).getTopicUrl(); + return "redirect:" + topicUrl + "?page=" + page + "#" + postId; } /** diff --git a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/PostControllerTest.java b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/PostControllerTest.java index 6e0939b06b..eb7fc70153 100644 --- a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/PostControllerTest.java +++ b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/PostControllerTest.java @@ -15,12 +15,14 @@ package org.jtalks.jcommune.web.controller; import org.jtalks.jcommune.model.entity.*; +import org.jtalks.jcommune.plugin.api.web.dto.TopicDto; import org.jtalks.jcommune.service.*; import org.jtalks.jcommune.plugin.api.exceptions.NotFoundException; import org.jtalks.jcommune.service.nontransactional.BBCodeService; import org.jtalks.jcommune.service.nontransactional.LocationService; import org.jtalks.jcommune.plugin.api.web.dto.Breadcrumb; import org.jtalks.jcommune.plugin.api.web.dto.PostDto; +import org.jtalks.jcommune.web.dto.EntityToDtoConverter; import org.jtalks.jcommune.web.dto.json.JsonResponse; import org.jtalks.jcommune.plugin.api.web.util.BreadcrumbBuilder; import org.jtalks.jcommune.web.dto.json.JsonResponseStatus; @@ -73,6 +75,8 @@ public class PostControllerTest { private LocationService locationService; @Mock private SessionRegistry sessionRegistry; + @Mock + private EntityToDtoConverter converter; public static final long POST_ID = 1; public static final long TOPIC_ID = 1L; @@ -105,7 +109,7 @@ public void init() throws NotFoundException { controller = new PostController( postService, breadcrumbBuilder, topicFetchService, topicModificationService, - bbCodeService, lastReadPostService, userService, locationService, sessionRegistry); + bbCodeService, lastReadPostService, userService, locationService, sessionRegistry, converter); } @Test @@ -188,6 +192,10 @@ public void testPartialQuotedAjax() throws NotFoundException { @Test public void testSubmitAnswerValidationPass() throws NotFoundException { BeanPropertyBindingResult resultWithoutErrors = mock(BeanPropertyBindingResult.class); + TopicDto dto = new TopicDto(post.getTopic()); + dto.setTopicUrl("/topics/" + TOPIC_ID); + + when(converter.convertTopicToDto(any(Topic.class))).thenReturn(dto); when(resultWithoutErrors.hasErrors()).thenReturn(false); when(topicModificationService.replyToTopic(anyLong(), Matchers.any(), eq(BRANCH_ID))).thenReturn(post); when(postService.calculatePageForPost(post)).thenReturn(1); @@ -198,7 +206,7 @@ public void testSubmitAnswerValidationPass() throws NotFoundException { verify(topicModificationService).replyToTopic(TOPIC_ID, POST_CONTENT, BRANCH_ID); //check result - assertViewName(mav, "redirect:/topics/" + TOPIC_ID + "?page=1#" + POST_ID); + assertViewName(mav, "redirect:" + dto.getTopicUrl() + "?page=1#" + POST_ID); } @@ -218,11 +226,15 @@ public void testSubmitAnswerValidationFail() throws NotFoundException { @Test public void testRedirectToPageWithPost() throws NotFoundException { + TopicDto dto = new TopicDto(post.getTopic()); + dto.setTopicUrl("/topics/" + TOPIC_ID); + + when(converter.convertTopicToDto(any(Topic.class))).thenReturn(dto); when(postService.calculatePageForPost(post)).thenReturn(5); String result = controller.redirectToPageWithPost(POST_ID); - assertEquals(result, "redirect:/topics/" + TOPIC_ID + "?page=5#" + POST_ID); + assertEquals(result, "redirect:" + dto.getTopicUrl() + "?page=5#" + POST_ID); } @Test(expectedExceptions = NotFoundException.class) @@ -292,11 +304,8 @@ public PostVoteMacher(boolean isVotedUp) { @Override public boolean matches(Object o) { - if (o instanceof PostVote) { - //should be both true or both false - return !(isVotedUp ^ ((PostVote)o).isVotedUp()); - } - return false; + //should be both true or both false + return o instanceof PostVote && !(isVotedUp ^ ((PostVote) o).isVotedUp()); } } /* @Test From a540498bc4c7f7eb60060301303517555ea471dc Mon Sep 17 00:00:00 2001 From: Vladimir Kamensky Date: Thu, 22 Jan 2015 13:22:14 +0200 Subject: [PATCH 006/433] JC-2004 TypeMismatchException to be DEBUG Has been added displaying full stack-trace as [DEBUG] log-message according to task description. --- .../jcommune/web/exception/PrettyLogExceptionResolver.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/exception/PrettyLogExceptionResolver.java b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/exception/PrettyLogExceptionResolver.java index 68cd1ede64..1d10a0f902 100644 --- a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/exception/PrettyLogExceptionResolver.java +++ b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/exception/PrettyLogExceptionResolver.java @@ -22,9 +22,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; +import java.io.*; import java.security.Principal; import java.util.Enumeration; import java.util.Properties; @@ -97,6 +95,9 @@ private String getLogMessage(HttpServletRequest request, Exception ex) { public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) { if (shouldApplyTo(request, handler)) { + if(logger.isDebugEnabled()) { + logger.debug(request,ex); + } logException(ex, request); prepareResponse(ex, response); return doResolveException(request, response, handler, ex); From f4e80abdf0bad2d65942aceb4c5e4f7bbb145f00 Mon Sep 17 00:00:00 2001 From: Mikhail Stryzhonok Date: Thu, 22 Jan 2015 21:55:09 +0300 Subject: [PATCH 007/433] #JC-2082 Plugin aware url resolution for emails Mail service checks if topic belong to plugin and whatever appropriate plugin is enabled and determines url using EntityToDtoConverter EntityToDtoConverter moved to service module --- .../service}/dto/EntityToDtoConverter.java | 2 +- .../service/nontransactional/MailService.java | 23 +++++++++++++++---- .../service/applicationContext-service.xml | 4 ++++ .../jtalks/jcommune/service/email-context.xml | 1 + .../dto/EntityToDtoConverterTest.java | 2 +- .../nontransactional/MailServiceTest.java | 9 +++++++- .../web/controller/BranchController.java | 2 +- .../web/controller/PostController.java | 2 +- .../web/controller/TopicController.java | 4 +--- .../web/controller/TopicSearchController.java | 2 +- .../web/applicationContext-controller.xml | 3 --- .../web/controller/BranchControllerTest.java | 2 +- .../web/controller/PostControllerTest.java | 2 +- .../web/controller/TopicControllerTest.java | 2 +- .../controller/TopicSearchControllerTest.java | 2 +- 15 files changed, 42 insertions(+), 20 deletions(-) rename {jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web => jcommune-service/src/main/java/org/jtalks/jcommune/service}/dto/EntityToDtoConverter.java (99%) rename {jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web => jcommune-service/src/test/java/org/jtalks/jcommune/service}/dto/EntityToDtoConverterTest.java (99%) diff --git a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/dto/EntityToDtoConverter.java b/jcommune-service/src/main/java/org/jtalks/jcommune/service/dto/EntityToDtoConverter.java similarity index 99% rename from jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/dto/EntityToDtoConverter.java rename to jcommune-service/src/main/java/org/jtalks/jcommune/service/dto/EntityToDtoConverter.java index ff5b559ff5..821e8ee0c6 100644 --- a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/dto/EntityToDtoConverter.java +++ b/jcommune-service/src/main/java/org/jtalks/jcommune/service/dto/EntityToDtoConverter.java @@ -12,7 +12,7 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package org.jtalks.jcommune.web.dto; +package org.jtalks.jcommune.service.dto; import org.jtalks.jcommune.model.dto.PageRequest; import org.jtalks.jcommune.model.entity.Topic; diff --git a/jcommune-service/src/main/java/org/jtalks/jcommune/service/nontransactional/MailService.java b/jcommune-service/src/main/java/org/jtalks/jcommune/service/nontransactional/MailService.java index 258467cc8b..a8d6bca7c4 100644 --- a/jcommune-service/src/main/java/org/jtalks/jcommune/service/nontransactional/MailService.java +++ b/jcommune-service/src/main/java/org/jtalks/jcommune/service/nontransactional/MailService.java @@ -18,6 +18,7 @@ import org.apache.velocity.tools.generic.EscapeTool; import org.jtalks.common.model.entity.Entity; import org.jtalks.jcommune.model.entity.*; +import org.jtalks.jcommune.service.dto.EntityToDtoConverter; import org.jtalks.jcommune.service.exceptions.MailingFailedException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -73,6 +74,7 @@ public class MailService { private final MessageSource messageSource; private final JCommuneProperty notificationsEnabledProperty; private final EscapeTool escapeTool; + private final EntityToDtoConverter converter; /** * Creates a mailing service with a default template message autowired. @@ -92,13 +94,15 @@ public MailService(JavaMailSender sender, VelocityEngine engine, MessageSource source, JCommuneProperty notificationsEnabledProperty, - EscapeTool escapeTool) { + EscapeTool escapeTool, + EntityToDtoConverter converter) { this.mailSender = sender; this.from = from; this.velocityEngine = engine; this.messageSource = source; this.notificationsEnabledProperty = notificationsEnabledProperty; this.escapeTool = escapeTool; + this.converter = converter; } /** @@ -225,7 +229,7 @@ public void sendAccountActivationMail(JCUser recipient) { * @param topic relocated topic */ public void sendTopicMovedMail(JCUser recipient, Topic topic) { - String urlSuffix = "/topics/" + topic.getId(); + String urlSuffix = getTopicUrlSuffix(topic); String url = this.getDeploymentRootUrl() + urlSuffix; Locale locale = recipient.getLanguage().getLocale(); Map model = new HashMap<>(); @@ -250,7 +254,7 @@ public void sendTopicMovedMail(JCUser recipient, Topic topic) { * @param curUser User that moved topic */ public void sendTopicMovedMail(JCUser recipient, Topic topic, String curUser) { - String urlSuffix = "/topics/" + topic.getId(); + String urlSuffix = getTopicUrlSuffix(topic); String url = this.getDeploymentRootUrl() + urlSuffix; Locale locale = recipient.getLanguage().getLocale(); Map model = new HashMap<>(); @@ -480,7 +484,7 @@ public void sendRemovingTopicMail(JCUser recipient, Topic topic, String curUser) */ void sendTopicCreationMail(JCUser subscriber, Topic topic) { try { - String urlSuffix = "/topics/" + topic.getId(); + String urlSuffix = getTopicUrlSuffix(topic); String url = this.getDeploymentRootUrl() + urlSuffix; Locale locale = subscriber.getLanguage().getLocale(); Map model = new HashMap<>(); @@ -508,4 +512,15 @@ private String getUnsubscribeBranchLink(SubscriptionAwareEntity entity) { } return null; } + + /** + * Gets url suffix of specified topic. Urls of topics provided by plugins can differ + * + * @param topic topic to get url + * + * @return url of specified topic + */ + private String getTopicUrlSuffix(Topic topic) { + return converter.convertTopicToDto(topic).getTopicUrl(); + } } diff --git a/jcommune-service/src/main/resources/org/jtalks/jcommune/service/applicationContext-service.xml b/jcommune-service/src/main/resources/org/jtalks/jcommune/service/applicationContext-service.xml index 62a81376ca..1d9a5efc97 100644 --- a/jcommune-service/src/main/resources/org/jtalks/jcommune/service/applicationContext-service.xml +++ b/jcommune-service/src/main/resources/org/jtalks/jcommune/service/applicationContext-service.xml @@ -449,6 +449,10 @@ + + + + diff --git a/jcommune-service/src/main/resources/org/jtalks/jcommune/service/email-context.xml b/jcommune-service/src/main/resources/org/jtalks/jcommune/service/email-context.xml index e5e901165e..9aebb95e84 100644 --- a/jcommune-service/src/main/resources/org/jtalks/jcommune/service/email-context.xml +++ b/jcommune-service/src/main/resources/org/jtalks/jcommune/service/email-context.xml @@ -70,6 +70,7 @@ + diff --git a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/dto/EntityToDtoConverterTest.java b/jcommune-service/src/test/java/org/jtalks/jcommune/service/dto/EntityToDtoConverterTest.java similarity index 99% rename from jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/dto/EntityToDtoConverterTest.java rename to jcommune-service/src/test/java/org/jtalks/jcommune/service/dto/EntityToDtoConverterTest.java index d08942df67..670922d7d7 100644 --- a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/dto/EntityToDtoConverterTest.java +++ b/jcommune-service/src/test/java/org/jtalks/jcommune/service/dto/EntityToDtoConverterTest.java @@ -12,7 +12,7 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package org.jtalks.jcommune.web.dto; +package org.jtalks.jcommune.service.dto; import org.jtalks.jcommune.model.entity.Topic; import org.jtalks.jcommune.model.entity.TopicTypeName; diff --git a/jcommune-service/src/test/java/org/jtalks/jcommune/service/nontransactional/MailServiceTest.java b/jcommune-service/src/test/java/org/jtalks/jcommune/service/nontransactional/MailServiceTest.java index f7227d1a81..86036277f0 100644 --- a/jcommune-service/src/test/java/org/jtalks/jcommune/service/nontransactional/MailServiceTest.java +++ b/jcommune-service/src/test/java/org/jtalks/jcommune/service/nontransactional/MailServiceTest.java @@ -19,6 +19,8 @@ import org.jtalks.common.model.entity.Property; import org.jtalks.jcommune.model.dao.PropertyDao; import org.jtalks.jcommune.model.entity.*; +import org.jtalks.jcommune.plugin.api.web.dto.TopicDto; +import org.jtalks.jcommune.service.dto.EntityToDtoConverter; import org.jtalks.jcommune.service.exceptions.MailingFailedException; import org.jtalks.jcommune.plugin.api.exceptions.NotFoundException; import org.mockito.ArgumentCaptor; @@ -64,6 +66,8 @@ public class MailServiceTest { private PropertyDao propertyDao; @Mock private MailSender sender; + @Mock + private EntityToDtoConverter converter; private JCommuneProperty notificationsEnabledProperty = SENDING_NOTIFICATIONS_ENABLED; // private MailService service; @@ -73,6 +77,7 @@ public class MailServiceTest { private Branch branch = new Branch("title Branch", "description"); private ArgumentCaptor captor; private ReloadableResourceBundleMessageSource messageSource; + private TopicDto topicDto = new TopicDto(topic); private long topicId = 777; private long branchId = 7; @@ -91,9 +96,11 @@ public void setUp() { messageSource = new ReloadableResourceBundleMessageSource(); messageSource.setBasename("classpath:/org/jtalks/jcommune/service/bundle/TemplatesMessages"); service = new MailService(sender, FROM, velocityEngine, messageSource, notificationsEnabledProperty, - new EscapeTool()); + new EscapeTool(), converter); MimeMessage message = new MimeMessage((Session) null); when(sender.createMimeMessage()).thenReturn(message); + topicDto.setTopicUrl("/topics/" + topicId); + when(converter.convertTopicToDto(any(Topic.class))).thenReturn(topicDto); captor = ArgumentCaptor.forClass(MimeMessage.class); topic.setId(topicId); branch.setId(branchId); diff --git a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/BranchController.java b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/BranchController.java index 9483ec3ba9..07780c0b8c 100644 --- a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/BranchController.java +++ b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/BranchController.java @@ -32,7 +32,7 @@ import org.jtalks.jcommune.web.dto.BranchDto; import org.jtalks.jcommune.plugin.api.web.dto.Breadcrumb; import org.jtalks.jcommune.plugin.api.web.util.BreadcrumbBuilder; -import org.jtalks.jcommune.web.dto.EntityToDtoConverter; +import org.jtalks.jcommune.service.dto.EntityToDtoConverter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.security.access.PermissionEvaluator; diff --git a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/PostController.java b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/PostController.java index 98ac3ee830..c6ae220b28 100644 --- a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/PostController.java +++ b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/PostController.java @@ -21,11 +21,11 @@ import org.jtalks.jcommune.model.entity.Topic; import org.jtalks.jcommune.service.*; import org.jtalks.jcommune.plugin.api.exceptions.NotFoundException; +import org.jtalks.jcommune.service.dto.EntityToDtoConverter; import org.jtalks.jcommune.service.nontransactional.BBCodeService; import org.jtalks.jcommune.service.nontransactional.LocationService; import org.jtalks.jcommune.plugin.api.web.dto.PostDto; import org.jtalks.jcommune.plugin.api.web.dto.TopicDto; -import org.jtalks.jcommune.web.dto.EntityToDtoConverter; import org.jtalks.jcommune.web.dto.json.JsonResponse; import org.jtalks.jcommune.web.dto.json.JsonResponseStatus; import org.jtalks.jcommune.plugin.api.web.util.BreadcrumbBuilder; diff --git a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/TopicController.java b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/TopicController.java index 0111856b34..d1402bbb4a 100644 --- a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/TopicController.java +++ b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/TopicController.java @@ -18,13 +18,11 @@ import org.jtalks.jcommune.model.entity.*; import org.jtalks.jcommune.plugin.api.exceptions.NotFoundException; import org.jtalks.jcommune.service.nontransactional.LocationService; -import org.jtalks.jcommune.web.dto.EntityToDtoConverter; +import org.jtalks.jcommune.service.dto.EntityToDtoConverter; import org.jtalks.jcommune.plugin.api.web.dto.PostDto; import org.jtalks.jcommune.plugin.api.web.dto.TopicDto; import org.jtalks.jcommune.plugin.api.web.util.BreadcrumbBuilder; import org.jtalks.jcommune.service.*; -import org.jtalks.jcommune.service.nontransactional.LocationService; -import org.jtalks.jcommune.web.dto.EntityToDtoConverter; import org.jtalks.jcommune.web.dto.json.JsonResponse; import org.jtalks.jcommune.web.dto.json.JsonResponseStatus; import org.jtalks.jcommune.web.validation.editors.DateTimeEditor; diff --git a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/TopicSearchController.java b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/TopicSearchController.java index 2e5ea1f258..0d560575c8 100644 --- a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/TopicSearchController.java +++ b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/TopicSearchController.java @@ -17,7 +17,7 @@ import org.jtalks.jcommune.model.entity.Topic; import org.jtalks.jcommune.service.LastReadPostService; import org.jtalks.jcommune.service.TopicFetchService; -import org.jtalks.jcommune.web.dto.EntityToDtoConverter; +import org.jtalks.jcommune.service.dto.EntityToDtoConverter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.http.HttpStatus; diff --git a/jcommune-view/jcommune-web-controller/src/main/resources/org/jtalks/jcommune/web/applicationContext-controller.xml b/jcommune-view/jcommune-web-controller/src/main/resources/org/jtalks/jcommune/web/applicationContext-controller.xml index 044c71d3a7..8fc3e15bc8 100644 --- a/jcommune-view/jcommune-web-controller/src/main/resources/org/jtalks/jcommune/web/applicationContext-controller.xml +++ b/jcommune-view/jcommune-web-controller/src/main/resources/org/jtalks/jcommune/web/applicationContext-controller.xml @@ -84,8 +84,5 @@ - - - diff --git a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/BranchControllerTest.java b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/BranchControllerTest.java index fc5d0eff35..4440ec4928 100644 --- a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/BranchControllerTest.java +++ b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/BranchControllerTest.java @@ -26,7 +26,7 @@ import org.jtalks.jcommune.web.dto.BranchDto; import org.jtalks.jcommune.plugin.api.web.dto.Breadcrumb; import org.jtalks.jcommune.plugin.api.web.util.BreadcrumbBuilder; -import org.jtalks.jcommune.web.dto.EntityToDtoConverter; +import org.jtalks.jcommune.service.dto.EntityToDtoConverter; import org.jtalks.jcommune.web.util.ForumStatisticsProvider; import org.mockito.Mock; import org.springframework.data.domain.Page; diff --git a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/PostControllerTest.java b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/PostControllerTest.java index eb7fc70153..043abcc62d 100644 --- a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/PostControllerTest.java +++ b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/PostControllerTest.java @@ -18,11 +18,11 @@ import org.jtalks.jcommune.plugin.api.web.dto.TopicDto; import org.jtalks.jcommune.service.*; import org.jtalks.jcommune.plugin.api.exceptions.NotFoundException; +import org.jtalks.jcommune.service.dto.EntityToDtoConverter; import org.jtalks.jcommune.service.nontransactional.BBCodeService; import org.jtalks.jcommune.service.nontransactional.LocationService; import org.jtalks.jcommune.plugin.api.web.dto.Breadcrumb; import org.jtalks.jcommune.plugin.api.web.dto.PostDto; -import org.jtalks.jcommune.web.dto.EntityToDtoConverter; import org.jtalks.jcommune.web.dto.json.JsonResponse; import org.jtalks.jcommune.plugin.api.web.util.BreadcrumbBuilder; import org.jtalks.jcommune.web.dto.json.JsonResponseStatus; diff --git a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/TopicControllerTest.java b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/TopicControllerTest.java index 36c34e48c4..1af29d6ed4 100644 --- a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/TopicControllerTest.java +++ b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/TopicControllerTest.java @@ -22,7 +22,7 @@ import org.jtalks.jcommune.plugin.api.web.dto.Breadcrumb; import org.jtalks.jcommune.plugin.api.web.dto.TopicDto; import org.jtalks.jcommune.plugin.api.web.util.BreadcrumbBuilder; -import org.jtalks.jcommune.web.dto.EntityToDtoConverter; +import org.jtalks.jcommune.service.dto.EntityToDtoConverter; import org.jtalks.jcommune.web.dto.json.JsonResponse; import org.jtalks.jcommune.web.dto.json.JsonResponseStatus; import org.mockito.Matchers; diff --git a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/TopicSearchControllerTest.java b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/TopicSearchControllerTest.java index a8f79eb631..bb04bc12aa 100644 --- a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/TopicSearchControllerTest.java +++ b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/TopicSearchControllerTest.java @@ -18,7 +18,7 @@ import org.jtalks.jcommune.plugin.api.web.dto.TopicDto; import org.jtalks.jcommune.service.LastReadPostService; import org.jtalks.jcommune.service.TopicFetchService; -import org.jtalks.jcommune.web.dto.EntityToDtoConverter; +import org.jtalks.jcommune.service.dto.EntityToDtoConverter; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.springframework.data.domain.Page; From fa56fc65746b46e79239adfb52c59cf9ee6c88e0 Mon Sep 17 00:00:00 2001 From: Mikhail Stryzhonok Date: Fri, 23 Jan 2015 13:29:25 +0300 Subject: [PATCH 008/433] #JC-2029 Fixed remarks from QA Now date for anonymous user displays considering current locale. JCLocaleResolver is used for detection of locale instead of directly reading current user locale Added "data-" prefix to custom html attribute to prevent w3c validation error --- .../plugin/api/web/locale/JcLocaleResolver.java | 10 ++++++++++ .../plugin/api/web/velocity/tool/JodaDateTimeTool.java | 6 ++++-- .../plugin/questionsandanswers/template/js/question.js | 2 +- .../plugin/questionsandanswers/template/question.vm | 4 ++-- .../controller/QuestionsAndAnswersControllerTest.java | 3 +++ 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/jcommune-plugin-api/src/main/java/org/jtalks/jcommune/plugin/api/web/locale/JcLocaleResolver.java b/jcommune-plugin-api/src/main/java/org/jtalks/jcommune/plugin/api/web/locale/JcLocaleResolver.java index 45a92b8727..e5b209a19b 100644 --- a/jcommune-plugin-api/src/main/java/org/jtalks/jcommune/plugin/api/web/locale/JcLocaleResolver.java +++ b/jcommune-plugin-api/src/main/java/org/jtalks/jcommune/plugin/api/web/locale/JcLocaleResolver.java @@ -68,4 +68,14 @@ public Locale resolveLocale(HttpServletRequest request) { request.setAttribute(LOCALE_REQUEST_ATTRIBUTE_NAME, locale); return locale; } + + /** + * Method delegated following DRY principle. Default locale should be determined in single place. In our case - + * in xml configuration. + * {@inheritDoc} + */ + @Override + public Locale getDefaultLocale() { + return super.getDefaultLocale(); + } } diff --git a/jcommune-plugin-api/src/main/java/org/jtalks/jcommune/plugin/api/web/velocity/tool/JodaDateTimeTool.java b/jcommune-plugin-api/src/main/java/org/jtalks/jcommune/plugin/api/web/velocity/tool/JodaDateTimeTool.java index 3dc3c6e429..888ebf47c2 100644 --- a/jcommune-plugin-api/src/main/java/org/jtalks/jcommune/plugin/api/web/velocity/tool/JodaDateTimeTool.java +++ b/jcommune-plugin-api/src/main/java/org/jtalks/jcommune/plugin/api/web/velocity/tool/JodaDateTimeTool.java @@ -18,6 +18,7 @@ import org.joda.time.DateTimeZone; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; +import org.jtalks.jcommune.plugin.api.web.locale.JcLocaleResolver; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; @@ -38,9 +39,11 @@ public class JodaDateTimeTool { private DateTimeFormatter formatter = DateTimeFormat.forPattern(DATE_FORMAT_PATTERN); private long offset = DEFAULT_OFFSET; + private Locale locale = Locale.ENGLISH; public JodaDateTimeTool(HttpServletRequest request) { if (request != null) { + locale = JcLocaleResolver.getInstance().resolveLocale(request); Cookie[] cookies = request.getCookies(); if (cookies != null) { for (Cookie cookie : cookies) { @@ -58,10 +61,9 @@ public JodaDateTimeTool(HttpServletRequest request) { * Example: 01 Jan 2011 05:13 * * @param dateTime Date and time to be converted to string - * @param locale locale to be used * @return dateTime string representation */ - public String format(DateTime dateTime, Locale locale) { + public String format(DateTime dateTime) { if (dateTime == null) { return ""; } diff --git a/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/js/question.js b/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/js/question.js index a2a9cb00b4..3666636663 100644 --- a/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/js/question.js +++ b/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/js/question.js @@ -145,7 +145,7 @@ function showErrorPopUp(postId, message) { * @return {boolean} true if post with specified id was created by current user, false otherwise */ function isOwnPost(postId) { - return $("#" + postId + "-rating").attr("viewer-is-post-owner") == "true"; + return $("#" + postId + "-rating").attr("data-viewer-is-post-owner") == "true"; } /** diff --git a/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/question.vm b/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/question.vm index 78d7f69df6..e4c872e739 100644 --- a/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/question.vm +++ b/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/question.vm @@ -125,7 +125,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
$rating + data-viewer-is-post-owner="$own">$rating
@@ -190,7 +190,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- ${dateTool.format(${post.creationDate}, ${currentUser.language.locale})} + ${dateTool.format(${post.creationDate})}

diff --git a/jcommune-plugins/questions-n-answers-plugin/src/test/java/org/jtalks/jcommune/plugin/questionsandanswers/controller/QuestionsAndAnswersControllerTest.java b/jcommune-plugins/questions-n-answers-plugin/src/test/java/org/jtalks/jcommune/plugin/questionsandanswers/controller/QuestionsAndAnswersControllerTest.java index 8e07a050ae..be583c4fff 100644 --- a/jcommune-plugins/questions-n-answers-plugin/src/test/java/org/jtalks/jcommune/plugin/questionsandanswers/controller/QuestionsAndAnswersControllerTest.java +++ b/jcommune-plugins/questions-n-answers-plugin/src/test/java/org/jtalks/jcommune/plugin/questionsandanswers/controller/QuestionsAndAnswersControllerTest.java @@ -24,6 +24,7 @@ import org.jtalks.jcommune.plugin.api.service.*; import org.jtalks.jcommune.plugin.api.web.dto.PostDto; import org.jtalks.jcommune.plugin.api.web.dto.TopicDto; +import org.jtalks.jcommune.plugin.api.web.locale.JcLocaleResolver; import org.jtalks.jcommune.plugin.api.web.util.BreadcrumbBuilder; import org.jtalks.jcommune.plugin.questionsandanswers.QuestionsAndAnswersPlugin; import org.mockito.Mock; @@ -105,6 +106,8 @@ public void init() { when(locationService.getUsersViewing(any(Entity.class))).thenReturn(Collections.EMPTY_LIST); doReturn(content).when(controller).getMergedTemplate(any(VelocityEngine.class), anyString(), anyString(), anyMap()); + when(userReader.getCurrentUser()).thenReturn(new JCUser("name", "example@mail.ru", "pwd")); + ((JcLocaleResolver)JcLocaleResolver.getInstance()).setUserReader(userReader); } @Test From 783cd52fc0b11f65af53a5aa7114db7a8eb224a8 Mon Sep 17 00:00:00 2001 From: Necros Date: Thu, 22 Jan 2015 20:36:41 +0300 Subject: [PATCH 009/433] JC-2028 Fix incorrect url in breadcrumb I deleted wrong part of url in breadcrumb section Also this bug no longer causes the error 400 when changing language after following a wrong link --- .../src/main/webapp/WEB-INF/tags/breadcrumb.tag | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/tags/breadcrumb.tag b/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/tags/breadcrumb.tag index 8e2978c7e4..245ac39974 100644 --- a/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/tags/breadcrumb.tag +++ b/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/tags/breadcrumb.tag @@ -31,7 +31,7 @@ <%--create root breadcrumb--%> - + From f085d9fa928f1ffb6aa46f39fadd95b02c7e7999 Mon Sep 17 00:00:00 2001 From: Andrei Vikulov Date: Sat, 24 Jan 2015 10:04:17 +0300 Subject: [PATCH 010/433] JC-1991 CSS styles for errors are different on login page and pop-up login window opened on login page --- .../src/main/webapp/WEB-INF/jsp/login.jsp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/jsp/login.jsp b/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/jsp/login.jsp index ba2bd66c50..4e86ecce03 100644 --- a/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/jsp/login.jsp +++ b/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/jsp/login.jsp @@ -40,10 +40,8 @@
- - - - + +
@@ -51,7 +49,7 @@
- + From 2f0e8402448355eb87ce02032dd8829720493aef Mon Sep 17 00:00:00 2001 From: Andrei Vikulov Date: Sun, 25 Jan 2015 12:35:28 +0300 Subject: [PATCH 011/433] JC-1991 CSS styles for errors are different on login page and pop-up login window opened on login page --- .../jcommune-web-view/src/main/webapp/WEB-INF/jsp/login.jsp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/jsp/login.jsp b/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/jsp/login.jsp index 4e86ecce03..f588758b08 100644 --- a/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/jsp/login.jsp +++ b/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/jsp/login.jsp @@ -40,8 +40,7 @@
- - +
@@ -49,7 +48,7 @@
- + From 47bfa50212d1448cb0411b2e91602533d9c996ff Mon Sep 17 00:00:00 2001 From: Vladimir Kamensky Date: Mon, 26 Jan 2015 11:22:09 +0200 Subject: [PATCH 012/433] JC-2004 TypeMismatchException to be DEBUG Has been deleted redundant checking of log-level. Also has been changed order of displaying log messages: firstly - INFO, secondary - DEBUG (stack-trace) --- .../jcommune/web/exception/PrettyLogExceptionResolver.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/exception/PrettyLogExceptionResolver.java b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/exception/PrettyLogExceptionResolver.java index 1d10a0f902..4754efe797 100644 --- a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/exception/PrettyLogExceptionResolver.java +++ b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/exception/PrettyLogExceptionResolver.java @@ -95,10 +95,8 @@ private String getLogMessage(HttpServletRequest request, Exception ex) { public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) { if (shouldApplyTo(request, handler)) { - if(logger.isDebugEnabled()) { - logger.debug(request,ex); - } logException(ex, request); + logger.debug(request,ex); prepareResponse(ex, response); return doResolveException(request, response, handler, ex); } From 8fa4407939cc5dfb15b07abe3be8cc3b0983c5db Mon Sep 17 00:00:00 2001 From: Mikhail Stryzhonok Date: Wed, 28 Jan 2015 11:54:09 +0300 Subject: [PATCH 013/433] #JC-2016 On create topic page valid fields not highlighted more Corrected script which adds error class to fields. Now it mark fields as incorrect only when they have element with "help-inline" class below Added highlighting of username field on login page Login error message on login page now placed below password field --- .../jcommune-web-view/src/main/webapp/WEB-INF/jsp/login.jsp | 6 +++++- .../src/main/webapp/resources/javascript/app/errorUtils.js | 4 +--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/jsp/login.jsp b/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/jsp/login.jsp index f588758b08..d3110360b4 100644 --- a/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/jsp/login.jsp +++ b/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/jsp/login.jsp @@ -41,6 +41,10 @@
+ <%-- Needed to highlight username input when login error occured--%> + + +
@@ -50,7 +54,7 @@
- + diff --git a/jcommune-view/jcommune-web-view/src/main/webapp/resources/javascript/app/errorUtils.js b/jcommune-view/jcommune-web-view/src/main/webapp/resources/javascript/app/errorUtils.js index 2222ad649b..dae17196de 100644 --- a/jcommune-view/jcommune-web-view/src/main/webapp/resources/javascript/app/errorUtils.js +++ b/jcommune-view/jcommune-web-view/src/main/webapp/resources/javascript/app/errorUtils.js @@ -20,9 +20,7 @@ ErrorUtils.patternForErrorRow = '${message}'; /** Add necessary classes to page elements to highlight errors for current design */ ErrorUtils.fixErrorHighlighting = function() { - if ($('.help-inline').closest('div.control-group').length) { - $('div.control-group:not(:has(.rememberme-lbl))').addClass('error'); - } + $('.help-inline').closest('div.control-group').addClass('error'); } /** Add required classes to highlight errors in specified input for current design From c886b2d0e51e0cfdedc95c30a4a39ebbef242214 Mon Sep 17 00:00:00 2001 From: standpoint Date: Wed, 28 Jan 2015 12:21:51 +0200 Subject: [PATCH 014/433] JC-2004 TypeMismatchException to be DEBUG Has been added test method for checking order of resolveException(...) execution - are there INFO message with exception details before the DEBUG message at the logs? --- .../PrettyLogExceptionResolverTest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/exception/PrettyLogExceptionResolverTest.java b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/exception/PrettyLogExceptionResolverTest.java index 46b160a565..f900c33100 100644 --- a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/exception/PrettyLogExceptionResolverTest.java +++ b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/exception/PrettyLogExceptionResolverTest.java @@ -17,8 +17,10 @@ import org.apache.commons.logging.Log; import org.jtalks.jcommune.plugin.api.exceptions.NotFoundException; +import org.mockito.InOrder; import org.springframework.beans.TypeMismatchException; import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.security.access.AccessDeniedException; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.util.ReflectionUtils; @@ -95,6 +97,21 @@ public void testLogExceptionWithoutNotFoundException() throws Exception { verify(mockLog, times(1)).info(anyString()); } + @Test + public void testResolveExceptionFirstlyLogExceptionThenDebug() throws Exception { + Log mockLog = replaceLoggerWithMock(prettyLogExceptionResolver); + Exception exception = new Exception(); + MockHttpServletRequest request = new MockHttpServletRequest("GET", "/"); + MockHttpServletResponse response = new MockHttpServletResponse(); + Object handler = new Object(); + request.setContent("".getBytes()); + prettyLogExceptionResolver.resolveException(request, response, handler, exception); + + InOrder inOrder = inOrder(mockLog); + inOrder.verify(mockLog, times(1)).info(anyString()); + inOrder.verify(mockLog, times(1)).debug(request,exception); + } + private Log replaceLoggerWithMock(PrettyLogExceptionResolver resolver) throws Exception { Log mockLog = mock(Log.class); Field loggerField = ReflectionUtils.findField(PrettyLogExceptionResolver.class, "logger"); From b0b0ec16bf157ba0b7974602de0998ff10b92cb2 Mon Sep 17 00:00:00 2001 From: jenkins Date: Mon, 2 Feb 2015 22:15:34 +0100 Subject: [PATCH 015/433] [maven-release-plugin] prepare release jcommune-2.14 --- jcommune-model/pom.xml | 2 +- jcommune-plugin-api/pom.xml | 2 +- jcommune-plugins/jcommune-dummy-plugin/pom.xml | 2 +- jcommune-plugins/kaptcha-plugin/pom.xml | 2 +- jcommune-plugins/pom.xml | 4 ++-- jcommune-plugins/poulpe-auth-plugin/pom.xml | 2 +- jcommune-plugins/questions-n-answers-plugin/pom.xml | 2 +- jcommune-service/pom.xml | 2 +- jcommune-view/jcommune-web-controller/pom.xml | 2 +- jcommune-view/jcommune-web-view/pom.xml | 2 +- jcommune-view/pom.xml | 2 +- pom.xml | 4 ++-- 12 files changed, 14 insertions(+), 14 deletions(-) diff --git a/jcommune-model/pom.xml b/jcommune-model/pom.xml index 80d3d54faa..0fc713d8ea 100644 --- a/jcommune-model/pom.xml +++ b/jcommune-model/pom.xml @@ -4,7 +4,7 @@ jcommune org.jtalks.jcommune - 2.14-SNAPSHOT + 2.14 jcommune-model ${project.artifactId} diff --git a/jcommune-plugin-api/pom.xml b/jcommune-plugin-api/pom.xml index d0212cc37e..b9ac4535a1 100644 --- a/jcommune-plugin-api/pom.xml +++ b/jcommune-plugin-api/pom.xml @@ -4,7 +4,7 @@ jcommune org.jtalks.jcommune - 2.14-SNAPSHOT + 2.14 jcommune-plugin-api diff --git a/jcommune-plugins/jcommune-dummy-plugin/pom.xml b/jcommune-plugins/jcommune-dummy-plugin/pom.xml index 3d73b45042..ebc8142d97 100644 --- a/jcommune-plugins/jcommune-dummy-plugin/pom.xml +++ b/jcommune-plugins/jcommune-dummy-plugin/pom.xml @@ -5,7 +5,7 @@ jcommune-plugins org.jtalks.jcommune - 2.14-SNAPSHOT + 2.14 jcommune-dummy-plugin diff --git a/jcommune-plugins/kaptcha-plugin/pom.xml b/jcommune-plugins/kaptcha-plugin/pom.xml index c4d95e0d7a..528fa74342 100644 --- a/jcommune-plugins/kaptcha-plugin/pom.xml +++ b/jcommune-plugins/kaptcha-plugin/pom.xml @@ -4,7 +4,7 @@ jcommune-plugins org.jtalks.jcommune - 2.14-SNAPSHOT + 2.14 kaptcha-plugin diff --git a/jcommune-plugins/pom.xml b/jcommune-plugins/pom.xml index 7738d32443..2018603748 100644 --- a/jcommune-plugins/pom.xml +++ b/jcommune-plugins/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.jtalks.jcommune jcommune-plugins - 2.14-SNAPSHOT + 2.14 pom @@ -195,7 +195,7 @@ scm:git:git@github.com:jtalks-org/jcommune.git scm:git:git@github.com:jtalks-org/jcommune.git scm:git:git@github.com:jtalks-org/jcommune.git - HEAD + jcommune-2.14 diff --git a/jcommune-plugins/poulpe-auth-plugin/pom.xml b/jcommune-plugins/poulpe-auth-plugin/pom.xml index cdc416e350..07989587c8 100644 --- a/jcommune-plugins/poulpe-auth-plugin/pom.xml +++ b/jcommune-plugins/poulpe-auth-plugin/pom.xml @@ -4,7 +4,7 @@ jcommune-plugins org.jtalks.jcommune - 2.14-SNAPSHOT + 2.14 poulpe-auth-plugin diff --git a/jcommune-plugins/questions-n-answers-plugin/pom.xml b/jcommune-plugins/questions-n-answers-plugin/pom.xml index ef16452979..5e3ba44a62 100644 --- a/jcommune-plugins/questions-n-answers-plugin/pom.xml +++ b/jcommune-plugins/questions-n-answers-plugin/pom.xml @@ -4,7 +4,7 @@ jcommune-plugins org.jtalks.jcommune - 2.14-SNAPSHOT + 2.14 questions-n-answers-plugin diff --git a/jcommune-service/pom.xml b/jcommune-service/pom.xml index 0383240566..3cde5da468 100644 --- a/jcommune-service/pom.xml +++ b/jcommune-service/pom.xml @@ -4,7 +4,7 @@ jcommune org.jtalks.jcommune - 2.14-SNAPSHOT + 2.14 jcommune-service ${project.artifactId} diff --git a/jcommune-view/jcommune-web-controller/pom.xml b/jcommune-view/jcommune-web-controller/pom.xml index a26a083fc9..3177fb20f3 100644 --- a/jcommune-view/jcommune-web-controller/pom.xml +++ b/jcommune-view/jcommune-web-controller/pom.xml @@ -4,7 +4,7 @@ jcommune-view org.jtalks.jcommune - 2.14-SNAPSHOT + 2.14 jcommune-web-controller ${project.artifactId} diff --git a/jcommune-view/jcommune-web-view/pom.xml b/jcommune-view/jcommune-web-view/pom.xml index ecfe90dc2c..60e7f42145 100644 --- a/jcommune-view/jcommune-web-view/pom.xml +++ b/jcommune-view/jcommune-web-view/pom.xml @@ -4,7 +4,7 @@ jcommune-view org.jtalks.jcommune - 2.14-SNAPSHOT + 2.14 jcommune-web-view war diff --git a/jcommune-view/pom.xml b/jcommune-view/pom.xml index c01c1a86ac..77a70929a6 100644 --- a/jcommune-view/pom.xml +++ b/jcommune-view/pom.xml @@ -4,7 +4,7 @@ jcommune org.jtalks.jcommune - 2.14-SNAPSHOT + 2.14 jcommune-view pom diff --git a/pom.xml b/pom.xml index 8477583462..59c8da98e3 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.jtalks.jcommune jcommune pom - 2.14-SNAPSHOT + 2.14 ${project.artifactId} jcommune-model @@ -548,7 +548,7 @@ scm:git:git@github.com:jtalks-org/jcommune.git scm:git:git@github.com:jtalks-org/jcommune.git scm:git:git@github.com:jtalks-org/jcommune.git - HEAD + jcommune-2.14 From 8becd0a428c7c58c33f02252ebbd796dd801501e Mon Sep 17 00:00:00 2001 From: jenkins Date: Mon, 2 Feb 2015 22:15:38 +0100 Subject: [PATCH 016/433] [maven-release-plugin] prepare for next development iteration --- jcommune-model/pom.xml | 2 +- jcommune-plugin-api/pom.xml | 2 +- jcommune-plugins/jcommune-dummy-plugin/pom.xml | 2 +- jcommune-plugins/kaptcha-plugin/pom.xml | 2 +- jcommune-plugins/pom.xml | 4 ++-- jcommune-plugins/poulpe-auth-plugin/pom.xml | 2 +- jcommune-plugins/questions-n-answers-plugin/pom.xml | 2 +- jcommune-service/pom.xml | 2 +- jcommune-view/jcommune-web-controller/pom.xml | 2 +- jcommune-view/jcommune-web-view/pom.xml | 2 +- jcommune-view/pom.xml | 2 +- pom.xml | 4 ++-- 12 files changed, 14 insertions(+), 14 deletions(-) diff --git a/jcommune-model/pom.xml b/jcommune-model/pom.xml index 0fc713d8ea..e1d10383fd 100644 --- a/jcommune-model/pom.xml +++ b/jcommune-model/pom.xml @@ -4,7 +4,7 @@ jcommune org.jtalks.jcommune - 2.14 + 3.0-SNAPSHOT jcommune-model ${project.artifactId} diff --git a/jcommune-plugin-api/pom.xml b/jcommune-plugin-api/pom.xml index b9ac4535a1..130626bcb1 100644 --- a/jcommune-plugin-api/pom.xml +++ b/jcommune-plugin-api/pom.xml @@ -4,7 +4,7 @@ jcommune org.jtalks.jcommune - 2.14 + 3.0-SNAPSHOT jcommune-plugin-api diff --git a/jcommune-plugins/jcommune-dummy-plugin/pom.xml b/jcommune-plugins/jcommune-dummy-plugin/pom.xml index ebc8142d97..345a6a9e80 100644 --- a/jcommune-plugins/jcommune-dummy-plugin/pom.xml +++ b/jcommune-plugins/jcommune-dummy-plugin/pom.xml @@ -5,7 +5,7 @@ jcommune-plugins org.jtalks.jcommune - 2.14 + 3.0-SNAPSHOT jcommune-dummy-plugin diff --git a/jcommune-plugins/kaptcha-plugin/pom.xml b/jcommune-plugins/kaptcha-plugin/pom.xml index 528fa74342..f1be162adb 100644 --- a/jcommune-plugins/kaptcha-plugin/pom.xml +++ b/jcommune-plugins/kaptcha-plugin/pom.xml @@ -4,7 +4,7 @@ jcommune-plugins org.jtalks.jcommune - 2.14 + 3.0-SNAPSHOT kaptcha-plugin diff --git a/jcommune-plugins/pom.xml b/jcommune-plugins/pom.xml index 2018603748..99c636a37b 100644 --- a/jcommune-plugins/pom.xml +++ b/jcommune-plugins/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.jtalks.jcommune jcommune-plugins - 2.14 + 3.0-SNAPSHOT pom @@ -195,7 +195,7 @@ scm:git:git@github.com:jtalks-org/jcommune.git scm:git:git@github.com:jtalks-org/jcommune.git scm:git:git@github.com:jtalks-org/jcommune.git - jcommune-2.14 + HEAD diff --git a/jcommune-plugins/poulpe-auth-plugin/pom.xml b/jcommune-plugins/poulpe-auth-plugin/pom.xml index 07989587c8..4b2f0a1fe0 100644 --- a/jcommune-plugins/poulpe-auth-plugin/pom.xml +++ b/jcommune-plugins/poulpe-auth-plugin/pom.xml @@ -4,7 +4,7 @@ jcommune-plugins org.jtalks.jcommune - 2.14 + 3.0-SNAPSHOT poulpe-auth-plugin diff --git a/jcommune-plugins/questions-n-answers-plugin/pom.xml b/jcommune-plugins/questions-n-answers-plugin/pom.xml index 5e3ba44a62..ad5a7a7efc 100644 --- a/jcommune-plugins/questions-n-answers-plugin/pom.xml +++ b/jcommune-plugins/questions-n-answers-plugin/pom.xml @@ -4,7 +4,7 @@ jcommune-plugins org.jtalks.jcommune - 2.14 + 3.0-SNAPSHOT questions-n-answers-plugin diff --git a/jcommune-service/pom.xml b/jcommune-service/pom.xml index 3cde5da468..c9a37bf955 100644 --- a/jcommune-service/pom.xml +++ b/jcommune-service/pom.xml @@ -4,7 +4,7 @@ jcommune org.jtalks.jcommune - 2.14 + 3.0-SNAPSHOT jcommune-service ${project.artifactId} diff --git a/jcommune-view/jcommune-web-controller/pom.xml b/jcommune-view/jcommune-web-controller/pom.xml index 3177fb20f3..8afce411e2 100644 --- a/jcommune-view/jcommune-web-controller/pom.xml +++ b/jcommune-view/jcommune-web-controller/pom.xml @@ -4,7 +4,7 @@ jcommune-view org.jtalks.jcommune - 2.14 + 3.0-SNAPSHOT jcommune-web-controller ${project.artifactId} diff --git a/jcommune-view/jcommune-web-view/pom.xml b/jcommune-view/jcommune-web-view/pom.xml index 60e7f42145..b96ae5c3ab 100644 --- a/jcommune-view/jcommune-web-view/pom.xml +++ b/jcommune-view/jcommune-web-view/pom.xml @@ -4,7 +4,7 @@ jcommune-view org.jtalks.jcommune - 2.14 + 3.0-SNAPSHOT jcommune-web-view war diff --git a/jcommune-view/pom.xml b/jcommune-view/pom.xml index 77a70929a6..a85930d2d7 100644 --- a/jcommune-view/pom.xml +++ b/jcommune-view/pom.xml @@ -4,7 +4,7 @@ jcommune org.jtalks.jcommune - 2.14 + 3.0-SNAPSHOT jcommune-view pom diff --git a/pom.xml b/pom.xml index 59c8da98e3..3f4833d7f0 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.jtalks.jcommune jcommune pom - 2.14 + 3.0-SNAPSHOT ${project.artifactId} jcommune-model @@ -548,7 +548,7 @@ scm:git:git@github.com:jtalks-org/jcommune.git scm:git:git@github.com:jtalks-org/jcommune.git scm:git:git@github.com:jtalks-org/jcommune.git - jcommune-2.14 + HEAD From db73baee932bb134b96ae5aa20162d2506320ed7 Mon Sep 17 00:00:00 2001 From: Stanislav Date: Mon, 26 Jan 2015 19:21:45 +0300 Subject: [PATCH 017/433] JC-2104 Update Delete Code Review dialog message Now if a user deletes an code review he sees propper warning message. I also added a translation of messages in all languages. --- .../org/jtalks/jcommune/web/view/messages_en.properties | 1 + .../org/jtalks/jcommune/web/view/messages_es.properties | 1 + .../org/jtalks/jcommune/web/view/messages_ru.properties | 1 + .../org/jtalks/jcommune/web/view/messages_uk.properties | 1 + .../src/main/webapp/WEB-INF/jsp/topic/postList.jsp | 3 +++ 5 files changed, 7 insertions(+) diff --git a/jcommune-view/jcommune-web-view/src/main/resources/org/jtalks/jcommune/web/view/messages_en.properties b/jcommune-view/jcommune-web-view/src/main/resources/org/jtalks/jcommune/web/view/messages_en.properties index d924ea3de9..c4668d7a3d 100644 --- a/jcommune-view/jcommune-web-view/src/main/resources/org/jtalks/jcommune/web/view/messages_en.properties +++ b/jcommune-view/jcommune-web-view/src/main/resources/org/jtalks/jcommune/web/view/messages_en.properties @@ -89,6 +89,7 @@ label.deleteCommentConfirmation=Are you sure you want to delete this Comment? label.deleteTopicConfirmation=Are you sure you want to delete the first post (topic would be deleted too)? label.deleteContactConfirmation=Delete this contact? label.deleteContactFailture=Due to an error contact has not been deleted +label.deleteCodeReviewConfirmation=Are you sure you want to delete code review (comments would be deleted too)? label.deletePMConfirmation=Are you sure you want to delete checked messages? label.deletePMGroupConfirmation=Are you sure you want to delete checked messages? %s message(s) will be deleted #login and register page diff --git a/jcommune-view/jcommune-web-view/src/main/resources/org/jtalks/jcommune/web/view/messages_es.properties b/jcommune-view/jcommune-web-view/src/main/resources/org/jtalks/jcommune/web/view/messages_es.properties index fb27d5c0dc..c873c13910 100644 --- a/jcommune-view/jcommune-web-view/src/main/resources/org/jtalks/jcommune/web/view/messages_es.properties +++ b/jcommune-view/jcommune-web-view/src/main/resources/org/jtalks/jcommune/web/view/messages_es.properties @@ -462,3 +462,4 @@ label.branch.header.lastMessage.tooltip=Ver \u00FAltimo mensaje label.topic.section.in=en label.tips.close=Cerrar este tema label.tips.open=Reabrir este tema +label.deleteCodeReviewConfirmation=\u00bfEst\u00e1s seguro de que deseas eliminar la revisi\u00f3n de c\u00f3digo?(los comentarios tambi\u00e9n ser\u00e1n eliminados). diff --git a/jcommune-view/jcommune-web-view/src/main/resources/org/jtalks/jcommune/web/view/messages_ru.properties b/jcommune-view/jcommune-web-view/src/main/resources/org/jtalks/jcommune/web/view/messages_ru.properties index ea54dd0679..607373aee6 100644 --- a/jcommune-view/jcommune-web-view/src/main/resources/org/jtalks/jcommune/web/view/messages_ru.properties +++ b/jcommune-view/jcommune-web-view/src/main/resources/org/jtalks/jcommune/web/view/messages_ru.properties @@ -460,3 +460,4 @@ label.branch.header.lastMessage.tooltip=\u041F\u0435\u0440\u0435\u0439\u0442\u04 label.topic.section.in=\u0432 label.tips.close=\u0417\u0430\u043A\u0440\u044B\u0442\u044C \u0442\u0435\u043C\u0443 label.tips.open=\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0442\u0435\u043C\u0443 +label.deleteCodeReviewConfirmation=\u0412\u044B \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u043E \u0445\u043E\u0442\u0438\u0442\u0435 \u0443\u0434\u0430\u043B\u0438\u0442\u044C \u0440\u0435\u0446\u0435\u043D\u0437\u0438\u044E \u043A\u043E\u0434\u0430 (\u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0438 \u0442\u043E\u0436\u0435 \u0431\u0443\u0434\u0443\u0442 \u0443\u0434\u0430\u043B\u0435\u043D\u044B)? diff --git a/jcommune-view/jcommune-web-view/src/main/resources/org/jtalks/jcommune/web/view/messages_uk.properties b/jcommune-view/jcommune-web-view/src/main/resources/org/jtalks/jcommune/web/view/messages_uk.properties index b749da0834..650cd90323 100644 --- a/jcommune-view/jcommune-web-view/src/main/resources/org/jtalks/jcommune/web/view/messages_uk.properties +++ b/jcommune-view/jcommune-web-view/src/main/resources/org/jtalks/jcommune/web/view/messages_uk.properties @@ -462,3 +462,4 @@ label.branch.header.lastMessage.tooltip=\u041F\u0435\u0440\u0435\u0439\u0442\u04 label.topic.section.in=\u0432 label.tips.close=\u0417\u0430\u043A\u0440\u0438\u0442\u0438 \u0442\u0435\u043C\u0443 label.tips.open=\u0412\u0456\u0434\u043A\u0440\u0438\u0442\u0438 \u0442\u0435\u043C\u0443 +label.deleteCodeReviewConfirmation=\u0412\u0438 \u0434\u0456\u0439\u0441\u043d\u043e \u0431\u0430\u0436\u0430\u0454\u0442\u0435 \u0432\u0438\u0434\u0430\u043b\u0438\u0442\u0438 \u0440\u0435\u0446\u0435\u043d\u0437\u0456\u044e \u043a\u043e\u0434\u0443 (\u043a\u043e\u043c\u0435\u043d\u0442\u0430\u0440\u0456 \u0442\u0430\u043a\u043e\u0436 \u0431\u0443\u0434\u0435 \u0432\u0438\u0434\u0430\u043b\u0435\u043d\u043e)? diff --git a/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/jsp/topic/postList.jsp b/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/jsp/topic/postList.jsp index 44b82c5e7e..36815229c5 100644 --- a/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/jsp/topic/postList.jsp +++ b/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/jsp/topic/postList.jsp @@ -155,6 +155,9 @@ + + + <%-- url to delete & edit post --%> From d203e95c0e8a45544a61a636208812354405bb6b Mon Sep 17 00:00:00 2001 From: Mikhail Stryzhonok Date: Thu, 5 Feb 2015 14:38:53 +0300 Subject: [PATCH 018/433] #JC-2099 Increased threshold of rating style changing Now new rating style applied if new rating value between 3 and -3 --- .../plugin/questionsandanswers/template/js/question.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/js/question.js b/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/js/question.js index 3666636663..97a3a87ca3 100644 --- a/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/js/question.js +++ b/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/js/question.js @@ -159,7 +159,8 @@ function changeRating(ratingSpan, value) { rating = rating + value; ratingSpan.text(rating); // we need apply new style only if rating state changed - if ((rating > - 2) && (rating < 2)) { + // but rating value may changed by 2 if user revotes for post + if ((rating > - 3) && (rating < 3)) { applyRatingStyle(ratingSpan, rating); } } From 50587759c50e17de2dbfa8b7f2512db7ace9b103 Mon Sep 17 00:00:00 2001 From: Stanislav Date: Mon, 2 Feb 2015 14:39:08 +0300 Subject: [PATCH 019/433] JC-2122 Fix empty field after validation error in profile I added data for fields "Registration date", "Last login" and "Post Count". Now the data is sent over hidden form fields if there is a validation error. Earlier the form submitted the DTO with empty fields to controller and controller filled new form with empty data. I added missing fields to userProfile.jsp for fix it. --- .../src/main/webapp/WEB-INF/jsp/editUserProfile.jsp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/jsp/editUserProfile.jsp b/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/jsp/editUserProfile.jsp index a5405c13ea..0d74de562c 100644 --- a/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/jsp/editUserProfile.jsp +++ b/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/jsp/editUserProfile.jsp @@ -21,6 +21,9 @@ <%@ taglib prefix="jtalks" uri="http://www.jtalks.org/tags" %> + + + #if($post.comments.size() > $shownComments) -
- - -
+
+ #else + + + #if($canLeavePosts) -
+
${messages.getString("label.add.comment")}
#end -
- +
+ diff --git a/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/js/question.js b/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/js/question.js index 97a3a87ca3..898671ce62 100644 --- a/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/js/question.js +++ b/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/js/question.js @@ -18,6 +18,8 @@ $(function () { $('.comment-prompt').click(function (e) { e.preventDefault(); + var postId = $(this).attr("id").split("-")[1]; + toggleCommentsFor(postId); $(this).hide(); $(this).next(".comment-container").show(); $(this).next(".comment-container").children(".comment-textarea").focus(); @@ -32,16 +34,8 @@ $(function () { $('.expand').click(function(e){ e.preventDefault(); - $(this).parent().prev(".comment-list").children(".togglable").toggle(); - var buttons = $(this).parent().children(".togglable"); - buttons.toggle(); - buttons.focus(); - var thirdComment = $(this).parent().prev(".comment-list").children(".hiddenBorder"); - if (thirdComment.hasClass("bordered")) { - thirdComment.removeClass("bordered"); - } else { - thirdComment.addClass("bordered"); - } + var postId = $(this).attr("data-postId"); + toggleCommentsFor(postId); }); $(".vote-up").mouseup(voteUpHandler); @@ -56,6 +50,29 @@ $(function () { if ($('#answerForm .error:visible').length > 0) { $('#postBody').focus(); } + + $('.comment-submit').click(function (e){ + var commentDto = {}; + var postId = $(this).attr('data-post-id'); + commentDto.postId = postId; + commentDto.body = $("#commentBody-" + postId).val(); + console.log(commentDto); + $.ajax({ + url: baseUrl + "/topics/question/newcomment", + type: "POST", + contentType: "application/json", + async: false, + data: JSON.stringify(commentDto), + success: function(data) { + console.log(data); + hideCommentForm(postId); + addCommentToPost(postId, data.result); + }, + error: function() { + console.log("error"); + } + }); + }); }); var voteUpHandler = function voteUp(e) { @@ -263,4 +280,84 @@ function hideEmptyCommentTextArea() { $(this).parent().children(".comment-prompt").show(); } }); +} + +/** + * Hides comment form for post with specified id + * + * @param postId id of the post to hide comment form + */ +function hideCommentForm(postId) { + $("#commentForm-" + postId).hide(); + $("#commentBody-" + postId).val(""); + $("#prompt-" + postId).show(); +} + +function addCommentToPost(postId, comment) { + var commentList = $("#comments-" + postId).children(); + if (commentList.length != 0) { + $(commentList[commentList.length - 1]).addClass("bordered"); + } + if(commentList.length == 3) { + $("#btns-" + postId).show(); + $($("#btns-" + postId).children()[0]).hide(); + } + $("#comments-" + postId).append(getCommentHtml(comment)); + if (commentList.length > 2) { + applyCommentsCssClasses(postId); + } +} + +function getCommentHtml(comment) { + return "
" + + "
" + + "" + + "
" + + " " + + "
" + + "
" + comment.formattedCreationDate + "
" + + "
" + comment.body + "
"; +} + +function toggleCommentsFor(postId) { + console.log($("#comments-" + postId).children().not(":visible").length); + var commentList = $("#comments-" + postId); + commentList.children(".togglable").toggle(); + var buttons = $("#btns-" + postId); + buttons.children(".togglable").toggle(); + buttons.focus(); + var thirdComment = commentList.children(".hiddenBorder"); + if (thirdComment.hasClass("bordered")) { + thirdComment.removeClass("bordered"); + } else { + thirdComment.addClass("bordered"); + } +} + +function isCommentsHidden(postId) { + return $("#comments-" + postId).children().not(":visible").length == 0; +} + +function applyCommentsCssClasses(postId) { + var i = 0; + $("#comments-" + postId).children().each(function() { + $(this).removeClass("bordered"); + $(this).removeClass("togglable"); + $(this).removeClass("hiddenBorder"); + if (i != $("#comments-" + postId).children().length - 1) { + $(this).addClass("bordered"); + console.log(i + " bordered"); + } + if (i == 2) { + $(this).addClass("hiddenBorder"); + console.log(i + " hiddenBorder"); + } + if (i > 2) { + $(this).addClass("togglable"); + console.log(i + " togglable"); + } + i ++; + }); } \ No newline at end of file diff --git a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/AdministrationController.java b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/AdministrationController.java index d9b95b01b8..12ed135421 100644 --- a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/AdministrationController.java +++ b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/AdministrationController.java @@ -28,8 +28,8 @@ import org.jtalks.jcommune.web.dto.BranchPermissionDto; import org.jtalks.jcommune.web.dto.GroupDto; import org.jtalks.jcommune.web.dto.PermissionGroupsDto; -import org.jtalks.jcommune.web.dto.json.JsonResponse; -import org.jtalks.jcommune.web.dto.json.JsonResponseStatus; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponse; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponseStatus; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.MessageSource; import org.springframework.security.access.AccessDeniedException; diff --git a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/CodeReviewCommentController.java b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/CodeReviewCommentController.java index 4be19eac60..adf08f78ea 100644 --- a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/CodeReviewCommentController.java +++ b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/CodeReviewCommentController.java @@ -21,11 +21,11 @@ import org.jtalks.jcommune.service.PostService; import org.jtalks.jcommune.web.dto.CodeReviewCommentDto; import org.jtalks.jcommune.web.dto.CodeReviewDto; -import org.jtalks.jcommune.web.dto.json.FailJsonResponse; -import org.jtalks.jcommune.web.dto.json.FailValidationJsonResponse; -import org.jtalks.jcommune.web.dto.json.JsonResponse; -import org.jtalks.jcommune.web.dto.json.JsonResponseReason; -import org.jtalks.jcommune.web.dto.json.JsonResponseStatus; +import org.jtalks.jcommune.plugin.api.web.dto.json.FailJsonResponse; +import org.jtalks.jcommune.plugin.api.web.dto.json.FailValidationJsonResponse; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponse; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponseReason; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponseStatus; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.propertyeditors.StringTrimmerEditor; import org.springframework.security.access.AccessDeniedException; diff --git a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/ExternalLinkController.java b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/ExternalLinkController.java index 9a12fe53ce..9d62a325f5 100644 --- a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/ExternalLinkController.java +++ b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/ExternalLinkController.java @@ -18,8 +18,8 @@ import org.jtalks.jcommune.model.entity.ExternalLink; import org.jtalks.jcommune.service.ComponentService; import org.jtalks.jcommune.service.ExternalLinkService; -import org.jtalks.jcommune.web.dto.json.JsonResponse; -import org.jtalks.jcommune.web.dto.json.JsonResponseStatus; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponse; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponseStatus; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.validation.BindingResult; diff --git a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/ImageUploadController.java b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/ImageUploadController.java index 297cbf3d9f..d6d9fea5b4 100644 --- a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/ImageUploadController.java +++ b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/ImageUploadController.java @@ -20,8 +20,8 @@ import org.jtalks.jcommune.service.exceptions.ImageFormatException; import org.jtalks.jcommune.service.exceptions.ImageProcessException; import org.jtalks.jcommune.service.exceptions.ImageSizeException; -import org.jtalks.jcommune.web.dto.json.FailJsonResponse; -import org.jtalks.jcommune.web.dto.json.JsonResponseReason; +import org.jtalks.jcommune.plugin.api.web.dto.json.FailJsonResponse; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponseReason; import org.jtalks.jcommune.web.util.ImageControllerUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -177,7 +177,7 @@ protected ResponseEntity createPreviewOfImage(MultipartFile file, ImageC throws IOException, ImageProcessException { HttpHeaders responseHeaders = new HttpHeaders(); responseHeaders.setContentType(MediaType.TEXT_HTML); - Map responseContent = new HashMap(); + Map responseContent = new HashMap<>(); return imageControllerUtils.prepareResponse(file, responseHeaders, responseContent); } @@ -193,7 +193,7 @@ protected ResponseEntity createPreviewOfImage(MultipartFile file, ImageC protected Map createPreviewOfImage(byte[] imageBytes, HttpServletResponse response, ImageControllerUtils imageControllerUtils) throws ImageProcessException { - Map responseContent = new HashMap(); + Map responseContent = new HashMap<>(); imageControllerUtils.prepareResponse(imageBytes, response, responseContent); return responseContent; } diff --git a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/PluginController.java b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/PluginController.java index ce174b8407..c064813a89 100644 --- a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/PluginController.java +++ b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/PluginController.java @@ -27,8 +27,8 @@ import org.jtalks.jcommune.service.ComponentService; import org.jtalks.jcommune.service.PluginService; import org.jtalks.jcommune.service.UserService; -import org.jtalks.jcommune.web.dto.json.JsonResponse; -import org.jtalks.jcommune.web.dto.json.JsonResponseStatus; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponse; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponseStatus; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; diff --git a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/PostController.java b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/PostController.java index c6ae220b28..2e7c694eb1 100644 --- a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/PostController.java +++ b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/PostController.java @@ -26,8 +26,8 @@ import org.jtalks.jcommune.service.nontransactional.LocationService; import org.jtalks.jcommune.plugin.api.web.dto.PostDto; import org.jtalks.jcommune.plugin.api.web.dto.TopicDto; -import org.jtalks.jcommune.web.dto.json.JsonResponse; -import org.jtalks.jcommune.web.dto.json.JsonResponseStatus; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponse; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponseStatus; import org.jtalks.jcommune.plugin.api.web.util.BreadcrumbBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/SecurityController.java b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/SecurityController.java index fc08013b21..f4a2fc9c6c 100644 --- a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/SecurityController.java +++ b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/SecurityController.java @@ -15,8 +15,8 @@ package org.jtalks.jcommune.web.controller; import org.jtalks.jcommune.service.security.PermissionService; -import org.jtalks.jcommune.web.dto.json.JsonResponse; -import org.jtalks.jcommune.web.dto.json.JsonResponseStatus; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponse; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponseStatus; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/TopicController.java b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/TopicController.java index d1402bbb4a..261b158896 100644 --- a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/TopicController.java +++ b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/TopicController.java @@ -23,8 +23,8 @@ import org.jtalks.jcommune.plugin.api.web.dto.TopicDto; import org.jtalks.jcommune.plugin.api.web.util.BreadcrumbBuilder; import org.jtalks.jcommune.service.*; -import org.jtalks.jcommune.web.dto.json.JsonResponse; -import org.jtalks.jcommune.web.dto.json.JsonResponseStatus; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponse; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponseStatus; import org.jtalks.jcommune.web.validation.editors.DateTimeEditor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/UserController.java b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/UserController.java index a6fd22e282..7b5b889544 100644 --- a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/UserController.java +++ b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/UserController.java @@ -31,8 +31,8 @@ import org.jtalks.jcommune.service.exceptions.UserTriesActivatingAccountAgainException; import org.jtalks.jcommune.plugin.api.filters.TypeFilter; import org.jtalks.jcommune.web.dto.RestorePasswordDto; -import org.jtalks.jcommune.web.dto.json.JsonResponse; -import org.jtalks.jcommune.web.dto.json.JsonResponseStatus; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponse; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponseStatus; import org.jtalks.jcommune.web.interceptors.RefererKeepInterceptor; import org.jtalks.jcommune.web.util.MutableHttpRequest; import org.jtalks.jcommune.web.validation.editors.DefaultStringEditor; diff --git a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/util/ImageControllerUtils.java b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/util/ImageControllerUtils.java index 30c5fb4402..6bd27dfbc9 100644 --- a/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/util/ImageControllerUtils.java +++ b/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/util/ImageControllerUtils.java @@ -17,7 +17,7 @@ import org.jtalks.jcommune.service.exceptions.ImageProcessException; import org.jtalks.jcommune.service.nontransactional.ImageService; -import org.jtalks.jcommune.web.dto.json.JsonResponseStatus; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponseStatus; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -74,7 +74,7 @@ public ResponseEntity prepareResponse( imageService.validateImageSize(bytes); prepareNormalResponse(bytes, responseContent); String body = getResponceJSONString(responseContent); - return new ResponseEntity(body, responseHeaders, HttpStatus.OK); + return new ResponseEntity<>(body, responseHeaders, HttpStatus.OK); } public String getResponceJSONString(Map responseContent) throws IOException { diff --git a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/AdministrationControllerTest.java b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/AdministrationControllerTest.java index eaeec2e034..cc8aa9be1e 100644 --- a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/AdministrationControllerTest.java +++ b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/AdministrationControllerTest.java @@ -29,8 +29,8 @@ import org.jtalks.jcommune.web.dto.BranchDto; import org.jtalks.jcommune.web.dto.BranchPermissionDto; import org.jtalks.jcommune.web.dto.PermissionGroupsDto; -import org.jtalks.jcommune.web.dto.json.JsonResponse; -import org.jtalks.jcommune.web.dto.json.JsonResponseStatus; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponse; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponseStatus; import org.jtalks.jcommune.web.util.ImageControllerUtils; import org.mockito.Mock; import org.springframework.context.MessageSource; diff --git a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/CodeReviewCommentControllerTest.java b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/CodeReviewCommentControllerTest.java index 5abeb04137..ed6262dad3 100644 --- a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/CodeReviewCommentControllerTest.java +++ b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/CodeReviewCommentControllerTest.java @@ -15,13 +15,13 @@ package org.jtalks.jcommune.web.controller; import org.jtalks.jcommune.model.entity.*; +import org.jtalks.jcommune.plugin.api.web.dto.json.*; import org.jtalks.jcommune.service.PostCommentService; import org.jtalks.jcommune.plugin.api.exceptions.NotFoundException; import org.jtalks.jcommune.service.PostService; import org.jtalks.jcommune.service.nontransactional.NotificationService; import org.jtalks.jcommune.web.dto.CodeReviewCommentDto; import org.jtalks.jcommune.web.dto.CodeReviewDto; -import org.jtalks.jcommune.web.dto.json.*; import org.mockito.Mock; import org.springframework.beans.propertyeditors.StringTrimmerEditor; import org.springframework.security.access.AccessDeniedException; diff --git a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/ExternalLinkControllerTest.java b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/ExternalLinkControllerTest.java index 74157dcbb4..1ad4cf7d02 100644 --- a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/ExternalLinkControllerTest.java +++ b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/ExternalLinkControllerTest.java @@ -18,8 +18,8 @@ import org.jtalks.jcommune.model.entity.ExternalLink; import org.jtalks.jcommune.service.ComponentService; import org.jtalks.jcommune.service.ExternalLinkService; -import org.jtalks.jcommune.web.dto.json.JsonResponse; -import org.jtalks.jcommune.web.dto.json.JsonResponseStatus; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponse; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponseStatus; import org.mockito.Mock; import org.springframework.validation.BindingResult; import org.testng.annotations.BeforeMethod; diff --git a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/ImageUploadControllerTest.java b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/ImageUploadControllerTest.java index 3a065d9e54..126ec8f973 100644 --- a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/ImageUploadControllerTest.java +++ b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/ImageUploadControllerTest.java @@ -19,9 +19,9 @@ import org.apache.commons.lang.time.DateFormatUtils; import org.jtalks.jcommune.service.exceptions.ImageFormatException; import org.jtalks.jcommune.service.exceptions.ImageSizeException; -import org.jtalks.jcommune.web.dto.json.FailJsonResponse; -import org.jtalks.jcommune.web.dto.json.JsonResponseReason; -import org.jtalks.jcommune.web.dto.json.JsonResponseStatus; +import org.jtalks.jcommune.plugin.api.web.dto.json.FailJsonResponse; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponseReason; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponseStatus; import org.mockito.Matchers; import org.mockito.Mock; import org.springframework.context.MessageSource; diff --git a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/PluginControllerTest.java b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/PluginControllerTest.java index b68d247534..c2665d9207 100644 --- a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/PluginControllerTest.java +++ b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/PluginControllerTest.java @@ -23,8 +23,8 @@ import org.jtalks.jcommune.service.ComponentService; import org.jtalks.jcommune.service.PluginService; import org.jtalks.jcommune.service.UserService; -import org.jtalks.jcommune.web.dto.json.JsonResponse; -import org.jtalks.jcommune.web.dto.json.JsonResponseStatus; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponse; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponseStatus; import org.jtalks.jcommune.plugin.api.dto.PluginActivatingDto; import org.jtalks.jcommune.plugin.api.filters.NameFilter; import org.jtalks.jcommune.plugin.api.PluginLoader; diff --git a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/PostControllerTest.java b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/PostControllerTest.java index 043abcc62d..e845ba7cb9 100644 --- a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/PostControllerTest.java +++ b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/PostControllerTest.java @@ -23,9 +23,9 @@ import org.jtalks.jcommune.service.nontransactional.LocationService; import org.jtalks.jcommune.plugin.api.web.dto.Breadcrumb; import org.jtalks.jcommune.plugin.api.web.dto.PostDto; -import org.jtalks.jcommune.web.dto.json.JsonResponse; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponse; import org.jtalks.jcommune.plugin.api.web.util.BreadcrumbBuilder; -import org.jtalks.jcommune.web.dto.json.JsonResponseStatus; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponseStatus; import org.mockito.ArgumentMatcher; import org.mockito.Matchers; import org.mockito.Mock; diff --git a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/SecurityControllerTest.java b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/SecurityControllerTest.java index 7bffd1d8f5..2c7d301a92 100644 --- a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/SecurityControllerTest.java +++ b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/SecurityControllerTest.java @@ -15,8 +15,8 @@ package org.jtalks.jcommune.web.controller; import org.jtalks.jcommune.service.security.PermissionService; -import org.jtalks.jcommune.web.dto.json.JsonResponse; -import org.jtalks.jcommune.web.dto.json.JsonResponseStatus; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponse; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponseStatus; import org.mockito.Mock; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; diff --git a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/TopicControllerTest.java b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/TopicControllerTest.java index 1af29d6ed4..afba8dd084 100644 --- a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/TopicControllerTest.java +++ b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/TopicControllerTest.java @@ -23,8 +23,8 @@ import org.jtalks.jcommune.plugin.api.web.dto.TopicDto; import org.jtalks.jcommune.plugin.api.web.util.BreadcrumbBuilder; import org.jtalks.jcommune.service.dto.EntityToDtoConverter; -import org.jtalks.jcommune.web.dto.json.JsonResponse; -import org.jtalks.jcommune.web.dto.json.JsonResponseStatus; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponse; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponseStatus; import org.mockito.Matchers; import org.mockito.Mock; import org.springframework.beans.propertyeditors.StringTrimmerEditor; diff --git a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/UserControllerTest.java b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/UserControllerTest.java index 6de5733cc2..5dcd25d463 100644 --- a/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/UserControllerTest.java +++ b/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/UserControllerTest.java @@ -33,8 +33,8 @@ import org.jtalks.jcommune.service.exceptions.UserTriesActivatingAccountAgainException; import org.jtalks.jcommune.plugin.api.filters.TypeFilter; import org.jtalks.jcommune.web.dto.RestorePasswordDto; -import org.jtalks.jcommune.web.dto.json.JsonResponse; -import org.jtalks.jcommune.web.dto.json.JsonResponseStatus; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponse; +import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponseStatus; import org.jtalks.jcommune.web.util.MutableHttpRequest; import org.jtalks.jcommune.web.validation.editors.DefaultStringEditor; import org.springframework.beans.propertyeditors.StringTrimmerEditor; From 6a5677067053bb211a0d829c50758ff48f573036 Mon Sep 17 00:00:00 2001 From: Andrei Alikov Date: Thu, 12 Feb 2015 22:26:12 +0900 Subject: [PATCH 021/433] #JC-1878 Added migration sql script to add the "admin" user. User will be added if it does not exist. Also the "Administrators" group will be created and the "admin" will be assigned to this group. "admin" will get the administrator rights for the "FORUM" component. sample-forum.sql script was also changed in order to not create the "moderators" group if it is already created. --- .../migrations/V65__Add_admin_user.sql | 101 ++++++++++++++++++ .../jtalks/jcommune/model/sample-forum.sql | 6 +- 2 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 jcommune-model/src/main/resources/org/jtalks/jcommune/migrations/V65__Add_admin_user.sql diff --git a/jcommune-model/src/main/resources/org/jtalks/jcommune/migrations/V65__Add_admin_user.sql b/jcommune-model/src/main/resources/org/jtalks/jcommune/migrations/V65__Add_admin_user.sql new file mode 100644 index 0000000000..db0ec4d88a --- /dev/null +++ b/jcommune-model/src/main/resources/org/jtalks/jcommune/migrations/V65__Add_admin_user.sql @@ -0,0 +1,101 @@ +set @adminUserName := 'admin'; +set @adminPassword := 'admin'; +set @adminGroupName := 'Administrators'; +set @adminGroupDescription := 'Administrators group.'; +set @adminRoleName := 'ADMIN_ROLE'; +set @adminEMail := 'admin@jtalks.org'; +set @moderatorsGroupName := 'Moderators'; +set @moderatorsGroupDescription := 'General group for all moderators'; +set @forumComponentName := 'JTalks Sample Forum'; +set @forumComponentType := 'FORUM'; +set @forumComponentAclClass :='COMPONENT'; +set @forumComponentId := 2; +set @availableUsersText := 'Available users: admin/admin'; +set @isPrincipal := true; +set @notPricipal := false; +set @adminMask := 16; + +insert into COMPONENTS (CMP_ID, COMPONENT_TYPE, UUID, `NAME`, DESCRIPTION) + select @forumComponentId, @forumComponentType, UUID(), @forumComponentName, @availableUsersText + from dual + where not exists (select 1 from COMPONENTS where COMPONENT_TYPE = @forumComponentType); + +-- 'FROM COMPONENTS' are not used, but query mast contain 'FROM dual' clause +-- @see http://dev.mysql.com/doc/refman/5.0/en/select.html/a>. +insert into GROUPS (UUID, `NAME`, DESCRIPTION) + select UUID(), @moderatorsGroupName, @moderatorsGroupDescription + from dual + where not exists (select GROUP_ID from GROUPS where `NAME` = @moderatorsGroupName); + +insert into GROUPS (UUID, `NAME`, DESCRIPTION) + select UUID(), @adminGroupName, @adminGroupDescription + from dual + where not exists (select gr.GROUP_ID from GROUPS gr where gr.NAME = @adminGroupName); + +insert into USERS (UUID, FIRST_NAME, LAST_NAME, USERNAME, ENCODED_USERNAME, EMAIL, PASSWORD, ROLE, SALT, ENABLED) + select UUID(), @adminUserName, @adminUserName, @adminUserName, @adminUserName, @adminEMail, MD5(@adminPassword), @adminRoleName, '', true + from dual + where not exists (select 1 from USERS where USERNAME = @adminUserName); + +alter table JC_USER_DETAILS add unique (USER_ID); +insert into JC_USER_DETAILS (USER_ID, REGISTRATION_DATE, POST_COUNT) + select ID, NOW(), 0 + from USERS + where USERNAME = @adminUserName and not exists (select 1 from JC_USER_DETAILS where USER_ID = USERS.ID); + +-- Adding created Admin to Administrators group(created at this migration or common migration) ). +set @admin_group_id := (select GROUP_ID from GROUPS where `NAME` = @adminGroupName); +insert into GROUP_USER_REF (GROUP_ID, USER_ID) + select @admin_group_id, ID + from USERS + where USERNAME = @adminUserName and not exists (select * + from GROUP_USER_REF + where GROUP_ID = @admin_group_id and USER_ID = USERS.ID); + +-- Adding record with added component class. +set @component_acl_class := 1; +set @group_acl_class := 2; +set @branch_acl_class := 3; + +insert ignore into acl_class (ID, CLASS) + values (@branch_acl_class, 'BRANCH'), (@group_acl_class, 'GROUP'), (@component_acl_class, 'COMPONENT'); + +set @acl_sid_admin_group := (select GROUP_CONCAT('usergroup:', CONVERT(GROUP_ID, char(19))) + from GROUPS g + where g.NAME = @adminGroupName); +set @acl_sid_admin_user := (select GROUP_CONCAT('user:', CONVERT(ID, char(19))) + from USERS u + where u.USERNAME = @adminUserName); +set @forum_object_id_identity := (select component.CMP_ID + from COMPONENTS component + where component.COMPONENT_TYPE = @forumComponentType); + +-- Adding record to acl_sid table, this record wires sid and user id. +insert into acl_sid (principal, sid) + select @isPrincipal, @acl_sid_admin_user + from dual + where not exists (select acl_sid.sid from acl_sid where sid = @acl_sid_admin_user); + +set @acl_sid_admin_user_id := (select sid.id from acl_sid sid where sid.sid = @acl_sid_admin_user); + +-- Adding record to acl_sid table, this record wires sid and group id. +insert ignore into acl_sid (principal, sid) + values(@notPrincipal, @acl_sid_admin_group); + +set @acl_sid_admin_group_id := (select sid.id from acl_sid sid where sid.sid = @acl_sid_admin_group); +set @forum_component_acl_class_id := (select class.id from acl_class class where class.class = @forumComponentAclClass); + +insert ignore into acl_object_identity (object_id_class, object_id_identity, owner_sid, entries_inheriting) + select @forum_component_acl_class_id, @forum_object_id_identity, @acl_sid_admin_user_id, 1 + from dual; + +set @forum_acl_object_identity_id := (select aoi.id from acl_object_identity aoi + where aoi.object_id_class = @forum_component_acl_class_id + and aoi.object_id_identity = @forum_object_id_identity); + +set @ace_order_max := (select MAX(ae.ace_order) from acl_entry ae); +set @ace_order := (case when @ace_order_max is null then 0 else @ace_order_max + 1 end); + +insert ignore into acl_entry (acl_object_identity, sid, ace_order, mask, granting, audit_success, audit_failure) + select @forum_acl_object_identity_id, @acl_sid_admin_group_id, @ace_order, @adminMask, 1, 0 , 0 + from dual; \ No newline at end of file diff --git a/jcommune-model/src/main/resources/org/jtalks/jcommune/model/sample-forum.sql b/jcommune-model/src/main/resources/org/jtalks/jcommune/model/sample-forum.sql index 906cdeacb2..84908e1f55 100644 --- a/jcommune-model/src/main/resources/org/jtalks/jcommune/model/sample-forum.sql +++ b/jcommune-model/src/main/resources/org/jtalks/jcommune/model/sample-forum.sql @@ -14,7 +14,11 @@ insert ignore into SECTIONS (SECTION_ID, UUID, `NAME`, DESCRIPTION, POSITION, CO (10,(SELECT UUID() FROM dual),'Leisure', 'Have free time?', 9, @forum_component_id); -- GROUPS BEGIN -insert ignore into GROUPS (UUID, `NAME`, DESCRIPTION) VALUES ((SELECT UUID() FROM dual), 'Moderators', 'General group for all moderators'); +insert ignore into GROUPS (UUID, `NAME`, DESCRIPTION) + select UUID(), 'Moderators', 'General group for all moderators' + from dual + where not exists (select GROUP_ID from GROUPS where `NAME` = 'Moderators'); + SET @admin_group_id := (select GROUP_ID from GROUPS where `NAME`='Administrators'); SET @registered_group_id := (select GROUP_ID from GROUPS where `NAME`='Registered Users'); SET @banned_group_id := (select GROUP_ID from GROUPS where `NAME`='Banned Users'); From afc65edf4ac156d1f9481f1b63e179829bb6001a Mon Sep 17 00:00:00 2001 From: ctapobep Date: Fri, 13 Feb 2015 09:37:40 +0300 Subject: [PATCH 022/433] JC-2138 Change info where to upload artifacts Previously we didn't use `distributionManagement` info and were uploading every build to a `deployment-pipeline` - only war file was placed there. Now we need to do the same for all the artifacts including plugins - let's leave old repo untouched. --- pom.xml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 3f4833d7f0..bf3e65c9ad 100644 --- a/pom.xml +++ b/pom.xml @@ -574,16 +574,12 @@ jtalks-nexus jtalks nexus - - http://repo.jtalks.org/content/repositories/releases - + http://repo.jtalks.org/content/repositories/builds jtalks-nexus jtalks nexus - - http://repo.jtalks.org/content/repositories/snapshots - + http://repo.jtalks.org/content/repositories/snapshots From 0f5b2cff8a3e3f9335c078dab85e1031b9a24ec7 Mon Sep 17 00:00:00 2001 From: ctapobep Date: Fri, 13 Feb 2015 09:51:33 +0300 Subject: [PATCH 023/433] JC-2138 Change info where to upload plugins Since plugins modules are not inherited from root `pom.xml`, they have to declare their own distribution management section. --- jcommune-plugins/pom.xml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/jcommune-plugins/pom.xml b/jcommune-plugins/pom.xml index 99c636a37b..3dc01d88cb 100644 --- a/jcommune-plugins/pom.xml +++ b/jcommune-plugins/pom.xml @@ -215,16 +215,12 @@ jtalks-nexus jtalks nexus - - http://repo.jtalks.org/content/repositories/releases - + http://repo.jtalks.org/content/repositories/builds jtalks-nexus jtalks nexus - - http://repo.jtalks.org/content/repositories/snapshots - + http://repo.jtalks.org/content/repositories/snapshots From 03535fad715bdfb0c04e35cd3c5af6b0010b4f55 Mon Sep 17 00:00:00 2001 From: Mikhail Stryzhonok Date: Thu, 12 Feb 2015 17:29:13 +0300 Subject: [PATCH 024/433] #JC-2073 initial implementation of comment edition --- .../api/service/PluginCommentService.java | 36 +++++++ .../TransactionalPluginCommentService.java | 66 +++++++++++++ .../QuestionsAndAnswersController.java | 27 ++++- .../questionsandanswers/template/comments.vm | 18 +++- .../template/css/question.css | 6 +- .../template/js/question.js | 99 ++++++++++++++++++- .../questionsandanswers/template/question.vm | 1 + .../TransactionalPostCommentService.java | 3 +- .../service/applicationContext-service.xml | 7 +- 9 files changed, 253 insertions(+), 10 deletions(-) create mode 100644 jcommune-plugin-api/src/main/java/org/jtalks/jcommune/plugin/api/service/PluginCommentService.java create mode 100644 jcommune-plugin-api/src/main/java/org/jtalks/jcommune/plugin/api/service/transactional/TransactionalPluginCommentService.java diff --git a/jcommune-plugin-api/src/main/java/org/jtalks/jcommune/plugin/api/service/PluginCommentService.java b/jcommune-plugin-api/src/main/java/org/jtalks/jcommune/plugin/api/service/PluginCommentService.java new file mode 100644 index 0000000000..c7cd2fe0b1 --- /dev/null +++ b/jcommune-plugin-api/src/main/java/org/jtalks/jcommune/plugin/api/service/PluginCommentService.java @@ -0,0 +1,36 @@ +/** + * Copyright (C) 2011 JTalks.org Team + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +package org.jtalks.jcommune.plugin.api.service; + +import org.jtalks.jcommune.model.entity.PostComment; +import org.jtalks.jcommune.plugin.api.exceptions.NotFoundException; + +/** + * @author Mikhail Stryzhonok + */ +public interface PluginCommentService { + + /** + * Updates comment's body + * + * @param id ID of comment + * @param body new body of comment + * @param branchId ID of branch containing code review to check permissions + * + * @return updated comment entity + * @throws NotFoundException when entity not found + */ + PostComment updateComment(long id, String body, long branchId) throws NotFoundException; +} diff --git a/jcommune-plugin-api/src/main/java/org/jtalks/jcommune/plugin/api/service/transactional/TransactionalPluginCommentService.java b/jcommune-plugin-api/src/main/java/org/jtalks/jcommune/plugin/api/service/transactional/TransactionalPluginCommentService.java new file mode 100644 index 0000000000..80a25c816c --- /dev/null +++ b/jcommune-plugin-api/src/main/java/org/jtalks/jcommune/plugin/api/service/transactional/TransactionalPluginCommentService.java @@ -0,0 +1,66 @@ +/** + * Copyright (C) 2011 JTalks.org Team + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +package org.jtalks.jcommune.plugin.api.service.transactional; + +import org.jtalks.jcommune.model.entity.PostComment; +import org.jtalks.jcommune.plugin.api.exceptions.NotFoundException; +import org.jtalks.jcommune.plugin.api.service.PluginCommentService; + +/** + * Class for manipulating with comments from plugin.To manipulate with comments from jcommune use classes from service + * module + * + * This class is singleton because we can't use spring dependency injection mechanism in plugins due plugins can be + * added or removed in runtime. + * + * @author Mikhail Stryzhonok + */ +public class TransactionalPluginCommentService implements PluginCommentService{ + private static final TransactionalPluginCommentService INSTANCE = new TransactionalPluginCommentService(); + + private PluginCommentService commentService; + + /** Use {@link #getInstance()}, this class is singleton. */ + private TransactionalPluginCommentService() { + + } + + /** + * Gets instance of {@link TransactionalPluginCommentService class + * + * @return instance of {@link TransactionalPluginCommentService class + */ + public static PluginCommentService getInstance() { + return INSTANCE; + } + + /** + * {@inheritDoc} + */ + @Override + public PostComment updateComment(long id, String body, long branchId) throws NotFoundException { + return commentService.updateComment(id, body, branchId); + } + + /** + * Sets specified {@link org.jtalks.jcommune.plugin.api.service.PluginCommentService} implementation + * Should be used once, during initialization + * + * @param commentService {@link org.jtalks.jcommune.plugin.api.service.PluginCommentService} implementation to set + */ + public void setCommentService(PluginCommentService commentService) { + this.commentService = commentService; + } +} diff --git a/jcommune-plugins/questions-n-answers-plugin/src/main/java/org/jtalks/jcommune/plugin/questionsandanswers/controller/QuestionsAndAnswersController.java b/jcommune-plugins/questions-n-answers-plugin/src/main/java/org/jtalks/jcommune/plugin/questionsandanswers/controller/QuestionsAndAnswersController.java index a90745ff3c..897a54bb67 100644 --- a/jcommune-plugins/questions-n-answers-plugin/src/main/java/org/jtalks/jcommune/plugin/questionsandanswers/controller/QuestionsAndAnswersController.java +++ b/jcommune-plugins/questions-n-answers-plugin/src/main/java/org/jtalks/jcommune/plugin/questionsandanswers/controller/QuestionsAndAnswersController.java @@ -25,12 +25,14 @@ import org.jtalks.jcommune.plugin.api.service.nontransactional.BbToHtmlConverter; import org.jtalks.jcommune.plugin.api.service.nontransactional.PluginLocationServiceImpl; import org.jtalks.jcommune.plugin.api.service.transactional.TransactionalPluginBranchService; +import org.jtalks.jcommune.plugin.api.service.transactional.TransactionalPluginCommentService; import org.jtalks.jcommune.plugin.api.service.transactional.TransactionalPluginLastReadPostService; import org.jtalks.jcommune.plugin.api.service.transactional.TransactionalPluginPostService; import org.jtalks.jcommune.plugin.api.service.transactional.TransactionalTypeAwarePluginTopicService; import org.jtalks.jcommune.plugin.api.web.PluginController; import org.jtalks.jcommune.plugin.api.web.dto.PostDto; import org.jtalks.jcommune.plugin.api.web.dto.TopicDto; +import org.jtalks.jcommune.plugin.api.web.dto.json.FailValidationJsonResponse; import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponse; import org.jtalks.jcommune.plugin.api.web.dto.json.JsonResponseStatus; import org.jtalks.jcommune.plugin.api.web.locale.JcLocaleResolver; @@ -430,12 +432,27 @@ public String deleteAnswer(@PathVariable Long answerId) */ @RequestMapping(method = RequestMethod.POST, value = "newcomment") @ResponseBody - JsonResponse addComment(@Valid @RequestBody CommentDto dto, HttpServletRequest request) throws NotFoundException { + JsonResponse addComment(@Valid @RequestBody CommentDto dto, BindingResult result, + HttpServletRequest request) throws NotFoundException { + if (result.hasErrors()) { + return new FailValidationJsonResponse(result.getAllErrors()); + } PostComment comment = getPluginPostService().addComment(dto.getPostId(), Collections.EMPTY_MAP, dto.getBody()); JodaDateTimeTool dateTimeTool = new JodaDateTimeTool(request); return new JsonResponse(JsonResponseStatus.SUCCESS, new CommentDto(comment, dateTimeTool)); } + @RequestMapping(method = RequestMethod.POST, value = "editcomment") + @ResponseBody + JsonResponse editComment(@Valid @RequestBody CommentDto dto, BindingResult result, + @RequestParam("branchId") long branchId) throws NotFoundException { + if (result.hasErrors()) { + return new FailValidationJsonResponse(result.getAllErrors()); + } + PostComment updatedComment = getCommentService().updateComment(dto.getId(), dto.getBody(), branchId); + return new JsonResponse(JsonResponseStatus.SUCCESS, updatedComment.getBody()); + } + /** * Gets copy of specified collection of posts sorted by rating and creation date @@ -596,6 +613,7 @@ String getMergedTemplate(VelocityEngine velocityEngine, String templateLocation, Map model) throws VelocityException { return VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, templateLocation, encoding, model); } + /** * Needed for mocking */ @@ -603,6 +621,13 @@ PluginLocationService getLocationService() { return PluginLocationServiceImpl.getInstance(); } + /** + * Needed for mocking + */ + PluginCommentService getCommentService() { + return TransactionalPluginCommentService.getInstance(); + } + /** * Needed for tests */ diff --git a/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/comments.vm b/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/comments.vm index 0ac8c2c0bc..f595cb196b 100644 --- a/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/comments.vm +++ b/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/comments.vm @@ -41,7 +41,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#if(($currentUser.id == $comment.author.id && $permissionTool.hasPermission($targedId.longValue(), "BRANCH","BranchPermission.EDIT_OWN_POSTS")) || ($currentUser.id != $comment.author.id && $permissionTool.hasPermission($targedId.longValue(), "BRANCH","BranchPermission.EDIT_OTHERS_POSTS"))) -   + + +   #end #if(($currentUser.id == $comment.author.id && $permissionTool.hasPermission($targedId.longValue(), "BRANCH","BranchPermission.DELETE_OWN_POSTS")) || ($currentUser.id != $comment.author.id && $permissionTool.hasPermission($targedId.longValue(), "BRANCH","BranchPermission.DELETE_OTHERS_POSTS"))) @@ -55,7 +57,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- ${esc.html($comment.body)} + ${esc.html($comment.body)} +
#end @@ -76,7 +88,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ${messages.getString("label.add.comment")}
#end -
+
diff --git a/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/css/question.css b/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/css/question.css index efe4f19e1c..f7e8dfc68d 100644 --- a/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/css/question.css +++ b/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/css/question.css @@ -223,4 +223,8 @@ position: absolute; padding: 0.7em 1em; font-size: 15px; -} \ No newline at end of file +} + +.edit { + margin-top: 5px; +} diff --git a/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/js/question.js b/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/js/question.js index 898671ce62..a0dc83d0ab 100644 --- a/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/js/question.js +++ b/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/js/question.js @@ -19,7 +19,9 @@ $(function () { $('.comment-prompt').click(function (e) { e.preventDefault(); var postId = $(this).attr("id").split("-")[1]; - toggleCommentsFor(postId); + if (isCommentsHidden(postId)) { + toggleCommentsFor(postId); + } $(this).hide(); $(this).next(".comment-container").show(); $(this).next(".comment-container").children(".comment-textarea").focus(); @@ -73,8 +75,57 @@ $(function () { } }); }); + updateCommentHandlers() }); +var editHandler = function(e) { + if (e.which != 1) { + return; + } + + var commentId = $(this).attr("data-comment-id"); + enableEditMode(commentId); +} + +var editSubmitHandler = function(e) { + if (e.which != 1) { + return; + } + var commentDto = {}; + commentId = $(this).attr("data-comment-id"); + commentDto.id = commentId; + commentDto.body = $("#editable-" + commentId).val(); + console.log(commentDto); + $.ajax({ + url: baseUrl + "/topics/question/editcomment?branchId=" + branchId, + type: "POST", + contentType: "application/json", + async: false, + data: JSON.stringify(commentDto), + success: function(data) { + console.log(data.status); + if(data.status == 'SUCCESS') { + $("#body-" + commentId).text(data.result); + enableViewMode(commentId); + } else { + displayValidationErrors(data.result, "editable-" + commentId); + } + }, + error: function() { + console.log("error"); + } + }); +} + +var editCancelHandler = function(e) { + if (e.which != 1) { + return; + } + + var commentId = $(this).attr("data-comment-id"); + enableViewMode(commentId); +} + var voteUpHandler = function voteUp(e) { if (e.which != 1) { return; @@ -303,11 +354,18 @@ function addCommentToPost(postId, comment) { $($("#btns-" + postId).children()[0]).hide(); } $("#comments-" + postId).append(getCommentHtml(comment)); + updateCommentHandlers(); if (commentList.length > 2) { applyCommentsCssClasses(postId); } } +function updateCommentHandlers() { + $('.icon-pencil').click(editHandler); + $('.edit-cancel').click(editCancelHandler); + $('.edit-submit').click(editSubmitHandler); +} + function getCommentHtml(comment) { return "
" + "
" @@ -315,10 +373,16 @@ function getCommentHtml(comment) { + "" + comment.authorUsername + ",
" + "
" - + " " + + " " + "
" + "
" + comment.formattedCreationDate + "
" - + "
" + comment.body + "
"; + + "
" + comment.body + "" + + "
"; } function toggleCommentsFor(postId) { @@ -360,4 +424,33 @@ function applyCommentsCssClasses(postId) { } i ++; }); +} + +function enableEditMode(commentId) { + $("#body-" + commentId).hide(); + $("#edit-" + commentId).show(); +} + +function enableViewMode(commentId) { + $("#body-" + commentId).show(); + $("#edit-" + commentId).hide(); +} + +function displayValidationErrors(errors, elementId) { + console.log("displayValidationErrors"); + var element = $("#" + elementId); + element.parent().addClass("error"); + $(getValidationErrorView(errors)).insertAfter("#" + elementId); +} + +function getValidationErrorView(errors) { + if(errors.length > 0) { + var errorsView = ""; + for (var i = 0; i < errors.length; i ++) { + errorsView += errors[i].message + '
'; + } + errorsView += "
"; + return errorsView; + } + return ""; } \ No newline at end of file diff --git a/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/question.vm b/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/question.vm index e4c872e739..f5de6765bc 100644 --- a/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/question.vm +++ b/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/question.vm @@ -27,6 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA var labelVoteErrorNoPermissions = "${messages.getString("label.vote.error.not.registered")}"; #end var labelVoteErrorOwnPost = "${messages.getString("label.vote.error.own.post")}"; + var branchId = ${question.branch.id}; diff --git a/jcommune-service/src/main/java/org/jtalks/jcommune/service/transactional/TransactionalPostCommentService.java b/jcommune-service/src/main/java/org/jtalks/jcommune/service/transactional/TransactionalPostCommentService.java index c7ccc807ff..0f4689a372 100644 --- a/jcommune-service/src/main/java/org/jtalks/jcommune/service/transactional/TransactionalPostCommentService.java +++ b/jcommune-service/src/main/java/org/jtalks/jcommune/service/transactional/TransactionalPostCommentService.java @@ -18,6 +18,7 @@ import org.jtalks.common.model.permissions.BranchPermission; import org.jtalks.jcommune.model.entity.PostComment; import org.jtalks.jcommune.model.entity.JCUser; +import org.jtalks.jcommune.plugin.api.service.PluginCommentService; import org.jtalks.jcommune.service.PostCommentService; import org.jtalks.jcommune.service.UserService; import org.jtalks.jcommune.plugin.api.exceptions.NotFoundException; @@ -31,7 +32,7 @@ */ public class TransactionalPostCommentService extends AbstractTransactionalEntityService> implements - PostCommentService { + PostCommentService, PluginCommentService { private PermissionService permissionService; private UserService userService; diff --git a/jcommune-service/src/main/resources/org/jtalks/jcommune/service/applicationContext-service.xml b/jcommune-service/src/main/resources/org/jtalks/jcommune/service/applicationContext-service.xml index 1d9a5efc97..e2e39b6694 100644 --- a/jcommune-service/src/main/resources/org/jtalks/jcommune/service/applicationContext-service.xml +++ b/jcommune-service/src/main/resources/org/jtalks/jcommune/service/applicationContext-service.xml @@ -339,7 +339,7 @@ - @@ -449,6 +449,11 @@ + + + + From 8d639c3611f28ceb14c70ed35c235702e982dd5a Mon Sep 17 00:00:00 2001 From: Mikhail Stryzhonok Date: Mon, 16 Feb 2015 17:41:21 +0300 Subject: [PATCH 025/433] #JC-2073 Initial implementation of client-side comments deletion --- .../questionsandanswers/template/comments.vm | 8 ++-- .../template/js/question.js | 43 ++++++++++++++++--- 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/comments.vm b/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/comments.vm index f595cb196b..bf82694d92 100644 --- a/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/comments.vm +++ b/jcommune-plugins/questions-n-answers-plugin/src/main/resources/org/jtalks/jcommune/plugin/questionsandanswers/template/comments.vm @@ -26,9 +26,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #set($commentClass = "hiddenBorder") #end #if($velocityCount > $shownComments) -