@@ -50,20 +50,20 @@ public Post getPost(Long postId) {
5050
5151 Post post = postRepository .findOne (postId );
5252
53- if (post == null ){
53+ if (post == null ) {
5454 throw new NotFoundException ("Post with id " + postId + " is not found." );
5555 }
5656
5757 return post ;
5858 }
5959
6060 @ Cacheable (CACHE_NAME )
61- public Post getPublishedPostByPermalink (String permalink ){
61+ public Post getPublishedPostByPermalink (String permalink ) {
6262 logger .debug ("Get post with permalink " + permalink );
6363
6464 Post post = postRepository .findByPermalinkAndPostStatus (permalink , PostStatus .PUBLISHED );
6565
66- if (post == null ){
66+ if (post == null ) {
6767 throw new NotFoundException ("Post with permalink '" + permalink + "' is not found." );
6868 }
6969
@@ -73,7 +73,7 @@ public Post getPublishedPostByPermalink(String permalink){
7373 @ Caching (evict = {
7474 @ CacheEvict (value = CACHE_NAME_ARCHIVE , allEntries = true ),
7575 @ CacheEvict (value = CACHE_NAME_PAGE , allEntries = true ),
76- @ CacheEvict (value = CACHE_NAME_COUNTS , allEntries = true )
76+ @ CacheEvict (value = CACHE_NAME_COUNTS , allEntries = true )
7777 })
7878 public Post createPost (Post post ) {
7979 if (post .getPostFormat () == PostFormat .MARKDOWN ) {
@@ -86,10 +86,10 @@ public Post createPost(Post post) {
8686 @ Caching (evict = {
8787 @ CacheEvict (value = CACHE_NAME , key = "#post.id" ),
8888 @ CacheEvict (value = CACHE_NAME , key = "#post.permalink" , condition = "#post.permalink != null" ),
89- @ CacheEvict (value = CACHE_NAME_TAGS , key = "#post.id.toString().concat('-tags')" ),
89+ @ CacheEvict (value = CACHE_NAME_TAGS , key = "#post.id.toString().concat('-tags')" ),
9090 @ CacheEvict (value = CACHE_NAME_ARCHIVE , allEntries = true ),
9191 @ CacheEvict (value = CACHE_NAME_PAGE , allEntries = true ),
92- @ CacheEvict (value = CACHE_NAME_COUNTS , allEntries = true )
92+ @ CacheEvict (value = CACHE_NAME_COUNTS , allEntries = true )
9393 })
9494 public Post updatePost (Post post ) {
9595 if (post .getPostFormat () == PostFormat .MARKDOWN ) {
@@ -105,7 +105,7 @@ public Post updatePost(Post post) {
105105 @ CacheEvict (value = CACHE_NAME_TAGS , key = "#post.id.toString().concat('-tags')" ),
106106 @ CacheEvict (value = CACHE_NAME_ARCHIVE , allEntries = true ),
107107 @ CacheEvict (value = CACHE_NAME_PAGE , allEntries = true ),
108- @ CacheEvict (value = CACHE_NAME_COUNTS , allEntries = true )
108+ @ CacheEvict (value = CACHE_NAME_COUNTS , allEntries = true )
109109 })
110110 public void deletePost (Post post ) {
111111 postRepository .delete (post );
@@ -127,7 +127,7 @@ public List<Post> getArchivePosts() {
127127 }
128128
129129 @ Cacheable (value = CACHE_NAME_TAGS , key = "#post.id.toString().concat('-tags')" )
130- public List <Tag > getPostTags (Post post ){
130+ public List <Tag > getPostTags (Post post ) {
131131 logger .debug ("Get tags of post " + post .getId ());
132132
133133 List <Tag > tags = new ArrayList <>();
@@ -140,7 +140,7 @@ public List<Tag> getPostTags(Post post){
140140 }
141141
142142
143- private Post extractPostMeta (Post post ){
143+ private Post extractPostMeta (Post post ) {
144144 Post archivePost = new Post ();
145145 archivePost .setId (post .getId ());
146146 archivePost .setTitle (post .getTitle ());
@@ -173,38 +173,38 @@ public Post createAboutPage() {
173173 return createPost (post );
174174 }
175175
176- public Set <Tag > parseTagNames (String tagNames ){
176+ public Set <Tag > parseTagNames (String tagNames ) {
177177 Set <Tag > tags = new HashSet <>();
178178
179- if (tagNames != null && !tagNames .isEmpty ()){
179+ if (tagNames != null && !tagNames .isEmpty ()) {
180180 tagNames = tagNames .toLowerCase ();
181181 String [] names = tagNames .split ("\\ s*,\\ s*" );
182- for (String name : names ){
182+ for (String name : names ) {
183183 tags .add (tagService .findOrCreateByName (name ));
184184 }
185185 }
186186
187187 return tags ;
188188 }
189189
190- public String getTagNames (Set <Tag > tags ){
190+ public String getTagNames (Set <Tag > tags ) {
191191 if (tags == null || tags .isEmpty ())
192192 return "" ;
193193
194194 StringBuilder names = new StringBuilder ();
195195 tags .forEach (tag -> names .append (tag .getName ()).append ("," ));
196- names .deleteCharAt (names .length ()- 1 );
196+ names .deleteCharAt (names .length () - 1 );
197197
198198 return names .toString ();
199199 }
200200
201201 // cache or not?
202- public Page <Post > findPostsByTag (String tagName , int page , int pageSize ){
202+ public Page <Post > findPostsByTag (String tagName , int page , int pageSize ) {
203203 return postRepository .findByTag (tagName , new PageRequest (page , pageSize , Sort .Direction .DESC , "createdAt" ));
204204 }
205205
206206 @ Cacheable (value = CACHE_NAME_COUNTS , key = "#root.method.name" )
207- public List <Map < String , Long >> countPostsByTags (){
207+ public List <Object []> countPostsByTags () {
208208 logger .debug ("Count posts group by tags." );
209209
210210 return postRepository .countPostsByTags (PostStatus .PUBLISHED );
0 commit comments