1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.internal.mandatory

File XWikiGroupsDocumentInitializer.java

 

Coverage histogram

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

Code metrics

2
10
2
1
79
37
3
0.3
5
2
1.5

Classes

Class Line # Actions
XWikiGroupsDocumentInitializer 43 10 0% 3 0
1.0100%
 

Contributing tests

No tests hitting this source file were found.

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 com.xpn.xwiki.internal.mandatory;
21   
22    import javax.inject.Inject;
23    import javax.inject.Named;
24    import javax.inject.Singleton;
25   
26    import org.xwiki.component.annotation.Component;
27    import org.xwiki.model.reference.DocumentReference;
28    import org.xwiki.sheet.SheetBinder;
29   
30    import com.xpn.xwiki.XWiki;
31    import com.xpn.xwiki.doc.XWikiDocument;
32    import com.xpn.xwiki.objects.classes.BaseClass;
33   
34    /**
35    * Update XWiki.XWikiGroups document with all required informations.
36    *
37    * @version $Id: b3f23bac9e6d9fbab8718cf0b04349bab1da3969 $
38    * @since 4.3M1
39    */
40    @Component
41    @Named("XWiki.XWikiGroups")
42    @Singleton
 
43    public class XWikiGroupsDocumentInitializer extends AbstractMandatoryDocumentInitializer
44    {
45    /**
46    * Used to bind a class to a document sheet.
47    */
48    @Inject
49    @Named("class")
50    private SheetBinder classSheetBinder;
51   
52    /**
53    * Default constructor.
54    */
 
55  60 toggle public XWikiGroupsDocumentInitializer()
56    {
57  60 super(XWiki.SYSTEM_SPACE, "XWikiGroups");
58    }
59   
 
60  118 toggle @Override
61    public boolean updateDocument(XWikiDocument document)
62    {
63  118 boolean needsUpdate = false;
64   
65  118 BaseClass bclass = document.getXClass();
66   
67  118 needsUpdate |= bclass.addTextField("member", "Member", 30);
68  118 needsUpdate |= setClassDocumentFields(document, "XWiki Group Class");
69   
70    // Use XWikiGroupSheet to display documents having XWikiGroups objects if no other class sheet is specified.
71  118 if (this.classSheetBinder.getSheets(document).isEmpty()) {
72  38 String wikiName = document.getDocumentReference().getWikiReference().getName();
73  38 DocumentReference sheet = new DocumentReference(wikiName, XWiki.SYSTEM_SPACE, "XWikiGroupSheet");
74  38 needsUpdate |= this.classSheetBinder.bind(document, sheet);
75    }
76   
77  118 return needsUpdate;
78    }
79    }