| 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 javax.servlet.http.HttpServletResponse; |
| 23 |
|
|
| 24 |
|
import com.xpn.xwiki.XWikiContext; |
| 25 |
|
import com.xpn.xwiki.XWikiException; |
| 26 |
|
import com.xpn.xwiki.doc.XWikiDocument; |
| 27 |
|
import com.xpn.xwiki.objects.classes.BaseClass; |
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
@version |
| 34 |
|
@since |
| 35 |
|
|
| |
|
| 0% |
Uncovered Elements: 27 (27) |
Complexity: 6 |
Complexity Density: 0.32 |
|
| 36 |
|
public abstract class AbstractPropChangeAction extends XWikiAction |
| 37 |
|
{ |
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
@param |
| 43 |
|
@return |
| 44 |
|
@link |
| 45 |
|
@throws |
| 46 |
|
|
| |
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 5 |
Complexity Density: 0.31 |
|
| 47 |
0 |
@Override... |
| 48 |
|
public boolean action(XWikiContext context) throws XWikiException |
| 49 |
|
{ |
| 50 |
0 |
XWikiResponse response = context.getResponse(); |
| 51 |
0 |
XWikiDocument doc = context.getDoc(); |
| 52 |
0 |
PropChangeForm form = (PropChangeForm) context.getForm(); |
| 53 |
0 |
String propertyName = form.getPropertyName(); |
| 54 |
0 |
BaseClass xclass = doc.getXClass(); |
| 55 |
|
|
| 56 |
0 |
if (propertyName != null && xclass.get(propertyName) != null) { |
| 57 |
|
|
| 58 |
0 |
if (!csrfTokenCheck(context)) { |
| 59 |
0 |
return false; |
| 60 |
|
} |
| 61 |
0 |
changePropertyDefinition(xclass, propertyName, context); |
| 62 |
|
} else { |
| 63 |
0 |
return true; |
| 64 |
|
} |
| 65 |
|
|
| 66 |
0 |
if (Utils.isAjaxRequest(context)) { |
| 67 |
0 |
response.setStatus(HttpServletResponse.SC_NO_CONTENT); |
| 68 |
0 |
response.setContentLength(0); |
| 69 |
|
} else { |
| 70 |
0 |
String redirect = Utils.getRedirect("edit", "editor=class", context); |
| 71 |
0 |
sendRedirect(response, redirect); |
| 72 |
|
} |
| 73 |
0 |
return false; |
| 74 |
|
} |
| 75 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 76 |
0 |
@Override... |
| 77 |
|
public String render(XWikiContext context) throws XWikiException |
| 78 |
|
{ |
| 79 |
0 |
context.getResponse().setStatus(HttpServletResponse.SC_NOT_FOUND); |
| 80 |
0 |
context.put("message", "core.model.xclass.classProperty.error.missingProperty"); |
| 81 |
0 |
return "exception"; |
| 82 |
|
} |
| 83 |
|
|
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
| 87 |
|
@param |
| 88 |
|
@param |
| 89 |
|
@param |
| 90 |
|
@throws |
| 91 |
|
|
| 92 |
|
public abstract void changePropertyDefinition(BaseClass xclass, String propertyName, XWikiContext context) |
| 93 |
|
throws XWikiException; |
| 94 |
|
} |