Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void setTopicModificationService(PluginTopicModificationService topicModi
*/
public Topic get(Long id, String type) throws NotFoundException {
Topic topic = topicFetchService.get(id);
if (!topic.getType().equals(type)) {
if (!topic.getType().equalsIgnoreCase(type)) {
throw new NotFoundException();
}
return topic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.joda.time.DateTime;
import org.jtalks.jcommune.model.entity.*;
import org.jtalks.jcommune.plugin.api.exceptions.NotFoundException;
import org.jtalks.jcommune.plugin.api.service.transactional.TransactionalTypeAwarePluginTopicService;
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.JsonResponse;
Expand Down Expand Up @@ -75,6 +76,7 @@ public class TopicController {

private TopicModificationService topicModificationService;
private TopicFetchService topicFetchService;
private TransactionalTypeAwarePluginTopicService pluginTopicService;
private TopicDraftService topicDraftService;
private PostService postService;
private BranchService branchService;
Expand Down Expand Up @@ -117,6 +119,7 @@ public void initBinder(WebDataBinder binder) {
@Autowired
public TopicController(TopicModificationService topicModificationService,
PostService postService,
TransactionalTypeAwarePluginTopicService pluginTopicService,
BranchService branchService,
LastReadPostService lastReadPostService,
UserService userService,
Expand All @@ -129,6 +132,7 @@ public TopicController(TopicModificationService topicModificationService,
RetryTemplate retryTemplate) {
this.topicModificationService = topicModificationService;
this.postService = postService;
this.pluginTopicService = pluginTopicService;
this.branchService = branchService;
this.lastReadPostService = lastReadPostService;
this.userService = userService;
Expand Down Expand Up @@ -291,6 +295,23 @@ public ModelAndView showTopicPage(WebRequest request, @PathVariable(TOPIC_ID) Lo
.addObject(BREADCRUMB_LIST, breadcrumbBuilder.getForumBreadcrumb(topic));
}

/**
* Displays to user a list of messages from the topic with pagination
*
* @param topicId the id of selected Topic
* @param page page
* @return {@code ModelAndView}
* @throws NotFoundException when topic or branch not found
*/
@RequestMapping(value = "/topics/{topicType:[A-Za-z]+}/{topicId}", method = RequestMethod.GET)
public String showTopicPage(WebRequest request,@PathVariable() String topicType, @PathVariable(TOPIC_ID) Long topicId,
@RequestParam(value = "page", defaultValue = "1", required = false) String page)
throws NotFoundException {
Topic topic = pluginTopicService.get(topicId, topicType);

return "redirect:/topics/"+topicId;
}

/**
* Shows edit topic page with form, populated with fields from topic.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.jtalks.common.model.entity.Section;
import org.jtalks.jcommune.model.dto.PageRequest;
import org.jtalks.jcommune.model.entity.*;
import org.jtalks.jcommune.plugin.api.service.transactional.TransactionalTypeAwarePluginTopicService;
import org.jtalks.jcommune.service.*;
import org.jtalks.jcommune.plugin.api.exceptions.NotFoundException;
import org.jtalks.jcommune.service.nontransactional.LocationService;
Expand Down Expand Up @@ -89,6 +90,8 @@ public class TopicControllerTest {
private LastReadPostService lastReadPostService;
@Mock
private EntityToDtoConverter converter;
@Mock
private TransactionalTypeAwarePluginTopicService pluginTopicService;

private TopicController controller;
@Mock
Expand All @@ -104,6 +107,7 @@ public void initEnvironment() {
controller = new TopicController(
topicModificationService,
postService,
pluginTopicService,
branchService,
lastReadPostService,
userService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
<mvc:annotation-driven/>
<bean class="org.jtalks.jcommune.plugin.api.web.PluginHandlerMapping" factory-method="getInstance">
<property name="pluginLoader" ref="pluginLoader"/>
<!--The fix for the correct URL mapping priority, when a plugin and an other controller use a same URL.-->
<property name="order" value="-2147483648"/>
</bean>

<!-- Beans -->
Expand Down