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

File DefaultStandardURLConfiguration.java

 

Coverage histogram

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

Code metrics

0
10
10
1
135
60
10
1
1
10
1

Classes

Class Line # Actions
DefaultStandardURLConfiguration 37 10 0% 10 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.url.internal.standard;
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.configuration.ConfigurationSource;
28   
29    /**
30    * Default implementation reading data from the {@code xwiki.properties} file.
31    *
32    * @version $Id: 462c73e50b96a74f664acac25877ee6d66471877 $
33    * @since 2.3M1
34    */
35    @Component
36    @Singleton
 
37    public class DefaultStandardURLConfiguration implements StandardURLConfiguration
38    {
39    /**
40    * Prefix for configuration keys for the Resource module.
41    */
42    private static final String PREFIX = "url.standard.";
43   
44    /**
45    * Defines from where to read the Resource configuration data.
46    */
47    @Inject
48    @Named("xwikiproperties")
49    private ConfigurationSource configuration;
50   
 
51  5 toggle @Override
52    public boolean isPathBasedMultiWiki()
53    {
54  5 return isPathBasedMultiWiki(Boolean.TRUE);
55    }
56   
57    /**
58    * Makes it easy for this class to be extended.
59    *
60    * @param defaultValue the default value to use if the key is not found in the configuration
61    * @return see {@link #isPathBasedMultiWiki()}
62    */
 
63  5 toggle protected boolean isPathBasedMultiWiki(Boolean defaultValue)
64    {
65  5 return this.configuration.getProperty(PREFIX + "multiwiki.isPathBased", defaultValue);
66    }
67   
 
68  33 toggle @Override
69    public String getWikiPathPrefix()
70    {
71  33 return getWikiPathPrefix("wiki");
72    }
73   
 
74  62 toggle @Override
75    public WikiNotFoundBehavior getWikiNotFoundBehavior()
76    {
77  62 return getWikiNotFoundBehavior(WikiNotFoundBehavior.REDIRECT_TO_MAIN_WIKI);
78    }
79   
 
80  35208 toggle @Override
81    public String getEntityPathPrefix()
82    {
83  35203 return getEntityPathPrefix("bin");
84    }
85   
 
86  1 toggle @Override
87    public boolean isViewActionHidden()
88    {
89  1 return isViewActionHidden(false);
90    }
91   
92    /**
93    * Makes it easy for this class to be extended.
94    *
95    * @param defaultValue the default value to use if the key is not found in the configuration
96    * @return see {@link #getWikiPathPrefix()}
97    */
 
98  33 toggle protected String getWikiPathPrefix(String defaultValue)
99    {
100  33 return this.configuration.getProperty(PREFIX + "multiwiki.wikiPathPrefix", defaultValue);
101    }
102   
103    /**
104    * Makes it easy for this class to be extended.
105    *
106    * @param defaultValue the default value to use if the key is not found in the configuration
107    * @return see {@link #isViewActionHidden()} ()}
108    */
 
109  1 toggle protected boolean isViewActionHidden(boolean defaultValue)
110    {
111  1 return this.configuration.getProperty(PREFIX + "hideViewAction", defaultValue);
112    }
113   
114    /**
115    * Makes it easy for this class to be extended.
116    *
117    * @param defaultValue the default value to use if the key is not found in the configuration
118    * @return see {@link #getEntityPathPrefix()} ()}
119    */
 
120  35105 toggle protected String getEntityPathPrefix(String defaultValue)
121    {
122  35129 return this.configuration.getProperty(PREFIX + "entityPathPrefix", defaultValue);
123    }
124   
125    /**
126    * Makes it easy for this class to be extended.
127    *
128    * @param defaultValue the default value to use if the key is not found in the configuration
129    * @return see {@link #getWikiNotFoundBehavior()}
130    */
 
131  59 toggle protected WikiNotFoundBehavior getWikiNotFoundBehavior(WikiNotFoundBehavior defaultValue)
132    {
133  61 return this.configuration.getProperty(PREFIX + "multiwiki.notFoundBehavior", defaultValue);
134    }
135    }