1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.extension.xar

File XarExtensionConfiguration.java

 

Coverage histogram

../../../../img/srcFileCovDistChart6.png
72% of files have more coverage

Code metrics

0
8
5
2
131
45
5
0.62
1.6
2.5
1

Classes

Class Line # Actions
XarExtensionConfiguration 33 0 - 0 0
-1.0 -
XarExtensionConfiguration.DocumentProtection 40 8 0% 5 6
0.5384615753.8%
 

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.extension.xar;
21   
22    import org.xwiki.component.annotation.Role;
23    import org.xwiki.stability.Unstable;
24   
25    /**
26    * Various configuration related to XAR extensions support.
27    *
28    * @version $Id: e59e0c8f4031da859521c5236c5a4fab1249e84c $
29    * @since 10.5RC1
30    */
31    @Role
32    @Unstable
 
33    public interface XarExtensionConfiguration
34    {
35    /**
36    * The type of protection to apply.
37    *
38    * @version $Id: e59e0c8f4031da859521c5236c5a4fab1249e84c $
39    */
 
40    enum DocumentProtection
41    {
42    /**
43    * No protection at all.
44    */
45    NONE(false, false, false, false),
46   
47    /**
48    * Everyone get a warning when trying to edit a protected document.
49    */
50    WARNING(true, false, false, false),
51   
52    /**
53    * EDIT/DELETE right is denied for everyone except for admins who just get a warning.
54    */
55    DENY(true, true, false, false),
56   
57    /**
58    * EDIT/DELETE right is denied for everyone including admins.
59    */
60    FORCEDDENY(true, true, true, false),
61   
62    /**
63    * EDIT/DELETE right is denied for simple users except for simple admins who just get a warning.
64    */
65    DENYSIMPLE(true, true, false, true),
66   
67    /**
68    * EDIT/DELETE right is denied for all simple users including simple admins.
69    */
70    FORCEDDENYSIMPLE(true, true, true, true);
71   
72    private final boolean warning;
73   
74    private final boolean deny;
75   
76    private final boolean forced;
77   
78    private final boolean simple;
79   
80    /**
81    * @param warning true if a warning should be showed when editing a protected document
82    * @param deny true if EDIT/DELETE rights should be denied
83    * @param forced true if the deny should apply to admins
84    * @param simple true if the deny should apply only to simple user and not advanced users
85    */
 
86  240 toggle DocumentProtection(boolean warning, boolean deny, boolean forced, boolean simple)
87    {
88  240 this.warning = warning;
89  240 this.deny = deny;
90  240 this.forced = this.deny && forced;
91  240 this.simple = simple;
92    }
93   
94    /**
95    * @return true if a warning should be showed when editing a protected document
96    */
 
97  0 toggle public boolean isWarning()
98    {
99  0 return this.warning;
100    }
101   
102    /**
103    * @return true if EDIT/DELETE rights should be denied
104    */
 
105  17171 toggle public boolean isDeny()
106    {
107  17179 return this.deny;
108    }
109   
110    /**
111    * @return true if the deny should apply to admins
112    */
 
113  0 toggle public boolean isForced()
114    {
115  0 return this.forced;
116    }
117   
118    /**
119    * @return true if the deny should apply only to simple user and not advanced users
120    */
 
121  0 toggle public boolean isSimple()
122    {
123  0 return this.simple;
124    }
125    }
126   
127    /**
128    * @return the protection to apply
129    */
130    DocumentProtection getDocumentProtection();
131    }