| 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 org.slf4j.Logger; |
| 23 |
|
import org.slf4j.LoggerFactory; |
| 24 |
|
|
| 25 |
|
import com.xpn.xwiki.XWikiContext; |
| 26 |
|
import com.xpn.xwiki.XWikiException; |
| 27 |
|
import com.xpn.xwiki.doc.XWikiDocument; |
| 28 |
|
import com.xpn.xwiki.doc.XWikiLock; |
| 29 |
|
|
| 30 |
|
|
| 31 |
|
@deprecated@link |
| 32 |
|
|
| 33 |
|
@Deprecated |
| |
|
| 68.3% |
Uncovered Elements: 19 (60) |
Complexity: 15 |
Complexity Density: 0.37 |
|
| 34 |
|
public class InlineAction extends XWikiAction |
| 35 |
|
{ |
| 36 |
|
private static final Logger LOGGER = LoggerFactory.getLogger(InlineAction.class); |
| 37 |
|
|
| |
|
| 67.8% |
Uncovered Elements: 19 (59) |
Complexity: 15 |
Complexity Density: 0.37 |
|
| 38 |
4 |
@Override... |
| 39 |
|
public String render(XWikiContext context) throws XWikiException |
| 40 |
|
{ |
| 41 |
4 |
XWikiDocument doc = context.getDoc(); |
| 42 |
|
|
| 43 |
4 |
synchronized (doc) { |
| 44 |
4 |
XWikiForm form = context.getForm(); |
| 45 |
|
|
| 46 |
4 |
XWikiDocument cdoc = (XWikiDocument) context.get("cdoc"); |
| 47 |
4 |
if (cdoc == null) { |
| 48 |
0 |
cdoc = doc; |
| 49 |
|
} |
| 50 |
|
|
| 51 |
4 |
EditForm peform = (EditForm) form; |
| 52 |
|
|
| 53 |
4 |
XWikiDocument doc2 = doc.clone(); |
| 54 |
4 |
context.put("doc", doc2); |
| 55 |
|
|
| 56 |
4 |
String parent = peform.getParent(); |
| 57 |
4 |
if (parent != null) { |
| 58 |
4 |
doc2.setParent(parent); |
| 59 |
|
} |
| 60 |
4 |
String creator = peform.getCreator(); |
| 61 |
4 |
if (creator != null) { |
| 62 |
0 |
doc2.setCreator(creator); |
| 63 |
|
} |
| 64 |
4 |
String defaultLanguage = peform.getDefaultLanguage(); |
| 65 |
4 |
if ((defaultLanguage != null) && !defaultLanguage.equals("")) { |
| 66 |
0 |
doc2.setDefaultLanguage(defaultLanguage); |
| 67 |
|
} |
| 68 |
4 |
if (doc2.getDefaultLanguage().equals("")) { |
| 69 |
4 |
doc2.setDefaultLanguage(context.getWiki().getLanguagePreference(context)); |
| 70 |
|
} |
| 71 |
4 |
try { |
| 72 |
4 |
doc2.readFromTemplate(peform, context); |
| 73 |
|
} catch (XWikiException e) { |
| 74 |
0 |
if (e.getCode() == XWikiException.ERROR_XWIKI_APP_DOCUMENT_NOT_EMPTY) { |
| 75 |
0 |
return "docalreadyexists"; |
| 76 |
|
} |
| 77 |
|
} |
| 78 |
|
|
| 79 |
4 |
if (doc == cdoc) { |
| 80 |
4 |
context.put("cdoc", doc2); |
| 81 |
|
} else { |
| 82 |
0 |
XWikiDocument cdoc2 = cdoc.clone(); |
| 83 |
0 |
cdoc2.readFromTemplate(peform, context); |
| 84 |
0 |
context.put("cdoc", cdoc2); |
| 85 |
|
} |
| 86 |
|
|
| 87 |
4 |
doc2.readFromForm((EditForm) form, context); |
| 88 |
|
|
| 89 |
|
|
| 90 |
|
|
| 91 |
|
|
| 92 |
|
|
| 93 |
4 |
if (doc2.isNew()) { |
| 94 |
4 |
doc2.setCreatorReference(context.getUserReference()); |
| 95 |
4 |
doc2.setAuthorReference(context.getUserReference()); |
| 96 |
4 |
doc2.setContentAuthorReference(context.getUserReference()); |
| 97 |
|
} |
| 98 |
|
|
| 99 |
|
|
| 100 |
4 |
try { |
| 101 |
4 |
XWikiLock lock = doc.getLock(context); |
| 102 |
4 |
if ((lock == null) || (lock.getUserName().equals(context.getUser())) || (peform.isLockForce())) { |
| 103 |
4 |
doc.setLock(context.getUser(), context); |
| 104 |
|
} |
| 105 |
|
} catch (Exception e) { |
| 106 |
|
|
| 107 |
|
|
| 108 |
0 |
LOGGER.error("Exception while setting up lock", e); |
| 109 |
|
} |
| 110 |
|
} |
| 111 |
|
|
| 112 |
|
|
| 113 |
|
|
| 114 |
4 |
context.put("display", "edit"); |
| 115 |
|
|
| 116 |
4 |
return "inline"; |
| 117 |
|
} |
| 118 |
|
} |