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

File DefaultRepositoryConfiguration.java

 

Coverage histogram

../../../../img/srcFileCovDistChart7.png
64% of files have more coverage

Code metrics

4
9
4
1
102
51
6
0.67
2.25
4
1.5

Classes

Class Line # Actions
DefaultRepositoryConfiguration 47 9 0% 6 5
0.705882470.6%
 

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 org.xwiki.repository.internal;
21   
22    import java.util.Collections;
23    import java.util.List;
24   
25    import javax.inject.Inject;
26    import javax.inject.Named;
27    import javax.inject.Provider;
28    import javax.inject.Singleton;
29   
30    import org.xwiki.component.annotation.Component;
31    import org.xwiki.model.reference.DocumentReferenceResolver;
32    import org.xwiki.model.reference.EntityReference;
33   
34    import com.xpn.xwiki.XWikiContext;
35    import com.xpn.xwiki.XWikiException;
36    import com.xpn.xwiki.doc.XWikiDocument;
37    import com.xpn.xwiki.objects.BaseObject;
38   
39    /**
40    * Default implementation of {@link RepositoryConfiguration}.
41    *
42    * @version $Id: f4786b50c6d022231420a44ff511d3fdc4a7ef30 $
43    * @since 4.5M1
44    */
45    @Component
46    @Singleton
 
47    public class DefaultRepositoryConfiguration implements RepositoryConfiguration
48    {
49    /**
50    * Gives access to the current {@link XWikiContext}.
51    */
52    @Inject
53    private Provider<XWikiContext> xcontextProvider;
54   
55    /**
56    * Used to create an absolute reference from a relative one.
57    */
58    @Inject
59    @Named("current")
60    private DocumentReferenceResolver<EntityReference> resolver;
61   
62    /**
63    * @return the XWiki object containing the configuration
64    * @throws XWikiException when failing to get the object
65    */
 
66  45 toggle private BaseObject getConfigurationObject() throws XWikiException
67    {
68  45 XWikiContext xcontext = this.xcontextProvider.get();
69   
70  45 XWikiDocument document =
71    xcontext.getWiki().getDocument(this.resolver.resolve(XWikiRepositoryModel.CONFIGURATION_REFERENCE),
72    xcontext);
73   
74  45 return document.getXObject(XWikiRepositoryModel.CONFIGURATION_CLASSREFERENCE);
75    }
76   
 
77  0 toggle @Override
78    public String getDefaultIdPrefix() throws XWikiException
79    {
80  0 BaseObject obj = getConfigurationObject();
81   
82  0 return obj != null ? obj.getStringValue(XWikiRepositoryModel.PROP_CONFIGURATION_DEFAULTIDPREFIX) : "";
83    }
84   
 
85  45 toggle @Override
86    public List<String> getValidTypes() throws XWikiException
87    {
88  45 BaseObject obj = getConfigurationObject();
89   
90  45 return obj != null ? obj.getListValue(XWikiRepositoryModel.PROP_CONFIGURATION_VALIDTYPEs) : Collections
91    .<String> emptyList();
92    }
93   
 
94  45 toggle @Override
95    public boolean isValidType(String type) throws XWikiException
96    {
97  45 List<String> types = getValidTypes();
98   
99  45 return types.isEmpty() || types.contains(type);
100    }
101   
102    }