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

File AbstractCheckRightsRequest.java

 

Coverage histogram

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

Code metrics

0
8
8
1
138
44
8
1
1
8
1

Classes

Class Line # Actions
AbstractCheckRightsRequest 35 8 0% 8 0
1.0100%
 

Contributing tests

This file is covered by 71 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.job.api;
21   
22    import org.xwiki.job.AbstractRequest;
23    import org.xwiki.model.reference.DocumentReference;
24    import org.xwiki.stability.Unstable;
25   
26    /**
27    * Define a request that have rights to check.
28    *
29    * @version $Id: 850543f00318da60dbce579e132dfd6c4b49ea6c $
30    * @since 10.10RC1
31    * @since 10.8.2
32    * @since 9.11.9
33    */
34    @Unstable
 
35    public abstract class AbstractCheckRightsRequest extends AbstractRequest
36    {
37    /**
38    * @see #getUserReference()
39    */
40    private static final String PROPERTY_USER_REFERENCE = "user.reference";
41   
42    /**
43    * @see #getAuthorReference()
44    */
45    private static final String PROPERTY_CALLER_REFERENCE = "caller.reference";
46   
47    /**
48    * @see #isCheckRights()
49    */
50    private static final String PROPERTY_CHECK_RIGHTS = "checkrights";
51   
52    /**
53    * @see #isCheckAuthorRights()
54    */
55    private static final String PROPERTY_CHECK_AUTHOR_RIGHTS = "checkAuthorRights";
56   
57    /**
58    * @return {@code true} in case the job should check if the author specified by {@link #getAuthorReference()} is
59    * authorized to perform the actions implied by this request, {@code false} otherwise
60    */
 
61  239 toggle public boolean isCheckAuthorRights()
62    {
63  239 return getProperty(PROPERTY_CHECK_AUTHOR_RIGHTS, true);
64    }
65   
66    /**
67    * Sets whether the job should check or not if the user specified by {@link #getAuthorReference()} is authorized to
68    * perform the actions implied by this request.
69    *
70    * @param checkAuthorRights {@code true} to check if {@link #getAuthorReference()} is authorized to perform this
71    * request, {@code false} to perform this request without checking rights
72    */
 
73  146 toggle public void setCheckAuthorRights(boolean checkAuthorRights)
74    {
75  146 setProperty(PROPERTY_CHECK_AUTHOR_RIGHTS, checkAuthorRights);
76    }
77   
78    /**
79    * @return {@code true} in case the job should check if the user specified by {@link #getUserReference()} is
80    * authorized to perform the actions implied by this request, {@code false} otherwise
81    */
 
82  259 toggle public boolean isCheckRights()
83    {
84  259 return getProperty(PROPERTY_CHECK_RIGHTS, true);
85    }
86   
87    /**
88    * Sets whether the job should check or not if the user specified by {@link #getUserReference()} is authorized to
89    * perform the actions implied by this request.
90    *
91    * @param checkRights {@code true} to check if {@link #getUserReference()} is authorized to perform this request,
92    * {@code false} to perform this request without checking rights
93    */
 
94  247 toggle public void setCheckRights(boolean checkRights)
95    {
96  247 setProperty(PROPERTY_CHECK_RIGHTS, checkRights);
97    }
98   
99    /**
100    * @return the user that should be used to perform this request; this user must be authorized to perform the actions
101    * implied by this request if {@link #isCheckRights()} is {@code true}.
102    */
 
103  434 toggle public DocumentReference getUserReference()
104    {
105  434 return getProperty(PROPERTY_USER_REFERENCE);
106    }
107   
108    /**
109    * Sets the user that should be used to perform this request. This user must be authorized to perform the actions
110    * implied by this request if {@link #isCheckRights()} is {@code true}.
111    *
112    * @param userReference the user reference
113    */
 
114  232 toggle public void setUserReference(DocumentReference userReference)
115    {
116  232 setProperty(PROPERTY_USER_REFERENCE, userReference);
117    }
118   
119    /**
120    * @return the author of the script which is performing the request; this user must be authorized to perform the
121    * actions implied by this request if {@link #isCheckRights()} is {@code true}.
122    */
 
123  93 toggle public DocumentReference getAuthorReference()
124    {
125  93 return getProperty(PROPERTY_CALLER_REFERENCE);
126    }
127   
128    /**
129    * Sets the author of the script which is performing the request. This user must be authorized to perform the
130    * actions implied by this request if {@link #isCheckRights()} is {@code true}.
131    *
132    * @param authorReference the author reference
133    */
 
134  216 toggle public void setAuthorReference(DocumentReference authorReference)
135    {
136  216 setProperty(PROPERTY_CALLER_REFERENCE, authorReference);
137    }
138    }