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

File SpacePreferencesConfigurationSource.java

 

Coverage histogram

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

Code metrics

4
9
3
1
82
40
5
0.56
3
3
1.67

Classes

Class Line # Actions
SpacePreferencesConfigurationSource 41 9 0% 5 0
1.0100%
 

Contributing tests

This file is covered by 1 test. .

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.configuration.internal;
21   
22    import javax.inject.Inject;
23    import javax.inject.Named;
24    import javax.inject.Singleton;
25   
26    import org.xwiki.bridge.DocumentAccessBridge;
27    import org.xwiki.component.annotation.Component;
28    import org.xwiki.model.reference.DocumentReference;
29    import org.xwiki.model.reference.SpaceReference;
30   
31    /**
32    * Configuration source taking its data in the Space Preferences wiki document (using data from the
33    * XWiki.XWikiPreferences object attached to that document).
34    *
35    * @version $Id: 53c12e2c788437e3b332e2e4d05a1fc5a255b7ff $
36    * @since 2.0M2
37    */
38    @Component
39    @Named("space")
40    @Singleton
 
41    public class SpacePreferencesConfigurationSource extends AbstractXWikiPreferencesConfigurationSource
42    {
43    static final String DOCUMENT_NAME = "WebPreferences";
44   
45    @Inject
46    private DocumentAccessBridge documentAccessBridge;
47   
 
48  722 toggle @Override
49    protected String getCacheId()
50    {
51  722 return "configuration.document.space";
52    }
53   
 
54  172456 toggle @Override
55    protected String getCacheKeyPrefix()
56    {
57  172451 DocumentReference currentDocumentReference = this.documentAccessBridge.getCurrentDocumentReference();
58  172459 if (currentDocumentReference != null) {
59  171357 return this.referenceSerializer.serialize(currentDocumentReference.getParent());
60    }
61   
62  1091 return null;
63    }
64   
 
65  38691 toggle @Override
66    protected DocumentReference getDocumentReference()
67    {
68    // Note: We would normally use a Reference Resolver here but since the Model module uses the Configuration
69    // module we cannot use one as otherwise we would create a cyclic build dependency...
70   
71    // Get the current document reference to extract the wiki and space names.
72  38692 DocumentReference currentDocumentReference = this.documentAccessBridge.getCurrentDocumentReference();
73   
74  38705 if (currentDocumentReference != null) {
75    // Add the current spaces and current wiki references to the Web Preferences document reference to form
76    // an absolute reference.
77  38542 return new DocumentReference(DOCUMENT_NAME, (SpaceReference) currentDocumentReference.getParent());
78    }
79   
80  162 return null;
81    }
82    }