1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.platform.blog.internal

File DefaultBlogVisibilityUpdater.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

2
4
1
1
58
23
2
0.5
4
1
2

Classes

Class Line # Actions
DefaultBlogVisibilityUpdater 43 4 0% 2 0
1.0100%
 

Contributing tests

This file is covered by 4 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.platform.blog.internal;
21   
22    import javax.inject.Singleton;
23   
24    import org.xwiki.component.annotation.Component;
25    import org.xwiki.model.reference.DocumentReference;
26    import org.xwiki.model.reference.SpaceReference;
27    import org.xwiki.platform.blog.BlogVisibilityUpdater;
28   
29    import com.xpn.xwiki.doc.XWikiDocument;
30    import com.xpn.xwiki.objects.BaseObject;
31   
32    /**
33    * Default implementation of {@link BlogVisibilityUpdater}.
34    *
35    * @version $Id: 0a31b3f57a2d9a4adfa1dece2fc23593e316f834 $
36    *
37    * @since 9.0RC1
38    * @since 8.4.3
39    * @since 7.4.6
40    */
41    @Component
42    @Singleton
 
43    public class DefaultBlogVisibilityUpdater implements BlogVisibilityUpdater
44    {
 
45  17 toggle @Override
46    public void synchronizeHiddenMetadata(XWikiDocument document)
47    {
48  17 final DocumentReference blogPostClass = new DocumentReference("BlogPostClass", new SpaceReference("Blog",
49    document.getDocumentReference().getWikiReference()));
50   
51  17 BaseObject blogPost = document.getXObject(blogPostClass);
52  17 if (blogPost != null) {
53    // Set the document visibility according to the values of the blog object.
54    // The change will be saved after because the event is sent before the actual saving.
55  5 document.setHidden(blogPost.getIntValue("published") == 0 || blogPost.getIntValue("hidden") == 1);
56    }
57    }
58    }