1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package com.xpn.xwiki.web; |
21 |
|
|
22 |
|
import java.util.List; |
23 |
|
|
24 |
|
import javax.servlet.http.HttpServletResponse; |
25 |
|
|
26 |
|
import com.xpn.xwiki.XWiki; |
27 |
|
import com.xpn.xwiki.XWikiContext; |
28 |
|
import com.xpn.xwiki.XWikiException; |
29 |
|
import com.xpn.xwiki.doc.XWikiDocument; |
30 |
|
import com.xpn.xwiki.objects.BaseObject; |
31 |
|
import com.xpn.xwiki.objects.BaseProperty; |
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
@version |
37 |
|
@since |
38 |
|
|
|
|
| 0% |
Uncovered Elements: 34 (34) |
Complexity: 7 |
Complexity Density: 0.26 |
|
39 |
|
public class ObjectsSynchronizeAction extends XWikiAction |
40 |
|
{ |
|
|
| 0% |
Uncovered Elements: 26 (26) |
Complexity: 5 |
Complexity Density: 0.23 |
|
41 |
0 |
@Override... |
42 |
|
public boolean action(XWikiContext context) throws XWikiException |
43 |
|
{ |
44 |
0 |
XWiki xwiki = context.getWiki(); |
45 |
0 |
XWikiResponse response = context.getResponse(); |
46 |
0 |
XWikiDocument doc = context.getDoc(); |
47 |
0 |
XWikiRequest request = context.getRequest(); |
48 |
|
|
49 |
0 |
String className = request.getParameter("classname"); |
50 |
0 |
String objectNumber = request.getParameter("object"); |
51 |
|
|
52 |
0 |
if (className != null && objectNumber != null) { |
53 |
0 |
try { |
54 |
0 |
BaseObject object = doc.getObject(className, Integer.valueOf(objectNumber)); |
55 |
0 |
synchronizeObject(object, context); |
56 |
|
} catch (Exception ex) { |
57 |
|
|
58 |
0 |
return true; |
59 |
|
} |
60 |
|
} else { |
61 |
0 |
for (List<BaseObject> classObjects : doc.getXObjects().values()) { |
62 |
0 |
for (BaseObject object : classObjects) { |
63 |
0 |
synchronizeObject(object, context); |
64 |
|
} |
65 |
|
} |
66 |
|
} |
67 |
|
|
68 |
|
|
69 |
0 |
doc.setAuthorReference(context.getUserReference()); |
70 |
|
|
71 |
0 |
xwiki.saveDocument(doc, localizePlainOrKey("core.model.xobject.synchronizeObjects.versionSummary"), true, |
72 |
|
context); |
73 |
|
|
74 |
0 |
if (Utils.isAjaxRequest(context)) { |
75 |
0 |
response.setStatus(HttpServletResponse.SC_NO_CONTENT); |
76 |
0 |
response.setContentLength(0); |
77 |
|
} else { |
78 |
|
|
79 |
0 |
String redirect = Utils.getRedirect("edit", "editor=object", context); |
80 |
0 |
sendRedirect(response, redirect); |
81 |
|
} |
82 |
0 |
return false; |
83 |
|
} |
84 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
85 |
0 |
@Override... |
86 |
|
public String render(XWikiContext context) throws XWikiException |
87 |
|
{ |
88 |
0 |
context.getResponse().setStatus(HttpServletResponse.SC_NOT_FOUND); |
89 |
0 |
context.put("message", "core.model.xobject.synchronizeObjects.error.missingObject"); |
90 |
0 |
return "exception"; |
91 |
|
} |
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
|
96 |
|
@param |
97 |
|
@param |
98 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
99 |
0 |
private void synchronizeObject(BaseObject object, XWikiContext context)... |
100 |
|
{ |
101 |
0 |
for (BaseProperty property : object.getXClass(context).getDeprecatedObjectProperties(object)) { |
102 |
0 |
object.removeField(property.getName()); |
103 |
|
} |
104 |
|
} |
105 |
|
} |