11
11
import de .holarse .queues .commands .SearchRefresh ;
12
12
import de .holarse .web .controller .commands .ArticleForm ;
13
13
import de .holarse .web .defines .WebDefines ;
14
+
15
+ import static de .holarse .web .defines .WebDefines .REVISION_DEFAULT_PAGE_SIZE ;
14
16
import static de .holarse .web .defines .WebDefines .WIKI_ARTICLES_DEFAULT_PAGE_SIZE ;
15
17
import de .holarse .web .renderer .Renderer ;
16
18
import de .holarse .web .services .AttachmentService ;
26
28
import org .slf4j .Logger ;
27
29
import org .slf4j .LoggerFactory ;
28
30
import org .springframework .beans .factory .annotation .Autowired ;
31
+ import org .springframework .data .domain .Page ;
29
32
import org .springframework .data .domain .Pageable ;
33
+ import org .springframework .data .domain .Sort ;
30
34
import org .springframework .data .web .PageableDefault ;
31
35
import org .springframework .jms .core .JmsTemplate ;
32
36
import org .springframework .stereotype .Controller ;
@@ -105,7 +109,7 @@ public ModelAndView show(@PathVariable("slug") final String slug, final ModelAnd
105
109
final ArticleRevision articleRevision = article .getArticleRevision ();
106
110
final Set <Tag > tags = article .getTags ();
107
111
final List <TagGroup > relevantTagGroups = tags .stream ().map (t -> t .getTagGroup ()).toList ();
108
- // final NodeSlug mainSlug = nodeSlugRepository.findMainSlug(article .getNodeId()).orElseThrow(EntityNotFoundException::new);
112
+ final NodeSlug mainSlug = nodeSlugRepository .findMainSlug (articleRevision .getNodeId (), NodeType . article ).orElseThrow (EntityNotFoundException ::new );
109
113
110
114
// TODO
111
115
// if (article.getNodeStatus().isDeleted() || !article.getNodeStatus().isPublished()) {
@@ -126,7 +130,7 @@ public ModelAndView show(@PathVariable("slug") final String slug, final ModelAnd
126
130
final List <Attachment > videos = attachmentService .getAttachments (article , attachmentGroupRepository .findByCode (AttachmentGroupType .video .name ()));
127
131
128
132
// View zusammenstellen
129
- final ArticleView view = ArticleView .of (articleRevision );
133
+ final ArticleView view = ArticleView .of (articleRevision , mainSlug );
130
134
view .setNodeId (article .getNodeId ());
131
135
view .setTagList (tags .stream ().map (TagView ::of ).sorted (Comparator .comparingInt (TagView ::getWeight ).reversed ().thenComparing (TagView ::getUseCount ).reversed ().thenComparing (TagView ::getName )).toList ());
132
136
view .setContent (renderer .render (view .getContent (), null ));
@@ -188,7 +192,7 @@ public ModelAndView edit(@PathVariable final Integer nodeId, final ModelAndView
188
192
189
193
@ Transactional
190
194
@ PostMapping ("{nodeId}" )
191
- public ModelAndView update (@ PathVariable ( "nodeId" ) final int nodeId , @ ModelAttribute ("form" ) final ArticleForm form , final ModelAndView mv , final Principal principal ) {
195
+ public ModelAndView update (@ PathVariable final int nodeId , @ ModelAttribute ("form" ) final ArticleForm form , final ModelAndView mv , final Principal principal ) {
192
196
logger .debug ("Updating by form {}" , form );
193
197
194
198
final Article article = articleRepository .findByNodeId (nodeId ).orElseThrow (EntityNotFoundException ::new );
@@ -262,7 +266,7 @@ public ModelAndView update(@PathVariable("nodeId") final int nodeId, @ModelAttri
262
266
logger .debug ("Should redirect to {}" , nodeSlug .getName ());
263
267
return new ModelAndView (String .format ("redirect:%s" , nodeSlug .getName ()));
264
268
}
265
-
269
+
266
270
protected Attachment createOrUpdate (final Integer nodeId , final Attachment formAttachment ) {
267
271
Attachment dbAttachment ;
268
272
if (formAttachment .getId () == null ) {
0 commit comments