1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package com.xpn.xwiki.web

File EditForm.java

 

Coverage histogram

../../../../img/srcFileCovDistChart9.png
41% of files have more coverage

Code metrics

10
73
38
1
317
220
43
0.59
1.92
38
1.13

Classes

Class Line # Actions
EditForm 29 73 0% 43 12
0.9008264590.1%
 

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 com.xpn.xwiki.web;
21   
22    import java.util.HashMap;
23    import java.util.Map;
24   
25    import org.apache.commons.lang3.math.NumberUtils;
26   
27    import com.xpn.xwiki.util.Util;
28   
 
29    public class EditForm extends XWikiForm
30    {
31    // ---- Form fields -------------------------------------------------
32    private String content;
33   
34    private String web;
35   
36    private String name;
37   
38    private String parent;
39   
40    private String creator;
41   
42    private String template;
43   
44    private String language;
45   
46    private String defaultLanguage;
47   
48    private String defaultTemplate;
49   
50    private String title;
51   
52    private String comment;
53   
54    private boolean isMinorEdit = false;
55   
56    private String tags;
57   
58    private boolean lockForce;
59   
60    private String syntaxId;
61   
62    private String hidden;
63   
64    private ObjectPolicyType objectPolicy;
65   
 
66  6163 toggle @Override
67    public void readRequest()
68    {
69  6165 XWikiRequest request = getRequest();
70  6165 setContent(request.getParameter("content"));
71  6162 setWeb(request.getParameter("web"));
72  6165 setName(request.getParameter("name"));
73  6165 setParent(request.getParameter("parent"));
74  6162 setTemplate(request.getParameter("template"));
75  6164 setDefaultTemplate(request.getParameter("default_template"));
76  6163 setCreator(request.getParameter("creator"));
77  6164 setLanguage(request.getParameter("language"));
78  6162 setTitle(request.getParameter("title"));
79  6164 setComment(request.getParameter("comment"));
80  6162 setDefaultLanguage(request.getParameter("defaultLanguage"));
81  6165 setTags(request.getParameterValues("tags"));
82  6164 setLockForce("1".equals(request.getParameter("force")));
83  6165 setMinorEdit(request.getParameter("minorEdit") != null);
84  6164 setSyntaxId(request.getParameter("syntaxId"));
85  6165 setHidden(request.getParameter("xhidden"));
86  6164 setObjectPolicy(request.getParameter("objectPolicy"));
87    }
88   
 
89  6164 toggle public void setTags(String[] parameter)
90    {
91  6166 if (parameter == null) {
92  6163 this.tags = null;
93  6163 return;
94    }
95  2 StringBuilder tags = new StringBuilder();
96  2 boolean first = true;
97  4 for (int i = 0; i < parameter.length; ++i) {
98  2 if (!parameter[i].equals("")) {
99  2 if (first) {
100  2 first = false;
101    } else {
102  0 tags.append("|");
103    }
104  2 tags.append(parameter[i]);
105    }
106    }
107  2 this.tags = tags.toString();
108    }
109   
 
110  1216 toggle public String getTags()
111    {
112  1216 return this.tags;
113    }
114   
 
115  1233 toggle public String getContent()
116    {
117  1233 return this.content;
118    }
119   
 
120  6411 toggle public void setContent(String content)
121    {
122  6412 this.content = content;
123    }
124   
 
125  0 toggle public String getWeb()
126    {
127  0 return this.web;
128    }
129   
 
130  6162 toggle public void setWeb(String web)
131    {
132  6165 this.web = web;
133    }
134   
 
135  0 toggle public String getName()
136    {
137  0 return this.name;
138    }
139   
 
140  6176 toggle public void setName(String name)
141    {
142  6178 this.name = name;
143    }
144   
 
145  3304 toggle public String getLanguage()
146    {
147  3307 return this.language;
148    }
149   
 
150  6670 toggle public void setLanguage(String language)
151    {
152  6670 this.language = Util.normalizeLanguage(language);
153    }
154   
 
155  0 toggle public int getObjectNumbers(String prefix)
156    {
157  0 String nb = getRequest().getParameter(prefix + "_nb");
158  0 return NumberUtils.toInt(nb);
159    }
160   
 
161  1350 toggle public Map<String, String[]> getObject(String prefix)
162    {
163  1350 @SuppressWarnings("unchecked")
164    Map<String, String[]> allParameters = getRequest().getParameterMap();
165  1350 Map<String, String[]> result = new HashMap<String, String[]>();
166  1350 for (String name : allParameters.keySet()) {
167  15828 if (name.startsWith(prefix + "_")) {
168  2303 String newname = name.substring(prefix.length() + 1);
169  2303 result.put(newname, allParameters.get(name));
170    }
171    }
172  1350 return result;
173    }
174   
 
175  1605 toggle public String getParent()
176    {
177  1605 return this.parent;
178    }
179   
 
180  6438 toggle public void setParent(String parent)
181    {
182  6438 this.parent = parent;
183    }
184   
 
185  1605 toggle public String getCreator()
186    {
187  1605 return this.creator;
188    }
189   
 
190  6165 toggle public void setCreator(String creator)
191    {
192  6166 this.creator = creator;
193    }
194   
 
195  2227 toggle public String getTemplate()
196    {
197  2227 return this.template;
198    }
199   
 
200  6480 toggle public void setTemplate(String template)
201    {
202  6482 this.template = template;
203    }
204   
 
205  1596 toggle public String getDefaultTemplate()
206    {
207  1596 return this.defaultTemplate;
208    }
209   
 
210  6163 toggle public void setDefaultTemplate(String defaultTemplate)
211    {
212  6164 this.defaultTemplate = defaultTemplate;
213    }
214   
 
215  1605 toggle public String getDefaultLanguage()
216    {
217  1605 return this.defaultLanguage;
218    }
219   
 
220  6189 toggle public void setDefaultLanguage(String defaultLanguage)
221    {
222  6190 this.defaultLanguage = Util.normalizeLanguage(defaultLanguage);
223    }
224   
 
225  1348 toggle public String getTitle()
226    {
227  1348 return this.title;
228    }
229   
 
230  6533 toggle public void setTitle(String title)
231    {
232  6534 this.title = title;
233    }
234   
 
235  1216 toggle public String getComment()
236    {
237  1216 return this.comment;
238    }
239   
 
240  6450 toggle public void setComment(String comment)
241    {
242  6451 this.comment = comment;
243    }
244   
 
245  1216 toggle public boolean isMinorEdit()
246    {
247  1216 return this.isMinorEdit;
248    }
249   
 
250  6211 toggle public void setMinorEdit(boolean isMinorEdit)
251    {
252  6213 this.isMinorEdit = isMinorEdit;
253    }
254   
 
255  1 toggle public boolean isLockForce()
256    {
257  1 return this.lockForce;
258    }
259   
 
260  6163 toggle public void setLockForce(boolean lockForce)
261    {
262  6161 this.lockForce = lockForce;
263    }
264   
 
265  1216 toggle public String getSyntaxId()
266    {
267  1216 return this.syntaxId;
268    }
269   
 
270  6240 toggle public void setSyntaxId(String syntaxId)
271    {
272  6240 this.syntaxId = syntaxId;
273    }
274   
 
275  1295 toggle public String getHidden()
276    {
277  1295 return this.hidden;
278    }
279   
 
280  6164 toggle public void setHidden(String hidden)
281    {
282  6166 this.hidden = hidden;
283    }
284   
285    /**
286    * Return the object policy given in the HTTP request. See {@link com.xpn.xwiki.web.ObjectPolicyType
287    * ObjectPolicyType} for more information about what is an object policy.
288    *
289    * @return the Object Policy type
290    * @since 7.0RC1
291    */
 
292  602 toggle public ObjectPolicyType getObjectPolicy() {
293  602 return this.objectPolicy;
294    }
295   
296    /**
297    * see {@link #getObjectPolicyType}
298    *
299   
300    * @since 7.0RC1
301    */
 
302  0 toggle private void setObjectPolicy(ObjectPolicyType objectPolicy)
303    {
304  0 this.objectPolicy = objectPolicy;
305    }
306   
307    /**
308    * see {@link #getObjectPolicyType}
309    *
310    * @param objectPolicy is a string converted to {@link com.xpn.xwiki.web.ObjectPolicyType ObjectPolicyType}
311    * @since 7.0RC1
312    */
 
313  6164 toggle private void setObjectPolicy(String objectPolicyName)
314    {
315  6166 this.objectPolicy = ObjectPolicyType.forName(objectPolicyName);
316    }
317    }