1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.query.script; |
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.component.manager.ComponentManager; |
28 |
|
import org.xwiki.query.Query; |
29 |
|
import org.xwiki.query.QueryException; |
30 |
|
import org.xwiki.query.QueryManager; |
31 |
|
import org.xwiki.query.SecureQuery; |
32 |
|
import org.xwiki.query.internal.ScriptQuery; |
33 |
|
import org.xwiki.script.service.ScriptService; |
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
@version |
39 |
|
@since |
40 |
|
|
41 |
|
@Component |
42 |
|
@Named("query") |
43 |
|
@Singleton |
|
|
| 78.6% |
Uncovered Elements: 3 (14) |
Complexity: 5 |
Complexity Density: 0.62 |
|
44 |
|
public class QueryManagerScriptService implements ScriptService |
45 |
|
{ |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
@Inject |
50 |
|
@Named("secure") |
51 |
|
private QueryManager secureQueryManager; |
52 |
|
|
53 |
|
|
54 |
|
@link |
55 |
|
|
56 |
|
@Inject |
57 |
|
private ComponentManager componentManager; |
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
@param |
63 |
|
@return |
64 |
|
@throws |
65 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
66 |
71 |
public Query xwql(String statement) throws QueryException... |
67 |
|
{ |
68 |
71 |
return createQuery(statement, Query.XWQL, false); |
69 |
|
} |
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
@param |
75 |
|
@return |
76 |
|
@throws |
77 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
78 |
292 |
public Query hql(String statement) throws QueryException... |
79 |
|
{ |
80 |
292 |
return createQuery(statement, Query.HQL, false); |
81 |
|
} |
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
@param |
87 |
|
@param |
88 |
|
@return |
89 |
|
@throws |
90 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
91 |
0 |
public Query createQuery(String statement, String language) throws QueryException... |
92 |
|
{ |
93 |
0 |
return createQuery(statement, language, true); |
94 |
|
} |
95 |
|
|
|
|
| 85.7% |
Uncovered Elements: 1 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
96 |
363 |
private Query createQuery(String statement, String language, boolean checkCurrentUser) throws QueryException... |
97 |
|
{ |
98 |
363 |
Query query = this.secureQueryManager.createQuery(statement, language); |
99 |
363 |
if (query instanceof SecureQuery) { |
100 |
363 |
((SecureQuery) query).checkCurrentAuthor(true); |
101 |
363 |
((SecureQuery) query).checkCurrentUser(checkCurrentUser); |
102 |
|
} |
103 |
|
|
104 |
363 |
return new ScriptQuery(query, this.componentManager); |
105 |
|
} |
106 |
|
} |