1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package com.xpn.xwiki.plugin.tag; |
21 |
|
|
22 |
|
import java.util.List; |
23 |
|
import java.util.Map; |
24 |
|
|
25 |
|
import org.slf4j.Logger; |
26 |
|
import org.slf4j.LoggerFactory; |
27 |
|
|
28 |
|
import com.xpn.xwiki.XWikiContext; |
29 |
|
import com.xpn.xwiki.XWikiException; |
30 |
|
import com.xpn.xwiki.doc.XWikiDocument; |
31 |
|
import com.xpn.xwiki.plugin.PluginApi; |
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
@see |
38 |
|
@version |
39 |
|
|
|
|
| 0% |
Uncovered Elements: 76 (76) |
Complexity: 24 |
Complexity Density: 0.46 |
|
40 |
|
public class TagPluginApi extends PluginApi<TagPlugin> |
41 |
|
{ |
42 |
|
|
43 |
|
private static final Logger LOGGER = LoggerFactory.getLogger(TagPluginApi.class); |
44 |
|
|
45 |
|
|
46 |
|
private static final String TAG_ACCESS_RIGHT = "edit"; |
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
@param |
52 |
|
@param |
53 |
|
@see |
54 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
55 |
0 |
public TagPluginApi(TagPlugin plugin, XWikiContext context)... |
56 |
|
{ |
57 |
0 |
super(plugin, context); |
58 |
|
} |
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
@return |
64 |
|
@throws |
65 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
66 |
0 |
public List<String> getAllTags() throws XWikiException... |
67 |
|
{ |
68 |
0 |
return this.getProtectedPlugin().getAllTags(this.context); |
69 |
|
} |
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
@return |
75 |
|
@throws |
76 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
77 |
0 |
public Map<String, Integer> getTagCount() throws XWikiException... |
78 |
|
{ |
79 |
0 |
return this.getProtectedPlugin().getTagCount(this.context); |
80 |
|
} |
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
@param |
86 |
|
@return |
87 |
|
@throws |
88 |
|
@since |
89 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
90 |
0 |
public Map<String, Integer> getTagCount(String space) throws XWikiException... |
91 |
|
{ |
92 |
0 |
return this.getProtectedPlugin().getTagCount(space, this.context); |
93 |
|
} |
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
@param |
99 |
|
@return |
100 |
|
@throws |
101 |
|
@since |
102 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
103 |
0 |
public Map<String, Integer> getTagCountForSpaces(String spaces) throws XWikiException... |
104 |
|
{ |
105 |
0 |
return this.getProtectedPlugin().getTagCountForSpaces(spaces, this.context); |
106 |
|
} |
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
@param |
127 |
|
@param |
128 |
|
@return |
129 |
|
@throws |
130 |
|
@since |
131 |
|
@see |
132 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
133 |
0 |
public Map<String, Integer> getTagCountForQuery(String from, String where) throws XWikiException... |
134 |
|
{ |
135 |
0 |
return getTagCountForQuery(from, where, null); |
136 |
|
} |
137 |
|
|
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
|
142 |
|
|
143 |
|
|
144 |
|
|
145 |
|
|
146 |
|
|
147 |
|
@param |
148 |
|
@param |
149 |
|
@param |
150 |
|
@return |
151 |
|
@throws |
152 |
|
@since |
153 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
154 |
0 |
public Map<String, Integer> getTagCountForQuery(String from, String where, List< ? > parameterValues)... |
155 |
|
throws XWikiException |
156 |
|
{ |
157 |
0 |
return this.getProtectedPlugin().getTagCountForQuery(from, where, parameterValues, this.context); |
158 |
|
} |
159 |
|
|
160 |
|
|
161 |
|
|
162 |
|
|
163 |
|
@param |
164 |
|
@return |
165 |
|
@throws |
166 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
167 |
0 |
public List<String> getDocumentsWithTag(String tag) throws XWikiException... |
168 |
|
{ |
169 |
0 |
return this.getProtectedPlugin().getDocumentsWithTag(tag, this.context); |
170 |
|
} |
171 |
|
|
172 |
|
|
173 |
|
|
174 |
|
|
175 |
|
@param |
176 |
|
@return |
177 |
|
@throws |
178 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
179 |
0 |
public List<String> getTagsFromDocument(String documentName) throws XWikiException... |
180 |
|
{ |
181 |
0 |
return this.getProtectedPlugin().getTagsFromDocument(documentName, this.context); |
182 |
|
} |
183 |
|
|
184 |
|
|
185 |
|
|
186 |
|
|
187 |
|
@param |
188 |
|
@param |
189 |
|
@return@link |
190 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.33 |
|
191 |
0 |
public TagOperationResult addTagToDocument(String tag, String documentName)... |
192 |
|
{ |
193 |
0 |
TagOperationResult result; |
194 |
0 |
try { |
195 |
0 |
XWikiDocument document = this.context.getWiki().getDocument(documentName, this.context); |
196 |
0 |
if (this.context.getWiki().checkAccess(TAG_ACCESS_RIGHT, document, this.context)) { |
197 |
0 |
result = this.getProtectedPlugin().addTagToDocument(tag, document, this.context); |
198 |
|
} else { |
199 |
0 |
result = TagOperationResult.NOT_ALLOWED; |
200 |
|
} |
201 |
|
} catch (Exception ex) { |
202 |
0 |
LOGGER.warn("Failed to add tag to document: [{}]", ex.getMessage()); |
203 |
0 |
result = TagOperationResult.FAILED; |
204 |
|
} |
205 |
0 |
return result; |
206 |
|
} |
207 |
|
|
208 |
|
|
209 |
|
|
210 |
|
|
211 |
|
@param |
212 |
|
@param |
213 |
|
@return@link@link |
214 |
|
@link |
215 |
|
|
216 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.33 |
|
217 |
0 |
public TagOperationResult addTagsToDocument(String tags, String documentName)... |
218 |
|
{ |
219 |
0 |
TagOperationResult result; |
220 |
0 |
try { |
221 |
0 |
XWikiDocument document = this.context.getWiki().getDocument(documentName, this.context); |
222 |
0 |
if (this.context.getWiki().checkAccess(TAG_ACCESS_RIGHT, document, this.context)) { |
223 |
0 |
result = this.getProtectedPlugin().addTagsToDocument(tags, document, this.context); |
224 |
|
} else { |
225 |
0 |
result = TagOperationResult.NOT_ALLOWED; |
226 |
|
} |
227 |
|
} catch (Exception ex) { |
228 |
0 |
LOGGER.warn("Failed to add tags to document: [{}]", ex.getMessage()); |
229 |
0 |
result = TagOperationResult.FAILED; |
230 |
|
} |
231 |
0 |
return result; |
232 |
|
} |
233 |
|
|
234 |
|
|
235 |
|
|
236 |
|
|
237 |
|
@param |
238 |
|
@param |
239 |
|
@return@link |
240 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.33 |
|
241 |
0 |
public TagOperationResult removeTagFromDocument(String tag, String documentName)... |
242 |
|
{ |
243 |
0 |
TagOperationResult result; |
244 |
0 |
try { |
245 |
0 |
XWikiDocument document = this.context.getWiki().getDocument(documentName, this.context); |
246 |
0 |
if (this.context.getWiki().checkAccess(TAG_ACCESS_RIGHT, document, this.context)) { |
247 |
0 |
result = this.getProtectedPlugin().removeTagFromDocument(tag, documentName, this.context); |
248 |
|
} else { |
249 |
0 |
result = TagOperationResult.NOT_ALLOWED; |
250 |
|
} |
251 |
|
} catch (Exception ex) { |
252 |
0 |
LOGGER.warn("Failed to remove tag from document: [{}]", ex.getMessage()); |
253 |
0 |
result = TagOperationResult.FAILED; |
254 |
|
} |
255 |
0 |
return result; |
256 |
|
} |
257 |
|
|
258 |
|
|
259 |
|
|
260 |
|
|
261 |
|
|
262 |
|
@param |
263 |
|
@param |
264 |
|
@return@link |
265 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.38 |
|
266 |
0 |
public TagOperationResult renameTag(String tag, String newTag)... |
267 |
|
{ |
268 |
0 |
TagOperationResult result; |
269 |
0 |
try { |
270 |
0 |
if (hasAdminRights()) { |
271 |
0 |
result = this.getProtectedPlugin().renameTag(tag, newTag, this.context); |
272 |
|
} else { |
273 |
0 |
result = TagOperationResult.NOT_ALLOWED; |
274 |
|
} |
275 |
|
} catch (Exception ex) { |
276 |
0 |
LOGGER.warn("Failed to rename tag: [{}]", ex.getMessage()); |
277 |
0 |
result = TagOperationResult.FAILED; |
278 |
|
} |
279 |
0 |
return result; |
280 |
|
} |
281 |
|
|
282 |
|
|
283 |
|
|
284 |
|
|
285 |
|
|
286 |
|
@param |
287 |
|
@return@link |
288 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.38 |
|
289 |
0 |
public TagOperationResult deleteTag(String tag)... |
290 |
|
{ |
291 |
0 |
TagOperationResult result; |
292 |
0 |
try { |
293 |
0 |
if (hasAdminRights()) { |
294 |
0 |
result = this.getProtectedPlugin().deleteTag(tag, this.context); |
295 |
|
} else { |
296 |
0 |
result = TagOperationResult.NOT_ALLOWED; |
297 |
|
} |
298 |
|
} catch (Exception ex) { |
299 |
0 |
LOGGER.warn("Failed to delete tag: [{}]", ex.getMessage()); |
300 |
0 |
result = TagOperationResult.FAILED; |
301 |
|
} |
302 |
0 |
return result; |
303 |
|
} |
304 |
|
} |